Skip to content
  • Simon Peyton Jones's avatar
    Add the primitive type Any, and use it for Dynamics · c128930d
    Simon Peyton Jones authored
    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
    c128930d