aboutsummaryrefslogtreecommitdiff
path: root/test/switch.go
diff options
context:
space:
mode:
authorDaniel Morsing <daniel.morsing@gmail.com>2012-09-17 21:29:10 +0200
committerDaniel Morsing <daniel.morsing@gmail.com>2012-09-17 21:29:10 +0200
commit551e26382385a91cbe9cfc94b1327d29f030f254 (patch)
treef7cd8275455917c0c4d8d76c56806b2b3db4c39c /test/switch.go
parentc7631f555f880409fb13143d0d8236ad9fb99c2c (diff)
downloadgo-551e26382385a91cbe9cfc94b1327d29f030f254.tar.gz
go-551e26382385a91cbe9cfc94b1327d29f030f254.zip
cmd/gc: add missing conversion from bool to interface in switches.
In switches without an expression, the compiler would not convert the implicit true to an interface, causing codegen errors. Fixes #3980. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/6497147
Diffstat (limited to 'test/switch.go')
-rw-r--r--test/switch.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/switch.go b/test/switch.go
index a4242f2571..fd8748b9bc 100644
--- a/test/switch.go
+++ b/test/switch.go
@@ -294,6 +294,17 @@ func main() {
assert(false, `i should be "hello"`)
}
+ // switch on implicit bool converted to interface
+ // was broken: see issue 3980
+ switch i := interface{}(true); {
+ case i:
+ assert(true, "true")
+ case false:
+ assert(false, "i should be true")
+ default:
+ assert(false, "i should be true")
+ }
+
// switch on array.
switch ar := [3]int{1, 2, 3}; ar {
case [3]int{1,2,3}: