From: krc Date: Tue, 19 Aug 2003 22:09:10 +0000 (+0000) Subject: [project @ 2003-08-19 22:09:09 by krc] X-Git-Tag: Approx_11550_changesets_converted~542 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=662cb69b4a361a22862a0c7acd0150cad0a830c0 [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. --- diff --git a/ghc/compiler/main/HscTypes.lhs b/ghc/compiler/main/HscTypes.lhs index c8cf4c7..88fd6b9 100644 --- a/ghc/compiler/main/HscTypes.lhs +++ b/ghc/compiler/main/HscTypes.lhs @@ -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 diff --git a/ghc/compiler/prelude/PrelNames.lhs b/ghc/compiler/prelude/PrelNames.lhs index 1c597a8..bacb0ec 100644 --- a/ghc/compiler/prelude/PrelNames.lhs +++ b/ghc/compiler/prelude/PrelNames.lhs @@ -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 "(#,,#)") diff --git a/ghc/compiler/typecheck/TcTyClsDecls.lhs b/ghc/compiler/typecheck/TcTyClsDecls.lhs index 45da667..378dc35 100644 --- a/ghc/compiler/typecheck/TcTyClsDecls.lhs +++ b/ghc/compiler/typecheck/TcTyClsDecls.lhs @@ -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