Repository navigation
fix(runtime): quote atoms under ~w and ~p as OTP does - #11
Merged
Merged
Conversation
mremond
force-pushed
the
fm/task-25dd220d
branch
from
November 12, 2026 17:22
61460f1 to
512a437
Compare
io:format/2 and io_lib:format/2 printed every atom bare, so a caught
exit came out as {EXIT,bye} and atoms such as 'Foo' or 'hello world'
did not read back as the same term.
~w, ~p, ~W and ~P now write atoms with OTP's io_lib rules: an atom is
bare only when it starts with a Latin-1 lowercase letter, holds only
Latin-1 letters, digits, _ and @, and is not a reserved word (maybe and
else included). Quotes, backslashes and control characters are escaped
inside the quotes, and characters above 255 print as \x{...} unless the
t modifier is given.
The io_format_atom_quoting fixture runs natively and on BEAM. The
Cowlib demo's two 'HTTP/1.1' lines now match OTP, so they leave its
known differences, and the docs that recorded them are updated.
mremond
force-pushed
the
fm/task-25dd220d
branch
from
November 12, 2026 17:22
512a437 to
254cb28
Compare
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
io:format and io_lib:format printed every atom bare, so a trapped exit came out as {EXIT,bye} and atoms such as 'Foo' or 'hello world' did not read back as the same term, unlike on BEAM.
What changed
Before and after
Before: Programs printed {EXIT,bye}, Foo and hello world; 43 of 44 lines of an atom probe differed from OTP 29.
After: Programs print {'EXIT',bye}, 'Foo' and 'hello world'; all 44 probe lines are byte-identical with OTP 29.
The change is in text a program prints, so the before and after are shown as program output rather than pictures.
Checked
How it was checked
cargo build --release --locked -p nera-runtime; cargo build --release --locked -p nera
cargo clippy --workspace --all-targets --locked -- -D warnings: clean
cargo test --workspace --locked --no-fail-fast: 2,139 passed, 0 failed, 1 ignored
./target/release/nera test -j 6 --timeout 30: 468 passed, 0 failed, 2 skipped (onecached fixtures needing external modules)
nera test io_format_atom_quoting ten times in a row: 10/10; erlc + erl running the same module ten times: 10/10
python3 scripts/test-cowlib-demo.py with the updated known differences: 4/4 tests pass, no known line newly identical
Probe module compiled with the base and patched compilers and with erlc, outputs diffed against OTP 29.1.2 on macOS arm64
After bringing the branch up to date with the native timer change: rebuilt, then io_format_atom_quoting, the six io_format/io_lib fixtures and the three timer fixtures pass (10/10), and the probe is still identical with OTP
Risk
Risk above low: Blast radius, medium — The shared term writer is used by every ~w/~p/~W/~P call and by crash messages; Behavior, medium — Printed output changes by default for atoms that need quotes, now matching BEAM
Full risk assessment
Not done
Nera's own crash message (Error in process ...) now quotes atoms too, since it shares the term writer.
The separate error_logger renderer keeps its own simpler quoting rule and is unchanged.