Diagnostic and cause
LinkNon-exhaustive match
- Family
- topaz
- Phase
- check
- Code
TPZ5021
Cause and conditions
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.
Related rule: Reserved runtime code and current checking diagnosticEvery match must satisfy match exhaustiveness during checking. A missing case or a missing final unconditional arm produces TPZ5021 at the match expression.
Related rule: Non-exhaustive matchResponse
Add arms for the missing cases or an appropriate wildcard arm. Keep error and empty cases explicit when they require different behavior.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 701-710 - compiler/crates/topaz_self_frontend/topaz/checker/expression_control.tpz at
151141d7bb44· 301-301 - issues/31 at
1cbf38d3d422 - compiler/crates/topaz_product_runtime/src/runtime/flow.rs at
151141d7bb44· 355-390 - compiler/crates/topaz_product_runtime/src/runtime/flow.rs at
151141d7bb44· 460-476 - compiler/crates/topaz_product_runtime/src/diagnostic.rs at
151141d7bb44· 78-90 - compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 553-561 - compiler/crates/topaz_self_frontend/topaz/checker/expression_control.tpz at
1cbf38d3d422· 296-305 - compiler/crates/topaz_self_frontend/topaz/checker/patterns.tpz at
1cbf38d3d422· 380-503 - compiler/crates/topaz_self_frontend/topaz/checker/expression_control.tpz at
151141d7bb44· 242-262 - compiler/crates/topaz_self_frontend/topaz/checker/expression_control.tpz at
151141d7bb44· 296-305 - compiler/crates/topaz_self_frontend/topaz/checker/patterns.tpz at
151141d7bb44· 380-396
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.
Why
Checking every match removes a separate runtime failure for missing cases. The same diagnostic covers closed cases and open inputs.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/checker/expression_control.tpz at
151141d7bb44· 242-262 - compiler/crates/topaz_self_frontend/topaz/checker/expression_control.tpz at
151141d7bb44· 296-305 - compiler/crates/topaz_self_frontend/topaz/checker/patterns.tpz at
151141d7bb44· 380-396 - issues/31 at
1cbf38d3d422
Response
LinkAdd arms for the missing cases or an appropriate wildcard arm. Keep error and empty cases explicit when they require different behavior.
Reproduction and verification
LinkRejected program
Linkfunction classify(value: bool) -> int {match (value) {case true => 1}}let result = classify(true)
No stdout.
Expected result
Source evidence
- compiler/crates/topaz_self_frontend/topaz/checker/expression_control.tpz at
151141d7bb44· 242-262 - compiler/crates/topaz_self_frontend/topaz/checker/expression_control.tpz at
151141d7bb44· 296-305 - compiler/crates/topaz_self_frontend/topaz/checker/patterns.tpz at
151141d7bb44· 380-396 - issues/31 at
1cbf38d3d422
Repaired program
Linkfunction classify(value: bool) -> int {match (value) {case true => 1case false => 0}}let result = classify(true)
Expected result
Expected result
Checking accepts the program. Exit code 0.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/checker/expression_control.tpz at
151141d7bb44· 242-262 - compiler/crates/topaz_self_frontend/topaz/checker/expression_control.tpz at
151141d7bb44· 296-305 - compiler/crates/topaz_self_frontend/topaz/checker/patterns.tpz at
151141d7bb44· 380-396 - issues/31 at
1cbf38d3d422