1
0
mirror of https://github.com/golang/go synced 2024-11-11 18:51:37 -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:
Josh Bleecher Snyder 2016-05-31 15:02:40 -07:00
parent 4109744973
commit cf20525bf4
2 changed files with 5 additions and 4 deletions

View File

@ -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

View File

@ -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"
}
}