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