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
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.
Summary
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 trapsmemory access out of bounds).Pre-existing + untested
81a59bf(pre INT-01 test(xmod): INT-01 — prove + regression-lock cross-module wasm linking (Refs #178) #244) and at currentmain(d88770a) — not a regression, long-standing.tests/codegen/test_for_loop.affineexists but there is notest_for_loop.mjs, sotools/run_codegen_wasm_tests.shcompiles 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
for-in/whilelowering inlib/codegen.ml.tests/codegen/test_for_loop.mjs(and awhileone) so the gate catches this class permanently.Surfaced by INT-08 (#183). Refs #183.