diff --git a/crates/oxc_parser/src/error_handler.rs b/crates/oxc_parser/src/error_handler.rs index 79ef228c94031..8520b8432b95b 100644 --- a/crates/oxc_parser/src/error_handler.rs +++ b/crates/oxc_parser/src/error_handler.rs @@ -19,8 +19,8 @@ impl<'a> ParserImpl<'a> { // The lexer should have reported a more meaningful diagnostic // when it is a undetermined kind. if matches!(self.cur_kind(), Kind::Eof | Kind::Undetermined) { - if let Some(error) = self.lexer.errors.pop() { - self.set_fatal_error(error); + if let Some(error) = self.lexer.errors.last() { + self.set_fatal_error(error.clone()); return; } } diff --git a/tasks/coverage/misc/fail/oxc-12816.ts b/tasks/coverage/misc/fail/oxc-12816.ts new file mode 100644 index 0000000000000..98cfa9b6dd24e --- /dev/null +++ b/tasks/coverage/misc/fail/oxc-12816.ts @@ -0,0 +1 @@ +if(\ ()<1){} \ No newline at end of file diff --git a/tasks/coverage/snapshots/parser_babel.snap b/tasks/coverage/snapshots/parser_babel.snap index 473f6387ac65a..449315390b025 100644 --- a/tasks/coverage/snapshots/parser_babel.snap +++ b/tasks/coverage/snapshots/parser_babel.snap @@ -1867,6 +1867,12 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc · ── ╰──── + × Unterminated string + ╭─[babel/packages/babel-parser/test/fixtures/core/uncategorised/381/input.js:1:9] + 1 │ var x = " + · ── + ╰──── + × Identifier expected. 'if' is a reserved word that cannot be used here. ╭─[babel/packages/babel-parser/test/fixtures/core/uncategorised/382/input.js:1:5] 1 │ var if = 42 @@ -4664,6 +4670,12 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc ╰──── help: Try insert a semicolon here + × Invalid Character `𫠞` + ╭─[babel/packages/babel-parser/test/fixtures/es2015/uncategorised/327/input.js:1:5] + 1 │ var 𫠞_ = 12; + · ── + ╰──── + × Invalid Character `𫠞` ╭─[babel/packages/babel-parser/test/fixtures/es2015/uncategorised/327/input.js:1:5] 1 │ var 𫠞_ = 12; @@ -9669,6 +9681,12 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc · ─ ╰──── + × Invalid Character `🀒` + ╭─[babel/packages/babel-parser/test/fixtures/esprima/es2015-identifier/invalid_id_smp/input.js:1:5] + 1 │ var 🀒 + · ─ + ╰──── + × Invalid Unicode escape sequence ╭─[babel/packages/babel-parser/test/fixtures/esprima/es2015-identifier/invalid_lone_surrogate/input.js:1:2] 1 │ \uD800! @@ -10688,6 +10706,12 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc · ── ╰──── + × Unterminated string + ╭─[babel/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0063/input.js:1:9] + 1 │ var x = " + · ── + ╰──── + × Identifier expected. 'if' is a reserved word that cannot be used here. ╭─[babel/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0064/input.js:1:5] 1 │ var if = 42 diff --git a/tasks/coverage/snapshots/parser_misc.snap b/tasks/coverage/snapshots/parser_misc.snap index 3f4579684208f..8467fe980ca37 100644 --- a/tasks/coverage/snapshots/parser_misc.snap +++ b/tasks/coverage/snapshots/parser_misc.snap @@ -1,7 +1,7 @@ parser_misc Summary: AST Parsed : 48/48 (100.00%) Positive Passed: 48/48 (100.00%) -Negative Passed: 78/78 (100.00%) +Negative Passed: 79/79 (100.00%) × Cannot assign to 'arguments' in strict mode ╭─[misc/fail/arguments-eval.ts:1:10] @@ -437,6 +437,12 @@ Negative Passed: 78/78 (100.00%) · ────────────────────── ╰──── + × Invalid Unicode escape sequence + ╭─[misc/fail/oxc-12816.ts:1:5] + 1 │ if(\ ()<1){} + · ─ + ╰──── + × 'super' can only be referenced in members of derived classes or object literal expressions. ╭─[misc/fail/oxc-13284.ts:5:9] 4 │ bar() { diff --git a/tasks/coverage/snapshots/parser_test262.snap b/tasks/coverage/snapshots/parser_test262.snap index 15226cc59581a..1185c18162451 100644 --- a/tasks/coverage/snapshots/parser_test262.snap +++ b/tasks/coverage/snapshots/parser_test262.snap @@ -2754,37 +2754,33 @@ Expect to Parse: tasks/coverage/test262/test/annexB/language/expressions/assignm · ── ╰──── - × Expected `in` but found `throw` - ╭─[test262/test/language/comments/hashbang/escaped-bang-041.js:20:1] - 19 │ - 20 │ throw "Test262: This statement should not be evaluated."; - · ──┬── - · ╰── `in` expected - ╰──── + × Invalid Unicode escape sequence + ╭─[test262/test/language/comments/hashbang/escaped-bang-041.js:1:3] + 1 │ #\041 + · ─ + 2 │ + ╰──── - × Expected `in` but found `throw` - ╭─[test262/test/language/comments/hashbang/escaped-bang-u0021.js:20:1] - 19 │ - 20 │ throw "Test262: This statement should not be evaluated."; - · ──┬── - · ╰── `in` expected - ╰──── + × Invalid Character `!` + ╭─[test262/test/language/comments/hashbang/escaped-bang-u0021.js:1:8] + 1 │ #\u0021 + · ▲ + 2 │ + ╰──── - × Expected `in` but found `throw` - ╭─[test262/test/language/comments/hashbang/escaped-bang-u21.js:20:1] - 19 │ - 20 │ throw "Test262: This statement should not be evaluated."; - · ──┬── - · ╰── `in` expected - ╰──── + × Invalid Character `!` + ╭─[test262/test/language/comments/hashbang/escaped-bang-u21.js:1:8] + 1 │ #\u{21} + · ▲ + 2 │ + ╰──── - × Expected `in` but found `throw` - ╭─[test262/test/language/comments/hashbang/escaped-bang-x21.js:20:1] - 19 │ - 20 │ throw "Test262: This statement should not be evaluated."; - · ──┬── - · ╰── `in` expected - ╰──── + × Invalid Unicode escape sequence + ╭─[test262/test/language/comments/hashbang/escaped-bang-x21.js:1:3] + 1 │ #\x21 + · ─ + 2 │ + ╰──── × Invalid Unicode escape sequence ╭─[test262/test/language/comments/hashbang/escaped-hash-043.js:1:2] @@ -21091,6 +21087,13 @@ Expect to Parse: tasks/coverage/test262/test/annexB/language/expressions/assignm × Invalid Character `ⸯ` ╭─[test262/test/language/identifiers/vertical-tilde-start.js:17:5] 16 │ + 17 │ var ⸯ; // U+2E2F + · ─ + ╰──── + + × Invalid Character `ⸯ` + ╭─[test262/test/language/identifiers/vertical-tilde-start.js:17:5] + 16 │ 17 │ var ⸯ; // U+2E2F · ─ ╰──── @@ -39181,6 +39184,13 @@ Expect to Parse: tasks/coverage/test262/test/annexB/language/expressions/assignm × Unterminated string ╭─[test262/test/language/types/string/S8.4_A13_T2.js:16:11] 15 │ + 16 │ var str = '; + · ─── + ╰──── + + × Unterminated string + ╭─[test262/test/language/types/string/S8.4_A13_T2.js:16:11] + 15 │ 16 │ var str = '; · ─── ╰──── @@ -39196,6 +39206,13 @@ Expect to Parse: tasks/coverage/test262/test/annexB/language/expressions/assignm × Unterminated string ╭─[test262/test/language/types/string/S8.4_A14_T1.js:16:11] 15 │ + 16 │ var str = "; + · ─── + ╰──── + + × Unterminated string + ╭─[test262/test/language/types/string/S8.4_A14_T1.js:16:11] + 15 │ 16 │ var str = "; · ─── ╰──── @@ -39264,3 +39281,10 @@ Expect to Parse: tasks/coverage/test262/test/annexB/language/expressions/assignm 33 │ var᠎foo; · ─ ╰──── + + × Invalid Character `᠎` + ╭─[test262/test/language/white-space/mongolian-vowel-separator.js:33:4] + 32 │ // U+180E between "var" and "foo"; UTF8(0x180E) = 0xE1 0xA0 0x8E + 33 │ var᠎foo; + · ─ + ╰──── diff --git a/tasks/coverage/snapshots/parser_typescript.snap b/tasks/coverage/snapshots/parser_typescript.snap index 0f9ef0ad4202a..00d2443eb7807 100644 --- a/tasks/coverage/snapshots/parser_typescript.snap +++ b/tasks/coverage/snapshots/parser_typescript.snap @@ -12938,6 +12938,15 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc 2 │ var es1 = "line 1 · ──────── 3 │ "; + 4 │ var es2 = 'line 1 + ╰──── + + × Unterminated string + ╭─[typescript/tests/cases/compiler/stringLiteralsErrors.ts:2:11] + 1 │ // Srtings missing line terminator + 2 │ var es1 = "line 1 + · ──────── + 3 │ "; 4 │ var es2 = 'line 1 ╰──── @@ -18337,6 +18346,18 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc · ────────────────── ╰──── + × Unterminated string + ╭─[typescript/tests/cases/conformance/es6/unicodeExtendedEscapes/unicodeExtendedEscapesInStrings24.ts:1:9] + 1 │ var x = "\u{00000000000067 + · ────────────────── + ╰──── + + × Unterminated string + ╭─[typescript/tests/cases/conformance/es6/unicodeExtendedEscapes/unicodeExtendedEscapesInStrings25.ts:1:9] + 1 │ var x = "\u{00000000000067} + · ─────────────────── + ╰──── + × Unterminated string ╭─[typescript/tests/cases/conformance/es6/unicodeExtendedEscapes/unicodeExtendedEscapesInStrings25.ts:1:9] 1 │ var x = "\u{00000000000067} @@ -24214,11 +24235,9 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc 1 │ foo(a, \ ╰──── - × Expected `,` but found `Identifier` - ╭─[typescript/tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens18.ts:1:7] + × Invalid Unicode escape sequence + ╭─[typescript/tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens18.ts:1:8] 1 │ foo(a \ - · ┬ - · ╰── `,` expected ╰──── × Invalid Unicode escape sequence @@ -24239,11 +24258,9 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc · ─ ╰──── - × Expected `,` but found `Identifier` - ╭─[typescript/tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens20.ts:1:12] + × Invalid Unicode escape sequence + ╭─[typescript/tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens20.ts:1:13] 1 │ var v: X