aboutsummaryrefslogtreecommitdiff
path: root/test/cmp.go
diff options
context:
space:
mode:
authorRémy Oudompheng <oudomphe@phare.normalesup.org>2014-02-24 19:51:59 +0100
committerRémy Oudompheng <oudomphe@phare.normalesup.org>2014-02-24 19:51:59 +0100
commit14b0af4272aa6c638e97cb3364a81962d69dbfc6 (patch)
treed196a94646d07a28fb89993e522450fe62454f51 /test/cmp.go
parentff15e5c00f7fe3fcec1277f932fbca381fd2d2ad (diff)
downloadgo-14b0af4272aa6c638e97cb3364a81962d69dbfc6.tar.gz
go-14b0af4272aa6c638e97cb3364a81962d69dbfc6.zip
cmd/gc: fix walkcompare bugs.
Revision c0e0467635ec (cmd/gc: return canonical Node* from temp) exposed original nodes of temporaries, allowing callers to mutate their types. In walkcompare a temporary could be typed as ideal because of this. Additionnally, assignment of a comparison result to a custom boolean type was broken. Fixes #7366. LGTM=rsc R=rsc, iant, khr CC=golang-codereviews https://golang.org/cl/66930044
Diffstat (limited to 'test/cmp.go')
-rw-r--r--test/cmp.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/cmp.go b/test/cmp.go
index 73de502f39..9ac0ebe79d 100644
--- a/test/cmp.go
+++ b/test/cmp.go
@@ -387,6 +387,23 @@ func main() {
isfalse(iz != x)
}
+ // named booleans
+ {
+ type mybool bool
+ var b mybool
+
+ type T struct{ data [20]byte }
+ var x, y T
+ b = x == y
+ istrue(x == y)
+ istrue(bool(b))
+
+ m := make(map[string][10]interface{})
+ b = m["x"] == m["y"]
+ istrue(m["x"] == m["y"])
+ istrue(bool(b))
+ }
+
shouldPanic(p1)
shouldPanic(p2)
shouldPanic(p3)