diff options
author | simonpj@microsoft.com <unknown> | 2009-10-08 16:23:29 +0000 |
---|---|---|
committer | simonpj@microsoft.com <unknown> | 2009-10-08 16:23:29 +0000 |
commit | 524c609b6d8d220b03640dc71a209530bf2ed280 (patch) | |
tree | 4abc6845492de9622cf7e4334e57356079d28be5 | |
parent | 754e039a8a15d5774fe73872ff9ac593b46370e0 (diff) | |
download | haskell-524c609b6d8d220b03640dc71a209530bf2ed280.tar.gz |
Make tyConSingleDataCon_maybe more forgiving
This function was barfing on a type family tycon; which in turn
crashed the compiler (when -ticky is in use) because of the use in
CmmTicky.hs. There's no need for it to reject such tycons, so I just
made it return Nothing rather than falling over.
-rw-r--r-- | compiler/types/TyCon.lhs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/compiler/types/TyCon.lhs b/compiler/types/TyCon.lhs index a7b0594bcf..bb21536b2d 100644 --- a/compiler/types/TyCon.lhs +++ b/compiler/types/TyCon.lhs @@ -1097,13 +1097,10 @@ synTyConResKind tycon = pprPanic "synTyConResKind" (ppr tycon) -- has more than one constructor, or represents a primitive or function type constructor then -- @Nothing@ is returned. In any other case, the function panics tyConSingleDataCon_maybe :: TyCon -> Maybe DataCon -tyConSingleDataCon_maybe (AlgTyCon {algTcRhs = DataTyCon {data_cons = [c] }}) = Just c -tyConSingleDataCon_maybe (AlgTyCon {algTcRhs = NewTyCon { data_con = c }}) = Just c -tyConSingleDataCon_maybe (AlgTyCon {}) = Nothing -tyConSingleDataCon_maybe (TupleTyCon {dataCon = con}) = Just con -tyConSingleDataCon_maybe (PrimTyCon {}) = Nothing -tyConSingleDataCon_maybe (FunTyCon {}) = Nothing -- case at funty -tyConSingleDataCon_maybe tc = pprPanic "tyConSingleDataCon_maybe: unexpected tycon " $ ppr tc +tyConSingleDataCon_maybe (TupleTyCon {dataCon = c}) = Just c +tyConSingleDataCon_maybe (AlgTyCon {algTcRhs = DataTyCon { data_cons = [c] }}) = Just c +tyConSingleDataCon_maybe (AlgTyCon {algTcRhs = NewTyCon { data_con = c }}) = Just c +tyConSingleDataCon_maybe _ = Nothing \end{code} \begin{code} |