Build error with multiple var declaration inside anonymous func
hectorj opened this issue · 2 comments
hectorj commented
godebug fails to build some code with multiple var declaration : https://github.com/hectorj/godebug/blob/multiple-var-declaration/testdata/single-file-tests/multiple-var-declaration-in.go
If you run the tests on that branch with -accept=true
, it fails like this :
--- FAIL: TestGoldenFiles (4.39 seconds)
endtoend_test.go:204: Golden file multiple-var-declaration-out.go failed to run under 'go run': exit status 2
# command-line-arguments
testdata/single-file-tests/multiple-var-declaration-out.go:21: undefined: y
testdata/single-file-tests/multiple-var-declaration-out.go:21: undefined: err
testdata/single-file-tests/multiple-var-declaration-out.go:25: undefined: y
testdata/single-file-tests/multiple-var-declaration-out.go:27: undefined: err
testdata/single-file-tests/multiple-var-declaration-out.go:29: undefined: err
testdata/single-file-tests/multiple-var-declaration-out.go:31: undefined: y
But the "in" code is valid
dradtke commented
I can second this, as I just ran into a number of "undefined" errors, and modifying my code from
var (
x = 1
y = 2
)
to
var x = 1
var y = 2
fixes it.
jeremyschlatter commented
Wow, that's surprising behavior. Thanks for reporting this and thanks for the clear test case!