
#16129: Incorrect non-exhaustive pattern warning with PatternSynonyms, ViewPatterns and TypeFamilies -------------------------------------+------------------------------------- Reporter: sjakobi | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Keywords: | Operating System: Unknown/Multiple PatternMatchWarnings | Architecture: | Type of failure: Incorrect Unknown/Multiple | error/warning at compile-time Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- {{{#!hs {-# language PatternSynonyms #-} {-# language ViewPatterns #-} {-# language TypeFamilies #-} module Bug where newtype GenLocated e = L e newtype WithSourceText a = WithSourceText a type StringLiteral = WithSourceText String {-# COMPLETE StringLiteral #-} pattern StringLiteral sl_s = WithSourceText sl_s type family SrcSpanLess a class HasSrcSpan a where decomposeSrcSpan :: a -> GenLocated (SrcSpanLess a) type instance SrcSpanLess (GenLocated e) = e instance HasSrcSpan (GenLocated a) where decomposeSrcSpan = id bug :: GenLocated StringLiteral -> String bug (decomposeSrcSpan->L (StringLiteral s)) = s workaround :: GenLocated StringLiteral -> String workaround (decomposeSrcSpan->L sl) = s where StringLiteral s = sl }}} {{{ $ ghci -Wincomplete-patterns Bug.hs GHCi, version 8.7.20190103: https://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/simon/.ghci [1 of 1] Compiling Bug ( Bug.hs, interpreted ) Bug.hs:27:1: warning: [-Wincomplete-patterns] Pattern match(es) are non-exhaustive In an equation for ‘bug’: Patterns not matched: _ | 27 | bug (decomposeSrcSpan->L (StringLiteral s)) = s | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Ok, one module loaded. }}} I've been able to reproduce the issue with all versions of GHC >= 7.8. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16129 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler