2015-11-19 16:43:05 -07:00
|
|
|
// errorcheck
|
|
|
|
|
|
|
|
// Copyright 2015 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2015-11-20 17:49:30 -07:00
|
|
|
// Verify that erroneous switch statements are detected by the compiler.
|
|
|
|
// Does not compile.
|
2015-11-19 16:43:05 -07:00
|
|
|
|
|
|
|
package main
|
|
|
|
|
2015-11-20 17:49:30 -07:00
|
|
|
func f() {
|
2015-11-19 16:43:05 -07:00
|
|
|
switch {
|
2022-08-25 17:41:35 -06:00
|
|
|
case 0; // ERROR "expecting := or = or : or comma|expected :"
|
2015-11-19 16:43:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
switch {
|
2022-08-25 17:41:35 -06:00
|
|
|
case 0; // ERROR "expecting := or = or : or comma|expected :"
|
2015-11-19 16:43:05 -07:00
|
|
|
default:
|
|
|
|
}
|
|
|
|
|
2015-11-20 17:49:30 -07:00
|
|
|
switch {
|
|
|
|
case 0: case 0: default:
|
|
|
|
}
|
|
|
|
|
|
|
|
switch {
|
|
|
|
case 0: f(); case 0:
|
2024-10-31 12:19:28 -06:00
|
|
|
case 0: f() case 0: // ERROR "unexpected keyword case at end of statement"
|
2015-11-20 17:49:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
switch {
|
|
|
|
case 0: f(); default:
|
2024-10-31 12:19:28 -06:00
|
|
|
case 0: f() default: // ERROR "unexpected keyword default at end of statement"
|
2015-11-20 17:49:30 -07:00
|
|
|
}
|
|
|
|
|
2015-11-19 16:43:05 -07:00
|
|
|
switch {
|
2022-08-25 17:41:35 -06:00
|
|
|
if x: // ERROR "expected case or default or }"
|
2015-11-19 16:43:05 -07:00
|
|
|
}
|
|
|
|
}
|