Repository navigation
fix(runtime): add list_to_float/1 natively with BEAM's float text rules - #109
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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
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
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.