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

Valid Unicode Codepoint Emojis Not Permitted in Runes #48683

Closed
JulianKnodt opened this issue Sep 29, 2021 · 4 comments
Closed

Valid Unicode Codepoint Emojis Not Permitted in Runes #48683

JulianKnodt opened this issue Sep 29, 2021 · 4 comments

Comments

@JulianKnodt
Copy link

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

$ go version
go 1.17.1, playground version

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

Fails on playground.

What did you do?

https://play.golang.org/p/GKmXPxtK52x

What did you expect to see?

I expected it to compile and print the emoji character.

What did you see instead?

Compilation fails, as it appears that the unicode is not a valid rune. This also happens for other sets of valid unicode code points, such as weightlifter = U+1F3CB.

It also seems to error either as multiple characters in rune literal, or invalid character in rune.

@seankhliao
Copy link
Member

Your "rune" has a trailing code point https://play.golang.org/p/FUpPZyI8aa3

@JulianKnodt
Copy link
Author

Hm, so it only works for a certain set of unicode characters which have a fixed number of code points?
Is it possible to update the compiler's error message for this case? It seems to be a strange edge case considering that it is not easily identifiable from just looking at the character itself.

I understand that runes can't support this case, but just saying "illegal character" is hard to understand.

@ianlancetaylor
Copy link
Member

The error I see from the compiler is

x.go:8:14: more than one character in rune literal

That seems reasonably clear. A rune literal can only include a single code point. See https://golang.org/ref/spec#Rune_literals .

@JulianKnodt
Copy link
Author

I think in go vet I'm getting the error that it's an illegal rune literal:
image
but probably nothing actionable.

Thanks anyhow!

@golang golang locked and limited conversation to collaborators Sep 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants