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: found illegal assignment #47708

Closed
4ad opened this issue Aug 15, 2021 · 2 comments
Closed

cmd/compile: internal compiler error: found illegal assignment #47708

4ad opened this issue Aug 15, 2021 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@4ad
Copy link
Member

4ad commented Aug 15, 2021

On 48dfddb.

Repro:

package main

import "fmt"

type Foo[t any] interface {
	Foo(Bar[t])
}
type Bar[t any] interface {
	Bar(Foo[t])
}

type Baz[t any] t

func (l Baz[t]) Foo(v Bar[t]) { v.Bar(l) }

func main() {
	fmt.Println("hello")
}

with -gcflags='-G=3' this fails with

go run -gcflags='-G=3' e.go
# command-line-arguments
./e.go:14:39: internal compiler error: found illegal assignment main.Baz[main.t₄] -> main.Foo[main.t₄]; :
	Baz[main.t₄] does not implement Foo[main.t₄] (missing Foo method)

goroutine 1 [running]:
runtime/debug.Stack()
	/Users/aram/go/src/runtime/debug/stack.go:24 +0x65
cmd/compile/internal/base.FatalfAt({0x4ac050, 0xc0}, {0x1903579, 0x27}, {0xc0004e2e90, 0x3, 0x3})
	/Users/aram/go/src/cmd/compile/internal/base/print.go:227 +0x154
cmd/compile/internal/base.Fatalf(...)
	/Users/aram/go/src/cmd/compile/internal/base/print.go:196
cmd/compile/internal/noder.assignconvfn({0x1a5ca18, 0xc0004d9930}, 0xc0004e6000)
	/Users/aram/go/src/cmd/compile/internal/noder/transform.go:413 +0x167
cmd/compile/internal/noder.typecheckaste(0x60, {0xc0004b2510, 0x1a5d120}, 0x0, 0xc000488b10, {0xc000488b10, 0x1, 0xc0004e4000}, 0x1)
	/Users/aram/go/src/cmd/compile/internal/noder/transform.go:465 +0x186
cmd/compile/internal/noder.Call({0x4e4000, 0xc0}, 0xc000488030, {0x1a5d120, 0xc0004c9860}, {0xc000488b10, 0xc00048cf90, 0x1}, 0x0)
	/Users/aram/go/src/cmd/compile/internal/noder/helpers.go:193 +0x293
cmd/compile/internal/noder.(*irgen).expr0(0xc0004e4000, {0x1a47158, 0x0}, {0x1a47d48, 0xc000496180})
	/Users/aram/go/src/cmd/compile/internal/noder/expr.go:147 +0xe89
cmd/compile/internal/noder.(*irgen).expr(0xc0004e4000, {0x1a47d48, 0xc000496180})
	/Users/aram/go/src/cmd/compile/internal/noder/expr.go:79 +0x5d0
cmd/compile/internal/noder.(*irgen).stmt(0xc0004e4000, {0x1a47ec8, 0xc000494380})
	/Users/aram/go/src/cmd/compile/internal/noder/stmt.go:38 +0x815
cmd/compile/internal/noder.(*irgen).stmts(0xc0004e67e0, {0xc000488040, 0x1, 0x9888bf8})
	/Users/aram/go/src/cmd/compile/internal/noder/stmt.go:18 +0xaf
cmd/compile/internal/noder.(*irgen).funcBody(0xc0004e4000, 0xc00048a2c0, 0x0, 0xc000496100, 0xc000496140)
	/Users/aram/go/src/cmd/compile/internal/noder/func.go:46 +0x25e
cmd/compile/internal/noder.(*irgen).funcDecl(0xc0004e4000, 0xc0004e3718, 0xc000486180)
	/Users/aram/go/src/cmd/compile/internal/noder/decl.go:108 +0x26f
cmd/compile/internal/noder.(*irgen).decls(0xc0004e4000, {0xc000498010, 0x5, 0xc000481b90})
	/Users/aram/go/src/cmd/compile/internal/noder/decl.go:28 +0x152
cmd/compile/internal/noder.(*irgen).generate(0xc0004e4000, {0xc00010ab50, 0x2, 0x203000})
	/Users/aram/go/src/cmd/compile/internal/noder/irgen.go:236 +0x565
cmd/compile/internal/noder.check2({0xc00010ab50, 0x2, 0x2})
	/Users/aram/go/src/cmd/compile/internal/noder/irgen.go:92 +0x16d
cmd/compile/internal/noder.LoadPackage({0xc000132120, 0x2, 0x0})
	/Users/aram/go/src/cmd/compile/internal/noder/noder.go:90 +0x365
cmd/compile/internal/gc.Main(0x1916550)
	/Users/aram/go/src/cmd/compile/internal/gc/main.go:190 +0xaf3
main.main()
	/Users/aram/go/src/cmd/compile/main.go:55 +0xdd

Works on go2go playground: https://go2goplay.golang.org/p/TT0JdEmcN_i

@4ad 4ad added this to the Go1.18 milestone Aug 15, 2021
@ALTree ALTree added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 15, 2021
@gopherbot
Copy link

Change https://golang.org/cl/342509 mentions this issue: cmd/compile: fix conversions from TypeParam to interface

@korzhao
Copy link
Contributor

korzhao commented Aug 17, 2021

Slightly simpler reproducer:

type Foo[t any] interface {
	Foo(t)
}
type Baz[t any] t
func (l Baz[t]) Foo(v t) {
	var i Foo[t] = l
	_ = i
}

@golang golang locked and limited conversation to collaborators Sep 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants