Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect exhaustiveness warning with GADTs #6395

Closed
vicuna opened this issue May 5, 2014 · 2 comments
Closed

Incorrect exhaustiveness warning with GADTs #6395

vicuna opened this issue May 5, 2014 · 2 comments
Assignees
Labels
bug typing typing-GADTS GADT typing and exhaustiveness bugs
Milestone

Comments

@vicuna
Copy link

vicuna commented May 5, 2014

Original bug ID: 6395
Reporter: @yallop
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2017-09-24T15:32:13Z)
Resolution: fixed
Priority: normal
Severity: minor
Target version: 4.03.1+dev
Fixed in version: 4.03.0+dev / +beta1
Category: typing
Child of: #5998
Monitored by: @hcarty

Bug description

Given the following type definitions:

type p = P
type q = Q

type _ t =
X : bool -> p t
| Y : q t

the following code correctly compiles without exhaustiveness warnings

let f : type a. a t * a t -> unit = function
| X _, X _ -> ()
| Y, Y -> ()

but the following code

let g : type a. a t * a t -> unit = function
| x, X false -> ()
| X _, X _ -> ()
| Y, Y -> ()

gives a warning:

Warning 8: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
(Y, X true)

@vicuna
Copy link
Author

vicuna commented May 11, 2014

Comment author: @garrigue

Another example which shows that the GADT exhaustiveness check, while sound, is extremely fragile.

@vicuna
Copy link
Author

vicuna commented Apr 5, 2016

Comment author: @garrigue

Fixed in 4.03 by the new exhaustuveness/redundancy check for GADTs.
But one could probably other (more involved) cases of asymmetry.

@vicuna vicuna closed this as completed Sep 24, 2017
@vicuna vicuna added the typing label Mar 14, 2019
@vicuna vicuna added this to the 4.03.1 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 2019
@Octachron Octachron added the typing-GADTS GADT typing and exhaustiveness bugs label May 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug typing typing-GADTS GADT typing and exhaustiveness bugs
Projects
None yet
Development

No branches or pull requests

3 participants