Repository navigation
fix(parser): accept catch Expr as a first call argument or tuple element - #107
Merged
Merged
Conversation
People who compile such code will notice: it now builds and gives the same results as standard Erlang, for a catch as the first argument of any call or the first element of a tuple. Code that nera fmt rewrote from id((catch X)) to id(catch X) now builds too. A new test checks catch in call arguments and in list and tuple elements, with Nera and with 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
Erlang code that passes a catch expression straight into a function call, such as id(catch error(badarg)), would not compile with Nera, although the standard Erlang compiler accepts it and runs it.
What changed
Before and after
Before: Of 28 places where a catch can appear, 10 failed to compile with "expected ')', found 'catch'" or "expected '}', found 'catch'"; the other 18 already gave the same results as standard Erlang.
After: All 28 compile and print the same results as standard Erlang (BEAM OTP 29).
The change is in the compiler's parser; nothing on screen changes.
Checked
How it was checked
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
erlc tests/catch_argument_element.erl and catch_argument_element:test() on OTP 29
Risk
Risk: low in every dimension.
Full risk assessment