scope invariants in core

Ranjit Jhala jhala at cs.ucsd.edu
Mon Mar 18 19:06:00 CET 2013


Hi all,

I have been manipulating CoreExpr to convert it to A-Normal Form.
Mostly, things have been working fine, but I hit an error this
morning of the form:

    lq_anf__d11u is out of scope

where lq_anf__d11u is a binder I have introduced in the transformed expression

    Data.ByteString.Internal.c_strlen =
   (\ (ds_d11l :: GHC.Ptr.Ptr Foreign.C.Types.CChar) ->
      case ds_d11l of lq_anf__d11t { GHC.Ptr.Ptr ds_d11n ->
      let {
        lq_anf__d11x
          :: GHC.Prim.State# GHC.Prim.RealWorld
             -> (# GHC.Prim.State# GHC.Prim.RealWorld, GHC.Word.Word32 #)
        [LclId]
        lq_anf__d11x =
          \ (ds_d11q :: GHC.Prim.State# GHC.Prim.RealWorld) ->
            case {__pkg_ccall main strlen GHC.Prim.Addr#
                         -> GHC.Prim.State# GHC.Prim.RealWorld
                         -> (# GHC.Prim.State# GHC.Prim.RealWorld,
GHC.Prim.Word# #)}
                   ds_d11n ds_d11q
            of lq_anf__d11u { __DEFAULT ->
            case lq_anf__d11u of lq_anf__d11v { (# ds_d11p, ds_d11o #) ->
            let {
              lq_anf__d11w :: GHC.Word.Word32
              [LclId]
              lq_anf__d11w = GHC.Word.W32# ds_d11o } in
            (# ds_d11p, lq_anf__d11w #)
            }
            } } in
      GHC.Types.IO @ GHC.Word.Word32 lq_anf__d11x
      })


It would appear, that the variable IS in scope (as it is bound by
the case-expression just before it is used, but perhaps the binder
is not added to the environment because of its type (# ... , ... #)?
Or is there some other invariant I am breaking?

Can anyone familiar with the scoping invariants of CoreExpr/CoreSyn
give me a hint as to what might be happening?

Many thanks in advance!

Ranjit.



More information about the Glasgow-haskell-users mailing list