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
{{ message }}
Repository navigation
wasm codegen: for-in/while loop bodies never execute in compiled programs (pre-existing, untested) #255
The wasm backend compiles loops but the loop body never runs in the produced module. Minimal repro:
```
fn main() -> Int {
let arr = [1, 2, 3, 4, 5];
let mut s = 0;
for x in arr { s += x; }
return s;
}
```
`affinescript compile` → wasm; `instance.exports.main()` returns 0 (expected 15). The same 0-iteration behaviour reproduces for while + index, and across element types ([Int], [String], [VNode], [(String,String)] — the tuple-list case additionally traps memory access out of bounds).
Zero test coverage: tests/codegen/test_for_loop.affine exists but there is no test_for_loop.mjs, so tools/run_codegen_wasm_tests.sh compiles it and never executes/asserts it. Arrays + direct indexing (a[0]) work and are asserted (test_tuple_record_array → 81); no asserted fixture exercises a loop.
Impact
Blocks every list-processing wasm program. Directly blocks INT-08 (#183) runtime (the DOM reconciler compiles cleanly but cannot iterate children/attributes at runtime) and likely INT-07 (#182) TEA run loop. Source-to-source targets (Deno-ESM etc.) are unaffected.
Asks
Root-cause + fix the for-in/while lowering in lib/codegen.ml.
Add an assertingtests/codegen/test_for_loop.mjs (and a while one) so the gate catches this class permanently.
Activity
feat(dom): INT-08 real VDOM reconciler + .as→.affine rename (Refs #183 …
feat(dom): INT-08 real VDOM reconciler + .as→.affine rename (Refs #183 …
fix(codegen): implement `++` list concatenation (was placeholder I32A…
feat(http): #225 PR3d — typed Response reader (ADR-013 §value-reconst…
docs(stdlib-roadmap): rows #3 + #4 ◯→●, codegen bug closed by #257 (#434
docs(ledger): truth INT-02 closure + spin satellite-shell scope to #489…
docs(ledger): truth INT-02 closure + spin satellite-shell scope to #489…
feat(stdlib): Canvas.affine — HTML5 Canvas 2D rendering (bindings #8) (…
docs: reconcile stale "#255 blocker" refs — loop-codegen defect is fi…
feat(dom): prove INT-08 reconciler runs end-to-end; ship the e2e harn…
feat(dom): prove INT-08 reconciler runs end-to-end; ship the e2e harn…