Opened 9 years ago

Closed 9 years ago

#4516 closed bug (fixed)

Over eager non-exhaustive pattern match warnings in lambda expressions.

Reported by: benl Owned by:
Priority: normal Milestone: 7.4.1
Component: Compiler Version: 7.0.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


When I write:

let thing = (\(Just x) -> x) whatever
in  rest

GHC shouldn't complain about non-exhaustive pattern matches for this code, because the form of the expression makes it obvious that some patterns are not being matched. The above fragment should behave like:

let thing = let Just x = whatever in x
in  rest

This pattern is also non-exhaustive, but that's obvious from the form of the expression. I use both of these forms all the time because the alternative of using something like fromJust gives bad error messages when it fails.

Here's a more concrete example from DDC:

let vks' = map (\(T.TVar k (T.UVar v')) -> (v', k))
         $ map toCoreT cts

To update my code to work with 7.0.1 I have to change all of these to:

let vks' = map (\tt -> let T.TVar k (T.UVar v') = tt in (v', k))
         $ map toCoreT cts

This is longer, uglier, and requires the introduction of the dummy variable tt

Change History (2)

comment:1 Changed 9 years ago by igloo

Milestone: 7.2.1

comment:2 Changed 9 years ago by batterseapower

Resolution: fixed
Status: newclosed

Fixed by #4905, I think

Note: See TracTickets for help on using tickets.