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:
Martok 2022-06-17 21:02:38 +02:00 committed by roytam1
commit a511ff812e
3 changed files with 43 additions and 0 deletions

View file

@ -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);

View file

@ -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;
}