Parse issue involving try-catch-catch
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
example : IO Unit := do
try
for _ in [1] do
try
pure ()
catch _ => unreachable!
catch _ => unreachable!
produces the error invalid `try`, it must have a `catch` or `finally` , tested on 4.20.0-rc2. It appears the issue is that it is parsed as a try-catch-catch block like this:
example : IO Unit := do
try
for _ in [1] do
try
pure ()
catch _ => unreachable!
catch _ => unreachable!
and so the first try is left orphaned. (Are multiple catch blocks like this actually used in practice? I would not expect this to be legal even without the weird indentation.)
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 example with Lean 4.20.0-rc2 and inspect how the parser handles the nested try and catch indentation. Confirm the intended parsing behavior, then verify that the example no longer produces the invalid-try error and that multiple catch blocks remain handled appropriately.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100