mirror of
https://github.com/golang/go
synced 2024-11-27 05:51:17 -07:00
6fa7669fd7
Consistent logic for handling both duplicate map keys and case values, and eliminates ad hoc value hashing code. Also makes cmd/compile consistent with go/types's handling of duplicate constants (see #28085), which is at least an improvement over the status quo even if we settle on something different for the spec. As a side effect, this also suppresses cmd/compile's warnings about duplicate nils in (non-interface expression) switch statements, which was technically never allowed by the spec anyway. Updates #28085. Updates #28378. Change-Id: I176a251e770c3c5bc11c2bf8d1d862db8f252a17 Reviewed-on: https://go-review.googlesource.com/c/152544 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
30 lines
490 B
Go
30 lines
490 B
Go
// errorcheck
|
|
|
|
// Copyright 2018 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package p
|
|
|
|
var _ = map[interface{}]int{
|
|
0: 0,
|
|
0: 0, // ERROR "duplicate"
|
|
}
|
|
|
|
var _ = map[interface{}]int{
|
|
interface{}(0): 0,
|
|
interface{}(0): 0, // ok
|
|
}
|
|
|
|
func _() {
|
|
switch interface{}(0) {
|
|
case 0:
|
|
case 0: // ERROR "duplicate"
|
|
}
|
|
|
|
switch interface{}(0) {
|
|
case interface{}(0):
|
|
case interface{}(0): // ok
|
|
}
|
|
}
|