[GHC] #10746: No non-exhaustive pattern match warning given for empty case analysis
GHC
ghc-devs at haskell.org
Fri May 13 15:42:47 UTC 2016
#10746: No non-exhaustive pattern match warning given for empty case analysis
-------------------------------------+-------------------------------------
Reporter: bgamari | Owner:
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.2
Resolution: | Keywords:
| PatternMatchWarnings
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect | Unknown/Multiple
warning at compile-time | Test Case:
Blocked By: | Blocking:
Related Tickets: #7669, #11806 | Differential Rev(s): Phab:D2105
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by gkaracha):
Replying to [comment:25 simonpj]:
> * Normalise `x`'s type, to get it to the form `T ty1 .. tyn`. (I don't
understand the "bounded" bit.) For this, we must reduce type families,
but NOT newtypes. For pattern matching purposes, newtypes behave just
like data types. So use `FamInstEnv.normaliseType`.
This sounds wrong to me. Newtypes and data types do not behave the same
when it comes to pattern matching. From [https://wiki.haskell.org/Newtype
Newtype Wiki Page]:
{{{#!hs
data Foo1 = Foo1 Int
newtype Foo3 = Foo3 Int
y1 = case undefined of
Foo1 _ -> 1 -- undefined
y3 = case undefined of
Foo3 _ -> 1 -- 1
}}}
which is verified by my GHCi (7.10). Additionally, by bounded I mean that
when we have a family
{{{#!hs
type family F (a :: *) :: *
type instance F a = F a
}}}
we do not want to keep rewriting forever. Hence, I would bound
normalization with a fixed number of maximum iterations. If we exceed
that, we (playing on the safe side) assume that the type is inhabited and
issue a warning.
The rest you mentioned I agree with, but I missed a bit:
> * If some of `T`'s data constructor are GADTs, then enumerate them all
and recurse.
What do you mean by **recurse** in this case? Does `EmptyCase` imply deep
evaluation (is it really strict pattern matching) or just in WHNF? Because
I thought that it means the latter.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10746#comment:26>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list