[GHC] #14547: Wrong warning by -Wincomplete-patterns

GHC ghc-devs at haskell.org
Tue May 1 12:07:06 UTC 2018


#14547: Wrong warning by -Wincomplete-patterns
-------------------------------------+-------------------------------------
        Reporter:  YoshikuniJujo     |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  low               |            Milestone:
       Component:  Compiler          |              Version:  8.2.1
      Resolution:                    |             Keywords:  incomplete-
                                     |  patterns OverloadedLists,
                                     |  PatternMatchWarnings TypeFamilies
Operating System:  Linux             |         Architecture:  x86
 Type of failure:  Incorrect         |            Test Case:
  error/warning at compile-time      |  deSugar/should_compile/T14547
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D4624
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Alas, with `RebindableSyntax` we don't know ''anything'' about `toList`.
 (Without `RebindableSyntax` I think your reasoning is correct.)

 But now I am worried about
 {{{
 f (x:xs) = ..
 f [p,q]  = ...
 }}}
 The `(x:xs)` pattern will translate as an ordinary cons pattern.  The
 `[p,q]` pattern will be subject to overloaded lists.  So if
 `RebindableSyntax` is on and `toList` does something strange, simply
 dropping the `toList` altogether, and desugaring to
 {{{
 f (x:xs)   = ..
 f (p:q:[]) = ...
 }}}
 may not be right.

 So in the presence of `RebindableSyntax` I think we should treat `ListPat`
 like any other view pattern; i.e. coverage/exhaustiveness does not help
 much.

 In the absence of `RebindableSyntax`, but with `-XOverloadedStrings`, can
 we be sure that `toList` is the identity function if the pattern type is a
 list type?  I think so.  In which case your simplified version is fine.

 Bottom line: check for `NoRebindableSyntax`!

 > Another silly question is that I still can't see why we need to concern
 about the view pattern for exhaustiveness checking of overloaded list. I
 think the toList and the [a] instance of IsList are different with
 ordinary view functions in view pattern.

 I could not parse the question.

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


More information about the ghc-tickets mailing list