compiling: module Overlap where f (n+1) = 2 f 0 = 1emits wrongly: Warning: Pattern match(es) are overlapped In the definition of `f': f 0 = ...The Patterns are disjoint, aren't they? At least "f 0"yields "1" when evaluated and negative inputs for f arerejected. However the warning is not emitted if the twoequations are given in reversed order.Christian (maeder@tzi.de)
Edited
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items
0
Show closed items
GraphQL error: The resource that you are attempting to access does not exist or you don't have permission to perform this action
No child items are currently open.
Linked items
0
Link issues together to show that they're related or that one is blocking others.
Learn more.
Logged In: YES user_id=50165Here's another example, from Peter WhiteWhen I compile the following module with the -Wall option on ghc v6.2.1 I get warnings:Warning: Pattern match(es) are non-exhaustive In a record-update construct: Patterns not matched D2.The warnings occur at both of the indicated places in the module.Since the functions both handle all the cases of the data type D, it seems the warning should not be given.data D = D1 { f1 :: Int } | D2-- Use pattern matching in the argumentf :: D -> Df d1@(D1 {f1 = n}) = d1 { f1 = f1 d1 + 1 } -- Warning heref d = d-- Use case pattern matchingg :: D -> Dg d1 = case d1 of D1 { f1 = n } -> d1 { f1 = n + 1 } -- Warning here also D2 -> d1
Logged In: YES user_id=50165Another example from Neil MitchellI have been playing around with -fwarn-incomplete-patterns under GHC6.4.1 on Windows.-- no warningex1 x = ss where (s:ss) = x-- no warningex2 x = let (s:ss) = x in ss-- Warning: Pattern match(es) are non-exhaustive-- In a case alternative: Patterns not matched: []ex3 x = case x of ~(s:ss) -> ssI have translated all 3 functions using the rules supplied in the Haskell 98 report, so they all have the same meaning, but only one gives an error. Is it intentional to ignore where/let pattern matches?
Logged In: YES user_id=618575When adding -fwarn-simple-patterns to the command line, all3 of the previous examples give an additional 2 warning's,i.e. ex1 and ex2 give two identical warnings, and ex3 gives3 identical warnings.Warning: Pattern match(es) are non-exhaustive In a case alternative: Patterns not matched: []
Logged In: YES user_id=50165Another example, this time from John Meachamthe following gives a 'non-exhaustive pattern matching' error when it shouldn't. the ~-pattern always matches. It is not the function that is non-exhausitive, but the irrefutable binding, which are necessarily always non-exhausive so warning about it is the wrong thing to do.f :: [a] -> af [x] = xf ~(_:xs) = f xs
All of these are fixed, except the first. I'm going to open a new bug report for that, since fixing n+k patterns isn't going to happen soon. And I'll close this.