[GHC] #13965: COMPLETE sets nerf redundant pattern-match warnings

GHC ghc-devs at haskell.org
Sat Sep 8 15:52:51 UTC 2018


#13965: COMPLETE sets nerf redundant pattern-match warnings
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.2.1-rc2
      Resolution:                    |             Keywords:
                                     |  PatternSynonyms,
                                     |  PatternMatchWarnings
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by ckoparkar):

 * cc: mpickering (added)


Comment:

 It looks like this was by design when the `COMPLETE` pragma was added in
 Phab:D2669.

 {{{
 #!diff
 compiler/deSugar/Check.hs
 @@ -1360,8 +1455,8 @@ wrapUpTmState (residual, (_, subst)) = (residual,
 flattenPmVarEnv subst)
  dsPmWarn :: DynFlags -> DsMatchContext -> PmResult -> DsM ()
  dsPmWarn dflags ctx@(DsMatchContext kind loc) pm_result
    = when (flag_i || flag_u) $ do
 -      let exists_r = flag_i && notNull redundant
 -          exists_i = flag_i && notNull inaccessible
 +      let exists_r = flag_i && notNull redundant && onlyBuiltin
 +          exists_i = flag_i && notNull inaccessible && onlyBuiltin
            exists_u = flag_u && notNull uncovered
        when exists_r $ forM_ redundant $ \(L l q) -> do
          putSrcSpanDs l (warnDs (Reason Opt_WarnOverlappingPatterns)
 @@ -1373,7 +1468,8 @@ dsPmWarn dflags ctx@(DsMatchContext kind loc)
 pm_result
 }}}

 Relevant comment:
 {{{compiler/deSugar/Check.hs}}}
 {{{
 #!haskell
 data PartialResult = PartialResult {
                         presultProvenance :: Provenance
                          -- keep track of provenance because we don't want
                          -- to warn about redundant matches if the result
                          -- is contaminated with a COMPLETE pragma
 ...}
 }}}

 Do we want to change this?

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13965#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list