Skip to content

fix(runtime): dispatch dynamic bitstring BIFs - #63

Merged
mremond merged 1 commit into
mainfrom
fm/task-22ef6d2e
Nov 16, 2026
Merged

mremond merged 1 commit into
mainfrom
fm/task-22ef6d2e

Conversation

@mremond

@mremond mremond commented Nov 15, 2026

Copy link
Copy Markdown
Member

Why

Dynamic calls to bit_size/1 and is_bitstring/1 raised undef even though direct calls worked.

What changed

  • Apply, variable-module/function and fun-reference calls now use the existing bitstring routines.
  • Dynamic bit_size/1 returns the bit count or raises badarg; is_bitstring/1 returns true or false.
  • One regression runs unchanged natively and on BEAM, with updated feature and test documentation.

Before and after

Before: For an 11-bit input, all three requested dynamic forms raised undef for both functions.

After: Those forms return 11 for bit_size/1 and true for is_bitstring/1, matching BEAM.

This changes native call results, not a screen; real native and BEAM program transcripts demonstrate the behavior.

Checked

Live validation: Demonstrated for this version. 2 of 3 scenarios driven live in the product.

Scenario Result Evidence
Dynamic sizes and type checks for bitstrings ✅ Passed live The same compiled program matches BEAM byte for byte; the regression covers 12 dynamic forms per BIF and 12 bitstrings.
Invalid-input results and caught-error recovery ✅ Passed live Twenty non-bitstrings produce badarg or false through each dynamic form, and a valid call succeeds after a caught error.
Complete local contribution gate (supplementary) ⏸ Supporting evidence Both builds, related fixtures, ten consecutive regression runs, clippy, workspace tests, allocator checks, full native suite and stacktrace checks passed.
  • Original native regression: All 12 dynamic bit_size call forms raised undef; the printed program reproduced both missing BIFs.
  • Native and BEAM program output: Output matches byte for byte for binaries, an 11-bit bitstring and non-bitstrings across direct, apply, variable-module and remote-fun calls.
  • New regression: Passed on BEAM and ten consecutive native runs without retries; covers 12 call forms per BIF, 12 bitstrings and 20 non-bitstrings.
  • Local contribution gate: Clippy passed; 2,213 workspace tests passed, one ignored; allocator and stacktrace checks passed.
  • Full native end-to-end suite: 522 passed, zero failed, two skipped because external modules are unavailable; four related fixtures also passed.
  • Independent review: Reviewed all five changed files and traced dispatch and error propagation; no material findings.
How it was checked

Built the runtime before the compiler with cargo build --release --locked -p nera-runtime and cargo build --release --locked -p nera.

Ran ./target/release/nera test bif_bitstring_dynamic bif_byte_size_dynamic bitstring_size_badarg binary_tail_byte_size -j 1 --timeout 30.

Compiled the new fixture with erlc and ran bif_bitstring_dynamic:test() on BEAM with explicit completion.

Ran the new native fixture ten times consecutively, without retries.

Ran cargo clippy --workspace --all-targets --locked -- -D warnings and cargo test --workspace --locked --no-fail-fast.

Ran python3 scripts/test-allocator-config.py, ./target/release/nera test -j 1 --timeout 30 and python3 scripts/test-stacktrace-order.py.

Local validation used macOS arm64; hosted platform checks are read separately before merge.

Risk

Risk: low in every dimension.

Full risk assessment
Dimension Level Why
Blast radius low Two dispatch entries in one runtime table.
Behavior low Corrects undef to match existing direct-call semantics.
Undo low Revert the change; no saved data moves.
Evidence low Real native and BEAM programs produce identical output.
Sensitivity low No sign-ins, keys, saved settings or release changes.
Novelty low Reuses the routines already used by direct calls.
Dependencies low No dependency changes.

Pipeline

Updates from git push no-mistakes

Infinitary checked this version: an independent review that also judged the documents, and live validation the review accepted.

@github-actions github-actions Bot added this to the 0.1.1 milestone Nov 15, 2026
@mremond
mremond merged commit 1a47427 into main Nov 16, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant