Skip to content

Commit 300336c

Browse files
committed
cmd/compile/internal/syntax: simplify jumpsOverVarDecl
To make it a bit clearer to read. Change-Id: I131941bc1d1918144f67fdcc1d32e6525009f0c0
1 parent 3871c0d commit 300336c

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/cmd/compile/internal/syntax/branches.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
package syntax
66

7-
import "fmt"
7+
import (
8+
"fmt"
9+
"slices"
10+
)
811

912
// checkBranches checks correct use of labels and branch
1013
// statements (break, continue, fallthrough, goto) in a function body.
@@ -146,14 +149,7 @@ func (ls *labelScope) blockBranches(parent *block, ctxt targets, lstmt *LabeledS
146149
}
147150

148151
jumpsOverVarDecl := func(fwd *BranchStmt) bool {
149-
if varPos.IsKnown() {
150-
for _, bad := range badGotos {
151-
if fwd == bad {
152-
return true
153-
}
154-
}
155-
}
156-
return false
152+
return varPos.IsKnown() && slices.Contains(badGotos, fwd)
157153
}
158154

159155
innerBlock := func(ctxt targets, start Pos, body []Stmt) {

0 commit comments

Comments
 (0)