From 7b41f44788e00842d590fa0688df3f6e0113c841 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Sat, 18 Apr 2009 21:26:57 +0000 Subject: [PATCH] Fixed a problem with the usage checking when one half had BK and the other half had none --- checks/ArrayUsageCheck.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/checks/ArrayUsageCheck.hs b/checks/ArrayUsageCheck.hs index d605505..cdd5891 100644 --- a/checks/ArrayUsageCheck.hs +++ b/checks/ArrayUsageCheck.hs @@ -776,7 +776,8 @@ squareAndPair lookupBK strip repVars s v lh s, squareEquations (nub (bkEqA ++ bkEqB) ++ eq, nub (bkIneqA ++ bkIneqB) ++ ineq ++ concat (applyAll (eq,ineq) (map addExtra repVars)))) - bk = case liftM2 (curry product2) (lookupBK (fst labels)) (lookupBK (snd labels)) of + bk = case liftM2 (curry product2) (liftM atLeastOne $ lookupBK (fst labels)) + (liftM atLeastOne $ lookupBK (snd labels)) of Right [] -> Right [(([],[]),([],[]))] -- No BK xs -> xs in bk >>* map f @@ -784,6 +785,10 @@ squareAndPair lookupBK strip repVars s v lh ,and (map (primeImpliesPlain (eq,ineq)) repVars) ] where + atLeastOne :: [(EqualityProblem, InequalityProblem)] -> [(EqualityProblem, InequalityProblem)] + atLeastOne [] = [([], [])] + atLeastOne xs = xs + itemPresent :: CoeffIndex -> [Array CoeffIndex Integer] -> Bool itemPresent x = any (\a -> arrayLookupWithDefault 0 a x /= 0)