[project @ 2004-03-31 15:23:16 by simonmar]
authorsimonmar <unknown>
Wed, 31 Mar 2004 15:23:18 +0000 (15:23 +0000)
committersimonmar <unknown>
Wed, 31 Mar 2004 15:23:18 +0000 (15:23 +0000)
ClosureInfo.might_be_a_function: this predicate wasn't taking into
account abstract types, which might also hide functions underneath.

Fixes broken compiler when compiled without -O.

ghc/compiler/codeGen/CgExpr.lhs
ghc/compiler/codeGen/ClosureInfo.lhs
ghc/compiler/types/TyCon.lhs

index d8c7b29..903db7e 100644 (file)
@@ -1,7 +1,7 @@
 %
 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
 %
-% $Id: CgExpr.lhs,v 1.56 2003/07/02 13:19:28 simonpj Exp $
+% $Id: CgExpr.lhs,v 1.57 2004/03/31 15:23:16 simonmar Exp $
 %
 %********************************************************
 %*                                                     *
@@ -480,7 +480,7 @@ primRetUnboxedTuple op args res_ty
       temp_uniqs  = map mkBuiltinUnique [ n_args .. n_args + length ty_args - 1]
       temp_amodes = zipWith CTemp temp_uniqs prim_reps
     in
-    ccallReturnUnboxedTuple temp_amodes        
+    ccallReturnUnboxedTuple temp_amodes
        (absC (COpStmt temp_amodes op arg_temps []))
 
 
index 2de8802..86380ec 100644 (file)
@@ -1,7 +1,7 @@
 %
 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
 %
-% $Id: ClosureInfo.lhs,v 1.61 2003/11/17 14:23:31 simonmar Exp $
+% $Id: ClosureInfo.lhs,v 1.62 2004/03/31 15:23:17 simonmar Exp $
 %
 \section[ClosureInfo]{Data structures which describe closures}
 
@@ -76,7 +76,7 @@ import PrimRep
 import SMRep           -- all of it
 import Type            ( isUnLiftedType, Type, repType, splitTyConApp_maybe )
 import TcType          ( tcSplitSigmaTy )
-import TyCon           ( isFunTyCon )
+import TyCon           ( isFunTyCon, isAbstractTyCon )
 import BasicTypes      ( TopLevelFlag(..), isNotTopLevel, isTopLevel, ipNameName )
 import Util            ( mapAccumL, listLengthCmp, lengthIs )
 import FastString
@@ -241,7 +241,9 @@ mkClosureLFInfo bndr top fvs upd_flag []
 might_be_a_function :: Type -> Bool
 might_be_a_function ty
   | Just (tc,_) <- splitTyConApp_maybe (repType ty), 
-    not (isFunTyCon tc) = False
+    not (isFunTyCon tc) && not (isAbstractTyCon tc) = False
+       -- don't forget to check for abstract types, which might
+       -- be functions too.
   | otherwise = True
 \end{code}
 
index 396df9c..24e94e5 100644 (file)
@@ -9,7 +9,7 @@ module TyCon(
 
        AlgTyConRhs(..), visibleDataCons,
 
-       isFunTyCon, isUnLiftedTyCon, isProductTyCon,
+       isFunTyCon, isUnLiftedTyCon, isProductTyCon, isAbstractTyCon,
        isAlgTyCon, isDataTyCon, isSynTyCon, isNewTyCon, isPrimTyCon,
        isEnumerationTyCon, 
        isTupleTyCon, isUnboxedTupleTyCon, isBoxedTupleTyCon, tupleTyConBoxity,
@@ -313,6 +313,10 @@ isFunTyCon :: TyCon -> Bool
 isFunTyCon (FunTyCon {}) = True
 isFunTyCon _             = False
 
+isAbstractTyCon :: TyCon -> Bool
+isAbstractTyCon (AlgTyCon { algTyConRhs = AbstractTyCon }) = True
+isAbstractTyCon _ = False
+
 isPrimTyCon :: TyCon -> Bool
 isPrimTyCon (PrimTyCon {}) = True
 isPrimTyCon _              = False