File tree Expand file tree Collapse file tree 4 files changed +18
-6
lines changed Expand file tree Collapse file tree 4 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -1117,3 +1117,10 @@ pub fn unexpected_optional_declaration(span: Span) -> OxcDiagnostic {
11171117 . with_label ( span)
11181118 . with_help ( "Remove the `?`" )
11191119}
1120+
1121+ #[ cold]
1122+ pub fn identifier_expected_after_question_dot ( span : Span ) -> OxcDiagnostic {
1123+ OxcDiagnostic :: error ( "Identifier expected after '?.'" )
1124+ . with_label ( span)
1125+ . with_help ( "Add an identifier after '?.'" )
1126+ }
Original file line number Diff line number Diff line change @@ -987,7 +987,7 @@ impl<'a> ParserImpl<'a> {
987987
988988 if let Some ( span) = question_dot_span {
989989 // We parsed `?.` but then failed to parse anything, so report a missing identifier here.
990- let error = diagnostics:: unexpected_token ( span) ;
990+ let error = diagnostics:: identifier_expected_after_question_dot ( span) ;
991991 return self . fatal_error ( error) ;
992992 }
993993
Original file line number Diff line number Diff line change @@ -14698,11 +14698,12 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc
1469814698 ╰────
1469914699 help: Try inserting a semicolon here
1470014700
14701- × Unexpected token
14701+ × Identifier expected after '?.'
1470214702 ╭─[babel/packages/babel-parser/test/fixtures/typescript/type-arguments/call-optional-chain-invalid/input.ts:1:2]
1470314703 1 │ f?.<string>[1];
1470414704 · ──
1470514705 ╰────
14706+ help: Add an identifier after '?.'
1470614707
1470714708 × TS(1099): Type argument list cannot be empty.
1470814709 ╭─[babel/packages/babel-parser/test/fixtures/typescript/type-arguments/empty-function/input.ts:1:4]
Original file line number Diff line number Diff line change @@ -3532,32 +3532,36 @@ Negative Passed: 120/120 (100.00%)
35323532 5 │ }
35333533 ╰────
35343534
3535- × Unexpected token
3535+ × Identifier expected after ' ?. '
35363536 ╭─[misc / fail / oxc - 9497.js :2 :8 ]
35373537 1 │ let repro = {};
35383538 2 │ repro .f ? .
35393539 · ──
35403540 ╰────
3541+ help : Add an identifier after ' ?.'
35413542
3542- × Unexpected token
3543+ × Identifier expected after ' ?. '
35433544 ╭─[misc / fail / oxc - 9525 - 1.js :1 :2 ]
35443545 1 │ x ? .;
35453546 · ──
35463547 ╰────
3548+ help : Add an identifier after ' ?.'
35473549
3548- × Unexpected token
3550+ × Identifier expected after ' ?. '
35493551 ╭─[misc / fail / oxc - 9525 - 2.js :1 :3 ]
35503552 1 │ [x ? .];
35513553 · ──
35523554 ╰────
3555+ help : Add an identifier after ' ?.'
35533556
3554- × Unexpected token
3557+ × Identifier expected after ' ?. '
35553558 ╭─[misc / fail / oxc - 9525 - 3.js :2 :4 ]
35563559 1 │ () => {
35573560 2 │ x ? .
35583561 · ──
35593562 3 │ }
35603563 ╰────
3564+ help : Add an identifier after ' ?.'
35613565
35623566 × The keyword ' let' is reserved
35633567 ╭─[misc / fail / oxc .js :3 :1 ]
You can’t perform that action at this time.
0 commit comments