Commit cf20525b authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

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: default avatarMatthew Dempsky <mdempsky@google.com>
parent 41097449
......@@ -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"
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment