[GHC] #13990: Core Lint error on empty case
GHC
ghc-devs at haskell.org
Wed Jul 19 21:56:24 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 simonpj):
> Or find out why exprIsHNF scrut is True here.
It's because in a case alternative
{{{
K x -> ...x...
}}}
where `K` is strict, we know that when we unpack `K x`, the field `x` must
be evaluated. So it is marked as such, and hence responds True to
`exprIsHNF`.
Joachim's solition is right; but it's very much a corner case and a bit
hard to get right. E.g.
{{{
data T a = T1 !(F a) Int | ...
}}}
When we pattern match on `T1 x y :: T X`, is that pattern impossible?
WEll it depends on whether `(F X)` evaluates to an empty type. Hard to be
sure it is fully nailed.
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.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13990#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list