mailgun/godebug

Don't show loop header after break statement

Opened this issue · 0 comments

After a loop reaches a break statement, godebug unnecessarily prints the loop statement again.

$ cat min.go
package main

func main() {
    _ = "breakpoint"
    for i := 1; i < 5; i++ {
        break
    }
}
$ godebug run min.go
-> _ = "breakpoint"
(godebug) n
-> for i := 1; i < 5; i++ {
(godebug) n
-> break
(godebug) n
-> for i := 1; i < 5; i++ {
(godebug) n
$

Though note this doesn't happen if no variables are declared in the loop statement:

$ cat min.go
package main

func main() {
    _ = "breakpoint"
    for {
        break
    }
}
$ godebug run min.go
-> _ = "breakpoint"
(godebug) n
-> for {
(godebug) n
-> break
(godebug) n
$