Перейти к содержимому
Топаз6.0 · До релиза
Загрузка →

Поиск в документации

Спецификация 6.0

Выберите результат стрелками и нажмите Enter, чтобы открыть его.

Введите имя API, номер диагностики, правило или тему проекта.

    Диагностика TPZ4003

    A range value used zero as its step.

    Diagnostic and cause

    Ссылка

    Range step is zero

    Семейство
    topaz
    Этап
    run
    Код
    TPZ4003

    Причина и условия

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

    Действия

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

    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.

    Правилоdiagnostics.tpz4003.rule

    Trigger and repair

    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.

    Reproduction and verification

    Ссылка

    Product diagnostic test

    Ссылка
    example.tpzProduct diagnostic testОткрыть песочницу →
    1. function collect(step: int) -> () {
    2. for value in (0..5 by step) { value }
    3. ()
    4. }
    5. collect(0)
    Целевой продукт 5.21.3
    Ожидаемый результат

    Ожидаемый результат

    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.

    Corrected program

    Ссылка
    example.tpzCorrected program
    1. function collect(step: int) -> () {
    2. for value in (0..5 by step) { value }
    3. ()
    4. }
    5. collect(1)
    Ожидаемый выводКод завершения 0
    Нет стандартного вывода.
    $ topaz run example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

    Ожидаемый результат

    Выполнение завершается. Код завершения 0.

    This program applies the repair described above. The verification status records whether it has been run.

    Меню

    Загрузка →