Перейти к содержимому
Топаз6.0 · До релиза
Загрузка →

Поиск в документации

Спецификация 6.0

Выберите результат стрелками и нажмите Enter, чтобы открыть его.

Введите имя API, номер диагностики, правило или тему проекта.

    Диагностика TPZ5021

    A match expression does not cover every known case of the scrutinee type.

    Diagnostic and cause

    Ссылка

    Non-exhaustive match

    Семейство
    topaz
    Этап
    check
    Код
    TPZ5021

    Причина и условия

    TPZ4006 is retired in Topaz 6.0.0. Its code and former meaning, runtime match failure, remain reserved and must not be reused. An incomplete match produces TPZ5021 during checking under match exhaustiveness.

    Every match must satisfy match exhaustiveness during checking. A missing case or a missing final unconditional arm produces TPZ5021 at the match expression.

    Действия

    Add arms for the missing cases or an appropriate wildcard arm. Keep error and empty cases explicit when they require different behavior.

    Compiler phase: check.

    Compiler explanation: A match expression does not cover every known case of the scrutinee type.

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

    • non-exhaustive match: missing ⟨value⟩ Source

    A match does not satisfy match exhaustiveness. Closed cases include nested closed payloads. Open input types require a final unguarded wildcard or name pattern. Guarded arms do not establish coverage.

    Правилоdiagnostics.tpz5021.p5.rule

    Non-exhaustive match

    Every match must satisfy match exhaustiveness during checking. A missing case or a missing final unconditional arm produces TPZ5021 at the match expression.

    Причина

    Checking every match removes a separate runtime failure for missing cases. The same diagnostic covers closed cases and open inputs.

    Response

    Ссылка

    Add arms for the missing cases or an appropriate wildcard arm. Keep error and empty cases explicit when they require different behavior.

    Reproduction and verification

    Ссылка

    Rejected program

    Ссылка
    example.tpzRejected programОткрыть песочницу →
    1. function classify(value: bool) -> int {
    2. match (value) {
    3. case true => 1
    4. }
    5. }
    6. let result = classify(true)
    Ожидаемый выводНенулевой код завершения
    Нет стандартного вывода.
    $ topaz check example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

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

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

    Repaired program

    Ссылка
    example.tpzRepaired program
    1. function classify(value: bool) -> int {
    2. match (value) {
    3. case true => 1
    4. case false => 0
    5. }
    6. }
    7. let result = classify(true)
    Ожидаемый выводКод завершения 0
    $ topaz check example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

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

    Проверка принимает программу. Код завершения 0.

    Меню

    Загрузка →