Repository navigation
fix(compiler): return unmatched values from maybe without else - #103
Merged
Merged
Conversation
The block now returns the unmatched value and skips the rest of the block. Successful matches and blocks with `else` behave as before.
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
When `?=` could not match a value in a `maybe` block without `else`, Nera raised an error instead of returning that value.
What changed
Before and after
Before: Nera raised `else_clause` in both tested positions, while the standard Erlang runtime, BEAM, returned `{error,e}` from the block.
After: Both `maybe` blocks now return `{error,e}`, and all three tested results match BEAM.
This changes what compiled programs return, not what appears on screen.
Checked
Live validation: Demonstrated for this version. 2 of 2 scenarios driven live in the product.
How it was checked
Built and ran the same three-case program on unchanged native Nera, fixed native Nera and BEAM. The fixed native output matches BEAM byte for byte.
Ran the shared fixture with `nera test maybe_without_else -j 1 --timeout 30` and with `erlc` followed by `maybe_without_else:test/0` on BEAM.
Ran the pinned, locked release build, Clippy with warnings denied, the workspace suite, allocator and stacktrace checks, and `nera test -j 1 --timeout 30`.
Risk
Risk: low in every dimension.
Full risk assessment
Not done
The local run ignored one Rust test and skipped two native tests that require external OneCached modules.
GitHub runs the hosted checks on the combined pull request after approval.