Description
This is present on master, for example on go version go1.25-devel_8131635e5a
and bisecting the problem leads to 988a20c.
The following piece of code:
1 package main
2
3 import (
4 "fmt"
5 "runtime"
6 )
7
8 func main() {
9 a := 0
10 {
11 a := 1
12 runtime.Breakpoint()
13 fmt.Println(a)
14 }
15 fmt.Println(a)
16 }
(also found at https://github.com/go-delve/delve/blob/4a2a6e1aeb90f92eb17f5f055bfe5d7f066a008d/_fixtures/testshadow.go)
When compiled with -gcflags='-N -l'
will produce a debug_line table such that execution proceeds as such: line 8, 9, 11, 12, 11 again, 13, 9 again, finally 15. Lines 9 and 11 are executed twice each.
The more variables initialized to a constant there are the more execution will jump back and forth, for example see https://github.com/go-delve/delve/blob/4a2a6e1aeb90f92eb17f5f055bfe5d7f066a008d/_fixtures/testvariables.go.
Now, this problem is probably way more prevalent in delve's test suite than in code so I'm probably the person who is most inconvenienced by this in the universe, nevertheless, it is a regression that I imagine will affect others as well.
cc @thepudds, @randall77 because of the bisect
cc @dr2chase because it's about line numbers