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
fix(codegen-deno): statement-position return + control flow (Refs #122)
The Deno-ESM backend inherited js_codegen's expression-only lowering of
`return`/`if`/`match`/`try`: a statement-position `return e;` became
`(() => { return e; })();`, whose value is discarded — so any function
using an explicit `return` (or early-return in an `if`, or `return`
inside a `for`/`while`) actually returned `undefined`. Phase 1 dodged
it only because every fixture used `= expr;` bodies.
Add a distinct statement-position lowering (gen_stmt_expr / gen_branch /
gen_stmt_seq / gen_match_stmt / gen_try_stmt): in statement context
`return` and control flow emit real JS statements; gen_expr keeps the
IIFE form for genuine expression positions. StmtExpr, and loop trailing
exprs, route through it.
Regression: tests/codegen-deno/control_flow.{affine,harness.mjs} —
while+trailing return, early return in if, return inside for+if,
fallthrough. Full Deno-ESM suite green; Phase 1 unaffected.
Refs #122.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
0 commit comments