본문으로 건너뛰기
토파즈6.0 · 출시 전
다운로드 →

문서 검색

명세 6.0

방향키로 결과를 고르고 Enter를 눌러 여세요.

API 이름, 진단 번호, 규칙 또는 프로젝트 주제를 입력하세요.

    진단 TPZ5721

    A loop expression has break values whose types cannot join to one result type.

    Diagnostic and cause

    링크

    Loop break values do not agree

    계열
    topaz
    단계
    check
    코드
    TPZ5721

    원인과 조건

    When a value-producing loop has no contextual result type, incompatible break-value types are rejected with TPZ5721. The int and string break values in this program are assignable in neither direction.

    대응

    Make the breaks produce compatible values. The repaired program returns int from both branches.

    Compiler phase: check.

    Compiler explanation: A loop expression has break values whose types cannot join to one result type.

    Message templates. The marker ⟨value⟩ stands for text computed for the reported program.

    • break values targeting this loop disagree — earlier break is ⟨value⟩, this is ⟨value⟩ (all break values must have the same type) Source

    When a value-producing loop has no contextual result type, incompatible break-value types are rejected with TPZ5721. The int and string break values in this program are assignable in neither direction.

    규칙diagnostics.tpz5721.p5.rule

    Inferred loop break types must be compatible

    When a value-producing loop has no contextual result type, incompatible break-value types are rejected with TPZ5721. The int and string break values in this program are assignable in neither direction.

    Response

    링크

    Make the breaks produce compatible values. The repaired program returns int from both branches.

    Reproduction and verification

    링크

    Rejected program

    링크
    example.tpzRejected program플레이그라운드 열기 →
    1. let flag: bool = true
    2. let result = loop {
    3. if (flag) { break 1 } else { break "text" }
    4. }
    기대 출력0이 아닌 종료 코드
    표준 출력 없음.
    $ topaz check example.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

    거절 단계 check. 종료 코드가 0이 아닙니다.

    This condition applies to a value loop with no expected result type and concrete incompatible break types. The checker compares assignability in both directions; the example does not impose a type-spelling equality rule on other loop contexts.

    Repaired program

    링크
    example.tpzRepaired program
    1. let flag: bool = true
    2. let result = loop {
    3. if (flag) { break 1 } else { break 2 }
    4. }
    기대 출력종료 코드 0
    $ topaz check example.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

    검사가 프로그램을 받아들입니다. 종료 코드 0.

    This condition applies to a value loop with no expected result type and concrete incompatible break types. The checker compares assignability in both directions; the example does not impose a type-spelling equality rule on other loop contexts.

    메뉴

    다운로드 →