Skip to content

cmd/compile: internal compiler error: found illegal assignment PTR-*Foo.T -> bang.Foo.U; #50147

@mcy

Description

@mcy

What version of Go are you using (go version)?

compile version devel go1.18-088bb4b Tue Nov 2 06:25:39 2021 +0000

Does this issue reproduce with the latest release?

This issue is only reproducible at head.

What operating system and processor architecture are you using (go env)?

GOHOSTARCH="amd64"
GOHOSTOS="linux"

What did you do?

package bang

func Foo[T any, U interface{~*T}](x T) {
  var _ U = &x
}

https://godbolt.org/z/GocK9493c

What did you expect to see?

Some kind of compilation error specifying that a conversion was not permitted.

What did you see instead?

ICE:

./example.go:4:14: internal compiler error: found illegal assignment PTR-*Foo.T -> bang.Foo.U; 

goroutine 1 [running]:
runtime/debug.Stack()
	/root/master/go/src/runtime/debug/stack.go:24 +0x65
cmd/compile/internal/base.FatalfAt({0x0?, 0x0?}, {0xd262b1, 0x27}, {0xc0000c4fb8, 0x3, 0x3})
	/root/master/go/src/cmd/compile/internal/base/print.go:227 +0x1ca
cmd/compile/internal/base.Fatalf(...)
	/root/master/go/src/cmd/compile/internal/base/print.go:196
cmd/compile/internal/noder.assignconvfn({0xe7d130, 0xc0003be190}, 0xc000396af0)
	/root/master/go/src/cmd/compile/internal/noder/transform.go:423 +0x1b2
cmd/compile/internal/noder.transformAssign({0xe7d450?, 0xc0003be1e0?}, {0xc0000c5200?, 0x1, 0x8?}, {0xc0000c51f0, 0x1, 0xc0000c51f0?})
	/root/master/go/src/cmd/compile/internal/noder/transform.go:369 +0x4b3
cmd/compile/internal/noder.(*irgen).varDecl.func1()
	/root/master/go/src/cmd/compile/internal/noder/decl.go:284 +0x5c5
cmd/compile/internal/noder.(*irgen).varDecl(0xc0000d4300, 0xc0000b3ae8, 0xc000087b60)
	/root/master/go/src/cmd/compile/internal/noder/decl.go:304 +0x331
cmd/compile/internal/noder.(*irgen).decls(0x1?, 0x0?, {0xc000080bc0?, 0x1, 0x0?})
	/root/master/go/src/cmd/compile/internal/noder/decl.go:34 +0xfd
cmd/compile/internal/noder.(*irgen).stmt(0xc0000d4300, {0xe7a960?, 0xc000385080?})
	/root/master/go/src/cmd/compile/internal/noder/stmt.go:50 +0x136
cmd/compile/internal/noder.(*irgen).stmts(0xc000396cb0?, {0xc000080bd0?, 0x1, 0x0?})
	/root/master/go/src/cmd/compile/internal/noder/stmt.go:19 +0xaf
cmd/compile/internal/noder.(*irgen).funcBody(0xc0000d4300, 0xc0003bcdc0, 0xb45c80?, 0xc0000b3780, 0xc0000b37c0)
	/root/master/go/src/cmd/compile/internal/noder/func.go:45 +0x25f
cmd/compile/internal/noder.(*irgen).funcDecl.func1()
	/root/master/go/src/cmd/compile/internal/noder/decl.go:143 +0xf5
cmd/compile/internal/noder.(*irgen).generate(0xc0000d4300, {0xc0000b0458, 0x1, 0x203000?})
	/root/master/go/src/cmd/compile/internal/noder/irgen.go:280 +0x227
cmd/compile/internal/noder.check2({0xc0000b0458, 0x1, 0x1})
	/root/master/go/src/cmd/compile/internal/noder/irgen.go:92 +0x16d
cmd/compile/internal/noder.LoadPackage({0xc0000b4100, 0x1, 0x0?})
	/root/master/go/src/cmd/compile/internal/noder/noder.go:90 +0x335
cmd/compile/internal/gc.Main(0xd3a138)
	/root/master/go/src/cmd/compile/internal/gc/main.go:191 +0xb13
main.main()
	/root/master/go/src/cmd/compile/main.go:55 +0xdd

Compiler returned: 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions