Skip to content
New issue

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

cmd/compile: internal compiler error using type parameters with local type alias #48184

Closed
dsnet opened this issue Sep 3, 2021 · 2 comments
Closed
Labels
Milestone

Comments

@dsnet
Copy link
Member

@dsnet dsnet commented Sep 3, 2021

I apologize for all the bug reports, but I'm hitting another internal compiler error.

$ go.tip version
go version devel go1.18-d9244f8b64 Fri Sep 3 21:31:30 2021 +0000 linux/amd64

$ go.tip build
# github.com/go-json-experiment/json
panic: interface conversion: ir.Node is *ir.typeNode, not *ir.Name

goroutine 1 [running]:
cmd/compile/internal/ir.(*Decl).editChildren(0xc001068930, 0xe65358)
	/usr/local/go.tip/src/cmd/compile/internal/ir/node_gen.go:462 +0x87
cmd/compile/internal/ir.EditChildren(...)
	/usr/local/go.tip/src/cmd/compile/internal/ir/visit.go:185
cmd/compile/internal/noder.(*subster).node.func1({0xe65358, 0xc000d2e6c0})
	/usr/local/go.tip/src/cmd/compile/internal/noder/stencil.go:942 +0x486
cmd/compile/internal/noder.(*subster).node(0xc000feba80, {0xe65358, 0xc000d2e6c0})
	/usr/local/go.tip/src/cmd/compile/internal/noder/stencil.go:1248 +0xa5
cmd/compile/internal/noder.(*subster).list(0xc00000ee98, {0xc0000b0f00, 0x9, 0xc000072640})
	/usr/local/go.tip/src/cmd/compile/internal/noder/stencil.go:1362 +0x8e
cmd/compile/internal/noder.(*irgen).genericSubst(0xc0004a8700, 0xc001063ae0, 0xc0005d4270, {0xc00106a0a0, 0x2, 0x2}, 0x1, 0xc00012d600)
	/usr/local/go.tip/src/cmd/compile/internal/noder/stencil.go:726 +0xce6
cmd/compile/internal/noder.(*irgen).getInstantiation(0xc0004a8700, 0xc0005d4270, {0xc00056c330, 0x2, 0x2}, 0x30)
	/usr/local/go.tip/src/cmd/compile/internal/noder/stencil.go:608 +0x33d
cmd/compile/internal/noder.(*irgen).instantiateMethods(0xc0004a8700)
	/usr/local/go.tip/src/cmd/compile/internal/noder/stencil.go:511 +0x248
cmd/compile/internal/noder.(*irgen).stencil(0xc0004a8700)
	/usr/local/go.tip/src/cmd/compile/internal/noder/stencil.go:50 +0x9b
cmd/compile/internal/noder.(*irgen).generate(0xc0004a8700, {0xc000069aa0, 0xc, 0x0})
	/usr/local/go.tip/src/cmd/compile/internal/noder/irgen.go:304 +0x359
cmd/compile/internal/noder.check2({0xc000069aa0, 0xc, 0xc})
	/usr/local/go.tip/src/cmd/compile/internal/noder/irgen.go:92 +0x175
cmd/compile/internal/noder.LoadPackage({0xc000001ae0, 0xc, 0x0})
	/usr/local/go.tip/src/cmd/compile/internal/noder/noder.go:90 +0x335
cmd/compile/internal/gc.Main(0xd1dcb0)
	/usr/local/go.tip/src/cmd/compile/internal/gc/main.go:190 +0xaf3
main.main()
	/usr/local/go.tip/src/cmd/compile/main.go:55 +0xdd

Reproduction:

$ git clone https://github.com/go-json-experiment/json.git
$ cd json
$ git checkout origin/generics-bug3
$ go build

Based on @mdempsky's comment in #48016 (comment), I tried building this with GOEXPERIMENT=unified and it seems to work.

The relevant change that seems to cause an ICE is the presence of a local type alias:

func (a *arshalers[Options, Coder]) lookup(fnc func(Options, *Coder, addressableValue) error, t reflect.Type) func(Options, *Coder, addressableValue) error {
	type F = func(Options, *Coder, addressableValue) error
	...
}

\cc @danscales @mdempsky @griesemer @ianlancetaylor

@cherrymui
Copy link
Contributor

@cherrymui cherrymui commented Sep 3, 2021

Yeah, local type with type parameter is not fully implemented yet.

Loading

@cherrymui cherrymui added this to the Go1.18 milestone Sep 3, 2021
@randall77
Copy link
Contributor

@randall77 randall77 commented Sep 3, 2021

Dup of #47631
(Although it may have a slightly different cause, they will probably be fixed together.)

Loading

@randall77 randall77 closed this Sep 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants