Ticket #5762 (new bug)

Opened 17 months ago

Last modified 17 months ago

GHC gives incorrect warnings with simple applications of the view patterns extension

Reported by: jmg Owned by:
Priority: normal Milestone: _|_
Component: Compiler Version: 7.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

GHC is not able to infer exhaustivity of f1 in the following example

{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -fwarn-incomplete-patterns #-}
module VP where


f1, f2 :: Either Int Int -> Either Int Int

f1 (id -> Left _ ) = undefined
f1 (id -> Right _ ) = undefined

f2 (Left _ ) = undefined
f2 (Right _ ) = undefined


f (id -> _) = undefined

GHC outputs:

[1 of 1] Compiling VP               ( VP.hs, interpreted )

VP.hs:8:1:
    Warning: Pattern match(es) are non-exhaustive
             In an equation for `f1': Patterns not matched: _
Ok, modules loaded: VP.

I've tested this with GHC 7.0.4, 7.2.2, and 7.4.1-rc1 on Mac OS X.

BTW: There is neither a version entry for 7.2.2 nor for 7.4.1-rc1 in Trac.

Change History

Changed 17 months ago by simonpj

  • difficulty set to Unknown
  • milestone set to _|_

Not easy to solve this; cf #595, #5728, #3927, #5724. Volunteers welcome.

Note: See TracTickets for help on using tickets.