aboutsummaryrefslogtreecommitdiff
path: root/test/syntax
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2020-02-06 15:32:40 -0800
committerRobert Griesemer <gri@golang.org>2020-02-21 22:57:52 +0000
commitffc0573b854ca2fc58ad85ad7599ec66f0a82b36 (patch)
treec9e863a427f9008fd6caf57e90268ec3648ff495 /test/syntax
parentd532d5f0fade2630612a5bdb0ac3f95824266ad5 (diff)
downloadgo-ffc0573b854ca2fc58ad85ad7599ec66f0a82b36.tar.gz
go-ffc0573b854ca2fc58ad85ad7599ec66f0a82b36.zip
cmd/compile/internal/syntax: better error when an assignment is used in value context
The error message is now positioned at the statement position (which is an identifing token, such as the '=' for assignments); and in case of assignments it emphasizes the assignment by putting the Lhs and Rhs in parentheses. Finally, the wording is changed from "use of * as value" to the stronger "cannot use * as value" (for which there is precedent elsewhere in the parser). Fixes #36858. Change-Id: Ic3f101bba50f58e3a1d9b29645066634631f2d61 Reviewed-on: https://go-review.googlesource.com/c/go/+/218337 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'test/syntax')
-rw-r--r--test/syntax/chan1.go2
-rw-r--r--test/syntax/typesw.go2
2 files changed, 2 insertions, 2 deletions
diff --git a/test/syntax/chan1.go b/test/syntax/chan1.go
index 4eb63796ac..56103d1d79 100644
--- a/test/syntax/chan1.go
+++ b/test/syntax/chan1.go
@@ -10,7 +10,7 @@ var c chan int
var v int
func main() {
- if c <- v { // ERROR "used as value"
+ if c <- v { // ERROR "cannot use c <- v as value"
}
}
diff --git a/test/syntax/typesw.go b/test/syntax/typesw.go
index f9120e8851..3781933978 100644
--- a/test/syntax/typesw.go
+++ b/test/syntax/typesw.go
@@ -7,7 +7,7 @@
package main
func main() {
- switch main() := interface{}(nil).(type) { // ERROR "invalid variable name|used as value"
+ switch main() := interface{}(nil).(type) { // ERROR "invalid variable name|cannot use .* as value"
default:
}
}