Pattern alternative binding empty type does not cause redundant alternative warning
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
So, lean has coverage checking in pattern-matching, e.g. this code...
def v : Option Bool -> Bool
| .none => false
-- | .some _ => true
...does not get accepted and missing case is reported. Good!
Lets now consider a slightly different definition:
def v' : Option Empty -> Bool
| .none => false
This one is considered correct by lean, no errors about missing cases are reported.
However, if I add another pattern to this definition...
def v' : Option Empty -> Bool
| .none => false
| .some _ => true -- offending pattern
...it still gets accepted without a warning. The redundant pattern is not reported as such!
This means that matches on empty types are redundant, but the helpful warning does not appear.
It would be helpful if it would, if possible.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two Option Empty definitions and compare their diagnostics with the Option Bool example. No file or test is named in the issue, so locate the pattern-matching coverage checker and add a regression test showing that the .some _ alternative produces a redundant-pattern warning; done means the warning appears without breaking valid empty-type matches.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100