Source file test/fixedbugs/issue33460.go

     1  // errorcheck
     2  
     3  // Copyright 2019 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  package p
     8  
     9  const (
    10  	zero = iota
    11  	one
    12  	two
    13  	three
    14  )
    15  
    16  const iii int = 0x3
    17  
    18  func f(v int) {
    19  	switch v {
    20  	case zero, one:
    21  	case two, one: // ERROR "previous case at LINE-1|duplicate case .*in.* switch"
    22  
    23  	case three:
    24  	case 3: // ERROR "previous case at LINE-1|duplicate case .*in.* switch"
    25  	case iii: // ERROR "previous case at LINE-2|duplicate case .*in.* switch"
    26  	}
    27  }
    28  
    29  const b = "b"
    30  
    31  var _ = map[string]int{
    32  	"a": 0,
    33  	b:   1,
    34  	"a": 2, // ERROR "previous key at LINE-2|duplicate key.*in map literal"
    35  	"b": 3, // GC_ERROR "previous key at LINE-2|duplicate key.*in map literal"
    36  	"b": 4, // GC_ERROR "previous key at LINE-3|duplicate key.*in map literal"
    37  }
    38  

View as plain text