Skip to content
Topaz6.0 · Before release
Download

Search documentation

Specification 6.0 · Not released · Tested product 5.21.3

Use arrow keys to choose a result. Press Enter to open.

Type an API name, diagnostic number, rule, or project topic.

    Diagnostics

    TPZ4003: Range step is zero

    A range value used zero as its step.

    Diagnostic and cause

    Link

    Range 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.

    Response

    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 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.

    Rulediagnostics.tpz4003.rule

    Trigger and repair

    Constructing a range with a computed int step of zero faults before the range can be iterated.

    Source evidence

    Response

    Link

    Pass a nonzero step. Use a negative step only with descending endpoints; the repair changes the step to one for 0..5.

    Reproduction and verification

    Link

    Product diagnostic test

    Link
    example.tpzProduct diagnostic testOpen in Playground
    1. function collect(step: int) -> () {
    2. for value in (0..5 by step) { value }
    3. ()
    4. }
    5. collect(0)
    target product 5.21.3
    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.tpz --language-version 5.21.

    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.tpz:2:19.

    Expect exactly one diagnostic.

    The diagnostic product test checks these expectations with the same files and command.

    Source evidence

    Corrected program

    Link
    example.tpzCorrected program
    1. function collect(step: int) -> () {
    2. for value in (0..5 by step) { value }
    3. ()
    4. }
    5. collect(1)
    Expected outputexit 0
    No stdout.
    $ topaz run example.tpz · target product 5.21.3
    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

    Menu

    Download