You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: implement import.defer() and import.source() dynamic import syntax (#5035)
This Pull Request adds parsing and runtime support for `import.defer()`
and `import.source()` dynamic import syntax, enabling 64
previously-ignored test262 tests.
It changes the following:
- Added `ImportPhase` enum (`Evaluation`, `Defer`, `Source`) and a
`phase` field to the `ImportCall` AST node in
`core/ast/src/expression/call.rs`, with proper `ToInternedString` output
for each phase.
- Extended the parser in
`core/parser/src/parser/expression/left_hand_side/mod.rs` to detect and
parse `import.defer(expr)` and `import.source(expr)` syntax, including
4-token lookahead in `is_keyword_call` and phase-aware token
consumption.
- Updated the bytecode compiler in
`core/engine/src/bytecompiler/expression/mod.rs` to encode `ImportPhase`
as an `IndexOperand` (0=evaluation, 1=defer, 2=source) on the
`ImportCall` instruction.
- Added `phase: IndexOperand` to the `ImportCall` opcode definition in
`core/engine/src/vm/opcode/mod.rs` and updated the code block display in
`core/engine/src/vm/code_block.rs` to show phase names.
- Updated the VM `ImportCall` handler in
`core/engine/src/vm/opcode/call/mod.rs` to decode the phase operand:
source phase rejects with `SyntaxError` per `GetModuleSource()` spec
(16.2.1.7.2), defer phase uses standard evaluation semantics.
- Removed `import-defer` and `source-phase-imports` from the ignored
features list in `test262_config.toml`, bringing `dynamic-import/catch`
suite from 112/176 to **176/176 (100% conformance)**.
0 commit comments