Skip to content

fix(runtime): add list_to_float/1 natively with BEAM's float text rules - #109

Merged
mremond merged 1 commit into
mainfrom
infinitary-batch/48aa4c09
Dec 4, 2026
Merged

mremond merged 1 commit into
mainfrom
infinitary-batch/48aa4c09

Conversation

@mremond

@mremond mremond commented Dec 4, 2026

Copy link
Copy Markdown
Member

Why

A module that called erlang:list_to_float/1 failed to build natively with "unresolved function `erlang:list_to_float/1`", while standard Erlang returns the parsed float.

What changed

  • Programs that call list_to_float/1 now build and run natively, through direct, apply and fun reference calls.
  • It accepts and rejects the same text as standard Erlang: a sign, digits around a `.` or `,` radix and an exponent, ending at a NUL.
  • Text beyond the float range raises badarg, and text below it returns a zero of its sign, as in standard Erlang.

Before and after

Before: Building a module that calls list_to_float("1.5") stopped with an unresolved function error.

After: The same module builds, and 92 probe inputs plus about 34,000 random ones give the same result natively as on standard Erlang OTP 29.

The change is in the compiler's runtime library and shows only as program output, which the checks below record.

Checked

  • New list_to_float_text test program, natively and on standard Erlang OTP 29: Passed 10 of 10 natively, 10 of 10 with one scheduler and 10 of 10 on OTP 29; it fails to build with the previous compiler
  • Same program against a deliberately loose parser and against the first version of the parser: Both fail, so its accepted and rejected cases guard the grammar and the exponent handling
  • 92 targeted inputs and about 34,000 random inputs compared natively and on OTP 29: Identical results, including range edges, signed zeros, comma radixes and digits shifted by up to 400,000 zeros
  • Two independent reviews: The first found two differences with very long text and comma radixes, both fixed; the second found none
  • Workspace build, clippy, Rust tests, full end-to-end suite, allocator and stacktrace scripts: All passed: 2,303 Rust tests and 561 end-to-end tests with the 2 known skips
How it was checked

cargo build --release --locked

cargo clippy --workspace --all-targets --locked -- -D warnings

cargo test --workspace --locked --no-fail-fast (2,303 passed)

./target/release/nera test -j 1 --timeout 30 (561 passed, 2 known skips)

python3 scripts/test-allocator-config.py

python3 scripts/test-stacktrace-order.py

erlc tests/list_to_float_text.erl and list_to_float_text:test() on OTP 29, 10 runs

Risk

Risk above low: Novelty, medium — New float text parser beside the existing binary_to_float one

Full risk assessment
Dimension Level Why
Blast radius low One new runtime function and its table entries; no existing function changes
Behavior low A call that failed to build now works as in standard Erlang
Undo low Revert the commits
Evidence low Same program and probes compared natively and on OTP 29
Sensitivity low No saved data, sign-ins or releases
Novelty medium New float text parser beside the existing binary_to_float one
Dependencies low No new or updated packages
Not done

binary_to_float/1 still uses its older, looser parser and differs from standard Erlang on text such as ".5", "5." and "1,5"; that is tracked separately.

Programs that call list_to_float/1 now build and run natively, through direct, apply and fun reference calls.

It accepts and rejects the same text as standard Erlang: a sign, digits around a `.` or `,` radix and an exponent, ending at a NUL.

Text beyond the float range raises badarg, and text below it returns a zero of its sign, as in standard Erlang.
@mremond
mremond merged commit 1a3b65b into main Dec 4, 2026
1 check passed
@mremond
mremond deleted the infinitary-batch/48aa4c09 branch December 4, 2026 10:26
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