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: duplicate case message for rune switch confusing #20112
Comments
But here's a gotcha:
Should we warn about |
AFK but look in swt.go for the error message (there may be multiple of them) and look at what format verb is used to print it. It should just be a matter of picking the right verb. |
Thanks - I'll look into this tomorrow. |
CL https://golang.org/cl/41852 mentions this issue. |
@josharian thanks for the pointer. I've come up with a small CL that seems to do the trick - input welcome. |
I'd lean towards always printing the original source expression, and then maybe parenthetically including the integer value when the expression was not originally an integer literal. Something like:
That's similar to what go/types does:
Incidentally, I notice that cmd/compile and go/types produce different error messages for:
cmd/compile:
go/types:
/cc @griesemer @bradfitz for input on the error messaging. |
After Josh's input, I also lean towards that: https://go-review.googlesource.com/c/41852/1/src/cmd/compile/internal/gc/swt.go#628 I'll update the CL tomorrow. |
What version of Go are you using (
go version
)?go version devel +34ee8ec193 Tue Apr 25 05:02:56 2017 +0000 linux/amd64
What did you do?
Compile
f.go
:What did you expect to see?
What did you see instead?
This is in a lexer/parser package, so I encounter these fairly frequently. And each time, I have to google for an ASCII table because I obviously don't remember all of them.
I assume this is because
rune
is an integer under the hood, and the compiler falls back to printing it as an integer instead of a character.I realise that printing runes is the same as printing integers in other scenarios: https://play.golang.org/p/_zNxHOZxOY
I'm not sure if this is by design or right, but IMO printing numbers in the compiler output from the case above is definitely misleading.
The text was updated successfully, but these errors were encountered: