From 97b28d274d7762daa7bc6adfe159eec09ddf63d9 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 6 Jan 2025 16:22:10 -0800 Subject: [PATCH] cmd/compile/internal/syntax: add test case for invalid label use 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 #70974. Change-Id: I0849376bf7514a9a7730846649c3fe28c91f44ca Reviewed-on: https://go-review.googlesource.com/c/go/+/640895 LUCI-TryBot-Result: Go LUCI Reviewed-by: Alan Donovan Reviewed-by: Robert Griesemer Auto-Submit: Robert Griesemer --- .../internal/syntax/testdata/issue70974.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/cmd/compile/internal/syntax/testdata/issue70974.go diff --git a/src/cmd/compile/internal/syntax/testdata/issue70974.go b/src/cmd/compile/internal/syntax/testdata/issue70974.go new file mode 100644 index 00000000000000..ebc69eda950254 --- /dev/null +++ b/src/cmd/compile/internal/syntax/testdata/issue70974.go @@ -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 + } +}