Skip to content

Commit

Permalink
cmd/compile/internal/syntax: add test case for invalid label use
Browse files Browse the repository at this point in the history
This case is not properly handled by the type checkers (see issue)
but the compiler uses the parser's label checking so it works as
expected.

For golang#70974.

Change-Id: I0849376bf7514a9a7730846649c3fe28c91f44ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/640895
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Alan Donovan <[email protected]>
Reviewed-by: Robert Griesemer <[email protected]>
Auto-Submit: Robert Griesemer <[email protected]>
  • Loading branch information
griesemer authored and wyf9661 committed Jan 21, 2025
1 parent 6d73211 commit 97b28d2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/cmd/compile/internal/syntax/testdata/issue70974.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2025 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package p

func _() {
M:
L:
for range 0 {
break L
break /* ERROR invalid break label M */ M
}
for range 0 {
break /* ERROR invalid break label L */ L
}
}

0 comments on commit 97b28d2

Please sign in to comment.