Skip to content

fix: underscored number literals lose leading zeros of digit groups - #370

Merged
santiagocardo merged 2 commits into
developfrom
prod-6381-basic-comparison-error-in-then-statements-5000-180000
Aug 13, 2026
Merged

fix: underscored number literals lose leading zeros of digit groups#370
santiagocardo merged 2 commits into
developfrom
prod-6381-basic-comparison-error-in-then-statements-5000-180000

Conversation

@fedme

@fedme fedme commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Expression supports Elixir-style underscore separators in number literals (123_456), but the int() parser captured each digit group between underscores with integer/1. Parsing "000" as an integer gives 0, so 180_000 joined into 1800 and 1_000_000 into 100. 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_000 evaluated to true and 200_000 + 1 to 2001. 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.89 for large floats too. Existing leniency is preserved: 1_ still parses as 1 and 1__1 still falls back to text.

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
fedme force-pushed the prod-6381-basic-comparison-error-in-then-statements-5000-180000 branch from f8c33c7 to 7d6747c Compare August 12, 2026 16:46
@fedme
fedme requested a review from santiagocardo August 12, 2026 16:47
santiagocardo
santiagocardo previously approved these changes Aug 12, 2026

@santiagocardo santiagocardo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

@fedme

fedme commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Done, bumped to 3.0.0-rc.2 in mix.exs and README.

@santiagocardo
santiagocardo merged commit b64e710 into develop Aug 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants