Files
golang.go/test/fixedbugs
Cuong Manh Le f665ff8bc1 cmd/compile: fix wrong label loop during rangefunc rewrite
During the rangefunc rewrite, the compiler must correctly identify
the target of branch statements. When a label is defined within a
nested scope - such as inside a function literal or a closure - it
can shadow a label with the same name in the outer scope.

If the rewrite logic does not account for this shadowing, it may
incorrectly associate a branch with a nested label rather than the
intended loop label. Since the typechecker already guarantees that
labels are unique within their respective scopes, any duplicate label
name encountered must belong to a nested scope. These should be
skipped to ensure branch computing correctly targets the current
range-loop scope.

Fixes #78408

Change-Id: I4dce8a4d956f41b3a717a509f8c3f7478720be9f
Reviewed-on: https://go-review.googlesource.com/c/go/+/761420
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2026-03-31 10:58:57 -07:00
..
2023-03-28 18:13:13 +00:00
2023-03-28 18:13:13 +00:00
2023-03-28 18:13:13 +00:00
2023-03-28 18:13:13 +00:00
2023-03-28 18:13:13 +00:00
2023-03-28 18:13:13 +00:00
2022-05-18 00:47:29 +00:00
2023-03-28 18:13:13 +00:00
2025-10-29 11:00:23 -07:00
2025-10-29 11:00:23 -07:00
2021-02-22 22:53:51 +00:00
2025-10-29 11:00:23 -07:00
2021-04-21 20:24:34 +00:00
2024-09-13 21:21:33 +00:00
2024-09-13 21:24:10 +00:00
2025-10-29 11:00:23 -07:00
2021-02-22 20:00:00 +00:00
2021-05-22 00:51:17 +00:00
2023-02-07 20:59:40 +00:00