Round whole numbers and numeric strings in ROUND - #374
Merged
Merged
Conversation
`ROUND` piped its argument straight into `Decimal.from_float/1`, which only accepts a float. So `ROUND(5)`, `ROUND(2 * 3)` and a variable holding a whole number all raised a `FunctionClauseError`, while the same expression with a fractional value worked. That error is not one `evaluate_block!/4` converts into an `Expression.Error`, so it crashed the caller. Coerce the value with the helper `FIXED` already uses, then build the decimal from either an integer or a float. A whole number now rounds to itself, a numeric string rounds like the number it holds, and a value that is not a number raises the standard "expression is not a number" error. Release as 3.0.0-rc.5. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
smn
approved these changes
Sep 21, 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
ROUNDonly accepts a float, soROUND(5),ROUND(2 * 3)or a variable holding a whole number raise aFunctionClauseErrorthat crashes the caller.What
ROUNDnow coerces its value the wayFIXEDdoes: whole numbers and numeric strings round, and anything else raises "expression is not a number".