You need to sign in or sign up before continuing.
unreachable GADT pattern clauses show up as warnings with -Wall
In the following code, there is a line commented out. With it commented out, I get the following warning:
patternbug.hs:10:0:
Warning: Pattern match(es) are non-exhaustive
In the definition of `interpret': Patterns not matched: EVar
With it uncommented, I get the following compiler error:
patternbug.hs:11:10:
Inaccessible case alternative: Can't match types `()' and `(a, vs)'
In the pattern: EVar
In the definition of `interpret':
interpret EVar = error "unreachable"
The exhaustive pattern-matching algorithm should ignore unreachable cases in its analysis.
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE GADTs #-}
module PatternBug where
data Expr a vs where
EPrim :: String -> a -> Expr a vs
EVar :: Expr a (a,vs)
interpret :: Expr a () -> a
interpret (EPrim _ a) = a
-- interpret EVar = error "unreachable"
Trac metadata
| Trac field | Value |
|---|---|
| Version | 6.8.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | ryani.spam@gmail.com |
| Operating system | Unknown |
| Architecture | Unknown |