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

GADT type information is not used to detect unused match cases #6220

Closed
vicuna opened this issue Nov 2, 2013 · 3 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link

commented Nov 2, 2013

Original bug ID: 6220
Reporter: @lpw25
Assigned to: @garrigue
Status: closed (set by @garrigue on 2015-12-04T00:46:13Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.01.0
Target version: 4.03.0+dev / +beta1
Fixed in version: 4.03.0+dev / +beta1
Category: typing
Child of: #5998 #6437
Monitored by: @gasche @hcarty

Bug description

It seems that warning 11 ("this match case is unused") does not take account of the type information of GADTs.

For example:

type 'a t = I : int t | F : float t;;

type 'a t = I : int t | F : float t

let f : int t -> int = function

  I -> 1;;
val f : int t -> int = <fun>

let f : int t -> int = function

  I -> 1
| _ -> 2;;
  val f : int t -> int = <fun>

I would have expected the second declaration of f to raise warning 11, but it does not.

@vicuna

This comment has been minimized.

Copy link
Author

commented Apr 27, 2015

Comment author: @garrigue

Indeed, the refined information is not used here.
Not completely clear how to do it, as inclusion is not easy in presence of gadts.

@vicuna

This comment has been minimized.

Copy link
Author

commented Dec 3, 2015

Comment author: @alainfrisch

Now we get warning 56 ("this match case is unreachable"). Is this considered ok (or should warning 11 be raised) ? I did not follow the discussion about "_ -> ." clauses, but I don't see offhand why this should be a different warning number.

@vicuna

This comment has been minimized.

Copy link
Author

commented Dec 4, 2015

Comment author: @garrigue

Solved together with its parent.

This has to be a different warning, because if a case is only unreachable (rather than unused), you cannot just remove it, but have to replace it by a refutation case.
Note that 56 is a subcase of 11: you only get warning 56 if both 11 and 56 are turned on.

@vicuna vicuna closed this Dec 4, 2015

@vicuna vicuna added the typing label Mar 14, 2019

@vicuna vicuna added this to the 4.03.0 milestone Mar 14, 2019

@vicuna vicuna added the bug label Mar 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.