mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 20:32:10 +00:00
feat(parsr): parse let.a = 1 with error recovery (#1587)
This commit is contained in:
parent
fd6a3ed918
commit
1554f7c0d2
3 changed files with 21 additions and 1 deletions
|
|
@ -31,6 +31,10 @@ impl<'a> Parser<'a> {
|
||||||
if peeked.is_assignment_operator() || peeked.is_binary_operator() {
|
if peeked.is_assignment_operator() || peeked.is_binary_operator() {
|
||||||
let expr = self.parse_assignment_expression_base()?;
|
let expr = self.parse_assignment_expression_base()?;
|
||||||
self.parse_expression_statement(span, expr)
|
self.parse_expression_statement(span, expr)
|
||||||
|
// let.a = 1, let()[a] = 1
|
||||||
|
} else if matches!(peeked, Kind::Dot | Kind::LParen) {
|
||||||
|
let expr = self.parse_expression()?;
|
||||||
|
Ok(self.ast.expression_statement(self.end_span(span), expr))
|
||||||
// single statement let declaration: while (0) let
|
// single statement let declaration: while (0) let
|
||||||
} else if (stmt_ctx.is_single_statement() && peeked != Kind::LBrack)
|
} else if (stmt_ctx.is_single_statement() && peeked != Kind::LBrack)
|
||||||
|| peeked == Kind::Semicolon
|
|| peeked == Kind::Semicolon
|
||||||
|
|
|
||||||
2
tasks/coverage/misc/fail/oxc.js
Normal file
2
tasks/coverage/misc/fail/oxc.js
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
let.a = 1;
|
||||||
|
let()[a] = 1;
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
parser_misc Summary:
|
parser_misc Summary:
|
||||||
AST Parsed : 8/8 (100.00%)
|
AST Parsed : 8/8 (100.00%)
|
||||||
Positive Passed: 8/8 (100.00%)
|
Positive Passed: 8/8 (100.00%)
|
||||||
Negative Passed: 2/2 (100.00%)
|
Negative Passed: 3/3 (100.00%)
|
||||||
× Unexpected token
|
× Unexpected token
|
||||||
╭─[fail/oxc-169.js:1:1]
|
╭─[fail/oxc-169.js:1:1]
|
||||||
1 │ 1<(V=82<<t-j0<(V=$<LBI<(V=ut<I<(V=$<LBI<(V=uIV=82<<t-j0<(V=$<LBI<(V=ut<I<(V=$<LBI<(V<II>
|
1 │ 1<(V=82<<t-j0<(V=$<LBI<(V=ut<I<(V=$<LBI<(V=uIV=82<<t-j0<(V=$<LBI<(V=ut<I<(V=$<LBI<(V<II>
|
||||||
|
|
@ -13,3 +13,17 @@ Negative Passed: 2/2 (100.00%)
|
||||||
· ─────────
|
· ─────────
|
||||||
╰────
|
╰────
|
||||||
|
|
||||||
|
× The keyword 'let' is reserved
|
||||||
|
╭─[fail/oxc.js:1:1]
|
||||||
|
1 │ let.a = 1;
|
||||||
|
· ───
|
||||||
|
2 │ let()[a] = 1;
|
||||||
|
╰────
|
||||||
|
|
||||||
|
× The keyword 'let' is reserved
|
||||||
|
╭─[fail/oxc.js:1:1]
|
||||||
|
1 │ let.a = 1;
|
||||||
|
2 │ let()[a] = 1;
|
||||||
|
· ───
|
||||||
|
╰────
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue