Commit 524c609b authored by simonpj@microsoft.com's avatar simonpj@microsoft.com

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.
parent 754e039a
......@@ -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}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment