You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
//go:noinline
func f[T any]() {
x := 5
g := func() int { return x }
g()
}
func main() {
f[int]()
}
generates
$ go tool compile -G=3 tmp.go
panic: interface conversion: interface {} is nil, not *escape.location
goroutine 1 [running]:
cmd/compile/internal/escape.(*batch).oldLoc(...)
/Users/khr/sandbox/ro/src/cmd/compile/internal/escape/escape.go:1311
A small debugging print in (*batch).oldLoc at that line number indicates the variable without a location is ~r0.
There's nothing directly related to generics going on here, just something I suspect triggered by the slightly different phase ordering when processing generic functions.
@dancsales
The text was updated successfully, but these errors were encountered:
This appears to be because we're not copying the formal parameters of a closure. When we copy a closure, we're not making new formal parameters for the closure because its type doesn't have any generic parameters. But we do make a copy of the formal parameter when we encounter it in the body of the closure. Escape analysis treats these two Names as different, and one of them was never assigned a location.
I think we need to copy the type of the closure always, even when it doesn't have any type parameters. it's not that simple though, or I would have fixed it already :(. Still looking.
generates
A small debugging print in
(*batch).oldLoc
at that line number indicates the variable without a location is~r0
.There's nothing directly related to generics going on here, just something I suspect triggered by the slightly different phase ordering when processing generic functions.
@dancsales
The text was updated successfully, but these errors were encountered: