aboutsummaryrefslogtreecommitdiff
path: root/test/switch3.go
diff options
context:
space:
mode:
authorRémy Oudompheng <oudomphe@phare.normalesup.org>2012-08-03 21:47:26 +0200
committerRémy Oudompheng <oudomphe@phare.normalesup.org>2012-08-03 21:47:26 +0200
commitf4f1ba2b1ebb76d4277cd775215ccd12994ffb40 (patch)
tree487bb7df55ec24a0071305933de2d3250a5606a3 /test/switch3.go
parent728f19131919734e473e3de425abb966b45b13f8 (diff)
downloadgo-f4f1ba2b1ebb76d4277cd775215ccd12994ffb40.tar.gz
go-f4f1ba2b1ebb76d4277cd775215ccd12994ffb40.zip
cmd/gc: accept switches on comparable arrays.
The compiler is incorrectly rejecting switches on arrays of comparable types. It also doesn't catch incomparable structs when typechecking the switch, leading to unreadable errors during typechecking of the generated code. Fixes #3894. R=rsc CC=gobot, golang-dev, r, remy https://golang.org/cl/6442074
Diffstat (limited to 'test/switch3.go')
-rw-r--r--test/switch3.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/switch3.go b/test/switch3.go
index dcb6fff208..28705e464e 100644
--- a/test/switch3.go
+++ b/test/switch3.go
@@ -45,6 +45,17 @@ func bad() {
case f1: // ERROR "can only compare func f to nil|func can only be compared to nil"
default:
}
+
+ var ar, ar1 [4]func()
+ switch ar { // ERROR "cannot switch on"
+ case ar1:
+ default:
+ }
+
+ var st, st1 struct{ f func() }
+ switch st { // ERROR "cannot switch on"
+ case st1:
+ }
}
func good() {