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
Commit 2e42667
Browse filesBrowse the repository at this point in the historyBrowse files
feat(codegen-bun): intrinsics are first-class values
Owner ruling 2026-12-01 ("First-class wrappers"). An intrinsic such as
`len`, `string_sub` or `trim` used as a value, not called, was emitted as
a bare name with no JS binding, so calling it threw a ReferenceError
(`let f = len; f(s)`; `apply(len, s)`). Declared externs were already
wrapped (#818). Non-extern intrinsics now are too.
- `builtin_arity`: each builtin's arity, read once from its type in
`Typecheck.register_builtins`. One source of truth, no hand-kept list.
- `wrap_builtin_value`: the lowering wrapped in an arrow of that arity.
It is shared with the #818 extern path, which now uses it, so there is
one wrapping rule. An awaiting lowering keeps the bare name, as #818
did.
Coverage:
- All 40 Bun builtins the type checker types are wrapped, and the new
suite fails if a typed builtin ever is not.
- The remaining Bun builtins are stdlib `extern fn`s, covered by #818.
- Two names, `acos` and `asin`, have a Bun lowering but are neither
resolvable nor typed, so no program can use them. That predates this
change and is reported in the PR.
Tests:
- tests/codegen-bun/intrinsic_values: len and to_uppercase passed to a
higher-order fn; trim, string_sub, string_find and int_to_string bound
with `let`. It fails on main with `ReferenceError: len is not defined`.
- test/test_intrinsic_values.ml: coverage, arity from type, and wrapper
text.
- dune runtest: 852 pass. Bun harnesses: pass. Ledger: ports #856's part
(main is red on property 3) and advances the stamp to 4a55253.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4QvDiosfvobXq67wbduuK
0 commit comments