Changeset 9480

Show
Ignore:
Timestamp:
03/13/06 11:17:08 (3 years ago)
Author:
audreyt
Message:

* fix overeager inferencer in simple array/hash indexing;

it was evaluating them in the current context, and if it's lvalue,
then the element could get autovivified.
rindolf++ for reporting the bug; t/pugsbugs/short_circuiting.t now passes.

Location:
src/Pugs
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Eval.hs

    r9383 r9480  
    176176    VControl c      -> retControl c 
    177177    _               -> action 
    178  
    179 {-| 
    180 Perform the given evaluation in an /LValue/ context. 
    181 -} 
    182 enterLValue :: Eval a -> Eval a 
    183 enterLValue = local (\e -> e{ envLValue = True }) 
    184 {-| 
    185 Perform the given evaluation in an /RValue/ (i.e. non-/LValue/) context. 
    186 -} 
    187 enterRValue :: Eval a -> Eval a 
    188 enterRValue = local (\e -> e{ envLValue = False }) 
    189  
    190  
    191178 
    192179evalRef :: VRef -> Eval Val 
  • src/Pugs/Eval/Var.hs

    r8931 r9480  
    376376inferExpType (Syn "=>" _)   = return $ mkType "Pair" 
    377377inferExpType exp@(Syn "{}" [_, idxExp]) = if isSimpleExp exp 
    378     then fromVal =<< evalExp exp 
     378    then fromVal =<< enterRValue (evalExp exp) 
    379379    else fmap typeOfCxt (inferExpCxt idxExp) 
    380380inferExpType exp@(Syn "[]" [_, idxExp]) = if isSimpleExp exp 
    381     then fromVal =<< evalExp exp 
     381    then fromVal =<< enterRValue (evalExp exp) 
    382382    else fmap typeOfCxt (inferExpCxt idxExp) 
    383383inferExpType (Syn "sub" [exp]) = inferExpType exp 
  • src/Pugs/Monads.hs

    r8705 r9480  
    1414 
    1515module Pugs.Monads ( 
     16    enterLValue, enterRValue, 
    1617    enterLex, enterContext, enterEvalContext, enterPackage, enterCaller, 
    1718    enterGiven, enterWhen, enterWhile, genSymPrim, genSymCC, 
     
    4748        return $ ma `mplus` mb 
    4849 
     50{-| 
     51Perform the given evaluation in an /LValue/ context. 
     52-} 
     53enterLValue :: Eval a -> Eval a 
     54enterLValue = local (\e -> e{ envLValue = True }) 
     55{-| 
     56Perform the given evaluation in an /RValue/ (i.e. non-/LValue/) context. 
     57-} 
     58enterRValue :: Eval a -> Eval a 
     59enterRValue = local (\e -> e{ envLValue = False }) 
    4960 
    5061{-|