go version)?$ go version go version go1.15 linux/amd64
It doesn't reproduce with Go 1.13. It does reproduce with Go 1.14, 1.15, and +721819e7ba. Going to rebuild a more fresh Go, try the tip, and update the issue in a moment.
Update: also reproduces with:
$ go version go version devel +5cc030aa19 Sun Sep 6 20:23:50 2020 +0000 linux/amd64
go env)?go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ainar/.cache/go-build"
GOENV="/home/ainar/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/ainar/go/pkg/mod"
GONOPROXY="REDACTED"
GONOSUMDB="REDACTED"
GOOS="linux"
GOPATH="/home/ainar/go"
GOPRIVATE="REDACTED"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/ainar/go/go1.15"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/ainar/go/go1.15/pkg/tool/linux_amd64"
GCCGO="/usr/bin/gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build723473563=/tmp/go-build -gno-record-gcc-switches"
https://play.golang.org/p/rHDhklq4E7D
func f() [2]int {
return [...]int{2: 0}
}
In Go 1.13:
# command-line-arguments
go/tmp.go:4:17: cannot use [3]int literal (type [3]int) as type [2]int in return argument
# command-line-arguments
go/tmp.go:4:17: cannot use [<node DDD>]int literal (type [3]int) as type [2]int in return argument
I saw that on @davecheney's Twitter and tried looking up “node DDD” in existing issues. There didn't seem to be one, so I filed this one.
I think this change is intentional, see this CL for mode details.
cc @mdempsky
I’m pretty sure @mdempsky did not intend for
Oops. Yeah, that error message is wrong.
It should say either [3]int literal or [...]int literal.
Edit: As Josh suggests, <node FOO> should never appear in user-facing diagnostics. User diagnostics should always be in terms of Go language concepts, but "nodes" are an internal compiler detail.
Change https://golang.org/cl/252942 mentions this issue: cmd/compile: handle ODDD in exprformat
That was quick! Now the message is:
# command-line-arguments go/tmp.go:4:17: cannot use [...]int literal (type [3]int) as type [2]int in return argument
Thanks, everyone!
Most helpful comment
That was quick! Now the message is:
Thanks, everyone!