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

문서 검색

명세 6.0

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

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

    진단 TPZ5007

    Runtime comparison guards produce TPZ5007 when a value comparison fails its domain or structural budget.

    Diagnostic and cause

    링크

    Runtime comparison guard

    계열
    topaz
    단계
    run
    코드
    TPZ5007

    원인과 조건

    The runtime comparison guard uses TPZ5007. A comparison that exhausts the structural budget fails at the comparison call. Finite nested values can reach this guard. Recursive declarations follow Nested conformance. Data values follow Value semantics.

    대응

    Reduce the nesting or compare smaller parts of the values before repeating the comparison.

    Compiler phase: check/runtime.

    Compiler explanation: The operation requires equality/order/key semantics that this type does not provide.

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

    • ⟨value⟩ is not ordered comparable, so .⟨value⟩() cannot sort it Source
    • the ⟨value⟩ key type ⟨value⟩ is not ordered comparable, so .⟨value⟩() cannot sort it Source
    • ⟨value⟩ is not comparable, so test.⟨value⟩ cannot compare it Source
    • ⟨value⟩ and ⟨value⟩ are not ordered comparable Source
    • ⟨value⟩ and ⟨value⟩ are not comparable values Source
    • ⟨value⟩ and ⟨value⟩ are never equal Source
    • ⟨value⟩ is not a valid Map/Set key (⟨value⟩ keys are not supported yet) Source

    Equality and ordering traverse their supported value structures. A comparison of finite values can exhaust the structural budget and raise runtime TPZ5007.

    규칙diagnostics.tpz5007.runtime.p5.rule

    Reject a comparison that exhausts the structural budget

    The runtime comparison guard uses TPZ5007. A comparison that exhausts the structural budget fails at the comparison call. Finite nested values can reach this guard. Recursive declarations follow Nested conformance. Data values follow Value semantics.

    Response

    링크

    Reduce the nesting or compare smaller parts of the values before repeating the comparison.

    Reproduction and verification

    링크

    Finite nested values exhaust the comparison budget

    링크
    example.tpzFinite nested values exhaust the comparison budget
    1. record Node derives Eq { children: Array<Node> }
    2. let mut left = Node { children: [] }
    3. let mut right = Node { children: [] }
    4. for _ in (0..200) {
    5. left = Node { children: [left] }
    6. right = Node { children: [right] }
    7. }
    8. Eq.equals(left, right)
    기대 출력0이 아닌 종료 코드
    표준 출력 없음.
    $ topaz run example.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

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

    • TPZ5007 →

      structures-comparison-recursion at example.tpz:8:1

    Both trees are finite. The deep comparison exceeds the structural budget. The repaired comparison stays within it. This pair has not been run with the public CLI.

    Shallow trees compare within the budget

    링크
    example.tpzShallow trees compare within the budget
    1. import std.io
    2. record Node derives Eq { children: Array<Node> }
    3. let mut left = Node { children: [] }
    4. let mut right = Node { children: [] }
    5. for _ in (0..2) {
    6. left = Node { children: [left] }
    7. right = Node { children: [right] }
    8. }
    9. io.writeLine("{Eq.equals(left, right)}")
    기대 출력종료 코드 0
    true
    
    $ topaz run example.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

    실행을 마칩니다. 종료 코드 0.

    기대 표준 출력
    1. true

    Both trees are finite. The deep comparison exceeds the structural budget. The repaired comparison stays within it. This pair has not been run with the public CLI.

    메뉴

    다운로드 →