Перейти к содержимому
Топаз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)
    Ожидаемый выводНенулевой код завершения
    Нет стандартного вывода.
    $ topaz run example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

    Ожидаемый результат

    Этап отклонения run. Ненулевой код завершения.

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

    Меню

    Загрузка →