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 #47724

Closed
fsouza opened this issue Aug 16, 2021 · 2 comments
Closed

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

fsouza opened this issue Aug 16, 2021 · 2 comments

Comments

@fsouza
Copy link
Contributor

@fsouza fsouza commented Aug 16, 2021

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

% go version
go version devel go1.18-a0adf91 Mon Aug 16 16:58:24 2021 +0000 darwin/amd64

Trying -G=3 on the latest master, I wasn't sure whether this is similar to #47708 or #47676, so I figured I could open a new ticket. This was extracted from a toy library I'm working on, apologies for the somewhat complex reproducer, I tried to simplify it as much as I could.

Reproducer:

package main

import "strconv"

func main() {
	ch := make(chan int, 10)
	for i := 0; i < 10; i++ {
		ch <- i
	}

	Map(ch, strconv.Itoa)
}

func Map[InputType, OutputType any](in <-chan InputType, f func(InputType) OutputType) <-chan OutputType {
	out := make(chan OutputType, cap(in))
	go func() {
		defer close(out)
		for v := range in {
			out <- f(v)
		}
	}()
	return out
}

Error message:

% go build -gcflags=-G=3
# github.com/fsouza/repro
./main.go:22:9: internal compiler error: found illegal assignment .shape.int -> main.InputType₁;

goroutine 1 [running]:
runtime/debug.Stack()
        /Users/fsouza/.cache/go/sdk/gotip/src/runtime/debug/stack.go:24 +0x65
cmd/compile/internal/base.FatalfAt({0x0, 0x0}, {0x1903740, 0x27}, {0xc0004de180, 0x3, 0x3})
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/base/print.go:227 +0x154
cmd/compile/internal/base.Fatalf(...)
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/base/print.go:196
cmd/compile/internal/noder.assignconvfn({0x1a5cc38, 0xc0004e4d00}, 0xc00049cc40)
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/noder/transform.go:413 +0x167
cmd/compile/internal/noder.typecheckaste(0x10, {0xc0004b0e10, 0xc0004b0e10}, 0x0, 0xc0004e4d00, {0xc000488a10, 0x1, 0x11af912}, 0x0)
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/noder/transform.go:465 +0x186
cmd/compile/internal/noder.transformCall(0xc0004b0e10)
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/noder/transform.go:160 +0x199
cmd/compile/internal/noder.(*subster).node.func1({0x1a5b658, 0xc0004b0900})
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:1043 +0xed5
cmd/compile/internal/ir.(*SendStmt).editChildren(0xc0004e8460, 0xc00048d0c8)
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/ir/node_gen.go:1137 +0xb5
cmd/compile/internal/ir.EditChildren(...)
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/ir/visit.go:185
cmd/compile/internal/noder.(*subster).node.func1({0x1a5d408, 0xc0004cb040})
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:901 +0x423
cmd/compile/internal/ir.editNodes({0xc000488a00, 0x1, 0x18c7280}, 0xc00048d0c8)
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/ir/node_gen.go:1521 +0x74
cmd/compile/internal/ir.(*RangeStmt).editChildren(0xc0004b0d80, 0xc00048d0c8)
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/ir/node_gen.go:1000 +0x16c
cmd/compile/internal/ir.EditChildren(...)
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/ir/visit.go:185
cmd/compile/internal/noder.(*subster).node.func1({0x1a5cf58, 0xc0004b0990})
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:901 +0x423
cmd/compile/internal/noder.(*subster).node(0xc0004bc180, {0x1a5cf58, 0xc0004b0990})
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:1184 +0xa5
cmd/compile/internal/noder.(*subster).namelist(0xc0004e83c0, {0xc0004843d0, 0x1, 0x0})
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:1255 +0xb7
cmd/compile/internal/noder.(*subster).node.func1({0x1a5b8b0, 0xc0004caf00})
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:1073 +0x1132
cmd/compile/internal/ir.(*CallExpr).editChildren(0xc0004b0cf0, 0xc00048d0b0)
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/ir/node_gen.go:274 +0x58
cmd/compile/internal/ir.EditChildren(...)
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/ir/visit.go:185
cmd/compile/internal/noder.(*subster).node.func1({0x1a5b658, 0xc0004b0a20})
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:901 +0x423
cmd/compile/internal/ir.(*GoDeferStmt).editChildren(0xc0004ec000, 0xc00048d0b0)
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/ir/node_gen.go:606 +0x58
cmd/compile/internal/ir.EditChildren(...)
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/ir/visit.go:185
cmd/compile/internal/noder.(*subster).node.func1({0x1a5c148, 0xc000497e80})
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:901 +0x423
cmd/compile/internal/noder.(*subster).node(0xc0004bc180, {0x1a5c148, 0xc000497e80})
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:1184 +0xa5
cmd/compile/internal/noder.(*subster).list(0xc000484450, {0xc000497ec0, 0x3, 0xc00008c640})
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:1267 +0x8e
cmd/compile/internal/noder.(*irgen).genericSubst(0xc0004e0000, 0xc0004cbf40, 0xc00049b860, {0xc000488910, 0x2, 0x2}, 0x0, 0xc000497fc0)
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:714 +0xcc6
cmd/compile/internal/noder.(*irgen).getInstantiation(0xc0004e0000, 0xc00049b860, {0xc000488900, 0x2, 0x2}, 0xb8)
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:600 +0x33d
cmd/compile/internal/noder.(*irgen).stencil.func1({0x1a5b658, 0xc0004b06c0})
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:109 +0x2df
cmd/compile/internal/ir.Visit.func1({0x1a5b658, 0xc0004b06c0})
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/ir/visit.go:105 +0x30
cmd/compile/internal/ir.doNodes({0xc000497dc0, 0x3, 0x0}, 0xc00048cea0)
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/ir/node_gen.go:1512 +0x67
cmd/compile/internal/ir.(*Func).doChildren(0x1a5bfb8, 0xc00048a2c0)
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/ir/func.go:152 +0x2e
cmd/compile/internal/ir.DoChildren(...)
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/ir/visit.go:94
cmd/compile/internal/ir.Visit.func1({0x1a5bfb8, 0xc00048a2c0})
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/ir/visit.go:106 +0x57
cmd/compile/internal/ir.Visit({0x1a5bfb8, 0xc00048a2c0}, 0xc000497f80)
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/ir/visit.go:108 +0xb8
cmd/compile/internal/noder.(*irgen).stencil(0xc0004e0000)
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:91 +0x26a
cmd/compile/internal/noder.(*irgen).generate(0xc0004e0000, {0xc000076b80, 0x2, 0x203000})
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/noder/irgen.go:265 +0x272
cmd/compile/internal/noder.check2({0xc000076b80, 0x2, 0x2})
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/noder/irgen.go:92 +0x16d
cmd/compile/internal/noder.LoadPackage({0xc00001e210, 0x2, 0x0})
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/noder/noder.go:90 +0x365
cmd/compile/internal/gc.Main(0x1916710)
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/internal/gc/main.go:190 +0xaf3
main.main()
        /Users/fsouza/.cache/go/sdk/gotip/src/cmd/compile/main.go:55 +0xdd
@ALTree
Copy link
Member

@ALTree ALTree commented Aug 16, 2021

Seems likely to be a #47676 dup? Involves closures and for range like #47676, and the stack trace is very similar. I would add your testcase in the #47676 thread to keep the discussion in one place.

Loading

@fsouza
Copy link
Contributor Author

@fsouza fsouza commented Aug 16, 2021

@ALTree makes sense! Should I close this and add a comment to #47676?

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants