Repository navigation
fix(parser): accept throw as the function name of a fun reference - #111
Merged
Merged
Conversation
`fun erlang:throw/1` and `fun M:throw/1` build natively, and calling the fun throws its argument, as on BEAM. Functions named `true` and `false` can be referenced the same way; reserved words such as `maybe` are still rejected, as erlc does. A new `throw_fun_ref` fixture checks this natively and 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
Code written for BEAM may pass `fun erlang:throw/1` like any other function, and erlc builds it, but Nera rejected it with "unexpected token ... found 'throw'".
What changed
Before and after
Before: A module containing `F = fun erlang:throw/1, F(x)` failed to build natively; only the quoted form `fun erlang:'throw'/1` built.
After: Both forms build, and `catch F(x)` returns `x` natively, as on BEAM OTP 29; the new fixture passes 20 of 20 native runs and 10 of 10 on BEAM.
A compiler change: nothing on screen changes; the evidence is build and run output.
Checked
How it was checked
cargo build --release --locked -p nera-runtime && 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
erlc tests/throw_fun_ref.erl and throw_fun_ref:test() on OTP 29, 10 runs
Risk
Risk: low in every dimension.
Full risk assessment
Not done
Hosted CI runs only on pull requests and main, so this branch has none of its own; the batch pull request runs it.