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
Bun-ESM: an intrinsic used as a value (e.g. len) emits a bare name — ReferenceError at run time #837
architectureStructural/system-level shape and runtime behaviourbindingsABI, FFI, WASM, and cross-language interop surfacesbugSomething is broken or behaves incorrectlypriority:p2Normal - queue itscope:repoConfined to this repositorystatus:readyFully specified and ready to be picked up
Codegen.UnboundVariable "len", at compile time: refused loudly, in the right phase
Classification
Loud divergence: the failure comes at run time when it should come at compile time. This is the same class as #832.
Options
Ranked by elegance and correctness first, then by dependability.
(Recommended: most elegant and correct) Eta-expand an intrinsic used as a value at codegen: len becomes (s) => __lowered_len(s), so intrinsics become first-class on every backend. Doing it once in a shared pre-codegen pass (ExprVar intrinsic not in call position, giving ExprLambda) fixes Bun, JS and wasm together, because wasm already lowers closures.
Problem: On Bun-ESM, an intrinsic used as a value (e.g. len passed to apply) is emitted as a bare name. The build succeeds, then fails at run time with ReferenceError: len is not defined. Interp prints 3, and core wasm refuses at compile time with Codegen.UnboundVariable "len". Reproduced on mainee211d3. Same class as #832.
Expected: Either the intrinsic works as a first-class value on every backend (option 1), or Bun-ESM refuses it at compile time, as wasm does (option 2).
Missing: choice between option 1 and option 2, confirmation that other intrinsics in value position hit the same failure
Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.
Create Plan
🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your .coderabbit.yaml:
issue_enrichment:
auto_enrich:
enabled: false
💬 Have feedback or questions? Drop into our discord!
architectureStructural/system-level shape and runtime behaviourbindingsABI, FFI, WASM, and cross-language interop surfacesbugSomething is broken or behaves incorrectlypriority:p2Normal - queue itscope:repoConfined to this repositorystatus:readyFully specified and ready to be picked up
Activity
whatproblem-ai commentedon Dec 1, 2026
Problem: On Bun-ESM, an intrinsic used as a value (e.g.
lenpassed toapply) is emitted as a bare name. The build succeeds, then fails at run time withReferenceError: len is not defined. Interp prints3, and core wasm refuses at compile time withCodegen.UnboundVariable "len". Reproduced onmainee211d3. Same class as #832.Expected: Either the intrinsic works as a first-class value on every backend (option 1), or Bun-ESM refuses it at compile time, as wasm does (option 2).
Missing: choice between option 1 and option 2, confirmation that other intrinsics in value position hit the same failure
Clarity: 93%. Clear enough to work on.
⌨️ Commands · 💬 Have feedback? Tell us · 🎯 New here? Add WhatProblem to your repo · 🔒 Privacy
coderabbitai commentedon Dec 1, 2026
📝 Issue Planner
Check the box below or use the
@coderabbitai plancommand to generate an implementation plan and prompts that you can use with your favorite coding assistant.🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord!
test(soundness): pin #836 wasm intrinsic-name shadowing as open (trac…
test(soundness): pin #836 wasm intrinsic-name shadowing as open (trac…
docs(audit): add #836 and #837 to the backend-divergence audit
fix(codegen): start the wasm heap after the last data segment (#830) (#…