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) { ...@@ -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) { ...@@ -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"
} }
} }
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