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.
Связанное правило · Reserved runtime code and current checking diagnostic →Every match must satisfy match exhaustiveness during checking. A missing case or a missing final unconditional arm produces TPZ5021 at the match expression.
Связанное правило · Non-exhaustive match →Действия
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.
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
Ссылкаfunction classify(value: bool) -> int {match (value) {case true => 1}}let result = classify(true)
Нет стандартного вывода.Ожидаемый результат
Ожидаемый результат
Этап отклонения check. Ненулевой код завершения.
match-not-exhaustive at
example.tpz:2:3
Repaired program
Ссылкаfunction classify(value: bool) -> int {match (value) {case true => 1case false => 0}}let result = classify(true)
Ожидаемый результат
Ожидаемый результат
Проверка принимает программу. Код завершения 0.