summaryrefslogtreecommitdiff
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
commit506438723710dd8473db2f5f7848d2fe721b7a22 (patch)
tree446219e01aa160977eaf02e4d0821739df900912 /test/switch.go
parent83ff7191f858e6bb834455b3503f785a50c762e9 (diff)
downloadgo-506438723710dd8473db2f5f7848d2fe721b7a22.tar.gz
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 issue 3980. R=golang-dev, rsc CC=golang-dev http://codereview.appspot.com/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 a4242f257..fd8748b9b 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}: