You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cmd/compile: confusing error message for a bad rune value, eg. '\xe4\xb8\x96' #20343
An error message like:
"Badly formed Rune" or "Bad rune value" maybe even
"runes with values larger than 255, 0xFF, can't be defined using multiple \xhh values"
What did you see instead?
tmp/sandbox523565836/main.go:5: missing '
tmp/sandbox523565836/main.go:5: illegal character U+005C '\'
tmp/sandbox523565836/main.go:5: syntax error: unexpected xb8 at end of statement
tmp/sandbox523565836/main.go:5: newline in character literal
Issue Explanation/Justification
I think the Go compilers error messages are unnecessarily unhelpful or confusing.
The source doesn't look like there is a "missing ' ", it looks like there are a matching pair of single quotes.
The character U+005C '\'is legal in rune values, so that seems confusing.
In this example, the value xb8 is apparently in the middle of the rune, and so "syntax error: unexpected xb8 at end of statement" seems confusing.
The line doesn't look like there is a "newline in character literal".
A plausible behaviour might be to 'collect' all the characters up to and including an unescaped closing single quote (on the same line, and before a '//' comment mark), and treat all of those characters as part of the bad rune value.
changed the title [-]Confusing Go compiler error message for a bad rune value, eg. '\xe4\xb8\x96'[/-][+]cmd/compile: confusing error message for a bad rune value, eg. '\xe4\xb8\x96'[/+]on May 13, 2017
As an aside ...
Is their a 'place' explaining all of the Go compilers error messages? My search didn't find it.
It would be nice to have all Go compiler error messages along with a brief explanation of a possible cause of the error in a web-searchable place.
I paste error messages from software into a web browser's search box, but in this case it didn't find much help. Sometimes stackoverflow is helpful, but not in this case.
Explaining compiler error-messages might be a straightforward, well-bounded, activity to ask the Developer Experience Working Group to solve. The result could be helpful for new or occasional Go programmers, and so help them climb the learning curve more quickly and effectively.
Further, if the 'place' had some authority or evidence of good quality, it might be the 'go to' place.
Is their a 'place' explaining all of the Go compilers error messages
I don't think there is. I know Rust has something like that; and I agree that it could be nice to have something similar (even though Go is a simpler language and error messages usually are easy to understand; I rarely see people puzzled by a compiler error when programming in Go).
Explaining compiler error-messages might be a straightforward, well-bounded, activity to ask the Developer Experience Working Group to solve
I agree. You could ask for this on their mailing list. I don't think it's "straightforward", though. Doing this (and doing it well) will require a fair amount of effort.
I apologise for not understanding this, but why add it to Go1.10 milestone? Didn't that happened years ago?
The dot in the versioning number is not a decimal point, i.e. 1.10 is not 1.1. The sequence goes 1.1, 1.2, ..., 1.9, 1.10, 1.11, etc...
The next go version will be go1.9, and then we'll have go1.10. I can't assign this issue to the 1.9 milestone because the go1.9 development phase is finished (we're now in a code freeze); so this will be likely considered for go1.10 (unless someone decides that this is critical and needs to be fixed for go1.9).
Thank you for your very swift, clear and useful responses.
I'll think about asking on the mailing list. When I do, I have a small, but hopefully useful, additional idea.
I'd understood the 'dot' in the version is not a decimal point.
I hadn't known milestone names don't align with Go versions. So that is helpful to know.
It seems a very low-priority to have version and milestone names align. I imagine retaining flexibility to have them be different probably significantly outweighs any small gains.
Activity
[-]Confusing Go compiler error message for a bad rune value, eg. '\xe4\xb8\x96'[/-][+]cmd/compile: confusing error message for a bad rune value, eg. '\xe4\xb8\x96'[/+]ALTree commentedon May 13, 2017
For reference,
go/typesprintsWe could mimic
go/typesbehaviour. I have no idea how much work would be needed, so leaving it to others to decide if it's worth it.gbulmer commentedon May 13, 2017
I'd be satisfied with "illegal rune literal". One message, terse, accurate.
gbulmer commentedon May 13, 2017
As an aside ...
Is their a 'place' explaining all of the Go compilers error messages? My search didn't find it.
It would be nice to have all Go compiler error messages along with a brief explanation of a possible cause of the error in a web-searchable place.
I paste error messages from software into a web browser's search box, but in this case it didn't find much help. Sometimes stackoverflow is helpful, but not in this case.
Explaining compiler error-messages might be a straightforward, well-bounded, activity to ask the Developer Experience Working Group to solve. The result could be helpful for new or occasional Go programmers, and so help them climb the learning curve more quickly and effectively.
Further, if the 'place' had some authority or evidence of good quality, it might be the 'go to' place.
gbulmer commentedon May 13, 2017
I apologise for not understanding this, but why add it to Go1.10 milestone? Didn't that happened years ago?
ALTree commentedon May 13, 2017
I don't think there is. I know Rust has something like that; and I agree that it could be nice to have something similar (even though Go is a simpler language and error messages usually are easy to understand; I rarely see people puzzled by a compiler error when programming in Go).
I agree. You could ask for this on their mailing list. I don't think it's "straightforward", though. Doing this (and doing it well) will require a fair amount of effort.
The dot in the versioning number is not a decimal point, i.e.
1.10is not1.1. The sequence goes1.1,1.2, ...,1.9,1.10,1.11, etc...The next go version will be go1.9, and then we'll have go1.10. I can't assign this issue to the 1.9 milestone because the go1.9 development phase is finished (we're now in a code freeze); so this will be likely considered for go1.10 (unless someone decides that this is critical and needs to be fixed for go1.9).
gbulmer commentedon May 13, 2017
Thank you for your very swift, clear and useful responses.
I'll think about asking on the mailing list. When I do, I have a small, but hopefully useful, additional idea.
I'd understood the 'dot' in the version is not a decimal point.
I hadn't known milestone names don't align with Go versions. So that is helpful to know.
It seems a very low-priority to have version and milestone names align. I imagine retaining flexibility to have them be different probably significantly outweighs any small gains.
griesemer commentedon May 15, 2017
Marking for 1.9 - easy enough to fix.
griesemer commentedon May 15, 2017
I'm going to close this. The 1.9 compiler already produces a nice error message. For
we get
That is, this is fixed in the latest tools.
The go playground will be updated to 1.9 once 1.9 is released.