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

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

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

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

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

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

    An integer division or remainder operation used zero as the divisor.

    Diagnostic and cause

    Ссылка

    Division or remainder by zero

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

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

    Integer division or remainder faults when its evaluated divisor is zero.

    Действия

    Require a nonzero divisor before dividing or taking a remainder. The repair passes one to the same function.

    Compiler phase: runtime.

    Compiler explanation: An integer division or remainder operation used zero as the divisor.

    Message templates are Pending. The explanation above is not an observed CLI message.

    Observed for the candidate in Topaz 5.21.3. Execution

    • error[TPZ4002]: integer division by zero

    The divisor of an int division or remainder evaluates to zero. The shared checked arithmetic leaf detects this before performing the operation.

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

    Trigger and repair

    Integer division or remainder faults when its evaluated divisor is zero.

    Response

    Ссылка

    Require a nonzero divisor before dividing or taking a remainder. The repair passes one to the same function.

    Reproduction and verification

    Ссылка

    Product diagnostic test

    Ссылка
    example.tpzProduct diagnostic testОткрыть песочницу →
    1. function divide(divisor: int) -> int {
    2. 42 / divisor
    3. }
    4. divide(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 TPZ4002.

    The divisor of an int division or remainder evaluates to zero. The shared checked arithmetic leaf detects this before performing the operation.

    The primary location is example.tpz:2:5.

    Expect exactly one diagnostic.

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

    Corrected program

    Ссылка
    example.tpzCorrected program
    1. function divide(divisor: int) -> int {
    2. 42 / divisor
    3. }
    4. divide(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.

    Меню

    Загрузка →