Erroneous warning
moran at galconn.com
moran at galconn.com
Mon Sep 17 12:11:12 EDT 2001
Ian Lynagh wrote:
> If Q.lhs is
>
> > module Q where
>
> > foo :: Int -> Int
> > foo (i+1) = i
> > foo 0 = -10
>
> then
>
> % ghc -c -o Q.o Q.lhs
>
> Q.lhs:5: Warning: Pattern match(es) are overlapped in the definition of
> function `foo':
> foo 0 = ...
This is acceptbale behaviour, since the first equation can match with i = -1.
The type is Int, not Nat.
Note that swapping the order of the equations gets rid of the warning.
Morally, it shouldn't (since, in a perfect world, equation order shouldn't
matter), but it does in GHC because of the way pattern matching is compiled.
Maybe there should there be a warning in both cases, or not at all (the latter
being Hugs' behaviour).
Cheers,
Andy
--
Andy Moran Ph. (503) 526 3472
Galois Connections Inc. Fax. (503) 350 0833
3875 SW Hall Blvd. http://www.galconn.com
Beaverton, OR 97005 moran at galconn.com
More information about the Glasgow-haskell-bugs
mailing list