Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(parser): parse import source from from 'mod' #8056

Merged
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
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
Loading