Semantic Diff

#8917 Reanalyze: skip Division_by_zero for non-zero literal divisors

1 commit, rendered from its record.

Summary

RangeCommitsChangelogAreasJS output changesFormatsFailed checks
58da277de4eeba0d27f17c8056fd4c192e7b7ad9..pr-89171๐Ÿ› Bug fixreanalyzetests0none0

Changelog draft

๐Ÿ› Bug fix
  • Reanalyze no longer reports Division_by_zero for / and mod with a non-zero literal divisor.

58da277de4eeba0d27f17c8056fd4c192e7b7ad9..pr-8917

9613978f3 ยท Christoph Knittel ยท Oct 19, 2026

Reanalyze: skip Division_by_zero for non-zero literal divisors

๐Ÿ› Bug fixreanalyzetests

The exception analysis treats / and mod as throwing Division_by_zero. It now skips that when the divisor is a non-zero int, float or bigint literal, so x / 10 needs no @throws annotation. Divisions by a variable or by a zero literal are still reported.

Example ReScript

let foo = (x: int) => x / 10

Diagnostic output

Before: foo might throw Division_by_zero ... and is not annotated
with @throws(Division_by_zero)
After: no warning
๐Ÿ› Bug fixReanalyze no longer reports Division_by_zero for / and mod with a non-zero literal divisor.

Review

No effect
Output: unchanged
Tests
analysis+ tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Division.res~ tests/analysis_tests/tests-reanalyze/deadcode/expected/exception.txt
4 files ยท +66 โˆ’2 ยท reanalyze 1 ยท changelog 1 ยท tests 2
Manalysis/reanalyze/src/exception.ml+25โˆ’1
Achanges/reanalyze-division-literal-divisor.fix.md+1โˆ’0
Mtests/analysis_tests/tests-reanalyze/deadcode/expected/exception.txt+21โˆ’1
Atests/analysis_tests/tests-reanalyze/deadcode/src/exception/Division.res+19โˆ’0
with Claude Opus 5.5