Skip to content
Topaz6.0 · Before release
Download

Search documentation

Specification 6.0 · Not released · Tested product 5.21.3

Use arrow keys to choose a result. Press Enter to open.

Type an API name, diagnostic number, rule, or project topic.

    Diagnostics

    TPZ5021: Non-exhaustive match

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

    Diagnostic and cause

    Link

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

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

    Response

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

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

    Why

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

    Source evidence

    Response

    Link

    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

    Link

    Rejected program

    Link
    example.tpzRejected programOpen in Playground
    1. function classify(value: bool) -> int {
    2. match (value) {
    3. case true => 1
    4. }
    5. }
    6. let result = classify(true)
    Expected outputNonzero exit
    No stdout.
    $ topaz check example.tpz · target product 5.21.3
    Expected result

    Expected result

    Rejection during check. Nonzero exit.

    • TPZ5021 match-not-exhaustive at example.tpz:2:3
    Source evidence

    Repaired program

    Link
    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)
    Expected outputexit 0
    $ topaz check example.tpz · target product 5.21.3
    Expected result

    Expected result

    Checking accepts the program. Exit code 0.

    Source evidence

    Menu

    Download