We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$ go version go version go1.7.1 darwin/amd64 $ go version go version go1.7.3 darwin/amd64
GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/xlab/Documents/dev/go" GORACE="" GOROOT="/usr/local/go" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" CC="clang" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/dr/2vrbtj0j7kl1yy32kp5cpn040000gn/T/go-build908632565=/tmp/go-build -gno-record-gcc-switches -fno-common" CXX="clang++" CGO_ENABLED="1"
The following code fails to compile:
package main type Foo func(b Bar) func Bar(fn Foo) { func() { fn(nil) }() }
https://play.golang.org/p/_5BweYoX9p
A compiler error, describing the case.
A panic stacktrace from the compiler, the compilation aborts.
$ go run a.go # command-line-arguments ./a.go:3: Bar is not a type ./a.go:6: internal compiler error: typecheckclosure: var fn does not have decldepth assigned goroutine 1 [running]: runtime/debug.Stack(0x0, 0x0, 0x0) /usr/local/go/src/runtime/debug/stack.go:24 +0x79 cmd/compile/internal/gc.Fatalf(0x50d877, 0x39, 0xc42042bb40, 0x1, 0x1) /usr/local/go/src/cmd/compile/internal/gc/subr.go:165 +0x248 cmd/compile/internal/gc.typecheckclosure(0xc42041c750, 0xe) /usr/local/go/src/cmd/compile/internal/gc/closure.go:113 +0x476 cmd/compile/internal/gc.typecheck1(0xc42041c750, 0xe, 0xc42041c510) /usr/local/go/src/cmd/compile/internal/gc/typecheck.go:1895 +0x582d cmd/compile/internal/gc.typecheck(0xc42041c750, 0xe, 0x0) /usr/local/go/src/cmd/compile/internal/gc/typecheck.go:188 +0x654 cmd/compile/internal/gc.typecheck1(0xc42041c990, 0x1, 0x8) /usr/local/go/src/cmd/compile/internal/gc/typecheck.go:1200 +0x3cb4 cmd/compile/internal/gc.typecheck(0xc42041c990, 0x1, 0x0) /usr/local/go/src/cmd/compile/internal/gc/typecheck.go:188 +0x654 cmd/compile/internal/gc.typecheckslice(0xc420030798, 0x1, 0x1, 0x1) /usr/local/go/src/cmd/compile/internal/gc/typecheck.go:49 +0x57 cmd/compile/internal/gc.Main() /usr/local/go/src/cmd/compile/internal/gc/main.go:389 +0x178d cmd/compile/internal/amd64.Main() /usr/local/go/src/cmd/compile/internal/amd64/galign.go:93 +0x2fa main.main() /usr/local/go/src/cmd/compile/main.go:33 +0x2a3
The text was updated successfully, but these errors were encountered:
cc @mdempsky
Sorry, something went wrong.
CL https://golang.org/cl/32415 mentions this issue.
Name.Decldepth is 0 in typecheckclosure(), because in case of Func.Nname.Type==nil, [typecheckfunc() returns](https://github.com/golang/go/blob/master/src/cmd/compile/internal/gc/typecheck.go#L3421&q="if t == nil {") without [initializing the Decldepth](https://github.com/golang/go/blob/master/src/cmd/compile/internal/gc/typecheck.go#L3432&q="ln.Name.Decldepth = 1") for func's autodcls.
Name.Decldepth
typecheckclosure()
Func.Nname.Type==nil
typecheckfunc()
Decldepth
After golang.org/cl/32415:
$ ../pkg/tool/linux_amd64/compile ../test/fixedbugs/issue17588.go ../test/fixedbugs/issue17588.go:9: Hehe is not a type
f46239b
No branches or pull requests
What version of Go are you using?
What operating system and processor architecture are you using?
What did you do?
The following code fails to compile:
https://play.golang.org/p/_5BweYoX9p
What did you expect to see?
A compiler error, describing the case.
What did you see instead?
A panic stacktrace from the compiler, the compilation aborts.
The text was updated successfully, but these errors were encountered: