Fixed type-checking on ambigious record fields, so that now the cgtests are happy again
This commit is contained in:
parent
82be1bd726
commit
de097bb138
|
@ -215,19 +215,19 @@ subscriptType sub t = diePC (findMeta sub) $ formatCode "Unsubscriptable type: %
|
||||||
|
|
||||||
-- | The inverse of 'subscriptType': given a type that we know is the result of
|
-- | The inverse of 'subscriptType': given a type that we know is the result of
|
||||||
-- a subscript, return what the type being subscripted is.
|
-- a subscript, return what the type being subscripted is.
|
||||||
unsubscriptType :: (CSMR m, Die m) => A.Subscript -> A.Type -> m A.Type
|
unsubscriptType :: A.Subscript -> A.Type -> Maybe A.Type
|
||||||
unsubscriptType _ A.Infer
|
unsubscriptType _ A.Infer
|
||||||
= return $ A.Infer
|
= Just $ A.Infer
|
||||||
unsubscriptType (A.SubscriptFromFor _ _ _ _) t
|
unsubscriptType (A.SubscriptFromFor _ _ _ _) t
|
||||||
= return $ removeFixedDimension t
|
= Just $ removeFixedDimension t
|
||||||
unsubscriptType (A.SubscriptFrom _ _ _) t
|
unsubscriptType (A.SubscriptFrom _ _ _) t
|
||||||
= return $ removeFixedDimension t
|
= Just $ removeFixedDimension t
|
||||||
unsubscriptType (A.SubscriptFor _ _ _) t
|
unsubscriptType (A.SubscriptFor _ _ _) t
|
||||||
= return $ removeFixedDimension t
|
= Just $ removeFixedDimension t
|
||||||
unsubscriptType (A.SubscriptField m _) t
|
unsubscriptType (A.SubscriptField m _) t
|
||||||
= dieP m $ "unsubscript of record type (but we can't tell which one)"
|
= Nothing
|
||||||
unsubscriptType (A.Subscript _ _ sub) t
|
unsubscriptType (A.Subscript _ _ sub) t
|
||||||
= return $ addDimensions [A.UnknownDimension] t
|
= Just $ addDimensions [A.UnknownDimension] t
|
||||||
|
|
||||||
-- | Just remove the first dimension from an array type -- like doing
|
-- | Just remove the first dimension from an array type -- like doing
|
||||||
-- subscriptType with constant 0 as a subscript, but without the checking.
|
-- subscriptType with constant 0 as a subscript, but without the checking.
|
||||||
|
|
|
@ -686,10 +686,7 @@ inferTypes = occamOnlyPass "Infer types"
|
||||||
A.IntrinsicFunctionCall _ _ _ -> noTypeContext $ descend outer
|
A.IntrinsicFunctionCall _ _ _ -> noTypeContext $ descend outer
|
||||||
A.SubscriptedExpr m s e ->
|
A.SubscriptedExpr m s e ->
|
||||||
do ctx <- getTypeContext
|
do ctx <- getTypeContext
|
||||||
ctx' <- case ctx of
|
e' <- inTypeContext (ctx >>= unsubscriptType s) $ recurse e
|
||||||
Just t -> unsubscriptType s t >>* Just
|
|
||||||
Nothing -> return Nothing
|
|
||||||
e' <- inTypeContext ctx' $ recurse e
|
|
||||||
t <- astTypeOf e'
|
t <- astTypeOf e'
|
||||||
s' <- recurse s >>= fixSubscript t
|
s' <- recurse s >>= fixSubscript t
|
||||||
return $ A.SubscriptedExpr m s' e'
|
return $ A.SubscriptedExpr m s' e'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user