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
I was playing around with generating go code and found a degenerate goto case that
causes go test to choke.
$ go version
go version go1.2 darwin/amd64
file: junk/bad.go
package junk
func Foo() {
goto bar
bar:
// Still reproduces with a "return" here.
// Does not reproduce with a "Foo()" here.
}
file: junk/bad_test.go
package junk
import (
"testing"
)
func TestFoo(t *testing.T) {
Foo()
}
It seems to build fine.
$ go install ./...
$ ls pkg/darwin_amd64/
junk.a
But for some reason chokes the tester.
$ go test ./...
# testmain
/var/folders/jd/0qfhxkbd51qf9pgggpx1xxt40000gn/T/go-build916942264/junk/_test/_testmain.go:9:
syntax error: unexpected <
FAIL junk [build failed]
The text was updated successfully, but these errors were encountered:
Export data is corrupted. The bug also exists in Go 1.1.2 so it must be very old.
[remy@mastermind tmp]$ cat z.go
package p
func Foo() {
goto bar
bar:
}
[remy@mastermind tmp]$ go tool 6g -pack -o z.a z.go
[remy@mastermind tmp]$ ar pf z.a __.PKGDEF
go object linux amd64 devel +c4b7c0824984 Fri Dec 20 23:19:32 2013 -0800 X:none
$$
package p
import runtime "runtime"
func @"".Foo () { <node goto>; @"".bar: }
$$
The fix is a one-liner: https://golang.org/cl/46190043
Affter the patch:
[remy@mastermind tmp]$ go tool 6g -pack -o z.a z.go
[remy@mastermind tmp]$ ar pf z.a __.PKGDEF
go object linux amd64 devel +c4b7c0824984 Fri Dec 20 23:19:32 2013 -0800 X:none
$$
package p
import runtime "runtime"
func @"".Foo () { goto @"".bar; @"".bar: }
$$
by ncbray@google.com:
The text was updated successfully, but these errors were encountered: