
#14253: Pattern match checker mistakenly concludes pattern match on pattern synonym is unreachable -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.4.1 Component: Compiler | Version: 8.2.1 Resolution: | Keywords: | PatternSynonyms, | PatternMatchWarnings Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: #11984, #14098 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * related: => #11984, #14098 Comment: Phab:D4005 adds the rules to the GHC users' guide (proofreaders wanted). As for why this bug happens in the first place, I have a strong hunch that there's a symptom in common with #11984 (and #14098). The reason is because while this give a warning: {{{#!hs u :: S -> Bool u (MkS MkT2') = True }}} {{{ Pattern match has inaccessible right hand side In an equation for āuā: u (MkS MkT2') = ... }}} You can work around the issue using the same trick in https://ghc.haskell.org/trac/ghc/ticket/11984#comment:7 : {{{#!hs u :: S -> Bool u (MkS x) = case x of MkT2' -> True }}} After this, instead of emitting the garbage inaccessible right-hand-side warning from before, GHC will warn: {{{ Pattern match(es) are non-exhaustive In a case alternative: Patterns not matched: MkT1 }}} As we would expect. So now we need to figure out why there is a discrepancy between the pattern match checker's coverage of `case` and nested constructors. (I'm hoping I gain some insight after talking to SPJ about this part of the codebase tomorrow.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14253#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler