cmd/compile: better error message when offending/missing token is a keyword

Prefix keywords (type, default, case, etc.) with "keyword" in error
messages to make them less ambiguous.

Fixes #68589.

Change-Id: I1eb92d1382f621b934167b3a4c335045da26be9f
Reviewed-on: https://go-review.googlesource.com/c/go/+/623819
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
This commit is contained in:
Robert Griesemer 2024-10-31 11:19:28 -07:00 committed by Gopher Robot
parent 3730814f2f
commit 2eac154b1c
5 changed files with 17 additions and 6 deletions

View file

@ -25,12 +25,12 @@ func f() {
switch {
case 0: f(); case 0:
case 0: f() case 0: // ERROR "unexpected case at end of statement"
case 0: f() case 0: // ERROR "unexpected keyword case at end of statement"
}
switch {
case 0: f(); default:
case 0: f() default: // ERROR "unexpected default at end of statement"
case 0: f() default: // ERROR "unexpected keyword default at end of statement"
}
switch {