mirror of
https://github.com/aphrody-labs/oxc.git
synced 2026-10-15 06:39:17 +00:00
fix(parser): stop delimited lists at end of file (#25542)
Stop parsing delimited-list elements after a separator when EOF or an undetermined token follows, preventing malformed tuple syntax from creating reversed spans during error recovery. Validated with `cargo coverage -- parser --filter oxc-23670 --detail`. AI assistance was used to prepare this change. Closes #23670.
This commit is contained in:
4 files changed
+19
-6
No files matched your search
@@ -523,10 +523,14 @@ impl<'a, C: Config> ParserImpl<'a, C> {
|
||||
return None;
|
||||
}
|
||||
self.advance(separator);
|
||||
if self.cur_kind() == close {
|
||||
let kind = self.cur_kind();
|
||||
if kind == close {
|
||||
let trailing_separator = self.prev_token_end - 1;
|
||||
return Some(trailing_separator);
|
||||
}
|
||||
if matches!(kind, Kind::Eof | Kind::Undetermined) {
|
||||
return None;
|
||||
}
|
||||
let element = parse_element(self);
|
||||
list.push(element);
|
||||
}
|
||||
@@ -607,6 +611,9 @@ impl<'a, C: Config> ParserImpl<'a, C> {
|
||||
}
|
||||
break;
|
||||
}
|
||||
if matches!(kind, Kind::Eof | Kind::Undetermined) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(r) = &rest {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<[m?,
|
||||
@@ -1382,7 +1382,7 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc
|
||||
1 │ [
|
||||
╰────
|
||||
|
||||
× Unexpected token
|
||||
× Expected `]` but found `EOF`
|
||||
╭─[babel/packages/babel-parser/test/fixtures/core/uncategorised/376/input.js:1:3]
|
||||
1 │ [,
|
||||
╰────
|
||||
@@ -1397,7 +1397,7 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc
|
||||
1 │ 1 + { t:t
|
||||
╰────
|
||||
|
||||
× Unexpected token
|
||||
× Expected `}` but found `EOF`
|
||||
╭─[babel/packages/babel-parser/test/fixtures/core/uncategorised/379/input.js:1:11]
|
||||
1 │ 1 + { t:t,
|
||||
╰────
|
||||
@@ -10861,7 +10861,7 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc
|
||||
1 │ [
|
||||
╰────
|
||||
|
||||
× Unexpected token
|
||||
× Expected `]` but found `EOF`
|
||||
╭─[babel/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0058/input.js:2:1]
|
||||
1 │ [,
|
||||
╰────
|
||||
@@ -10876,7 +10876,7 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc
|
||||
1 │ 1 + { t:t
|
||||
╰────
|
||||
|
||||
× Unexpected token
|
||||
× Expected `}` but found `EOF`
|
||||
╭─[babel/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0061/input.js:2:1]
|
||||
1 │ 1 + { t:t,
|
||||
╰────
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
parser_misc Summary:
|
||||
AST Parsed : 77/77 (100.00%)
|
||||
Positive Passed: 77/77 (100.00%)
|
||||
Negative Passed: 160/160 (100.00%)
|
||||
Negative Passed: 161/161 (100.00%)
|
||||
|
||||
× Cannot assign to 'arguments' in strict mode
|
||||
╭─[misc/fail/arguments-eval-ambient.ts:2:13]
|
||||
@@ -3805,6 +3805,11 @@ Negative Passed: 160/160 (100.00%)
|
||||
╰────
|
||||
help: Wrap this with parenthesis
|
||||
|
||||
× Expected `]` but found `EOF`
|
||||
╭─[misc/fail/oxc-23670.ts:2:1]
|
||||
1 │ <[m?,
|
||||
╰────
|
||||
|
||||
× Unexpected token
|
||||
╭─[misc/fail/oxc-23681.js:4:7]
|
||||
3 │ var prefix = 'fas';
|
||||
|
||||
Reference in new issue
Block a user