Diagnostic and cause
LinkRange step is zero
- Family
- topaz
- Phase
- run
- Code
TPZ4003
Cause and conditions
Constructing a range with a computed int step of zero faults before the range can be iterated.
Related rule: Trigger and repairResponse
Pass a nonzero step. Use a negative step only with descending endpoints; the repair changes the step to one for 0..5.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 526-534 - compiler/crates/topaz_product_runtime/src/diagnostic.rs at
151141d7bb44· 56-56 - compiler/crates/topaz_value/src/lib.rs at
151141d7bb44· 163-163 - compiler/crates/topaz_value/src/value/operators.rs at
151141d7bb44· 869-915 - compiler/crates/topaz_product_runtime/src/runtime/evaluate.rs at
151141d7bb44· 933-961 - compiler/crates/topaz_value/src/lib.rs at
151141d7bb44· 157-164 - compiler/crates/topaz_product_runtime/src/diagnostic.rs at
151141d7bb44· 38-57 - compiler/crates/topaz_cli/src/compile/direct_run.rs at
151141d7bb44· 37-77 - TPZ4003 at
f42fbeb4f27e - TPZ4003 repair at
151141d7bb44
Compiler phase: runtime.
Compiler explanation: A range value used zero as its step.
Message templates are Pending. The explanation above is not an observed CLI message.
The evaluated range step is zero. Range construction requires a nonzero int step so traversal can make progress.
Trigger and repair
Constructing a range with a computed int step of zero faults before the range can be iterated.
Source evidence
- compiler/crates/topaz_value/src/value/operators.rs at
151141d7bb44· 869-915 - compiler/crates/topaz_product_runtime/src/runtime/evaluate.rs at
151141d7bb44· 933-961 - compiler/crates/topaz_value/src/lib.rs at
151141d7bb44· 157-164 - compiler/crates/topaz_product_runtime/src/diagnostic.rs at
151141d7bb44· 38-57 - compiler/crates/topaz_cli/src/compile/direct_run.rs at
151141d7bb44· 37-77 - TPZ4003 at
f42fbeb4f27e - TPZ4003 repair at
151141d7bb44
Response
LinkPass a nonzero step. Use a negative step only with descending endpoints; the repair changes the step to one for 0..5.
Reproduction and verification
LinkProduct diagnostic test
Linkfunction collect(step: int) -> () {for value in (0..5 by step) { value }()}collect(0)
Expected result
Expected result
The separate diagnostic product test validates this command, runtime diagnostic, or filesystem setup. The shared example runner does not execute that assertion plan.
Run topaz run example..
Expect exit status 1, empty standard output, and TPZ4003.
The evaluated range step is zero. Range construction requires a nonzero int step so traversal can make progress.
The primary location is example..
Expect exactly one diagnostic.
The diagnostic product test checks these expectations with the same files and command.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 526-534 - compiler/crates/topaz_product_runtime/src/diagnostic.rs at
151141d7bb44· 56-56 - compiler/crates/topaz_value/src/lib.rs at
151141d7bb44· 163-163 - compiler/crates/topaz_value/src/value/operators.rs at
151141d7bb44· 869-915 - compiler/crates/topaz_product_runtime/src/runtime/evaluate.rs at
151141d7bb44· 933-961 - compiler/crates/topaz_value/src/lib.rs at
151141d7bb44· 157-164 - compiler/crates/topaz_product_runtime/src/diagnostic.rs at
151141d7bb44· 38-57 - compiler/crates/topaz_cli/src/compile/direct_run.rs at
151141d7bb44· 37-77 - TPZ4003 at
f42fbeb4f27e - TPZ4003 repair at
151141d7bb44
Corrected program
Linkfunction collect(step: int) -> () {for value in (0..5 by step) { value }()}collect(1)
No stdout.
Expected result
Expected result
Execution completes. Exit code 0.
This program applies the repair described above. The verification status records whether it has been run.
Source evidence
- compiler/crates/topaz_value/src/value/operators.rs at
151141d7bb44· 869-915 - compiler/crates/topaz_product_runtime/src/runtime/evaluate.rs at
151141d7bb44· 933-961 - compiler/crates/topaz_value/src/lib.rs at
151141d7bb44· 157-164 - compiler/crates/topaz_product_runtime/src/diagnostic.rs at
151141d7bb44· 38-57 - compiler/crates/topaz_cli/src/compile/direct_run.rs at
151141d7bb44· 37-77 - TPZ4003 at
f42fbeb4f27e - TPZ4003 repair at
151141d7bb44