Skip to content
Topaz6.0 · Before release
Download

Search documentation

Specification 6.0 · Not released · Tested product 5.21.3

Use arrow keys to choose a result. Press Enter to open.

Type an API name, diagnostic number, rule, or project topic.

    Diagnostics

    TPZ5007 Runtime comparison guard

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

    Diagnostic and cause

    Link

    Runtime comparison guard

    Family
    topaz
    Phase
    run
    Code
    TPZ5007

    Cause and conditions

    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.

    Source evidence

    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.

    Rulediagnostics.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.

    Source evidence

    Response

    Link

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

    Reproduction and verification

    Link

    Finite nested values exhaust the comparison budget

    Link
    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)
    Expected outputNonzero exit
    No stdout.
    $ topaz run example.tpz · target product 5.21.3
    Expected result

    Expected result

    Rejection during run. Nonzero exit.

    • 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.

    Source evidence

    Shallow trees compare within the budget

    Link
    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)}")
    Expected outputexit 0
    true
    
    $ topaz run example.tpz · target product 5.21.3
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    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.

    Source evidence

    Menu

    Download