go: [dev.typeparams] internal compiler error: cannot export = (22) node
What version of Go are you using (go version
)?
$ gotip version go version devel go1.18-1b193598b3a Tue Aug 3 02:42:15 2021 +0000 linux/amd64
What operating system and processor architecture are you using (go env
)?
go env
Output
$ gotip env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/enikolov/.cache/go-build" GOENV="/home/enikolov/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/enikolov/.asdf/installs/golang/1.16.6/packages/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/enikolov/.asdf/installs/golang/1.16.6/packages" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/home/enikolov/sdk/gotip" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/home/enikolov/sdk/gotip/pkg/tool/linux_amd64" GOVCS="" GOVERSION="devel go1.18-1b193598b3a Tue Aug 3 02:42:15 2021 +0000" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/enikolov/dev/golang-design/go2generics/go.mod" 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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3230277771=/tmp/go-build -gno-record-gcc-switches"
What did you do?
I tried to compile the following program
package main
func Do[T any]() {
_ = func() string {
return ""
}
}
func main() {
}
using
gotip run -gcflags=all=-G=3 main.go
What did you expect to see?
I expected it to compile
What did you see instead?
# command-line-arguments main.go:5:3: internal compiler error: cannot export = (22) node ==> please file an issue and assign to gri@ goroutine 1 [running]: runtime/debug.Stack() /home/enikolov/sdk/gotip/src/runtime/debug/stack.go:24 +0x65 cmd/compile/internal/base.FatalfAt({0x4913b0, 0xc0}, {0xd0be24, 0x47}, {0xc000455418, 0x2, 0x2}) /home/enikolov/sdk/gotip/src/cmd/compile/internal/base/print.go:227 +0x154 cmd/compile/internal/base.Fatalf(...) /home/enikolov/sdk/gotip/src/cmd/compile/internal/base/print.go:196 cmd/compile/internal/typecheck.(*exportWriter).expr(0xc00049d7a0, {0xe575f0, 0xc0004913b0}) /home/enikolov/sdk/gotip/src/cmd/compile/internal/typecheck/iexport.go:2056 +0x19c5 cmd/compile/internal/typecheck.(*exportWriter).exprList(0xc00049d7a0, {0xc000488340, 0x1, 0x604639}) /home/enikolov/sdk/gotip/src/cmd/compile/internal/typecheck/iexport.go:1618 +0x76 cmd/compile/internal/typecheck.(*exportWriter).stmt(0xc00049d7a0, {0xe59468, 0xc000490460}) /home/enikolov/sdk/gotip/src/cmd/compile/internal/typecheck/iexport.go:1512 +0x83f cmd/compile/internal/typecheck.(*exportWriter).node(0xc000455546, {0xe59468, 0xc000490460}) /home/enikolov/sdk/gotip/src/cmd/compile/internal/typecheck/iexport.go:1438 +0x65 cmd/compile/internal/typecheck.(*exportWriter).stmtList(0xc00049d7a0, {0xc000488310, 0x1, 0xc000455596}) /home/enikolov/sdk/gotip/src/cmd/compile/internal/typecheck/iexport.go:1431 +0x76 cmd/compile/internal/typecheck.(*exportWriter).expr(0xc00049d7a0, {0xe57c30, 0xc000490280}) /home/enikolov/sdk/gotip/src/cmd/compile/internal/typecheck/iexport.go:1732 +0x1efa cmd/compile/internal/typecheck.(*exportWriter).stmt(0xc00049d7a0, {0xe575f0, 0xc0004904b0}) /home/enikolov/sdk/gotip/src/cmd/compile/internal/typecheck/iexport.go:1484 +0x22d cmd/compile/internal/typecheck.(*exportWriter).node(0x30, {0xe575f0, 0xc0004904b0}) /home/enikolov/sdk/gotip/src/cmd/compile/internal/typecheck/iexport.go:1438 +0x65 cmd/compile/internal/typecheck.(*exportWriter).stmtList(0xc00049d7a0, {0xc0004881a0, 0x1, 0xcb7140}) /home/enikolov/sdk/gotip/src/cmd/compile/internal/typecheck/iexport.go:1431 +0x76 cmd/compile/internal/typecheck.(*exportWriter).funcBody(0xc00049d7a0, 0xc00048a2c0) /home/enikolov/sdk/gotip/src/cmd/compile/internal/typecheck/iexport.go:1426 +0x5b cmd/compile/internal/typecheck.(*iexporter).doInline(0xc0003ac370, 0xc00049a5b0) /home/enikolov/sdk/gotip/src/cmd/compile/internal/typecheck/iexport.go:619 +0xc5 cmd/compile/internal/typecheck.(*exportWriter).funcExt(0xc00049cd20, 0xc00049a5b0) /home/enikolov/sdk/gotip/src/cmd/compile/internal/typecheck/iexport.go:1363 +0x1b6 cmd/compile/internal/typecheck.(*iexporter).doDecl(0xc0003ac370, 0xc00049a5b0) /home/enikolov/sdk/gotip/src/cmd/compile/internal/typecheck/iexport.go:503 +0x1d7 cmd/compile/internal/typecheck.WriteExports({0xe3f160, 0xc0000a7530}, 0x1) /home/enikolov/sdk/gotip/src/cmd/compile/internal/typecheck/iexport.go:300 +0x2eb cmd/compile/internal/noder.WriteExports(0xc00007e330) /home/enikolov/sdk/gotip/src/cmd/compile/internal/noder/export.go:40 +0x7a cmd/compile/internal/gc.dumpCompilerObj(0xc00007e330) /home/enikolov/sdk/gotip/src/cmd/compile/internal/gc/obj.go:107 +0x28 cmd/compile/internal/gc.dumpobj1({0x7ffd056a0007, 0x24}, 0x3) /home/enikolov/sdk/gotip/src/cmd/compile/internal/gc/obj.go:63 +0x185 cmd/compile/internal/gc.dumpobj() /home/enikolov/sdk/gotip/src/cmd/compile/internal/gc/obj.go:44 +0x36 cmd/compile/internal/gc.Main(0xd13510) /home/enikolov/sdk/gotip/src/cmd/compile/internal/gc/main.go:321 +0x10d6 main.main() /home/enikolov/sdk/gotip/src/cmd/compile/main.go:55 +0xdd
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (8 by maintainers)
Commits related to this issue
- [dev.typeparams] cmd/compile: make sure closures inside generic funcs are not compiled Closures inside generic functions were being added to the g.target.Decls list during noding, just like other clo... — committed to golang/go by danscales 3 years ago
- [dev.typeparams] cmd/compile: call transformArgs before early typecheckaste in noder In the cases where we do an early call to typecheckaste() in noder to expose CONVIFACE nodes, we need a preceding ... — committed to golang/go by danscales 3 years ago
Change https://golang.org/cl/345411 mentions this issue:
cmd/compile: fix reference to generic type needed by crawler
Yes, thanks for the original case and the new case! I’m aware of the issue of the new case, which relates to the use of multiple return values in generic calls. The original case is mainly related to closures in generic functions, so they are largely unrelated. I’ll leave the issue open for the second case, which I’m still working on the cleanest way to fix.
@randall77 Yeah, I think the problem is that in
irgen.funcDecl
, we setfn.Inl.Body = fn.Body
. Thus later,fn.Body
is changed during walk, causefn.Inl.Body
also changed.I think
irgen
need to do something like unified IRexapandInline
does.