fix: underscored number literals lose leading zeros of digit groups - #370
Merged
santiagocardo merged 2 commits intoAug 13, 2026
Conversation
The int parser captured each digit group between underscores with integer/1, which parses "000" as 0, so 180_000 was joined into 1800 and 1_000_000 into 100. Elixir's code formatter writes numbers longer than five digits with underscore separators, so expressions generated from Elixir ASTs hit this constantly: 5000 > 180_000 evaluated to true. Capture digit groups as strings so leading zeros survive the join, and give floats the same underscore support since the formatter emits underscores for large floats too.
fedme
force-pushed
the
prod-6381-basic-comparison-error-in-then-statements-5000-180000
branch
from
August 12, 2026 16:46
f8c33c7 to
7d6747c
Compare
santiagocardo
previously approved these changes
Aug 12, 2026
santiagocardo
left a comment
Contributor
There was a problem hiding this comment.
Wow 🤯 I would never imagine this bug haha - thanks @fedme!
Could you please update mix.exs and README.md to version: "3.0.0-rc.2" to release it directly after merging?
Contributor
Author
|
Done, bumped to 3.0.0-rc.2 in mix.exs and README. |
santiagocardo
approved these changes
Aug 13, 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.
Expression supports Elixir-style underscore separators in number literals (
123_456), but theint()parser captured each digit group between underscores withinteger/1. Parsing"000"as an integer gives0, so180_000joined into1800and1_000_000into100. Elixir's code formatter writes any number longer than five digits with underscore separators, so expression strings generated from Elixir ASTs hit this constantly:5000 > 180_000evaluated totrueand200_000 + 1to2001. Since the result is still a valid boolean or number, nothing ever logged.The fix captures digit groups as strings so leading zeros survive the join, and gives floats the same underscore support since the formatter emits
1_234_567.89for large floats too. Existing leniency is preserved:1_still parses as1and1__1still falls back to text.