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: a named fn passed as a value fails to compile (UnboundVariable) — interp/Bun accept it #839
architectureStructural/system-level shape and runtime behaviourbindingsABI, FFI, WASM, and cross-language interop surfacesbugSomething is broken or behaves incorrectlymigrationPorting between languages or toolchains (e.g. -> AffineScript)priority:p2Normal - queue itscope:repoConfined to this repository
Classification: a loud divergence. It is refused at compile time, so nothing runs with a wrong value.
Options
Ranked by elegance and correctness first, then by dependability.
(Recommended: most elegant and correct) Treat a named top-level function in value position as a closure. Its environment pointer is null (0), and it dispatches through a table entry pointing to a small trampoline that drops the environment argument. This reuses the existing closure ABI (func_id, env_ptr), so callers need no change. The same pass covers the intrinsic-as-value case (Bun-ESM: an intrinsic used as a value (e.g. len) emits a bare name — ReferenceError at run time #837) once intrinsics are eta-expanded.
(Most dependable) Keep refusing, but name the cause: "a named fn cannot be passed as a value on core wasm yet; wrap it: |s| nine(s)".
Problem: On core wasm, passing a named top-level fn as a value (call(nine) where call takes fn(String) -> Int) fails at codegen with UnboundVariable "nine" on mainee211d3. The interpreter and Bun-ESM print 9. The failure happens at compile time, so no wrong value is produced.
Expected: core wasm compiles and prints 9, matching interp and Bun. If that is not yet supported, the compiler should give an error that names the cause and suggests the |s| nine(s) workaround.
architectureStructural/system-level shape and runtime behaviourbindingsABI, FFI, WASM, and cross-language interop surfacesbugSomething is broken or behaves incorrectlymigrationPorting between languages or toolchains (e.g. -> AffineScript)priority:p2Normal - queue itscope:repoConfined to this repository
Activity
whatproblem-ai commentedon Dec 1, 2026
Problem: On core wasm, passing a named top-level fn as a value (
call(nine)wherecalltakesfn(String) -> Int) fails at codegen withUnboundVariable "nine"onmainee211d3. The interpreter and Bun-ESM print9. The failure happens at compile time, so no wrong value is produced.Expected: core wasm compiles and prints
9, matching interp and Bun. If that is not yet supported, the compiler should give an error that names the cause and suggests the|s| nine(s)workaround.Clarity: 93%. Clear enough to work on.
⌨️ Commands · 💬 Have feedback? Tell us · 🎯 New here? Add WhatProblem to your repo · 🔒 Privacy
docs(audit): add #838 (local does not shadow fn on wasm, fixed in #840)…
fix(codegen): a local shadows a same-named fn on wasm; intern call_in…
docs(audit): add #838 (local does not shadow fn on wasm, fixed in #840)…
docs(audit): add #838 (local does not shadow fn on wasm, fixed in #840)…
fix(codegen): start the wasm heap after the last data segment (#830) (#…