diff options
author | krc <unknown> | 2003-08-19 22:09:10 +0000 |
---|---|---|
committer | krc <unknown> | 2003-08-19 22:09:10 +0000 |
commit | 662cb69b4a361a22862a0c7acd0150cad0a830c0 (patch) | |
tree | 29cabbfe1fb668cb0055bb15e3c7b321e8165a4b /ghc | |
parent | a465e8bda2a03163fa45976c531307faeea76490 (diff) | |
download | haskell-662cb69b4a361a22862a0c7acd0150cad0a830c0.tar.gz |
[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.
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/compiler/main/HscTypes.lhs | 2 | ||||
-rw-r--r-- | ghc/compiler/prelude/PrelNames.lhs | 3 | ||||
-rw-r--r-- | ghc/compiler/typecheck/TcTyClsDecls.lhs | 2 |
3 files changed, 5 insertions, 2 deletions
diff --git a/ghc/compiler/main/HscTypes.lhs b/ghc/compiler/main/HscTypes.lhs index c8cf4c79f3..88fd6b9562 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 1c597a833d..bacb0ec9ce 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 45da66704e..378dc35943 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 |