Skip to content

Commit

Permalink
Single-variable sizes are not special.
Browse files Browse the repository at this point in the history
  • Loading branch information
athas committed Sep 7, 2023
1 parent 92d9db5 commit 150d52d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Language/Futhark/TypeChecker/Terms.hs
Original file line number Diff line number Diff line change
Expand Up @@ -986,10 +986,15 @@ boundInsideType (Scalar (Arrow _ pn _ t1 (RetType dims t2))) =
dimUses :: TypeBase Size u -> (Names, Names)
dimUses = flip execState mempty . traverseDims f
where
f bound _ (Var v _ _) | qualLeaf v `S.member` bound = pure ()
f _ PosImmediate (Var v _ _) = modify ((S.singleton (qualLeaf v), mempty) <>)
f _ PosParam (Var v _ _) = modify ((mempty, S.singleton (qualLeaf v)) <>)
f _ _ _ = pure ()
f bound pos e =
case pos of
PosImmediate ->
modify ((fvVars fv, mempty) <>)
PosParam ->
modify ((mempty, fvVars fv) <>)
PosReturn -> pure ()
where
fv = freeInExp e `freeWithout` bound

checkApply ::
SrcLoc ->
Expand All @@ -1007,7 +1012,7 @@ checkApply loc (fname, _) (Scalar (Arrow _ pname d1 tp1 tp2)) argexp = do
argtype' <- normTypeFully argtype

-- Check whether this would produce an impossible return type.
let (tp2_produced_dims, tp2_paramdims) = dimUses $ toStruct tp2'
let (tp2_produced_dims, tp2_paramdims) = dimUses tp2'
problematic = S.fromList ext <> boundInsideType argtype'
problem = any (`S.member` problematic) (tp2_paramdims `S.difference` tp2_produced_dims)
when (not (S.null problematic) && problem) $ do
Expand Down

0 comments on commit 150d52d

Please sign in to comment.