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

Closed
go101 opened this issue Oct 24, 2018 · 4 comments
Closed

cmd/compile: unnecessary error message #28376

go101 opened this issue Oct 24, 2018 · 4 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@go101
Copy link

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
Copy link
Member

mvdan commented Oct 25, 2018

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

@mvdan mvdan added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 25, 2018
@mvdan mvdan added this to the Unplanned milestone Oct 25, 2018
@griesemer griesemer self-assigned this Oct 25, 2018
@ManushB
Copy link

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.

@cuonglm
Copy link
Member

cuonglm commented Oct 18, 2020

go1.14 and go1.15 now report only first message, we can close this now.

I think this is fixed when @mdempsky refactoring the typecheck switch code.

@go101
Copy link
Author

go101 commented Oct 18, 2020

True. Thanks for the noticing.

@go101 go101 closed this as completed Oct 18, 2020
@golang golang locked and limited conversation to collaborators Oct 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants