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: unnecessary error message #28376

Open
go101 opened this Issue Oct 24, 2018 · 2 comments

Comments

Projects
None yet
4 participants
@go101

go101 commented Oct 24, 2018

What version of Go are you using (go version)?

go version go1.11.1 linux/amd64

Does this issue reproduce with the latest release?

yes

What did you do?

package main

func main() {
	var a int64
	switch a {
	case int64(123):
	case int32(123):
	}
}

What did you see instead?

gc reports:

./aa.go:7:2: invalid case int32(123) in switch on a (mismatched types int32 and int64)
./aa.go:7:2: duplicate case int32(123) (value 123) in switch
	previous case at ./aa.go:6:12

Although it is not a big problem, I think the second error message is not very necessary, for it implies int32(123) is comparable to int64(123). (gccgo doesn't report the second error)

@mvdan

This comment has been minimized.

Member

mvdan commented Oct 25, 2018

Sounds to me like something to fix. /cc @griesemer

@mvdan mvdan added the NeedsFix label Oct 25, 2018

@mvdan mvdan added this to the Unplanned milestone Oct 25, 2018

@griesemer griesemer self-assigned this Oct 25, 2018

@ManushB

This comment has been minimized.

ManushB commented Oct 27, 2018

The issue seems to be in this function.

func typecheckswitch(n *Node) {

I want to take up the issue but am new to this. Can you suggest the approach?

In my opinion, a flag should be used to return before calling checkDupExprCases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment