Ticket #4516 (closed bug: fixed)

Opened 3 years ago

Last modified 2 years ago

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 Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

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

Changed 2 years ago by igloo

  • milestone set to 7.2.1

Changed 2 years ago by batterseapower

  • status changed from new to closed
  • resolution set to fixed

Fixed by #4905, I think

Note: See TracTickets for help on using tickets.