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(bun-esm): extern fn used as a value emits an unbound name #818
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)
go([]) throws ReferenceError: sha256 is not defined.
Cause
lib/codegen_deno.ml, gen_expr, the ExprVar value-position branch. A direct call goes through the builtin table, which lowers to a host expression. A bare name emits the AffineScript name. An extern has no JavaScript binding with that name. This applies to every extern, not only the crypto ones.
Problem: On the Bun-ESM backend, an extern fn used as a value rather than called, such as apply(sha256, b), compiles but throws ReferenceError: sha256 is not defined at runtime. The ExprVar value-position branch of gen_expr in lib/codegen_deno.ml emits the bare AffineScript name. Externs have no JavaScript binding with that name. This affects every extern.
Expected:go([]) returns the same result as calling sha256([]) directly. Passing any extern as a function value should run without a ReferenceError.
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)
Activity
whatproblem-ai commentedon Nov 27, 2026
Problem: On the Bun-ESM backend, an
extern fnused as a value rather than called, such asapply(sha256, b), compiles but throwsReferenceError: sha256 is not definedat runtime. TheExprVarvalue-position branch ofgen_exprinlib/codegen_deno.mlemits the bare AffineScript name. Externs have no JavaScript binding with that name. This affects every extern.Expected:
go([])returns the same result as callingsha256([])directly. Passing any extern as a function value should run without aReferenceError.Clarity: 93%. Clear enough to work on.
⌨️ Commands · 💬 Have feedback? Tell us · 🎯 New here? Add WhatProblem to your repo · 🔒 Privacy
fix(codegen): extern values in shorthand record fields; keep await lo…
fix(codegen): lower an extern used as a value to an arrow (#818)
fix(codegen): extern values in shorthand record fields; keep await lo…