Skip to content

Add arithmetic error reporting for MathInterpreter#16809

Open
kojix2 wants to merge 1 commit intocrystal-lang:masterfrom
kojix2:math-interpreter-overflow
Open

Add arithmetic error reporting for MathInterpreter#16809
kojix2 wants to merge 1 commit intocrystal-lang:masterfrom
kojix2:math-interpreter-overflow

Conversation

@kojix2
Copy link
Copy Markdown
Contributor

@kojix2 kojix2 commented Apr 5, 2026

This pull request attempts to fix #11746.

MathInterpreter is called by SemanticVisitor when resolving constant integer values and when interpreting numeric values of Enums. Previously, errors that occurred during operations were not caught, resulting in compiler errors. This pull request adds handling to catch OverflowError and DivisionByZeroError.

The code was edited with the assistance of the Codex in VSCode Copilot Chat.

else
interpret_call_macro(node)
end
rescue ex : OverflowError | DivisionByZeroError
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: We should really have a common parent type for these arithmetic error type (cf. #11639).

@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:semantic labels Apr 7, 2026
@straight-shoota straight-shoota added this to the 1.20.0 milestone Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:semantic

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make MathInterpreter not raise on arithmetic overflows

3 participants