본문으로 건너뛰기
토파즈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.

    메뉴

    다운로드 →