[GHC] #15305: Erroneous "non-exhaustive pattern match" using nested GADT with strictness annotation

GHC ghc-devs at haskell.org
Tue Jul 24 19:20:13 UTC 2018


#15305: Erroneous "non-exhaustive pattern match" using nested GADT with strictness
annotation
-------------------------------------+-------------------------------------
        Reporter:  jkoppel           |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Compiler (Type    |              Version:  8.4.3
  checker)                           |             Keywords:
      Resolution:                    |  PatternMatchWarnings
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Incorrect         |  Unknown/Multiple
  error/warning at compile-time      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 I tried thinking of an (ad hoc) algorithm to check for this sort of thing.
 This is the closest I could get:

 1. In `mkOneConFull` (which generates pattern-matching information for
 each constructor), record the type and strictness of each constructor's
 fields.
 2. When checking if a match on that constructor is reachable, perform the
 following additional checks:
   i. Check if all fields are strict.
   ii. Check if each field's type is uninhabitable.

   If both (i) and (ii) are true, then deem the entire constructor to be
 unreachable.

 I think this would work for the original program, but not the program in
 comment:6

 {{{#!hs
 data Abyss = MkAbyss !Abyss

 stareIntoTheAbyss :: Abyss -> a
 stareIntoTheAbyss a = case a of {}
 }}}

 Why? In order to check that a match on `(MkAbyss _)` is unreachable, we
 need to check:

 i. That the field of `MkAbyss` is strict. (This is the case.)
 ii. That the type of the field of `MkAbyss` (`Abyss`) is uninhabitable.

 But in order to check that `Abyss` in uninhabitable, we need to check the
 `MkAbyss` constructor again, which requires repeating this algorithm. Now
 we've entered an infinite loop!

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


More information about the ghc-tickets mailing list