Add the primitive type Any, and use it for Dynamics
authorsimonpj@microsoft.com <unknown>
Wed, 18 Oct 2006 11:56:58 +0000 (11:56 +0000)
committersimonpj@microsoft.com <unknown>
Wed, 18 Oct 2006 11:56:58 +0000 (11:56 +0000)
commitc128930dc98c73e2459a4610539fee73ca941247
tree6dbcf4ed51032bc560265f2dbb6615d23f2db0e7
parent5e41a5afcc39480f4e60055843a5e4106b6f8875
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
compiler/codeGen/ClosureInfo.lhs
compiler/deSugar/DsBinds.lhs
compiler/iface/MkIface.lhs
compiler/prelude/PrelNames.lhs
compiler/prelude/TysPrim.lhs
compiler/prelude/TysWiredIn.lhs
compiler/typecheck/TcHsSyn.lhs
compiler/types/TyCon.lhs