Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions crates/oxc_parser/src/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ impl<'a> ParserImpl<'a> {
pub(crate) fn parse_delimited_list_with_rest<E, A, D>(
&mut self,
close: Kind,
opening_span: Span,
parse_element: E,
rest_last_diagnostic: D,
) -> (Vec<'a, A>, Option<BindingRestElement<'a>>)
Expand All @@ -497,8 +498,13 @@ impl<'a> ParserImpl<'a> {
} else {
let comma_span = self.cur_token().span();
if kind != Kind::Comma {
let error =
diagnostics::expect_token(Kind::Comma.to_str(), kind.to_str(), comma_span);
let error = diagnostics::expect_closing_or_separator(
close.to_str(),
Kind::Comma.to_str(),
kind.to_str(),
comma_span,
opening_span,
);
self.set_fatal_error(error);
break;
}
Expand Down
4 changes: 4 additions & 0 deletions crates/oxc_parser/src/js/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ impl<'a> ParserImpl<'a> {
/// Section 14.3.3 Object Binding Pattern
fn parse_object_binding_pattern(&mut self) -> BindingPatternKind<'a> {
let span = self.start_span();
let opening_span = self.cur_token().span();
self.expect(Kind::LCurly);
let (list, rest) = self.parse_delimited_list_with_rest(
Kind::RCurly,
opening_span,
Self::parse_binding_property,
diagnostics::binding_rest_element_last,
);
Expand All @@ -67,9 +69,11 @@ impl<'a> ParserImpl<'a> {
/// Section 14.3.3 Array Binding Pattern
fn parse_array_binding_pattern(&mut self) -> BindingPatternKind<'a> {
let span = self.start_span();
let opening_span = self.cur_token().span();
self.expect(Kind::LBrack);
let (list, rest) = self.parse_delimited_list_with_rest(
Kind::RBrack,
opening_span,
Self::parse_array_binding_element,
diagnostics::binding_rest_element_last,
);
Expand Down
2 changes: 2 additions & 0 deletions crates/oxc_parser/src/js/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ impl<'a> ParserImpl<'a> {
params_kind: FormalParameterKind,
) -> (Option<TSThisParameter<'a>>, Box<'a, FormalParameters<'a>>) {
let span = self.start_span();
let opening_span = self.cur_token().span();
self.expect(Kind::LParen);
let this_param = if self.is_ts && self.at(Kind::This) {
let param = self.parse_ts_this_parameter();
Expand All @@ -56,6 +57,7 @@ impl<'a> ParserImpl<'a> {
};
let (list, rest) = self.parse_delimited_list_with_rest(
Kind::RParen,
opening_span,
|p| p.parse_formal_parameter(func_kind),
diagnostics::rest_parameter_last,
);
Expand Down
4 changes: 2 additions & 2 deletions tasks/coverage/snapshots/formatter_babel.snap
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ Unexpected token. Did you mean `{'>'}` or `&gt;`?
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/explicit-resource-management/valid-for-using-declaration-binding-of/input.js
Unexpected token
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/regression/nested-extends-in-arrow-type-param/input.ts
Expected `,` but found `extends`
Expected `,` or `)` but found `extends`
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/regression/nested-extends-in-arrow-type-param-babel-7/input.ts
Expected `,` but found `extends`
Expected `,` or `)` but found `extends`
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/type-arguments-bit-shift-left-like/class-heritage/input.ts
Expected `{` but found `<<`
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/type-arguments-bit-shift-left-like/class-heritage-babel-7/input.ts
Expand Down
28 changes: 16 additions & 12 deletions tasks/coverage/snapshots/parser_babel.snap
Original file line number Diff line number Diff line change
Expand Up @@ -679,20 +679,22 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc

Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/regression/nested-extends-in-arrow-type-param/input.ts

× Expected `,` but found `extends`
× Expected `,` or `)` but found `extends`
╭─[babel/packages/babel-parser/test/fixtures/typescript/regression/nested-extends-in-arrow-type-param/input.ts:1:31]
1 │ type Equals = A extends (x: B extends C ? D : E) => 0 ? F : G;
· ───┬───
· ╰── `,` expected
· ┬ ───┬───
· │ ╰── `,` or `)` expected
· ╰── Opened here
╰────

Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/regression/nested-extends-in-arrow-type-param-babel-7/input.ts

× Expected `,` but found `extends`
× Expected `,` or `)` but found `extends`
╭─[babel/packages/babel-parser/test/fixtures/typescript/regression/nested-extends-in-arrow-type-param-babel-7/input.ts:1:31]
1 │ type Equals = A extends (x: B extends C ? D : E) => 0 ? F : G;
· ───┬───
· ╰── `,` expected
· ┬ ───┬───
· │ ╰── `,` or `)` expected
· ╰── Opened here
╰────

Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/type-arguments-bit-shift-left-like/class-heritage/input.ts
Expand Down Expand Up @@ -3165,11 +3167,12 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc
╰────
help: Replace this operator with `=`.

× Expected `,` but found `(`
× Expected `,` or `}` but found `(`
╭─[babel/packages/babel-parser/test/fixtures/es2015/destructuring/invalid-object-method/input.js:1:12]
1 │ const { foo() {} } = foo();
· ┬
· ╰── `,` expected
· ┬ ┬
· │ ╰── `,` or `}` expected
· ╰── Opened here
╰────

× Cannot assign to this expression
Expand Down Expand Up @@ -5538,11 +5541,12 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc
╰────
help: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern.

× Expected `,` but found `?`
× Expected `,` or `)` but found `?`
╭─[babel/packages/babel-parser/test/fixtures/es2017/async-call/with-optional-operator/input.js:1:8]
1 │ async(x?)
· ┬
· ╰── `,` expected
· ┬ ┬
· │ ╰── `,` or `)` expected
· ╰── Opened here
╰────

× Expected a semicolon or an implicit semicolon after a statement, but found none
Expand Down
95 changes: 57 additions & 38 deletions tasks/coverage/snapshots/parser_typescript.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6943,21 +6943,23 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
╰────
help: Remove the duplicate modifier.

× Expected `,` but found `:`
× Expected `,` or `)` but found `:`
╭─[typescript/tests/cases/compiler/decoratorInJsFile.ts:3:10]
2 │ class SomeClass {
3 │ foo(x: number) {
· ┬
· ╰── `,` expected
· ┬ ┬
· │ ╰── `,` or `)` expected
· ╰── Opened here
4 │
╰────

× Expected `,` but found `:`
× Expected `,` or `)` but found `:`
╭─[typescript/tests/cases/compiler/decoratorInJsFile1.ts:3:10]
2 │ class SomeClass {
3 │ foo(x: number) {
· ┬
· ╰── `,` expected
· ┬ ┬
· │ ╰── `,` or `)` expected
· ╰── Opened here
4 │
╰────

Expand Down Expand Up @@ -8454,12 +8456,19 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
15 │ }
╰────

× Expected `,` but found `var`
× Expected `,` or `)` but found `var`
╭─[typescript/tests/cases/compiler/functionTypesLackingReturnTypes.ts:2:11]
1 │ // Error (no '=>')
2 │ function f(x: ()) {
· ┬
· ╰── Opened here
3 │ }
╰────
╭─[typescript/tests/cases/compiler/functionTypesLackingReturnTypes.ts:6:1]
5 │ // Error (no '=>')
6 │ var g: (param);
· ─┬─
· ╰── `,` expected
· ╰── `,` or `)` expected
7 │
╰────

Expand Down Expand Up @@ -9126,11 +9135,12 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
╰────
help: Try inserting a semicolon here

× Expected `,` but found `?`
× Expected `,` or `)` but found `?`
╭─[typescript/tests/cases/compiler/jsFileCompilationOptionalParameter.ts:1:13]
1 │ function F(p?) { }
· ┬
· ╰── `,` expected
· ┬ ┬
· │ ╰── `,` or `)` expected
· ╰── Opened here
╰────

× TS(8012): Parameter modifiers can only be used in TypeScript files.
Expand Down Expand Up @@ -9173,11 +9183,12 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
· ─
╰────

× Expected `,` but found `:`
× Expected `,` or `)` but found `:`
╭─[typescript/tests/cases/compiler/jsFileCompilationTypeOfParameter.ts:1:13]
1 │ function F(a: number) { }
· ┬
· ╰── `,` expected
· ┬ ┬
· │ ╰── `,` or `)` expected
· ╰── Opened here
╰────

× Expected `{` but found `<`
Expand Down Expand Up @@ -11001,12 +11012,13 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
3 │ }
╰────

× Expected `,` but found `:`
× Expected `,` or `)` but found `:`
╭─[typescript/tests/cases/compiler/parametersSyntaxErrorNoCrash1.ts:3:28]
2 │
3 │ function identity<T>(arg: T: T {
· ┬
· ╰── `,` expected
· ┬ ┬
· │ ╰── `,` or `)` expected
· ╰── Opened here
4 │ return arg;
╰────

Expand Down Expand Up @@ -12069,12 +12081,13 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
· ──────
╰────

× Expected `,` but found `Identifier`
× Expected `,` or `)` but found `Identifier`
╭─[typescript/tests/cases/compiler/restParamModifier.ts:2:27]
1 │ class C {
2 │ constructor(...public rest: string[]) {}
· ──┬─
· ╰── `,` expected
· ┬ ──┬─
· │ ╰── `,` or `)` expected
· ╰── Opened here
3 │ }
╰────

Expand Down Expand Up @@ -16802,12 +16815,13 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
5 │ }
╰────

× Expected `,` but found `@`
× Expected `,` or `)` but found `@`
╭─[typescript/tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter4.ts:4:24]
3 │ class C {
4 │ constructor(public @dec p: number) {}
· ┬
· ╰── `,` expected
· ┬ ┬
· │ ╰── `,` or `)` expected
· ╰── Opened here
5 │ }
╰────

Expand Down Expand Up @@ -17489,12 +17503,13 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
╰────
help: Add an initializer (e.g. ` = undefined`) here

× Expected `,` but found `?`
× Expected `,` or `}` but found `?`
╭─[typescript/tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts:2:7]
1 │ // Error
2 │ var {h?} = { h?: 1 };
· ┬
· ╰── `,` expected
· ┬ ┬
· │ ╰── `,` or `}` expected
· ╰── Opened here
3 │ var {i}: string | number = { i: 2 };
╰────

Expand Down Expand Up @@ -22579,11 +22594,12 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
· ──
╰────

× Expected `,` but found `:`
× Expected `,` or `)` but found `:`
╭─[typescript/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression14.ts:1:9]
1 │ a() ? (b: number, c?: string): void => d() : e; // Not legal JS; "Unexpected token ':'" at first colon
· ┬
· ╰── `,` expected
· ┬ ┬
· │ ╰── `,` or `)` expected
· ╰── Opened here
╰────

× Expected a semicolon or an implicit semicolon after a statement, but found none
Expand Down Expand Up @@ -23218,11 +23234,12 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
· ╰── `:` expected
╰────

× Expected `,` but found `{`
× Expected `,` or `)` but found `{`
╭─[typescript/tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList1.ts:1:14]
1 │ function f(a {
· ┬
· ╰── `,` expected
· ┬ ┬
· │ ╰── `,` or `)` expected
· ╰── Opened here
2 │ }
╰────

Expand All @@ -23239,11 +23256,12 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
2 │ }
╰────

× Expected `,` but found `=>`
× Expected `,` or `)` but found `=>`
╭─[typescript/tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList5.ts:1:11]
1 │ (a:number => { }
· ─┬
· ╰── `,` expected
· ┬ ─┬
· │ ╰── `,` or `)` expected
· ╰── Opened here
╰────

× Unexpected token
Expand Down Expand Up @@ -23318,11 +23336,12 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
╰────
help: Function name is required in function declaration or named export

× Expected `,` but found `=>`
× Expected `,` or `)` but found `=>`
╭─[typescript/tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserEqualsGreaterThanAfterFunction2.ts:1:13]
1 │ function (a => b;
· ─┬
· ╰── `,` expected
· ┬ ─┬
· │ ╰── `,` or `)` expected
· ╰── Opened here
╰────

× Expected a semicolon or an implicit semicolon after a statement, but found none
Expand Down
4 changes: 2 additions & 2 deletions tasks/coverage/snapshots/semantic_babel.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1565,10 +1565,10 @@ after transform: ScopeId(0): [ScopeId(1), ScopeId(2)]
rebuilt : ScopeId(0): []

semantic Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/regression/nested-extends-in-arrow-type-param/input.ts
Expected `,` but found `extends`
Expected `,` or `)` but found `extends`

semantic Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/regression/nested-extends-in-arrow-type-param-babel-7/input.ts
Expected `,` but found `extends`
Expected `,` or `)` but found `extends`

semantic Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/regression/nested-extends-in-arrow-type-return/input.ts
Scope children mismatch:
Expand Down
8 changes: 4 additions & 4 deletions tasks/track_memory_allocations/allocs_parser.snap
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
File | File size || Sys allocs | Sys reallocs || Arena allocs | Arena reallocs | Arena bytes
-------------------------------------------------------------------------------------------------------------------------------------------
checker.ts | 2.92 MB || 9671 | 21 || 267681 | 22847
checker.ts | 2.92 MB || 9672 | 21 || 267681 | 22847

cal.com.tsx | 1.06 MB || 2197 | 62 || 138162 | 13699
cal.com.tsx | 1.06 MB || 2212 | 62 || 138162 | 13699

RadixUIAdoptionSection.jsx | 2.52 kB || 1 | 0 || 365 | 66

pdf.mjs | 567.30 kB || 701 | 75 || 90678 | 8148
pdf.mjs | 567.30 kB || 703 | 75 || 90678 | 8148

antd.js | 6.69 MB || 6997 | 235 || 528505 | 55357
antd.js | 6.69 MB || 7132 | 235 || 528505 | 55357

binder.ts | 193.08 kB || 530 | 7 || 16791 | 1467

Loading
Loading