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
codegen(wasm): print(String) emits an invalid module (lowered as integer print) #850
architectureStructural/system-level shape and runtime behaviourbindingsABI, FFI, WASM, and cross-language interop surfacesbugSomething is broken or behaves incorrectlyenhancementNew capability or improvement to existing behaviourmigrationPorting between languages or toolchains (e.g. -> AffineScript)priority:p2Normal - queue itscope:repoConfined to this repository
print with a String argument produces an invalid core-wasm module. The failure is loud: the module fails validation, so nothing runs.
pub fn main() -> () { print("hi"); println(""); }
affinescript compile succeeds. bun run out.wasm then fails with CompileError: WebAssembly.Module doesn't validate: attempt to use unknown local 3, the number of locals is 3. Re-verified on main-based build 161eaaf.
Cause, found by the #836 work (PR #841): the wasm print arm in lib/codegen.ml lowers print as an integer print, but its type is String -> Unit.
Fix: lower print(String) like the string half of println, or refuse print on non-Int arguments by name until then. Add a fixture.
Problem: On the wasm backend, print with a String argument (print("hi")) is lowered as an integer print in lib/codegen.ml, even though its type is String -> Unit. affinescript compile succeeds, but the emitted module fails validation (attempt to use unknown local 3, the number of locals is 3), so nothing runs. Reproduced on 161eaaf. Expected:print(String) either compiles to a valid module that prints the string, lowered like the string half of println, or is rejected by name at compile time for non-Int arguments. A fixture covers it.
architectureStructural/system-level shape and runtime behaviourbindingsABI, FFI, WASM, and cross-language interop surfacesbugSomething is broken or behaves incorrectlyenhancementNew capability or improvement to existing behaviourmigrationPorting between languages or toolchains (e.g. -> AffineScript)priority:p2Normal - queue itscope:repoConfined to this repository
Activity
whatproblem-ai commentedon Dec 1, 2026
Problem: On the wasm backend,
printwith aStringargument (print("hi")) is lowered as an integer print inlib/codegen.ml, even though its type isString -> Unit.affinescript compilesucceeds, but the emitted module fails validation (attempt to use unknown local 3, the number of locals is 3), so nothing runs. Reproduced on161eaaf.Expected:
print(String)either compiles to a valid module that prints the string, lowered like the string half ofprintln, or is rejected by name at compile time for non-Int arguments. A fixture covers it.Clarity: 94%. Clear enough to work on.
⌨️ Commands · 💬 Have feedback? Tell us · 🎯 New here? Add WhatProblem to your repo · 🔒 Privacy