Closed Bug 1382209 Opened 7 years ago Closed 7 years ago

Add new restrictions for "yield" and "await" as binding identifiers per ES2018

Categories

(Core :: JavaScript Engine, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox57 --- fixed

People

(Reporter: anba, Assigned: anba)

Details

Attachments

(2 files, 2 obsolete files)

From https://github.com/tc39/ecma262/commit/925cdc437e0878b36f7ceb7dbecd9036157a6337

"yield" and "await" are now always parsed as binding identifiers, but additional static semantics restrict "yield" to non-generator and "await" to non-async function contexts.


Ecma262 PR: https://github.com/tc39/ecma262/pull/885
Test262 PR: https://github.com/tc39/test262/issues/1084
We no longer need to take the yield-handling into account when checking if the next token after |let| continues a let-declaration (resp. the await-is-keyword state for "await"). 

Waldo's test cases are superseded by https://github.com/tc39/test262/issues/1084, therefore we can remove them, too.
"yield" is forbidden as an identifier in module contexts, because modules are implicitly strict-mode code, and not because the Module (https://tc39.github.io/ecma262/#prod-Module) production has a [Yield] grammar parameter. So we actually should use YieldIsName instead of YieldIsKeyword for the various module related parser methods.
Attachment #8887922 - Flags: review?(shu)
Attachment #8887924 - Flags: review?(shu)
Comment on attachment 8887922 [details] [diff] [review]
bug1382209-part1-yield-await-bindingident.patch

Review of attachment 8887922 [details] [diff] [review]:
-----------------------------------------------------------------

This spec change is awesome.

::: js/src/frontend/Parser.cpp
@@ +7464,5 @@
>      MOZ_ALWAYS_TRUE(tokenStream.peekToken(&verify));
>      MOZ_ASSERT(next == verify);
>  #endif
>  
>      // Destructuring is (for once) the easy case.

Without the gnarly yield/await semantics, the comment now reads odd. I'd replace with

// Destructuring continues a let declaration.
Attachment #8887922 - Flags: review?(shu) → review+
Attachment #8887924 - Flags: review?(shu) → review+
Comment on attachment 8887924 [details] [diff] [review]
bug1382209-part2-yield-handling-modules.patch

Review of attachment 8887924 [details] [diff] [review]:
-----------------------------------------------------------------

While you're here, could you update the comment above ParserBase::isValidStrictBinding?
Update part 1 per review comments, carrying r+.
Attachment #8887922 - Attachment is obsolete: true
Attachment #8895344 - Flags: review+
Update part 2 per review comments, carrying r+.
Attachment #8887924 - Attachment is obsolete: true
Attachment #8895345 - Flags: review+
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/bf1ddf4c1619
Part 1: Add new restrictions for "yield" and "await" as binding identifiers per ES2018 draft spec. r=shu
https://hg.mozilla.org/integration/mozilla-inbound/rev/595d4c0210e2
Part 2: Use correct YieldHandling for module contexts. r=shu
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/bf1ddf4c1619
https://hg.mozilla.org/mozilla-central/rev/595d4c0210e2
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: