ADR-395: A Division the Compiler Shows Divides by Zero Is an Error, as an Index Past the End Is

Status: Accepted Date: November 8, 2026 (supervisor’s decision, by the language principles; asked by the owner) Answers: ADR-306 §6, Division by zero, the third check nobody writes that ADR-269 §6 names Related: ADR-306 D15 (a check nobody writes that the compiler shows fails is an error), ADR-269 D8 (a refutation is a model checked by evaluation), ADR-359 D9 (refuted-claims), Part I 1.4 and Part III 13.3, C.1 (NK1118)

1. Question

A program has three checks nobody writes: an index stays inside its list, an operation on whole numbers stays inside its type, and a divisor is not zero. ADR-306 D15 makes the first two an error where the compiler shows they fail for a value the program reaches. A divisor that is a constant zero is refused already (NK1118), but a divisor the compiler shows is zero only through the walk, as fn f(d: int) -> int { return 10 / d } called as f(0), builds and stops the program where it runs. ADR-306 left this open.

2. Decision

D1 - A divisor the walk shows is zero is refused, on D15’s terms.

A / or % on whole numbers whose divisor the walk shows is zero for a value the program reaches is refused with NK1207, naming the value, as an index past the end is (ADR-306 D15). Only on a refutation, never on unknown: a model checked by evaluation (ADR-269 D8). refuted-claims = "warn" builds it with the check, a warning where it is reached.

D2 - Its goal is asked where an index’s is.

d != 0 for each divisor d that is not a literal is a goal of the walk, as 0 <= i < xs.len() is for an index, and the walk runs for it at every build, whatever remove-*-checks says. A divisor that is a constant zero stays NK1118, refused before the walk.

D3 - No setting drops the check.

The check that a divisor is not zero stays in the machine code, proved or not. Whether remove-overflow-checks may also drop a proved one is not part of this decision; it is a question of speed and is asked with a measurement.

3. Why

4. Built when

A test in tests/compiler/ with f(0) over 10 / d is refused with NK1207 and the value; with refuted-claims = "warn" it builds and stops where it runs; a divisor the walk cannot decide builds as today.

This site is open source. Improve this page.