diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index 1969628f38..f2d87f52be 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -7348,6 +7348,11 @@ Parser::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: diff --git a/js/src/tests/test262/local/let-newline-await-in-async-function.js b/js/src/tests/test262/local/let-newline-await-in-async-function.js new file mode 100644 index 0000000000..c43a5b2745 --- /dev/null +++ b/js/src/tests/test262/local/let-newline-await-in-async-function.js @@ -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 +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); diff --git a/js/src/tests/test262/local/let-newline-await-in-normal-function.js b/js/src/tests/test262/local/let-newline-await-in-normal-function.js new file mode 100644 index 0000000000..f49f9ea528 --- /dev/null +++ b/js/src/tests/test262/local/let-newline-await-in-normal-function.js @@ -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 +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; +}