Repository navigation
fix(runtime): iterate built-in atom map keys in BEAM order - #104
Merged
Merged
Conversation
People will notice: maps of up to 32 keys now list false before true, as BEAM does, wherever a program walks, prints or encodes them The same now holds for 30 more names that exist before any program runs, such as error before ok All other keys keep their previous order, which can still differ from BEAM
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
Programs compiled by Nera listed a map's true key before its false key, while BEAM, the standard Erlang runtime, lists false first, so their output differed.
What changed
Before and after
Before: `maps:keys(#{true => 1, false => 2})` returned `[true, false]` in a compiled program, and all 16 lines of a probe that walks such maps differed from Erlang/OTP 29.
After: It returns `[false, true]`, and the same probe prints 16 of 16 lines identical to Erlang/OTP 29.
The change shows only in the values and text that compiled programs produce, so there is no screen to picture.
Checked
How it was checked
cargo build --release --locked
cargo clippy --workspace --all-targets --locked -- -D warnings
cargo test --workspace --locked --no-fail-fast
python3 scripts/test-allocator-config.py
./target/release/nera test -j 1 --timeout 30
python3 scripts/test-stacktrace-order.py
./target/release/nera test map_builtin_atom_order -j 1 --timeout 30 (ten times, and ten times with NERA_SCHEDULERS=1)
erlc tests/map_builtin_atom_order.erl && erl -noshell -eval 'map_builtin_atom_order:test(), halt().' (ten times on Erlang/OTP 29.1.2, plus embedded mode and other start options)
python3 tests/integration/cowlib/runner.py, python3 tests/integration/thoas/differential/runner.py and python3 scripts/test-cowlib-demo.py
Risk
Risk above low: Blast radius, medium — Every walk of a small map goes through the changed key comparison
Full risk assessment
Not done
Keys that are not among the names Nera creates at startup keep their previous order, which can differ from BEAM. BEAM also places some of its own names, such as timeout, between the ones fixed here.
Messages logged through error_logger print maps with a separate printer that this change does not touch. That defect is recorded separately.
The hosted checks have not run on this version: they start only on pull requests, and this change joins a shared pull request once approved.