Parse "await" as an identifier in class fields
Categories
(Core :: JavaScript Engine, defect, P1)
Tracking
()
Tracking | Status | |
---|---|---|
firefox74 | --- | fixed |
People
(Reporter: nicolo.ribaudo, Assigned: nicolo.ribaudo)
Details
Attachments
(1 file, 1 obsolete file)
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36
Steps to reproduce:
This is code in a script context:
async () => class { x = await }
Is should be correctly parsed because the proposal uses ~Await to signal that "await" represents an identifier:
FieldDefinition[Yield, Await]:
ClassElementName[?Yield, ?Await] Initializer[In, ~Yield, ~Await]opt
I have never contributed to SpiderMonkey before, but I would like to fix this bug if no one is already working on it.
Actual results:
It throws "SyntaxError: await is a reserved identifier"
Expected results:
It should be correctly parsed
Comment 1•6 years ago
|
||
Good catch! I should have spotted this when I removed the YieldHandling
parameter in https://phabricator.services.mozilla.com/D53638. :-)
In case you need any pointers, the initialiser expression is parsed here and await
handling is implemented through the RAII class AutoAwaitIsKeyword
. https://searchfox.org/mozilla-central/source can help to navigate through the source tree.
Assignee | ||
Comment 2•6 years ago
|
||
The ParserBase::awaitIsKeyword function was originally designed to be
used to check if "await" should be parsed as an identifier or as the
beginning of an AwaitExpression. It has a role identical to the
[?Await] production parameter used in the specification.
Assignee | ||
Comment 3•6 years ago
|
||
The ParserBase::awaitIsKeyword function was originally designed to be
used to check if "await" should be parsed as an identifier or as the
beginning of an AwaitExpression. It has a role identical to the
[?Await] production parameter used in the specification.
Parse await as an identifier in fields initializers
The proposal specifies class fields as follows:
FieldDefinition[Yield, Await]:
ClassElementName[?Yield, ?Await] Initializer[In, ~Yield, ~Await]opt
This means that await should be parsed according to the context
where the class is defined, while they should always be parsed as
identifiers inside initializers.
Currently also yield parsing is broken, but the ~Yield parameter is
handled differently from ~Await and it is fixed by
https://phabricator.services.mozilla.com/D53638
Updated•6 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Comment 5•6 years ago
|
||
bugherder |
Description
•