Make pushTypeContext handle Infer as no context.

This commit is contained in:
Adam Sampson 2008-04-06 18:43:01 +00:00
parent bfd7b079a7
commit 2d15eb800c

View File

@ -569,7 +569,9 @@ evalBytesInType t
-- | Run an operation in a given type context.
inTypeContext :: Maybe A.Type -> PassM a -> PassM a
inTypeContext ctx body
= do pushTypeContext ctx
= do pushTypeContext (case ctx of
Just A.Infer -> Nothing
_ -> ctx)
v <- body
popTypeContext
return v
@ -894,10 +896,7 @@ inferTypes = applyExplicitM9 doExpression doDimension doSubscript
_ -> diePC m $ formatCode "Table literal is not valid for type %" wantT
-- An expression: descend into it with the right context.
doArrayElem wantT (A.ArrayElemExpr e)
= do let ctx = case wantT of
A.Infer -> Nothing
_ -> Just wantT
e' <- inTypeContext ctx $ doExpression descend e
= do e' <- inTypeContext (Just wantT) $ doExpression descend e
t <- typeOfExpression e'
checkType (findMeta e') wantT t
return (t, A.ArrayElemExpr e')