2026-06-15
Pre-release
Pre-release
fix index overflow in enumerate with large start Summary: **Index overflow in `enumerate` with a large start** The per-element index is built as `k as i32 + start`, so when the caller passes a `start` near `i32::MAX` the addition overflows on the first elements rather than at some unreachable list length. Cause is doing the arithmetic in `i32` even though Starlark integers are arbitrary precision, so the correct result does not fit. Fix widens the running index to `i64` before adding the offset. `enumerate(['a', 'b'], 2147483647)` panics with "attempt to add with overflow" in debug and wraps to a negative index in release; it should yield `[(2147483647, 'a'), (2147483648, 'b')]`. Added a regression test alongside the existing builtin tests. Should be safe as the index can no longer exceed `i64` for any in-memory iterable, though a reviewer may prefer matching whatever width the range work settled on. X-link: https://github.com/facebook/starlark-rust/pull/203 Reviewed By: JakobDegen Differential Revision: D108556073 fbshipit-source-id: 2d2b80304aba92dc806f4338e8227c143820fc69