7The Rust port should be structurally as close to the TypeScript as possible: viewing the TS and Rust side by side, the logic should look, read, and feel similar while working naturally in Rust.
8
9▶**Current status**: M1-M13 fully implemented. All statement types, expression types, destructuring, function expressions, JSX, switch/try-catch, for-of/in, optional chaining, and recursive lowering are complete. No `todo!()` stubs remain. `cargo check` passes. Remaining work: test against fixtures and fix divergences from TypeScript output.
10
11**Known issues to fix:**
· · ·
232Following the port notes:
233- `CompilerError.invariant(cond, ...)` → `if !cond { panic!(...) }` or dedicated `compiler_invariant!` macro
234▶- `CompilerError.throwTodo(...)` → `return Err(CompilerDiagnostic::todo(...))`
235- `builder.recordError(...)` → `builder.record_error(...)` (accumulates on Environment)
236- Non-null assertions (`!`) → `.unwrap()` or `.expect("...")`
· · ·
238The `lower()` function returns `Result<HirFunction, CompilerError>` for invariant/thrown errors, while accumulated errors go to `env.errors`.
239
240▶### 6. `todo!()` Strategy for Incremental Implementation
241
242BuildHIR is too large (4555 lines) for a single implementation pass. Use Rust's `todo!()` macro to stub unimplemented branches:
· · ·
242▶BuildHIR is too large (4555 lines) for a single implementation pass. Use Rust's `todo!()` macro to stub unimplemented branches:
243
244```rust
· · ·
249 ast::Statement::BlockStatement(s) => lower_block_statement(builder, s),
250 // Stubbed — will be filled in later milestones
251▶ ast::Statement::ForStatement(_) => todo!("lower ForStatement"),
252 ast::Statement::WhileStatement(_) => todo!("lower WhileStatement"),
253 ast::Statement::SwitchStatement(_) => todo!("lower SwitchStatement"),
+ 12 more matches in this file