diff options
author | Robert Griesemer <gri@golang.org> | 2017-02-08 17:56:41 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2017-02-09 03:54:47 +0000 |
commit | 3c22e5ca271ca4ad17b34d965e6a9baf7b5cf94d (patch) | |
tree | 4e334b6df478459a3a7e82103af4c364c2f81208 /test/syntax | |
parent | 7ad512e7ffe576c4894ea84b02e954846fbda643 (diff) | |
download | go-3c22e5ca271ca4ad17b34d965e6a9baf7b5cf94d.tar.gz go-3c22e5ca271ca4ad17b34d965e6a9baf7b5cf94d.zip |
cmd/compile/internal/parser: improved syntax error for incorrect if/for/switch header
Starting the error message with "expecting" rather than "missing"
causes the syntax error mechanism to add additional helpful info
(it recognizes "expecting" but not "missing").
Fixes #17328.
Change-Id: I8482ca5e5a6a6b22e0ed0d831b7328e264156334
Reviewed-on: https://go-review.googlesource.com/36637
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'test/syntax')
-rw-r--r-- | test/syntax/semi1.go | 2 | ||||
-rw-r--r-- | test/syntax/semi3.go | 2 | ||||
-rw-r--r-- | test/syntax/semi4.go | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/test/syntax/semi1.go b/test/syntax/semi1.go index c755445b42..8eed05c1ca 100644 --- a/test/syntax/semi1.go +++ b/test/syntax/semi1.go @@ -7,7 +7,7 @@ package main func main() { - if x; y // ERROR "missing .*{.* after if clause|undefined" + if x; y // ERROR "expected .*{.* after if clause|undefined" { z // GCCGO_ERROR "undefined" diff --git a/test/syntax/semi3.go b/test/syntax/semi3.go index d625d08350..d064ce631c 100644 --- a/test/syntax/semi3.go +++ b/test/syntax/semi3.go @@ -7,7 +7,7 @@ package main func main() { - for x; y; z // ERROR "missing .*{.* after for clause|undefined" + for x; y; z // ERROR "expected .*{.* after for clause|undefined" { z // GCCGO_ERROR "undefined" diff --git a/test/syntax/semi4.go b/test/syntax/semi4.go index 6f5592ef0e..0b5e677680 100644 --- a/test/syntax/semi4.go +++ b/test/syntax/semi4.go @@ -13,5 +13,5 @@ package main func main() { for x // GCCGO_ERROR "undefined" - { // ERROR "missing .*{.* after for clause|missing operand" - z // ERROR "undefined|missing { after for clause" + { // ERROR "expecting .*{.* after for clause|missing operand" + z // ERROR "undefined|expecting { after for clause" |