Skip to content
Latchkey

What Is Exhaustiveness Checking?

Exhaustiveness checking is a static analysis that ensures a set of patterns covers all possible values of the type being matched, reporting an error when a case is left out. For a sum type, it confirms every variant is handled. This catches forgotten cases before the code runs.

Why it matters

Exhaustiveness checks turn "I forgot to handle that case" into a compile error rather than a runtime surprise. They are especially valuable when a new variant is added, since every incomplete match then fails to compile.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →