parent
a8b1697df6
commit
decd2d16df
|
@ -197,20 +197,19 @@ checkExpressionBool e = checkExpressionType A.Bool e
|
||||||
|
|
||||||
-- | Pick the more specific of a pair of types.
|
-- | Pick the more specific of a pair of types.
|
||||||
betterType :: A.Type -> A.Type -> A.Type
|
betterType :: A.Type -> A.Type -> A.Type
|
||||||
betterType t1 t2
|
betterType A.Infer t = t
|
||||||
= case betterType' t1 t2 of
|
betterType t A.Infer = t
|
||||||
Left () -> t1
|
betterType t@(A.UserDataType _) _ = t
|
||||||
Right () -> t2
|
betterType _ t@(A.UserDataType _) = t
|
||||||
|
betterType t1@(A.Array ds1 et1) t2@(A.Array ds2 et2)
|
||||||
|
| length ds1 == length ds2
|
||||||
|
= A.Array (zipWith betterDim ds1 ds2) $ betterType et1 et2
|
||||||
|
| length ds1 < length ds2 = t1
|
||||||
where
|
where
|
||||||
betterType' :: A.Type -> A.Type -> Either () ()
|
betterDim A.UnknownDimension d@(A.Dimension _) = d
|
||||||
betterType' A.Infer t = Right ()
|
-- All other cases (both unknown, right is unknown, both known), use left:
|
||||||
betterType' t A.Infer = Left ()
|
betterDim d _ = d
|
||||||
betterType' t@(A.UserDataType _) _ = Left ()
|
betterType t _ = t
|
||||||
betterType' _ t@(A.UserDataType _) = Right ()
|
|
||||||
betterType' t1@(A.Array ds1 et1) t2@(A.Array ds2 et2)
|
|
||||||
| length ds1 == length ds2 = betterType' et1 et2
|
|
||||||
| length ds1 < length ds2 = Left ()
|
|
||||||
betterType' t _ = Left ()
|
|
||||||
|
|
||||||
--}}}
|
--}}}
|
||||||
--{{{ more complex checks
|
--{{{ more complex checks
|
||||||
|
@ -1241,8 +1240,7 @@ inferTypes = occamOnlyPass "Infer types"
|
||||||
do subT <- trivialSubscriptType m underT
|
do subT <- trivialSubscriptType m underT
|
||||||
(elemT, aes') <- doElems subT aes
|
(elemT, aes') <- doElems subT aes
|
||||||
let dim = makeDimension m (length aes)
|
let dim = makeDimension m (length aes)
|
||||||
return (applyDimension dim wantT,
|
return (addDimensions [dim] elemT, A.Several m aes')
|
||||||
A.Several m aes')
|
|
||||||
A.Record _ ->
|
A.Record _ ->
|
||||||
do nts <- recordFields m underT
|
do nts <- recordFields m underT
|
||||||
aes <- sequence [doArrayElem t ae >>* snd
|
aes <- sequence [doArrayElem t ae >>* snd
|
||||||
|
|
Loading…
Reference in New Issue
Block a user