Skip to content

Allow _ between hex digits in \u{...} escapes - #2923

Open
ibmibmibm wants to merge 1 commit into
WebAssembly:mainfrom
WasmEdge:fix-unicode-escape-underscore
Open

ibmibmibm wants to merge 1 commit into
WebAssembly:mainfrom
WasmEdge:fix-unicode-escape-underscore

Conversation

@ibmibmibm

Copy link
Copy Markdown

The text format defines the digits of a \u{...} escape as a hexnum,
which lets a single _ separate two hex digits, for example
\u{1_F600}. WebAssembly/spec#2352 adds this case to names.wast, and
wabt rejects it with bad escape "\u{1". The lexer and the string
decoder now accept it. A leading, trailing or double _ is still a bad
escape.

@ibmibmibm
ibmibmibm force-pushed the fix-unicode-escape-underscore branch from 132f8b7 to 3606110 Compare November 26, 2026 01:01
@zherczeg

Copy link
Copy Markdown
Collaborator

Could you show this part in the standard?

@ibmibmibm

Copy link
Copy Markdown
Author

@ibmibmibm
ibmibmibm force-pushed the fix-unicode-escape-underscore branch from 3606110 to 07e53ef Compare November 26, 2026 11:17
@zherczeg

Copy link
Copy Markdown
Collaborator

Ok, I misunderstood the "separate two hex digits" part, and the d_800 test. I thought digits must be in pairs, and was surprised. Ok, so a single _ can be anywhere between two hex digits.

Comment thread src/wast-lexer.cc Resolved
@ibmibmibm
ibmibmibm force-pushed the fix-unicode-escape-underscore branch 3 times, most recently from 7be5307 to 89f5fe3 Compare November 27, 2026 02:41
The text format defines the digits of a `\u{...}` escape as a hexnum,
which lets a single `_` separate two hex digits, for example
`\u{1_F600}`. WebAssembly/spec#2352 adds this case to names.wast, and
wabt rejects it with `bad escape "\u{1"`. The lexer and the string
decoder now accept it. A leading, trailing or double `_` is still a bad
escape.
@ibmibmibm
ibmibmibm force-pushed the fix-unicode-escape-underscore branch from 89f5fe3 to 4dfd139 Compare November 27, 2026 02:48
Comment thread src/wast-parser.cc
src += 2;

do {
for (; src[0] != '}'; src++) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a bugfix? Or why do you changed it?

This branch has not been deployed

No deployments
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.

2 participants