mirror of
https://github.com/golang/go
synced 2024-11-22 15:24:42 -07:00
cmd/compile: set correct line number for multiple defaults in switch error
Fixes #15911. Change-Id: I500533484de61aa09abe4cecb010445e3176324e Reviewed-on: https://go-review.googlesource.com/26760 TryBot-Result: Gobot Gobot <gobot@golang.org> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
4109744973
commit
cf20525bf4
@ -107,6 +107,7 @@ func typecheckswitch(n *Node) {
|
||||
if ncase.List.Len() == 0 {
|
||||
// default
|
||||
if def != nil {
|
||||
setlineno(ncase)
|
||||
Yyerror("multiple defaults in switch (first at %v)", def.Line())
|
||||
} else {
|
||||
def = ncase
|
||||
|
@ -21,12 +21,12 @@ func f0(e error) {
|
||||
|
||||
// Verify that the compiler rejects multiple default cases.
|
||||
func f1(e interface{}) {
|
||||
switch e { // ERROR "multiple defaults in switch"
|
||||
default:
|
||||
switch e {
|
||||
default:
|
||||
default: // ERROR "multiple defaults in switch"
|
||||
}
|
||||
switch e.(type) { // ERROR "multiple defaults in switch"
|
||||
default:
|
||||
switch e.(type) {
|
||||
default:
|
||||
default: // ERROR "multiple defaults in switch"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user