Repository navigation
Conversation
| let code = | ||
| [SI.i|module Main where | ||
| test t | ||
| | t < 0, t < -5 = 0 |
There was a problem hiding this comment.
What about redundancy within one guard line? Isn't t < 0 redundant in t < 0, t < -5?
This comment was marked as resolved.
This comment was marked as resolved.
|
Is Say, someone has test t
| t < 4 = 0
| t >= 4 = 1
| t >= 9 = 2At least test t
| t < 4 = 0
| otherwise = 1
| t >= 9 = 2or test t
| t < 4 = 0
| t >= 4 = 1
| otherwise = 2or test t
| t < 4 = 0
| otherwise = 1
| otherwise = 2In each of these three cases, what would be the detector's next response be? |
|
The newly added tests answer most questions. Redundancy within one guard is currently not reported.
|
| [SI.i|module Main where | ||
| test t | True = 0 | ||
| |] | ||
| detect code `shouldReturn` [("test", Right [(Redundant, "True")])] |
There was a problem hiding this comment.
If anything would become simpler in the implementation without detecting this particular case (also with otherwise), I would be fine with going that way.
There was a problem hiding this comment.
It would only make a difference if we were to completely drop the check on definitions with a single guard.
| | t < 10 = 2 | ||
| |] | ||
| -- this result is weird because the whole conjunction is unreachable and not the two arguments | ||
| detect code `shouldReturn` [("test", (False, [(Unreachable, "t < 0"), (Unreachable, "t >= 0")]))] |
There was a problem hiding this comment.
I think the feedback shouldn't be about the conditions at all. It should be about that whole line being removable.
| combineMaybeArithExprs :: Show a => Bool -> (AST -> AST -> Z3 AST) -> ScopedExp a -> ScopedExp a -> Maybe (Z3 AST) | ||
| combineMaybeArithExprs onInt f l r = liftM2 (\(_, a) (_, b) -> join $ liftM2 f a b) (toZ3 l) (toZ3 r) | ||
| where | ||
| toZ3 v = second (if onInt then (mkReal2Int =<<) else id) <$> arithAstToZ3 v |
There was a problem hiding this comment.
Are you sure this will give a semantic interpretation on the SMT side that is equivalent to the Haskell semantics of mod etc.?
I remember that Oliver had problems with that. The SMT solver had a different interpretation of integer division in the negatives than what Haskell uses. With the consequence that relying on semantic information from the SMT solver could lead to wrong analysis results regarding the Haskell program under consideration.
There was a problem hiding this comment.
I didn't investigate that yet.
No description provided.