Files
delve/_fixtures/issue4000.go
Alessandro Arzilli efbc259a67 pkg/proc: make closure captured vars visible on closure's first line (#4049)
Variables normally become visible on the line after the one they are
defined at, because on their definition line they will not be
initialized. This is a problem for variables captured by closures
because they get the closure function's first line as the declaration
line.
Make variables captured by closures visible on their declaration line
and load their value from the closure struct if they are unreadable.

Fixes #4000
2025-07-08 09:58:46 -07:00

15 lines
185 B
Go

package main
import "fmt"
func main() {
var test = "a string"
var f = func() {
test = "another string"
fmt.Println("test", test)
}
fmt.Println(test)
f()
fmt.Println(test)
}