You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Exhaustiveness check skips tuple, literal and list patterns #645
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