Commit 662cb69b authored by krc's avatar krc

[project @ 2003-08-19 22:09:09 by krc]

External Core programs sometimes contain newtype declarations with no
data constructors. GHC expected every newtype declaration to have at
least one data constructor, so it would previously fail with an "empty list"
error if you tried to compile such a program. These declarations are handled
properly now.
parent a465e8bd
......@@ -457,7 +457,7 @@ implicitTyThings things
-- Newtypes don't have a worker Id, so don't generate that
extras (ATyCon tc) = map AnId (tyConGenIds tc ++ tyConSelIds tc) ++ data_con_stuff
where
data_con_stuff | isNewTyCon tc = [ADataCon dc1, AnId (dataConWrapId dc1)]
data_con_stuff | isNewTyCon tc = (if (null dcs) then [] else [ADataCon dc1, AnId (dataConWrapId dc1)])
| otherwise = concatMap (extras_plus . ADataCon) dcs
dcs = tyConDataCons tc
dc1 = head dcs
......
......@@ -324,7 +324,8 @@ mkTupNameStr Boxed 3 = (pREL_TUP_Name, mkFastString "(,,)") -- ditto
mkTupNameStr Boxed 4 = (pREL_TUP_Name, mkFastString "(,,,)") -- ditto
mkTupNameStr Boxed n = (pREL_TUP_Name, mkFastString ("(" ++ nOfThem (n-1) ',' ++ ")"))
mkTupNameStr Unboxed 0 = panic "Name.mkUbxTupNameStr: 0 ???"
mkTupNameStr Unboxed 0 = (gHC_PRIM_Name, mkFastString "(# #)") -- 1 and 0 both make sense!!!
--panic "Name.mkUbxTupNameStr: 0 ???"
mkTupNameStr Unboxed 1 = (gHC_PRIM_Name, mkFastString "(# #)") -- 1 and 0 both make sense!!!
mkTupNameStr Unboxed 2 = (gHC_PRIM_Name, mkFastString "(#,#)")
mkTupNameStr Unboxed 3 = (gHC_PRIM_Name, mkFastString "(#,,#)")
......
......@@ -411,6 +411,8 @@ mkNewTyConRep :: TyCon -- The original type constructor
-- The trick is to to deal correctly with recursive newtypes
-- such as newtype T = MkT T
-- a newtype with no data constructors -- appears in External Core programs
mkNewTyConRep tc | (null (tyConDataCons tc)) = unitTy
mkNewTyConRep tc
= go [] tc
where
......
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