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

Or patterns, redundant patterns #2702

Closed
vicuna opened this issue Mar 9, 2001 · 2 comments
Closed

Or patterns, redundant patterns #2702

vicuna opened this issue Mar 9, 2001 · 2 comments

Comments

@vicuna
Copy link

vicuna commented Mar 9, 2001

Original bug ID: 305
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Fermin Reig
Version: version 3.00+22 (2001-02-05)
OS: alpha linux
Submission from: giro.gla.ac.uk (130.209.6.41)

In this or-pattern

let f1 = function
Some n -> 0
| None | Some 1 -> 1

"Some 1" is an unused match case. The compiler does not report it.
For a similar or-pattern

let f2 = function
n -> 0
| 0 | 1 -> 1

"1" is correctly reported as an unused match case.

@vicuna
Copy link
Author

vicuna commented Mar 9, 2001

Comment author: administrator

Full_Name: Fermin Reig
Version: version 3.00+22 (2001-02-05)
OS: alpha linux
Submission from: giro.gla.ac.uk (130.209.6.41)

In this or-pattern

let f1 = function
Some n -> 0
| None | Some 1 -> 1

"Some 1" is an unused match case. The compiler does not report it.
For a similar or-pattern

let f2 = function
n -> 0
| 0 | 1 -> 1

"1" is correctly reported as an unused match case.

This is rather a plea for a new feature than a plain bug.

In f1, the second clause
| None | Some 1 -> 1
is not unsused since its pattern matches ``None''.

The clause is in some sense partially unused, since it can
be simplified into ``| None -> 1''

In your second example, the clause is a true unused ine : its
pattern never matches.

Flagging ``partially unused clausses'' is a good
idea.

--Luc Maranget

@vicuna
Copy link
Author

vicuna commented Nov 6, 2002

Comment author: administrator

Done in 3.05 (Luc Maranget).

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

1 participant