You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ n zz_test.go
1 package z
2
3 func f() {
4 _ = g[:]
5 }
6
7 var g [1]byte
8
9 func f2() {
10 for g := 0; g < 2; g++ {
11 go func(g int) {
12 }(g)
13 }
14 }
15
16 var g interface{}
$ go test zz_test.go
# command-line-arguments
./zz_test.go:4:7: cannot slice g (type interface {})
./zz_test.go:16:5: g redeclared in this block
previous declaration at ./zz_test.go:11:13
FAIL command-line-arguments [build failed]
$
The conflicting "previous declaration" is at line 7, not line 11.
This is reduced from a much larger example; I was very confused for a bit as to how one global declaration could possibly be conflicting with a closure parameter name. I had to guess to look for a different global variable by hand.
The conflicting "previous declaration" is at line 7, not line 11.
This is reduced from a much larger example; I was very confused for a bit as to how one global declaration could possibly be conflicting with a closure parameter name. I had to guess to look for a different global variable by hand.
/cc @griesemer @mdempsky
The text was updated successfully, but these errors were encountered: