Skip to content

Stop range counters wrapping at integer boundaries - #29

Closed
qoke wants to merge 2 commits into
ardanlabs:mainfrom
iqhive:jinjafix-range-counter-overflow
Closed

qoke wants to merge 2 commits into
ardanlabs:mainfrom
iqhive:jinjafix-range-counter-overflow

Conversation

@qoke

@qoke qoke commented Oct 22, 2026

Copy link
Copy Markdown

Closes #21.

Applying a range step near an integer boundary could overflow the counter and continue iterating after it wrapped. For example, range(9223372036854775805, 9223372036854775807, 3) | list timed out instead of returning [9223372036854775805].

After appending the current valid item, the implementation now checks whether applying the next step would overflow. Positive and negative steps have separate boundary checks, and iteration stops before either can wrap the counter.

The regression test captures Python’s expected single-item result and the original Go timeout. With the fix, it verifies the exact output within an enforced deadline.

@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 (#21) 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.

Stop range counters wrapping at integer boundaries

2 participants