modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/fixedbugs/bug393.go (about)

     1  // compile
     2  
     3  // Copyright 2012 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  // issue 2672
     8  // was trying binary search with an interface type
     9  
    10  package bug393
    11  
    12  func f(x interface{}) int {
    13  	switch x {
    14  	case 1:
    15  		return 1
    16  	case 2:
    17  		return 2
    18  	case 3:
    19  		return 3
    20  	case 4:
    21  		return 4
    22  	case "5":
    23  		return 5
    24  	case "6":
    25  		return 6
    26  	default:
    27  		return 7
    28  	}
    29  	panic("switch")
    30  }