-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version
)?
golang.org goplayground (1.8 I believe)
What operating system and processor architecture are you using (go env
)?
I am using go playground from Firefox.
However for completeness:
GOARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
Firefox 53.0.2 (64-bit)
What did you do?
https://play.golang.org/p/NtvSPO4xx7
What did you expect to see?
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.