Opened 14 years ago

Closed 10 years ago

Last modified 6 years ago

#366 closed feature request (fixed)

incomplete patterns and GADT

Reported by: nobody Owned by:
Priority: normal Milestone:
Component: Compiler Version: None
Keywords: Cc: jcpetruzza@…, drl@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: tc215, deSugar/should_compile/GadtOverlap
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by igloo)

I would like to compile with 
-fwarn-incomplete-patterns and use GADTs, 
but I have bogus error messages. 
Suppose I define : 
 
data T a where 
    C1 :: T Char 
    C2 :: T Float 
 
then a function : 
 
exhaustive :: T Char -> Char 
exhaustive C1 = ' ' 
 
If I compile with incomplete pattern warnings, 
I get that my function "exhaustive" is not 
exhaustive. 
But if I add a case : 
 
exhaust C2 = ' ' 
 
then the compiler accurately warns me that this 
case is inaccessible. 
Would it be possible to add the accessibility check 
when compiling with incomplete patterns detection ? 

Change History (11)

comment:1 Changed 13 years ago by igloo

Architecture: Unknown
Description: modified (diff)
difficulty: Unknown
Milestone: 6.8
Operating System: Unknown
Test Case: tc215

comment:2 Changed 13 years ago by igloo

There's another case in 462.

comment:3 Changed 12 years ago by guest

Cc: jcpetruzza@… added

comment:4 Changed 12 years ago by simonpj

Cc: drl@… added
Milestone: 6.8 branch6.10 branch

Dan Licata is planning to work on this.

Simon

comment:5 Changed 11 years ago by simonmar

Component: NoneCompiler
Milestone: 6.10 branch_|_

Could be done with #595.

comment:6 Changed 11 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:7 Changed 11 years ago by simonmar

Operating System: UnknownUnknown/Multiple

comment:8 Changed 10 years ago by igloo

Owner: nobody deleted
Status: assignednew

comment:9 Changed 10 years ago by simonpj

Resolution: Nonefixed
Status: newclosed
Test Case: tc215tc215, deSugar/should_compile/GadtOverlap

I have not done the full overhaul envisaged by #595, but it turned out to be rather easy to make GADTs play nicely with overlapping-pattern warnings.

   * Take account of GADTs when reporting patterm-match overlap
   Ignore-this: 7dcbdcb91021e83e6e6208a2e68c50c9
   When matching against a GADT, some of the constructors may be impossible.
    For example
   	data T a where
             T1 :: T Int
             T2 :: T Bool
             T3 :: T a
        f :: T Int ->  Int
        f T1 = 3
        f T3 = 4

   Here, does not have any missing cases, despite omittting T2, because
   T2 :: T Bool.

   This patch teaches the overlap checker about GADTs, which happily
   turned out to be rather easy even though the overlap checker needs
   a serious rewrite.

Simon

comment:10 Changed 6 years ago by Ian Lynagh <igloo@…>

In 81ea2c04dd97f12297d01aa4e2dc338b9346f38a/ghc:

Tests for trac #366 (incomplete pattern warnings and GADTs)

comment:11 Changed 6 years ago by Ian Lynagh <igloo@…>

In 912694f7c03131919a503ddfe72bba9b19c6e903/ghc:

tc215 is broken: trac #366
Note: See TracTickets for help on using tickets.