diff --git a/crates/oxc_parser/src/js/module.rs b/crates/oxc_parser/src/js/module.rs index 7b40594c81997..2b1a5360b2794 100644 --- a/crates/oxc_parser/src/js/module.rs +++ b/crates/oxc_parser/src/js/module.rs @@ -178,6 +178,10 @@ impl<'a> ParserImpl<'a> { None => unreachable!(), } } else { + if has_default_specifier { + // `import something 'source'` + self.expect_without_advance(Kind::From); + } None } } else { diff --git a/tasks/coverage/misc/fail/import-defer-without-from.js b/tasks/coverage/misc/fail/import-defer-without-from.js new file mode 100644 index 0000000000000..92de23867cd48 --- /dev/null +++ b/tasks/coverage/misc/fail/import-defer-without-from.js @@ -0,0 +1 @@ +import defer 'module'; diff --git a/tasks/coverage/misc/fail/import-from-str.js b/tasks/coverage/misc/fail/import-from-str.js new file mode 100644 index 0000000000000..f0c1ff20f90ef --- /dev/null +++ b/tasks/coverage/misc/fail/import-from-str.js @@ -0,0 +1 @@ +import from 'module'; diff --git a/tasks/coverage/misc/fail/import-source-without-from.js b/tasks/coverage/misc/fail/import-source-without-from.js new file mode 100644 index 0000000000000..de9a6dcacbe7e --- /dev/null +++ b/tasks/coverage/misc/fail/import-source-without-from.js @@ -0,0 +1 @@ +import source 'module'; diff --git a/tasks/coverage/misc/fail/import-type-without-from.ts b/tasks/coverage/misc/fail/import-type-without-from.ts new file mode 100644 index 0000000000000..872e15abf43c0 --- /dev/null +++ b/tasks/coverage/misc/fail/import-type-without-from.ts @@ -0,0 +1 @@ +import type 'module'; diff --git a/tasks/coverage/misc/fail/import-without-from.js b/tasks/coverage/misc/fail/import-without-from.js new file mode 100644 index 0000000000000..06d652c11d5c8 --- /dev/null +++ b/tasks/coverage/misc/fail/import-without-from.js @@ -0,0 +1 @@ +import unknown 'module'; diff --git a/tasks/coverage/misc/pass/import-from-from.js b/tasks/coverage/misc/pass/import-from-from.js new file mode 100644 index 0000000000000..36a7fc88dc014 --- /dev/null +++ b/tasks/coverage/misc/pass/import-from-from.js @@ -0,0 +1 @@ +import from from 'module'; diff --git a/tasks/coverage/snapshots/codegen_misc.snap b/tasks/coverage/snapshots/codegen_misc.snap index 039ebf3251ae3..c3c0ff020993f 100644 --- a/tasks/coverage/snapshots/codegen_misc.snap +++ b/tasks/coverage/snapshots/codegen_misc.snap @@ -1,3 +1,3 @@ codegen_misc Summary: -AST Parsed : 49/49 (100.00%) -Positive Passed: 49/49 (100.00%) +AST Parsed : 50/50 (100.00%) +Positive Passed: 50/50 (100.00%) diff --git a/tasks/coverage/snapshots/formatter_misc.snap b/tasks/coverage/snapshots/formatter_misc.snap index 4f48848ce08e9..224a087461ff5 100644 --- a/tasks/coverage/snapshots/formatter_misc.snap +++ b/tasks/coverage/snapshots/formatter_misc.snap @@ -1,3 +1,3 @@ formatter_misc Summary: -AST Parsed : 49/49 (100.00%) -Positive Passed: 49/49 (100.00%) +AST Parsed : 50/50 (100.00%) +Positive Passed: 50/50 (100.00%) diff --git a/tasks/coverage/snapshots/parser_misc.snap b/tasks/coverage/snapshots/parser_misc.snap index 6621d34be164e..16e9a1e6eeb87 100644 --- a/tasks/coverage/snapshots/parser_misc.snap +++ b/tasks/coverage/snapshots/parser_misc.snap @@ -1,7 +1,7 @@ parser_misc Summary: -AST Parsed : 49/49 (100.00%) -Positive Passed: 49/49 (100.00%) -Negative Passed: 113/113 (100.00%) +AST Parsed : 50/50 (100.00%) +Positive Passed: 50/50 (100.00%) +Negative Passed: 118/118 (100.00%) × Cannot assign to 'arguments' in strict mode ╭─[misc/fail/arguments-eval.ts:1:10] @@ -187,6 +187,20 @@ Negative Passed: 113/113 (100.00%) · ╰── `,` or `]` expected ╰──── + × Expected `from` but found `string` + ╭─[misc/fail/import-defer-without-from.js:1:14] + 1 │ import defer 'module'; + · ────┬─── + · ╰── `from` expected + ╰──── + + × Expected `from` but found `string` + ╭─[misc/fail/import-from-str.js:1:13] + 1 │ import from 'module'; + · ────┬─── + · ╰── `from` expected + ╰──── + × Expected `from` but found `Identifier` ╭─[misc/fail/import-source-non-from.js:1:19] 1 │ import source foo bar from 'module'; @@ -194,6 +208,27 @@ Negative Passed: 113/113 (100.00%) · ╰── `from` expected ╰──── + × Expected `from` but found `string` + ╭─[misc/fail/import-source-without-from.js:1:15] + 1 │ import source 'module'; + · ────┬─── + · ╰── `from` expected + ╰──── + + × Expected `from` but found `string` + ╭─[misc/fail/import-type-without-from.ts:1:13] + 1 │ import type 'module'; + · ────┬─── + · ╰── `from` expected + ╰──── + + × Expected `from` but found `string` + ╭─[misc/fail/import-without-from.js:1:16] + 1 │ import unknown 'module'; + · ────┬─── + · ╰── `from` expected + ╰──── + × Unexpected JSX expression ╭─[misc/fail/jsx-in-js.js:1:20] 1 │ export const foo = ; diff --git a/tasks/coverage/snapshots/semantic_misc.snap b/tasks/coverage/snapshots/semantic_misc.snap index 04914f1a5349f..7e1b0bbe202ea 100644 --- a/tasks/coverage/snapshots/semantic_misc.snap +++ b/tasks/coverage/snapshots/semantic_misc.snap @@ -1,6 +1,6 @@ semantic_misc Summary: -AST Parsed : 49/49 (100.00%) -Positive Passed: 31/49 (63.27%) +AST Parsed : 50/50 (100.00%) +Positive Passed: 32/50 (64.00%) semantic Error: tasks/coverage/misc/pass/oxc-11593.ts Scope children mismatch: after transform: ScopeId(0): [ScopeId(1)] diff --git a/tasks/coverage/snapshots/transformer_misc.snap b/tasks/coverage/snapshots/transformer_misc.snap index 796fc8b9977ec..5228cd7b67ef4 100644 --- a/tasks/coverage/snapshots/transformer_misc.snap +++ b/tasks/coverage/snapshots/transformer_misc.snap @@ -1,3 +1,3 @@ transformer_misc Summary: -AST Parsed : 49/49 (100.00%) -Positive Passed: 49/49 (100.00%) +AST Parsed : 50/50 (100.00%) +Positive Passed: 50/50 (100.00%)