mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-10 01:56:15 +08:00
The clones checked every `+` and `-` for int32 overflow, even where the static integer-range analysis (ir/integer-ranges.ts) already proves the result is an int32, such as fib's `n - 1` and `n - 2`: callers pass int32-slots-proven arguments and the `n < 2` guard bounds n from below. The clone host now exposes the function's IntegerRanges, computed under the same parameter facts the clone assumes, and a sum or difference the analysis proves within int32 is emitted as a plain `add`/`sub nsw`. Clone values are never -0, so neither is such a result. Unproven sums, products and the accumulator keep their checks. The clones thus use the static proofs first and speculate only on what the analysis cannot bound.