Navigation Menu

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
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@ALTree
Copy link
Member

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

@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 13, 2021
@randall77 randall77 self-assigned this Aug 13, 2021
@gopherbot
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

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>
@golang golang locked and limited conversation to collaborators Jun 23, 2023
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

3 participants