Opened 4 months ago

#13965 new bug

COMPLETE sets nerf redundant pattern-match warnings

Reported by: RyanGlScott Owned by:
Priority: normal Milestone:
Component: Compiler Version: 8.2.1-rc2
Keywords: PatternSynonyms, PatternMatchWarnings Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

If I give redundant patterns for a datatype with a COMPLETE set, then GHC doesn't warn me at all. Here's an example:

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ViewPatterns #-}
module Bug (Boolean(F, TooGoodToBeTrue), catchAll) where

data Boolean = F | T
  deriving Eq

pattern TooGoodToBeTrue :: Boolean
pattern TooGoodToBeTrue <- ((== T) -> True)
  where
    TooGoodToBeTrue = T
{-# COMPLETE F, TooGoodToBeTrue #-}

catchAll :: Boolean -> Int
catchAll F               = 0
catchAll TooGoodToBeTrue = 1
catchAll F               = 2

GHC thinks this is fine and dandy:

$ /opt/ghc/8.2.1/bin/ghci Bug.hs -Wall
GHCi, version 8.2.0.20170704: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug              ( Bug.hs, interpreted )
Ok, 1 module loaded.

This problem also persists across modules:

module Foo where

import Bug

catchAll2 :: Boolean -> Int
catchAll2 F               = 0
catchAll2 TooGoodToBeTrue = 1
catchAll2 F               = 2
$ /opt/ghc/8.2.1/bin/ghci Foo.hs -Wall
GHCi, version 8.2.0.20170704: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 2] Compiling Bug              ( Bug.hs, interpreted )
[2 of 2] Compiling Foo              ( Foo.hs, interpreted )

Change History (0)

Note: See TracTickets for help on using tickets.