Skip to content

Commit

Permalink
fix(parser): parse import source from from 'mod' (#8056)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Dec 21, 2024
1 parent 8b025e3 commit be2c60d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
4 changes: 1 addition & 3 deletions crates/oxc_parser/src/js/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ impl<'a> ParserImpl<'a> {
let mut phase = None;
match self.cur_kind() {
Kind::Source => {
let peek_kind = self.peek_kind();
// Allow `import source from 'mod'`
if peek_kind.is_binding_identifier() && peek_kind != Kind::From {
if self.peek_kind().is_binding_identifier() && self.nth_kind(2) == Kind::From {
self.bump_any();
phase = Some(ImportPhase::Source);
}
Expand Down
12 changes: 2 additions & 10 deletions tasks/coverage/snapshots/parser_test262.snap
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
commit: c4317b0c

parser_test262 Summary:
AST Parsed : 44100/44101 (100.00%)
Positive Passed: 44100/44101 (100.00%)
AST Parsed : 44101/44101 (100.00%)
Positive Passed: 44101/44101 (100.00%)
Negative Passed: 4454/4454 (100.00%)
Expect to Parse: tasks/coverage/test262/test/language/module-code/source-phase-import/import-source-binding-name-2.js

× Unexpected token
╭─[test262/test/language/module-code/source-phase-import/import-source-binding-name-2.js:23:20]
22 │ import source source from '<do not resolve>';
23 │ import source from from '<do not resolve>';
· ────
╰────

× '0'-prefixed octal literals and octal escape sequences are deprecated
╭─[test262/test/annexB/language/expressions/template-literal/legacy-octal-escape-sequence-strict.js:19:4]
Expand Down
5 changes: 1 addition & 4 deletions tasks/coverage/snapshots/semantic_test262.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ commit: c4317b0c

semantic_test262 Summary:
AST Parsed : 44101/44101 (100.00%)
Positive Passed: 43582/44101 (98.82%)
Positive Passed: 43583/44101 (98.83%)
tasks/coverage/test262/test/annexB/language/function-code/if-decl-else-decl-a-func-block-scoping.js
semantic error: Symbol scope ID mismatch for "f":
after transform: SymbolId(3): ScopeId(4294967294)
Expand Down Expand Up @@ -3633,9 +3633,6 @@ Unresolved references mismatch:
after transform: ["$DONE", "Object", "assert", "require"]
rebuilt : ["$DONE", "Object", "_superprop_getMethod", "assert", "require"]

tasks/coverage/test262/test/language/module-code/source-phase-import/import-source-binding-name-2.js
semantic error: Unexpected token

tasks/coverage/test262/test/language/module-code/top-level-await/syntax/for-await-await-expr-func-expression.js
semantic error: Scope children mismatch:
after transform: ScopeId(14): [ScopeId(1)]
Expand Down

0 comments on commit be2c60d

Please sign in to comment.