aboutsummaryrefslogtreecommitdiff
path: root/test/used.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2020-12-04 11:37:54 -0500
committerRuss Cox <rsc@golang.org>2020-12-07 20:40:21 +0000
commitef5964dd6b092f7e0d9bd4332a5d258eb80ecef8 (patch)
tree8d0acc8858e73a3859329beaa0747018aaaae566 /test/used.go
parentdcc640e8391d6d022b595a3b53124bbcbd985c76 (diff)
downloadgo-ef5964dd6b092f7e0d9bd4332a5d258eb80ecef8.tar.gz
go-ef5964dd6b092f7e0d9bd4332a5d258eb80ecef8.zip
[dev.regabi] cmd/compile: arrange for typecheck1 to end in switch
Ending typecheck1 in the switch makes it safe for each case to do an appropriate type assertion. The main change is dropping the computation of "ok" and using the syntax nodes themselves to decide what's OK. Passes buildall w/ toolstash -cmp. Change-Id: I2a1873a51e3f1194d74bb87a6653cb9857a02a1b Reviewed-on: https://go-review.googlesource.com/c/go/+/275444 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'test/used.go')
-rw-r--r--test/used.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/test/used.go b/test/used.go
index adf2bfcb95..5c7aad24a6 100644
--- a/test/used.go
+++ b/test/used.go
@@ -10,7 +10,7 @@ import "unsafe"
const C = 1
-var x1, x int
+var x, x1, x2 int
var b bool
var s string
var c chan int
@@ -120,7 +120,6 @@ func _() {
_ = print(1) // ERROR "print\(1\) used as value"
println(1) // ok
_ = println(1) // ERROR "println\(1\) used as value"
- (x) // ERROR "x evaluated but not used"
c <- 1 // ok
slice[1:1] // ERROR "slice\[1:1\] evaluated but not used"
array[1:1] // ERROR "array\[1:1\] evaluated but not used"
@@ -137,6 +136,8 @@ func _() {
unsafe.Alignof(t.X) // ERROR "unsafe.Alignof\(t.X\) evaluated but not used"
unsafe.Offsetof(t.X) // ERROR "unsafe.Offsetof\(t.X\) evaluated but not used"
unsafe.Sizeof(t) // ERROR "unsafe.Sizeof\(t\) evaluated but not used"
- _ = new(x) // ERROR "x is not a type"
_ = int // ERROR "type int is not an expression"
+ (x) // ERROR "x evaluated but not used"
+ _ = new(x2) // ERROR "x2 is not a type"
+ _ = new(1 + 1) // ERROR "1 \+ 1 is not a type"
}