Source file test/fixedbugs/issue7214.go

     1  // errorcheck
     2  
     3  // Copyright 2014 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 7214: No duplicate key error for maps with interface{} key type
     8  
     9  package p
    10  
    11  var _ = map[interface{}]int{2: 1, 2: 1} // ERROR "duplicate key"
    12  var _ = map[interface{}]int{int(2): 1, int16(2): 1}
    13  var _ = map[interface{}]int{int16(2): 1, int16(2): 1} // ERROR "duplicate key"
    14  
    15  type S string
    16  
    17  var _ = map[interface{}]int{"a": 1, "a": 1} // ERROR "duplicate key"
    18  var _ = map[interface{}]int{"a": 1, S("a"): 1}
    19  var _ = map[interface{}]int{S("a"): 1, S("a"): 1} // ERROR "duplicate key"
    20  
    21  type I interface {
    22  	f()
    23  }
    24  
    25  type N int
    26  
    27  func (N) f() {}
    28  
    29  var _ = map[I]int{N(0): 1, N(2): 1}
    30  var _ = map[I]int{N(2): 1, N(2): 1} // ERROR "duplicate key"
    31  

View as plain text