Skip to content

await an expression with surrogate characters raises a SyntaxError#39929

Description

@Mesteery

Version

16.8.0

Platform

No response

Subsystem

repl

What steps will reproduce the bug?

$ node
Welcome to Node.js v16.8.0.
Type ".help" for more information.
> await '馃榾馃榾馃榾' // or
> await '馃榾馃榾馃榾'; // or
> await '馃榾馃榾馃榾';;

How often does it reproduce? Is there a required condition?

All the time, as long as there is a top level await with one or more surrogate chars with a semicolon, or at least 3 surrogate chars.

What is the expected behavior?

> await '馃榾馃榾馃榾'
'馃榾馃榾馃榾'

What do you see instead?

> await '馃榾馃榾馃榾'
 }))()
 ^

Uncaught SyntaxError: Unexpected token '}'

> await '馃榾馃榾馃榾';
(async () => { return (await '馃榾馃榾馃榾';
                                     ^

Uncaught SyntaxError: Unexpected token ';'

> await '馃榾馃榾馃榾';;
undefined

Additional information

This is obviously reproducible with a more complex expression (for example await new buffer.Blob(['aaa', Buffer.from('猫猫ee馃榿馃榿馃榿aaa')]).text().

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.replIssues and PRs related to the REPL subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions