Make isIrrefutableHsPat say True for existentials; fixes Trac #4439
authorsimonpj@microsoft.com <unknown>
Tue, 26 Oct 2010 07:04:05 +0000 (07:04 +0000)
committersimonpj@microsoft.com <unknown>
Tue, 26 Oct 2010 07:04:05 +0000 (07:04 +0000)
At last. A bug that is really easy to fix.

compiler/hsSyn/HsPat.lhs

index 1bf0aa8..25a350b 100644 (file)
@@ -47,6 +47,7 @@ import SrcLoc
 import FastString
 -- libraries:
 import Data.Data hiding (TyCon)
 import FastString
 -- libraries:
 import Data.Data hiding (TyCon)
+import Data.Maybe
 \end{code}
 
 
 \end{code}
 
 
@@ -411,7 +412,9 @@ isIrrefutableHsPat pat
 
     go1 (ConPatIn {})       = False    -- Conservative
     go1 (ConPatOut{ pat_con = L _ con, pat_args = details }) 
 
     go1 (ConPatIn {})       = False    -- Conservative
     go1 (ConPatOut{ pat_con = L _ con, pat_args = details }) 
-       =  isProductTyCon (dataConTyCon con)
+       =  isJust (tyConSingleDataCon_maybe (dataConTyCon con))
+          -- NB: tyConSingleDataCon_maybe, *not* isProductTyCon, because 
+          -- the latter is false of existentials. See Trac #4439
        && all go (hsConPatArgs details)
 
     go1 (LitPat {})    = False
        && all go (hsConPatArgs details)
 
     go1 (LitPat {})    = False