Skip to content

Erroneous warnings for -XPatternGuards

As nonstandard PatternGuards I get a meaningless warning:

walltest.hs:8:10:
    Warning: Pattern match(es) are non-exhaustive
             In the definition of `n': Patterns not matched:
Ok, modules loaded: Main.
{-# LANGUAGE PatternGuards #-}
{-# OPTIONS -Wall #-}

data T = A Int | B Int

funny :: T -> Int
funny t = n
    where n | A x <- t = x
            | B x <- t = x

But none of that happens when using a case expression for the same thing:

{-# OPTIONS -Wall #-}

data T = A Int | B Int

funny :: T -> Int
funny t = n
    where n = case t of
                (A x) -> x
                (B x) -> x
Trac metadata
Trac field Value
Version 6.10.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information