Parse let declarations whose id starts with \ (#13325)

This commit is contained in:
Nicolò Ribaudo
2021-05-17 15:46:59 +02:00
committed by GitHub
parent 229a5481f4
commit c2181343f1
5 changed files with 85 additions and 1 deletions

View File

@@ -188,7 +188,13 @@ export default class StatementParser extends ExpressionParser {
// Statement) is allowed here. If context is not empty then only a Statement
// is allowed. However, `let [` is an explicit negative lookahead for
// ExpressionStatement, so special-case it first.
if (nextCh === charCodes.leftSquareBracket) return true;
// Also, `let \` is never valid as an expression so this must be a keyword.
if (
nextCh === charCodes.backslash ||
nextCh === charCodes.leftSquareBracket
) {
return true;
}
if (context) return false;
if (nextCh === charCodes.leftCurlyBrace) return true;