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

Case suggested by exhaustivity checker is wrong #7504

Closed
vicuna opened this issue Mar 14, 2017 · 6 comments
Closed

Case suggested by exhaustivity checker is wrong #7504

vicuna opened this issue Mar 14, 2017 · 6 comments
Assignees
Milestone

Comments

@vicuna
Copy link

vicuna commented Mar 14, 2017

Original bug ID: 7504
Reporter: @johnwhitington
Assigned to: @Octachron
Status: resolved (set by @gasche on 2017-03-14T23:16:34Z)
Resolution: fixed
Priority: normal
Severity: tweak
Version: 4.04.0
Target version: 4.05.0 +dev/beta1/beta2/beta3/rc1
Fixed in version: 4.05.0 +dev/beta1/beta2/beta3/rc1
Category: language features
Related to: #7169

Bug description

Consider:

type t =
{a : int;
b : string}

let f x y =
match x with {a = c}, 0 -> 0

Which gives:

Warning 8: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
({}, 1)

{} isn't legal pattern match syntax. Shouldn't it read "(_, 1)"?

@vicuna
Copy link
Author

vicuna commented Mar 14, 2017

Comment author: @Octachron

Good catch, this case is indeed mishandled; a fix is incoming in #1106.

@vicuna
Copy link
Author

vicuna commented Mar 14, 2017

Comment author: @gasche

I have memories of working on a very similar issue in the recent months -- maybe of having already changed the formulation in 4.05+dev. (Is this just jetlag?)

@vicuna
Copy link
Author

vicuna commented Mar 14, 2017

Comment author: @Octachron

@gasche, maybe some remininescences of #501
or #7169? This is from last year, but the code in trunk and the 4.05 branch is still from this PR.

@vicuna
Copy link
Author

vicuna commented Mar 14, 2017

Comment author: @gasche

Yes, exactly, thanks. We should have noticed the current issue if we had been more careful thinking about the corner cases of the last patch.

(I think one could argue that "{ _ }" should be accepted by the language when no field is matched upon, and that using it there could make the code more regular, but your patch is just fine.)

@vicuna
Copy link
Author

vicuna commented Mar 14, 2017

Comment author: @Octachron

Would it not be unpratical to type { _ } without a record kind?

@vicuna
Copy link
Author

vicuna commented Mar 14, 2017

Comment author: @gasche

Solved by merging octachron's proposed fix. Thanks for the patch, and thanks for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants