delve
delve copied to clipboard
Wrong declLine inside a closure
trafficstars
- What version of Delve are you using (
dlv version)?
Delve Debugger
Version: 1.2.0
Build: 4779218a8354d2facdbf2c48263c4144be330ca0
- What version of Go are you using? (
go version)?
go version go1.12.9 linux/386
- What operating system and processor architecture are you using?
Linux, x86_64
- What did you do?
Debugged the following program with a breakpoint at line 8
package main
func main() {
v := 1
closure := func() {
println(v)
v := 2
println(v) //break
}
closure()
println(v)
}
Executed the locals command when debugger reaches the breakpoint.
- What did you expect to see?
The v=1 defined outside of the closure has DeclLine = 4.
- What did you see instead?
The v=1 defined outside of the closure has DeclLine = 6.
Full log: https://gist.github.com/nd/5fa605ac3e24fa42b35c7dc448998a5e.
This is a compiler bug, and it's compilcated, see $GOROOT/src/cmd/compile/internal/gc/pgen.go:425