Source file test/switch4.go
1 // errorcheck 2 3 // Copyright 2011 The Go Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 7 // Verify that erroneous switch statements are detected by the compiler. 8 // Does not compile. 9 10 package main 11 12 type I interface { 13 M() 14 } 15 16 func bad() { 17 18 i5 := 5 19 switch i5 { 20 case 5: 21 fallthrough // ERROR "cannot fallthrough final case in switch" 22 } 23 } 24 25 func good() { 26 var i interface{} 27 var s string 28 29 switch i { 30 case s: 31 } 32 33 switch s { 34 case i: 35 } 36 } 37