8000 Exhaustiveness check skips tuple, literal and list patterns · Issue #645 · kexhq/kex · GitHub
[go: up one dir, main page]

Skip to content

Exhaustiveness check skips tuple, literal and list patterns #645

Closed

Description

@akoskovacs

The exhaustiveness check looks only at top-level constructor patterns. A match whose clauses are tuple, literal, list or record patterns is never examined, so a missing case is found at run time.

Repro

let both(pair: (Integer?, Integer?)) -> Integer do
  match pair do
    (Just(a), Just(b)) => a + b
    (None, None) => 0
  end
end

main do
  IO.printLine("${both((Just(1), None))}")
end

Actual: accepted with no diagnostic; fails at run time with no matching clause for (Just(1), None).

Expected: Non-exhaustive match, naming (Just(_), None) and (None, Just(_)).

Cause

TypeChecker::checkMatchExhaustiveness (src/semantic/typechecker.cxx:2721-2774) collects the constructor names at the top of each clause and skips every other pattern kind ("literal/list/tuple/record/range patterns don't drive ADT exhaustiveness"). Covering nested patterns needs a pattern-matrix check (Maranget's algorithm), which would also report the missing cases.

Reproduced on kex 0.4.0-rc.3 (266b7a60) with the type checker on.

Activity

  1. added
    BugSomething isn't working
    Confirmed IssueBug is reproduced on the current development version
    on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingConfirmed IssueBug is reproduced on the current development versionTypechecker

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0