Skip to content

Preserve integer precision in numeric equality - #24

Closed
qoke wants to merge 2 commits into
ardanlabs:mainfrom
iqhive:jinjafix-integer-equality
Closed

qoke wants to merge 2 commits into
ardanlabs:mainfrom
iqhive:jinjafix-integer-equality

Conversation

@qoke

@qoke qoke commented Oct 22, 2026

Copy link
Copy Markdown

Closes #16.

Equality was converting integers to floating point before comparing them. Above 2^53, that allowed different integers to compare equal. For example, 9007199254740993 == 9007199254740992 must return False.

The fix compares integer and Boolean operands as integers and handles mixed integer–float comparisons without rounding the integer first. Evaluator equality now goes through the shared value comparison implementation, so direct comparisons, nested containers, and membership checks use the same numeric rules.

The five regression cases cover large integers, mixed numeric types, Boolean equality, nested values, and membership. They include Python reference output and the original failing Go results, and all pass with the fix.

go test -count=1 ./... passes.

@ardan-bkennedy

Copy link
Copy Markdown
Contributor

Thank you, @qoke, for reporting these issues and for providing proposed fixes. We reviewed all nine reports and used your suggestions where they made sense in the codebase. All nine issues have now been resolved in #34, each with corresponding regression tests, and the fixes are published in v1.11.0.

The issue addressed by this PR (#16) is covered by that release, so we are closing this PR in favor of the consolidated fix.

For future reports, please start with issues only so we can discuss the approach before opening pull requests. Thanks again for helping improve the project.

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.

Preserve integer precision in equality checks

2 participants