Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: inconsistent line number selection for duplicate type case error #15912

Closed
josharian opened this issue May 31, 2016 · 1 comment
Closed
Milestone

Comments

@josharian
Copy link
Contributor

func f4(e interface{}) {
    switch e.(type) {
    case int:
    case int: // ERROR "duplicate case int in type switch"
    case int64:
    case error: // ERROR "duplicate case error in type switch"
    case error:
    case fmt.Stringer:
    case fmt.Stringer: // ERROR "duplicate case fmt.Stringer in type switch"
    case struct {
        i int "tag1"
    }:
    case struct {
        i int "tag2"
    }:
    case struct {
        i int "tag1"
    }: // ERROR "duplicate case struct { i int .tag1. } in type switch"
    }
}

The error for case error occurs on the first case error, not the second. Removing the final three struct cases moves the error line back to where it belongs.

@josharian josharian added this to the Go1.8 milestone May 31, 2016
@josharian josharian self-assigned this May 31, 2016
mk0x9 pushed a commit to mk0x9/go that referenced this issue May 31, 2016
Some of these errors are reported in the wrong places.
That’s issue golang#15911 and golang#15912.

Change-Id: Ia09d7f89be4d15f05217a542a61b6ac08090dd87
Reviewed-on: https://go-review.googlesource.com/23588
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
josharian added a commit to josharian/go that referenced this issue Jun 16, 2016
This is a bit simpler than playing sorting games,
and it is clearer that it generates errors
in the correct (source) order.

It also allows us to simplify sorting.

While we’re here, refactoring deduping into separate functions.

Negligible compilebench impact.

Fixes golang#15912.

Change-Id: I6cc19edd38875389a70ccbdbdf0d9b7d5ac5946f
josharian added a commit to josharian/go that referenced this issue Jun 17, 2016
This is a bit simpler than playing sorting games,
and it is clearer that it generates errors
in the correct (source) order.

It also allows us to simplify sorting.

While we’re here, refactoring deduping into separate functions.

Negligible compilebench impact.

Fixes golang#15912.

Change-Id: I6cc19edd38875389a70ccbdbdf0d9b7d5ac5946f
@gopherbot
Copy link

CL https://golang.org/cl/26762 mentions this issue.

@golang golang locked and limited conversation to collaborators Aug 23, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants