mailgun / mailgun/godebug

Don't show loop header after break statement

Open
#39 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
2.5k
Forks
102
PR merge metrics
No merged PRs in 30d

Description

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
$
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the behavior with the two min.go examples using `godebug run min.go`, then trace the debugger's loop-stepping path. Done means a loop with a declared variable does not print its header again after `break`, while the existing behavior for `for {}` remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.