Repository navigation
fix(runtime): write printable lists as strings under ~P and ~tP - #113
Merged
Merged
Conversation
~P and ~tP print a printable Latin-1 list as a double-quoted string, using the same rule ~p uses. The string prints whole however little depth remains; at depth 1 a list still prints as [...]. Lists inside lists, tuples and maps are judged at the depth where each one is written. ~lP and ~W keep lists numeric, as on 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
Natively, io:format("~P", ["hi\n", 5]) printed [104,105,10], where BEAM prints "hi\n". The depth-limited ~P writer never wrote a list as a string, even after ~p learned to.
What changed
Before and after
Before: On the previous main, 23 of 52 lines of a ~P probe differed from BEAM OTP 29, because every printable list printed as integers.
After: All 52 probe lines, covering ~P, ~tP, ~lP and ~W at several depths, match BEAM OTP 29 byte for byte.
Native output of io_lib:format for seven ~P and ~lP calls
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
A 49-case ~P, ~tP, ~lP and ~W probe, built natively and run on BEAM OTP 29, compared byte for byte
Risk
Risk: low in every dimension.
Full risk assessment
Not done
~P and ~tP still write printable binaries as numbers; BEAM writes <<"abc">>, and under ~P only the first 4 characters per remaining depth level. This is already listed in the known limits.
~p and ~P still do not wrap long terms at the line width as BEAM does. The known limits now name ~P too.