diff options
Diffstat (limited to 'src/cmd')
| -rw-r--r-- | src/cmd/compile/internal/rangefunc/rewrite.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/rangefunc/rewrite.go b/src/cmd/compile/internal/rangefunc/rewrite.go index 551e126af8..2421efbad8 100644 --- a/src/cmd/compile/internal/rangefunc/rewrite.go +++ b/src/cmd/compile/internal/rangefunc/rewrite.go @@ -994,7 +994,14 @@ func (r *rewriter) computeBranchNext() { l := n.Label.Value labels = append(labels, l) f := forStack[len(forStack)-1] - r.labelLoop[l] = f + if _, existed := r.labelLoop[l]; existed { + // The typechecker has already validated that labels are unique within this scope. + // If a duplicate label 'X' is encountered, it must reside in a nested scope + // (e.g., inside a function literal). Because nested labels do not affect + // the current control flow analysis, they can be safely ignored. + } else { + r.labelLoop[l] = f + } } } else { n := stack[len(stack)-1] |
