]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: handle ODDD in exprformat
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Mon, 7 Sep 2020 05:14:30 +0000 (12:14 +0700)
committerRob Pike <r@golang.org>
Mon, 7 Sep 2020 05:44:53 +0000 (05:44 +0000)
Fixes #41247

Change-Id: Iaa9502cc610e2cc64be5dfd91ba3187f86f87cbd
Reviewed-on: https://go-review.googlesource.com/c/go/+/252942
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
src/cmd/compile/internal/gc/fmt.go
test/fixedbugs/issue41247.go [new file with mode: 0644]

index d6cc9fa4cf3a3897d297c86c64ff17c88ba1dd52..866cd0a7145f7e4cd895831ec99e290637cc3377 100644 (file)
@@ -1616,7 +1616,8 @@ func (n *Node) exprfmt(s fmt.State, prec int, mode fmtMode) {
                        }
                        n1.exprfmt(s, nprec, mode)
                }
-
+       case ODDD:
+               mode.Fprintf(s, "...")
        default:
                mode.Fprintf(s, "<node %v>", n.Op)
        }
diff --git a/test/fixedbugs/issue41247.go b/test/fixedbugs/issue41247.go
new file mode 100644 (file)
index 0000000..2df919c
--- /dev/null
@@ -0,0 +1,11 @@
+// errorcheck
+
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p
+
+func f() [2]int {
+       return [...]int{2: 0} // ERROR "cannot use \[\.\.\.\]int literal \(type \[3\]int\)"
+}