mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-07 08:18:41 +09:00
Issue #1918 - m-c 1353690: Properly exclude |await| from consideration as a |let| variable name in async functions, so that a newline between the two separates them into two distinct expressions.
This commit is contained in:
parent
8b14220c3c
commit
a511ff812e
3 changed files with 43 additions and 0 deletions
|
|
@ -7348,6 +7348,11 @@ Parser<ParseHandler>::nextTokenContinuesLetDeclaration(TokenKind next, YieldHand
|
|||
if (next == TOK_YIELD)
|
||||
return yieldHandling == YieldIsName;
|
||||
|
||||
// Somewhat similar logic applies for "await", except that it's not tracked
|
||||
// with an AwaitHandling argument.
|
||||
if (next == TOK_AWAIT)
|
||||
return !awaitIsKeyword();
|
||||
|
||||
// Otherwise a let declaration must have a name.
|
||||
if (TokenKindIsPossibleIdentifier(next)) {
|
||||
// A "let" edge case deserves special comment. Consider this:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Jeff Walden <jwalden+code@mit.edu>
|
||||
esid: sec-let-and-const-declarations
|
||||
description: >
|
||||
|await| is excluded from LexicalDeclaration by grammar parameter, in
|
||||
AsyncFunction. Therefore |let| followed by |await| inside AsyncFunction is
|
||||
an ASI opportunity, and this code must parse without error.
|
||||
---*/
|
||||
|
||||
async function f() {
|
||||
let
|
||||
await 0;
|
||||
}
|
||||
|
||||
reportCompare(true, f instanceof Function);
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// |reftest| error:SyntaxError
|
||||
// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Jeff Walden <jwalden+code@mit.edu>
|
||||
esid: sec-let-and-const-declarations
|
||||
description: >
|
||||
Outside AsyncFunction, |await| is a perfectly cromulent LexicalDeclaration
|
||||
variable name. Therefore ASI doesn't apply, and so the |0| where a |=| was
|
||||
expected is a syntax error.
|
||||
negative:
|
||||
phase: early
|
||||
type: SyntaxError
|
||||
---*/
|
||||
|
||||
function f() {
|
||||
let
|
||||
await 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue