aboutsummaryrefslogtreecommitdiff
path: root/test/switch2.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2015-11-20 16:49:30 -0800
committerRobert Griesemer <gri@golang.org>2015-11-21 07:21:23 +0000
commitaad18b849bd925c2d7cfdda45384d71fe0153d98 (patch)
tree0fa6548c98fc572d5002373a4be08f918f493629 /test/switch2.go
parent0383bb473ddd394495c17f1ce7f5e555e311986d (diff)
downloadgo-aad18b849bd925c2d7cfdda45384d71fe0153d98.tar.gz
go-aad18b849bd925c2d7cfdda45384d71fe0153d98.zip
cmd/compile: address several more 1.6 TODOs in parser
- fix/check location of popdcl calls where questioned - remove unnecessary handling of ... (LDDD) in ntype (couldn't be reached) - inlined and fnret_type and simplified fnres as a consequence - leave handling of ... (LDDD) in arg_list alone (remove TODO) - verify that parser requires a ';' after last statement in a case/default (added test case) Fixes #13243. Change-Id: Iad94b498591a5e85f4cb15bbc01e8e101415560d Reviewed-on: https://go-review.googlesource.com/17155 Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Chris Manghane <cmang@golang.org>
Diffstat (limited to 'test/switch2.go')
-rw-r--r--test/switch2.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/test/switch2.go b/test/switch2.go
index 3582da8be6..11ff5c5d9b 100644
--- a/test/switch2.go
+++ b/test/switch2.go
@@ -4,11 +4,12 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Check various syntax errors with switches.
+// Verify that erroneous switch statements are detected by the compiler.
+// Does not compile.
package main
-func _() {
+func f() {
switch {
case 0; // ERROR "expecting := or = or : or comma"
}
@@ -19,6 +20,20 @@ func _() {
}
switch {
+ case 0: case 0: default:
+ }
+
+ switch {
+ case 0: f(); case 0:
+ case 0: f() case 0: // ERROR "unexpected case at end of statement"
+ }
+
+ switch {
+ case 0: f(); default:
+ case 0: f() default: // ERROR "unexpected default at end of statement"
+ }
+
+ switch {
if x: // ERROR "expecting case or default or }"
}
}