mailgun / godebug

DEPRECATED! https://github.com/derekparker/delve
Apache License 2.0
2.5k stars 107 forks source link

Can't print vars of labeled loop's range #61

Closed stroborobo closed 3 years ago

stroborobo commented 9 years ago

Hey guys,

I just had the rare case where a labeled loop would be actually nice to use and while debugging something I noticed this behaviour:

main.go:

package main

func main() {
    a := []int{1, 2, 3}

    _ = "breakpoint"
loop:
    for _, av := range a {
        _ = av
        continue loop
    }

    _ = "breakpoint"
    for _, av := range a {
        _ = av
    }
}

godebug:

-> _ = "breakpoint"
(godebug) n
-> loop:
(godebug) n
-> _ = av
(godebug) p av
undefined: av
(godebug) c
-> _ = "breakpoint"
(godebug) n
-> for _, av := range a {
(godebug) n
-> _ = av
(godebug) p av
1
(godebug) quitting session
}
jeremyschlatter commented 9 years ago

Good catch, thanks!