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: misuse of CaptureName on closure variable #47684

Closed
ALTree opened this issue Aug 13, 2021 · 3 comments
Closed
Assignees

Comments

@ALTree
Copy link
Member

@ALTree ALTree commented Aug 13, 2021

$ gotip version
go version devel go1.18-4c8ffb3baa Fri Aug 13 00:20:28 2021 +0000 linux/amd64

Was playing around with -G=3 after the dev.typeparams merge into master.

package main

func f[G any]() int {
	return func() int {
		return func() int {
			return 0
		}()
	}()
}

func main() {
	f[int]()
}
$ gotip tool compile -G=3 crash.go

crash.go:5:10: internal compiler error: misuse of CaptureName on closure variable: .dict

goroutine 1 [running]:
runtime/debug.Stack()
	/home/alberto/go/src/runtime/debug/stack.go:24 +0x65
cmd/compile/internal/base.FatalfAt({0x401ba0, 0xc0}, {0xd0af82, 0x2d}, {0xc000114240, 0x1, 0x1})
	/home/alberto/go/src/cmd/compile/internal/base/print.go:227 +0x154
cmd/compile/internal/ir.CaptureName({0x40b2c0, 0xc0}, 0xc000402f20, 0xc00040e680)
	/home/alberto/go/src/cmd/compile/internal/ir/name.go:408 +0x8d
cmd/compile/internal/noder.(*subster).node.func1({0xe5eb90, 0xc0003f7ea0})
	/home/alberto/go/src/cmd/compile/internal/noder/stencil.go:1077 +0x118c
cmd/compile/internal/ir.(*CallExpr).editChildren(0xc0001726c0, 0xc00000db30)
	/home/alberto/go/src/cmd/compile/internal/ir/node_gen.go:274 +0x58
cmd/compile/internal/ir.EditChildren(...)

cc @danscales @randall77

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 13, 2021

Change https://golang.org/cl/342050 mentions this issue: cmd/compile: fix dictionaries for nested closures

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 16, 2021

Change https://golang.org/cl/342529 mentions this issue: [dev.typeparams] cmd/compile: fix dictionaries for nested closures

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 20, 2021

Change https://golang.org/cl/343871 mentions this issue: cmd/compile: copy captured dictionary var to local var

Loading

gopherbot pushed a commit that referenced this issue Aug 23, 2021
When starting a closure that needs a dictionary, copy the closure
variable to a local variable. This lets child closures capture that
dictionary variable correctly.

This is a better fix for #47684, which does not cause problems
like #47723.

Fixes #47723
Update #47684

Change-Id: Ib5d9ffc68a5142e28daa7d0d75683e7a35508540
Reviewed-on: https://go-review.googlesource.com/c/go/+/343871
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants