mirror of
https://github.com/golang/go
synced 2024-11-26 10:38:07 -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 {
|
if ncase.List.Len() == 0 {
|
||||||
// default
|
// default
|
||||||
if def != nil {
|
if def != nil {
|
||||||
|
setlineno(ncase)
|
||||||
Yyerror("multiple defaults in switch (first at %v)", def.Line())
|
Yyerror("multiple defaults in switch (first at %v)", def.Line())
|
||||||
} else {
|
} else {
|
||||||
def = ncase
|
def = ncase
|
||||||
|
@ -21,12 +21,12 @@ func f0(e error) {
|
|||||||
|
|
||||||
// Verify that the compiler rejects multiple default cases.
|
// Verify that the compiler rejects multiple default cases.
|
||||||
func f1(e interface{}) {
|
func f1(e interface{}) {
|
||||||
switch e { // ERROR "multiple defaults in switch"
|
switch e {
|
||||||
default:
|
|
||||||
default:
|
default:
|
||||||
|
default: // ERROR "multiple defaults in switch"
|
||||||
}
|
}
|
||||||
switch e.(type) { // ERROR "multiple defaults in switch"
|
switch e.(type) {
|
||||||
default:
|
|
||||||
default:
|
default:
|
||||||
|
default: // ERROR "multiple defaults in switch"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user