[GHC] #322: fromInteger-related pattern match overlap warnings

GHC trac at galois.com
Thu Oct 19 12:35:33 EDT 2006


#322: fromInteger-related pattern match overlap warnings
----------------------+-----------------------------------------------------
 Reporter:  ashley-y  |          Owner:  simonpj 
     Type:  bug       |         Status:  assigned
 Priority:  normal    |      Milestone:  _|_     
Component:  Compiler  |        Version:  6.4     
 Severity:  normal    |     Resolution:  None    
 Keywords:  warnings  |     Difficulty:  Unknown 
 Testcase:  ds060     |   Architecture:  Unknown 
       Os:  Unknown   |  
----------------------+-----------------------------------------------------
Changes (by igloo):

  * architecture:  => Unknown
  * difficulty:  => Unknown
  * milestone:  => _|_
  * keywords:  => warnings
  * testcase:  => ds060
  * os:  => Unknown

Old description:

> {{{
> The compiler incorrectly gives "Warning: Pattern match(es) are
> overlapped" for this file:
>
> {-# OPTIONS -Werror #-}
>
> module Buggy where
>
>         instance (Num a) => Num (Maybe a) where
>                 (Just a) + (Just b) = Just (a + b)
>                 _ + _ = Nothing
>                 (Just a) - (Just b) = Just (a - b)
>                 _ - _ = Nothing
>                 (Just a) * (Just b) = Just (a * b)
>                 _ * _ = Nothing
>                 negate (Just a) = Just (negate a)
>                 negate _ = Nothing
>                 abs (Just a) = Just (abs a)
>                 abs _ = Nothing
>                 signum (Just a) = Just (signum a)
>                 signum _ = Nothing
>                 fromInteger = Just . fromInteger
>
>         f :: Maybe Int -> Int
>         f 1 = 1
>         f Nothing = 2
>         f _ = 3
>
> }}}

New description:

 {{{
 The compiler incorrectly gives "Warning: Pattern match(es) are
 overlapped" for this file:

 {-# OPTIONS -Werror #-}

 module Buggy where

         instance (Num a) => Num (Maybe a) where
                 (Just a) + (Just b) = Just (a + b)
                 _ + _ = Nothing
                 (Just a) - (Just b) = Just (a - b)
                 _ - _ = Nothing
                 (Just a) * (Just b) = Just (a * b)
                 _ * _ = Nothing
                 negate (Just a) = Just (negate a)
                 negate _ = Nothing
                 abs (Just a) = Just (abs a)
                 abs _ = Nothing
                 signum (Just a) = Just (signum a)
                 signum _ = Nothing
                 fromInteger = Just . fromInteger

         f :: Maybe Int -> Int
         f 1 = 1
         f Nothing = 2
         f _ = 3

 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/322>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list