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

More precise error message for unencodable \u escapes #20272

Merged
merged 1 commit into from
Jun 12, 2024

Conversation

squeek502
Copy link
Collaborator

The surrogate code points U+D800 to U+DFFF are valid code points but are not Unicode scalar values. This commit makes the error message more accurately reflect what is actually allowed in \u escape sequences.

From https://www.unicode.org/versions/Unicode15.0.0/ch03.pdf:

D71 High-surrogate code point: A Unicode code point in the range U+D800 to U+DBFF.
D73 Low-surrogate code point: A Unicode code point in the range U+DC00 to U+DFFF.

3.9 Unicode Encoding Forms
D76 Unicode scalar value: Any Unicode code point except high-surrogate and low-surrogate code points.

Related: #20270

The surrogate code points U+D800 to U+DFFF are valid code points but are not Unicode scalar values. This commit makes the error message more accurately reflect what is actually allowed in `\u` escape sequences.

From https://www.unicode.org/versions/Unicode15.0.0/ch03.pdf:

> D71 High-surrogate code point: A Unicode code point in the range U+D800 to U+DBFF.
> D73 Low-surrogate code point: A Unicode code point in the range U+DC00 to U+DFFF.
>
> 3.9 Unicode Encoding Forms
> D76 Unicode scalar value: Any Unicode code point except high-surrogate and low-surrogate code points.

Related: ziglang#20270
@squeek502 squeek502 force-pushed the unicode-escape-error branch from 6ab1369 to f01f077 Compare June 12, 2024 05:59
@mnemnion
Copy link

Would it be possible to include the actual escape sequence in the error message? When I ran into this error, it was in generated test data consisting of an exceptionally long line of escape sequences, so "column 129416" wasn't very helpful in determining what was wrong.

@andrewrk andrewrk merged commit 0cef727 into ziglang:master Jun 12, 2024
10 checks passed
@andrewrk
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants