Permit %%placeholder%% in left-hand-side of a let declaration (#12725)
* Permit %%placeholder%% in left-hand-side of a let declaration * Test that "let" followed by modulo is still treated as an identifier * More tests for edge-case handling of "let" with placeholders enabled
This commit is contained in:
@@ -150,6 +150,28 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
* parser/statement.js *
|
||||
* ============================================================ */
|
||||
|
||||
isLet(context: ?string): boolean {
|
||||
if (super.isLet(context)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Replicate the original checks that lead to looking ahead for an
|
||||
// identifier.
|
||||
if (!this.isContextual("let")) {
|
||||
return false;
|
||||
}
|
||||
if (context) return false;
|
||||
|
||||
// Accept "let %%" as the start of "let %%placeholder%%", as though the
|
||||
// placeholder were an identifier.
|
||||
const nextToken = this.lookahead();
|
||||
if (nextToken.type === tt.placeholder) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
verifyBreakContinue(node: N.BreakStatement | N.ContinueStatement) {
|
||||
if (node.label && node.label.type === "Placeholder") return;
|
||||
super.verifyBreakContinue(...arguments);
|
||||
|
||||
Reference in New Issue
Block a user