[GHC] #13990: Core Lint error on empty case

GHC ghc-devs at haskell.org
Thu Jul 20 11:42:46 UTC 2017


#13990: Core Lint error on empty case
-------------------------------------+-------------------------------------
        Reporter:  mbieleck          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  highest           |            Milestone:  8.2.2
       Component:  Compiler          |              Version:  8.2.1-rc3
      Resolution:                    |             Keywords:  core-lint
                                     |  case
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  crash or panic                     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by mbieleck):

 Replying to [comment:7 simonpj]:
 > Better, I think, to say that
 > {{{
 > case x of {}
 > }}}
 > is fine if `x :: T` where `T` has no data constructors.   That would
 silence the warning and is obviously correct.

 Unfortunately that wouldn't fix my original problem. I encountered Core
 Lint errors when using
 [https://github.com/cdepillabout/servant-checked-
 exceptions/blob/master/src/Servant/Checked/Exceptions/Internal/Union.hs#L152
 Servant.Checked.Exceptions.Internal.Union.absurdUnion]. Here the type
 involved is a GADT which __does__ have data constructors, but none of them
 matches the type parameter `'[]`. For the purposes of simplifying the test
 case I replaced it with `Void`, since they are isomorphic, but it makes a
 difference when linting.

 Here's a test case better reflecting the situation:

 {{{#!hs
 {-# LANGUAGE EmptyCase, GADTs #-}
 module Bug where

 data T a where
   TInt :: T Int

 absurd :: T Bool -> a
 absurd v = case v of {}

 data Foo = Foo !(T Bool)

 absurdFoo :: Foo -> a
 absurdFoo (Foo x) = absurd x
 }}}

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


More information about the ghc-tickets mailing list