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.
관련 규칙 · Reject a comparison that exhausts the structural budget →대응
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.cannot sort it Source⟨value⟩() - the
⟨value⟩key type⟨value⟩is not ordered comparable, so.cannot sort it Source⟨value⟩() ⟨value⟩is not comparable, sotest.cannot compare it Source⟨value⟩ ⟨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.
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
링크record Node derives Eq { children: Array<Node> }let mut left = Node { children: [] }let mut right = Node { children: [] }for _ in (0..200) {left = Node { children: [left] }right = Node { children: [right] }}Eq.equals(left, right)
표준 출력 없음.기대 결과
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
링크import std.iorecord Node derives Eq { children: Array<Node> }let mut left = Node { children: [] }let mut right = Node { children: [] }for _ in (0..2) {left = Node { children: [left] }right = Node { children: [right] }}io.writeLine("{Eq.equals(left, right)}")
true
기대 결과
기대 결과
실행을 마칩니다. 종료 코드 0.
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.