
#15139: EmptyCase produces incorrect SrcSpans -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.2 (Parser) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Poor/confusing Unknown/Multiple | error message Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- If you compile the following program, you'll get a warning for `f` with an improperly placed `SrcSpan`: {{{#!hs {-# LANGUAGE EmptyCase #-} {-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -Wincomplete-patterns #-} module Bug where import Data.Type.Equality can'tHappen :: Int :~: Bool can'tHappen = undefined f, g :: Bool -> Bool f True = case can'tHappen of {} g True = case () of () -> True }}} {{{ $ /opt/ghc/8.4.2/bin/ghci Bug.hs GHCi, version 8.4.2: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci [1 of 1] Compiling Bug ( Bug.hs, interpreted ) Bug.hs:12:1: warning: [-Wincomplete-patterns] Pattern match(es) are non-exhaustive In an equation for ‘f’: Patterns not matched: False | 12 | f True = case can'tHappen of {} | ^^^^^^^^^^^^^ Bug.hs:13:1: warning: [-Wincomplete-patterns] Pattern match(es) are non-exhaustive In an equation for ‘g’: Patterns not matched: False | 13 | g True = case () of () -> True | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Ok, one module loaded. }}} Compare that to the warning for `g`, whose `SrcSpan` spans the entire clause, as expected. The bug lies in the parser—patch incoming. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15139 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler