mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-28 06:53:42 +08:00
The range analysis narrowed a counter only when the comparison read the counter itself (`i < n`). A comparison of the counter plus or minus an integer literal (`i + 1 < xs.length`, `1 + i < n`, `i - 1 >= 0`) now narrows it as `i < n - c` does. Against a bound within 2^52, a sum that rounds has a magnitude of at least 2^53, so every such comparison answers as the exact sum would. The counter of `for (let i = 0; i + 1 < xs.length; i++)` then lands in an i32 slot like the one of `i < xs.length - 1`, and helper calls that index arrays with it read the elements without the double index checks.