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

This commit is contained in:
Boshen 2024-12-13 10:26:35 +00:00
parent e4d040583c
commit 7610dc19ff
10 changed files with 34 additions and 55 deletions

View file

@ -10,7 +10,7 @@ runs:
show-progress: false
repository: tc39/test262
path: tasks/coverage/test262
ref: eefc5cf367b999768445432e167606fd1acf1734
ref: dc0082c5ea347e5ecb585c1d7ebf4555aa429528
- uses: actions/checkout@v4
with:

View file

@ -59,9 +59,13 @@ impl<'a> ParserImpl<'a> {
let mut import_kind = ImportOrExportKind::Value;
let mut phase = None;
match self.cur_kind() {
Kind::Source if self.peek_kind().is_binding_identifier() => {
self.bump_any();
phase = Some(ImportPhase::Source);
Kind::Source => {
let peek_kind = self.peek_kind();
// Allow `import source from 'mod'`
if peek_kind.is_binding_identifier() && peek_kind != Kind::From {
self.bump_any();
phase = Some(ImportPhase::Source);
}
}
Kind::Defer if self.peek_at(Kind::Star) => {
self.bump_any();

View file

@ -36,7 +36,7 @@ ready:
# Clone or update submodules
# Make sure to update `.github/actions/clone-submodules/action.yml` too
submodules:
just clone-submodule tasks/coverage/test262 https://github.com/tc39/test262.git eefc5cf367b999768445432e167606fd1acf1734
just clone-submodule tasks/coverage/test262 https://github.com/tc39/test262.git dc0082c5ea347e5ecb585c1d7ebf4555aa429528
just clone-submodule tasks/coverage/babel https://github.com/babel/babel.git 54a8389fa31ce4fd18b0335b05832dc1ad3cc21f
just clone-submodule tasks/coverage/typescript https://github.com/microsoft/TypeScript.git d85767abfd83880cea17cea70f9913e9c4496dcc
just clone-submodule tasks/prettier_conformance/prettier https://github.com/prettier/prettier.git 37fd1774d13ef68abcc03775ceef0a91f87a57d7

View file

@ -1,5 +1,5 @@
commit: eefc5cf3
commit: dc0082c5
codegen_test262 Summary:
AST Parsed : 44169/44169 (100.00%)
Positive Passed: 44169/44169 (100.00%)
AST Parsed : 44096/44096 (100.00%)
Positive Passed: 44096/44096 (100.00%)

View file

@ -1,5 +1,5 @@
commit: eefc5cf3
commit: dc0082c5
minifier_test262 Summary:
AST Parsed : 44169/44169 (100.00%)
Positive Passed: 44169/44169 (100.00%)
AST Parsed : 44096/44096 (100.00%)
Positive Passed: 44096/44096 (100.00%)

View file

@ -1,38 +1,18 @@
commit: eefc5cf3
commit: dc0082c5
parser_test262 Summary:
AST Parsed : 44166/44169 (99.99%)
Positive Passed: 44166/44169 (99.99%)
AST Parsed : 44095/44096 (100.00%)
Positive Passed: 44095/44096 (100.00%)
Negative Passed: 4454/4456 (99.96%)
Expect Syntax Error: tasks/coverage/test262/test/language/import/import-attributes/json-invalid.js
Expect Syntax Error: tasks/coverage/test262/test/language/import/import-attributes/json-named-bindings.js
Expect to Parse: tasks/coverage/test262/test/language/import/import-defer/errors/resolution-error/import-defer-of-missing-module-fails.js
Expect to Parse: tasks/coverage/test262/test/language/module-code/source-phase-import/import-source-binding-name-2.js
× Expected `from` but found `string`
╭─[test262/test/language/import/import-defer/errors/resolution-error/import-defer-of-missing-module-fails.js:22:22]
21 │
22 │ import defer * as ns "./resolution-error_FIXTURE.js";
· ───────────────┬───────────────
· ╰── `from` expected
╰────
Expect to Parse: tasks/coverage/test262/test/language/import/import-defer/errors/syntax-error/import-defer-of-syntax-error-fails.js
× Expected `from` but found `string`
╭─[test262/test/language/import/import-defer/errors/syntax-error/import-defer-of-syntax-error-fails.js:22:22]
21 │
22 │ import defer * as ns "./syntax-error_FIXTURE.js";
· ─────────────┬─────────────
· ╰── `from` expected
╰────
Expect to Parse: tasks/coverage/test262/test/language/module-code/source-phase-import/import-source-binding-name.js
× Expected `from` but found `string`
╭─[test262/test/language/module-code/source-phase-import/import-source-binding-name.js:22:20]
21 │
22 │ import source from '<do not resolve>';
· ─────────┬────────
· ╰── `from` expected
23 │ import from from '<do not resolve>';
× 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

View file

@ -1,4 +1,4 @@
commit: eefc5cf3
commit: dc0082c5
runtime Summary:
AST Parsed : 18055/18055 (100.00%)

View file

@ -1,8 +1,8 @@
commit: eefc5cf3
commit: dc0082c5
semantic_test262 Summary:
AST Parsed : 44169/44169 (100.00%)
Positive Passed: 43640/44169 (98.80%)
AST Parsed : 44096/44096 (100.00%)
Positive Passed: 43569/44096 (98.80%)
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)
@ -3695,14 +3695,8 @@ Unresolved references mismatch:
after transform: ["$DONE", "Object", "assert", "require"]
rebuilt : ["$DONE", "Object", "_superprop_getMethod", "assert", "require"]
tasks/coverage/test262/test/language/import/import-defer/errors/resolution-error/import-defer-of-missing-module-fails.js
semantic error: Expected `from` but found `string`
tasks/coverage/test262/test/language/import/import-defer/errors/syntax-error/import-defer-of-syntax-error-fails.js
semantic error: Expected `from` but found `string`
tasks/coverage/test262/test/language/module-code/source-phase-import/import-source-binding-name.js
semantic error: Expected `from` but found `string`
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:

View file

@ -1,5 +1,5 @@
commit: eefc5cf3
commit: dc0082c5
transformer_test262 Summary:
AST Parsed : 44169/44169 (100.00%)
Positive Passed: 44169/44169 (100.00%)
AST Parsed : 44096/44096 (100.00%)
Positive Passed: 44096/44096 (100.00%)

View file

@ -27,6 +27,7 @@ impl<T: Case> Suite<T> for Test262Suite<T> {
fn skip_test_path(&self, path: &Path) -> bool {
let path = path.to_string_lossy();
path.contains("test262/test/staging") ||
// ignore markdown files
path.ends_with(".md") ||
// ignore fixtures