summaryrefslogtreecommitdiff
path: root/compiler/codeGen
diff options
context:
space:
mode:
authorsimonpj@microsoft.com <unknown>2006-10-18 11:56:58 +0000
committersimonpj@microsoft.com <unknown>2006-10-18 11:56:58 +0000
commitc128930dc98c73e2459a4610539fee73ca941247 (patch)
tree6dbcf4ed51032bc560265f2dbb6615d23f2db0e7 /compiler/codeGen
parent5e41a5afcc39480f4e60055843a5e4106b6f8875 (diff)
downloadhaskell-c128930dc98c73e2459a4610539fee73ca941247.tar.gz
Add the primitive type Any, and use it for Dynamics
GHC's code generator can only enter a closure if it's guaranteed not to be a function. In the Dynamic module, we were using the type (forall a.a) as the type to which the dynamic type was unsafely cast: type Obj = forall a.a Gut alas this polytype was sometimes instantiated to (), something like this (it only bit when profiling was enabled) let y::() = dyn () in (y `cast` ..) p q As a result, an ASSERT in ClosureInfo fired (hooray). I've tided this up by making a new, primitive, lifted type Any, and arranging that Dynamic uses Any, thus: type Obj = ANy While I was at it, I also arranged that when the type checker instantiates un-constrained type variables, it now instantiates them to Any, not () e.g. length Any [] [There remains a Horrible Hack when we want Any-like things at arbitrary kinds. This essentially never happens, but see comments with TysPrim.mkAnyPrimTyCon.] Anyway, this fixes Trac #905
Diffstat (limited to 'compiler/codeGen')
-rw-r--r--compiler/codeGen/ClosureInfo.lhs10
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/codeGen/ClosureInfo.lhs b/compiler/codeGen/ClosureInfo.lhs
index 8f62bc7e0e..e6319898db 100644
--- a/compiler/codeGen/ClosureInfo.lhs
+++ b/compiler/codeGen/ClosureInfo.lhs
@@ -257,12 +257,12 @@ mkLFThunk thunk_ty top fvs upd_flag
(might_be_a_function thunk_ty)
might_be_a_function :: Type -> Bool
+-- Return False only if we are *sure* it's a data type
+-- Look through newtypes etc as much as poss
might_be_a_function ty
- | Just (tc,_) <- splitTyConApp_maybe (repType ty),
- not (isFunTyCon tc) && not (isAbstractTyCon tc) = False
- -- don't forget to check for abstract types, which might
- -- be functions too.
- | otherwise = True
+ = case splitTyConApp_maybe (repType ty) of
+ Just (tc, _) -> not (isDataTyCon tc)
+ Nothing -> True
\end{code}
@mkConLFInfo@ is similar, for constructors.