Reraise a runtime arithmetic error as Expression.Error - #372
Merged
joaothallis merged 1 commit intoSep 17, 2026
Merged
Conversation
`evaluate_block!/4` and `evaluate!/4` already convert a `RuntimeError` raised during evaluation into an `Expression.Error`; this is how a non-numeric operand, which raises "expression is not a number", surfaces to callers. A division by zero is the one arithmetic failure that slips through: the operands are valid numbers, so the numeric guard passes, and the raw `Kernel.//2` then raises `ArithmeticError`, which is not a `RuntimeError` and so escaped the rescue and crashed the caller. Add `ArithmeticError` alongside `RuntimeError` in both reraise clauses so any runtime arithmetic fault surfaces as an `Expression.Error`, consistent with every other unusable value. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
joaothallis
force-pushed
the
reraise-arithmetic-error-as-expression-error
branch
from
September 17, 2026 02:15
3bc17a7 to
ffaef8a
Compare
benonymus
approved these changes
Sep 17, 2026
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
evaluate_block!/4andevaluate!/4already convert aRuntimeErrorraised during evaluation into anExpression.Error. That is how a non-numeric operand surfaces: the numeric guard doesraise "expression is not a number"(aRuntimeError), which the rescue reraises asExpression.Error, so callers get a typed evaluation error instead of a crash.A division by zero is the one arithmetic failure that slips through. The operands are valid numbers, so the guard passes, and the raw
Kernel.//2then raisesArithmeticError, which is not aRuntimeError. It escaped the rescue and crashed the calling process.What
Add
ArithmeticErroralongsideRuntimeErrorin both reraise clauses, so any runtime arithmetic fault surfaces as anExpression.Error(type: :eval), consistent with every other unusable value.evaluate_as_string!/4is intentionally left as is: it does not wrapRuntimeErroreither, so anArithmeticError-only rescue there would be inconsistent.🤖 Generated with Claude Code