Skip to content

Parse issue involving try-catch-catch #8220

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

Open
digama0 opened this issue May 4, 2025 · 1 comment · May be fixed by #8252
Open

Parse issue involving try-catch-catch #8220

digama0 opened this issue May 4, 2025 · 1 comment · May be fixed by #8252
Labels
bug Something isn't working

Comments

@digama0
Copy link
Collaborator

digama0 commented May 4, 2025

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.)

@digama0 digama0 added the bug Something isn't working label May 4, 2025
@Rob23oba
Copy link
Contributor

Rob23oba commented May 5, 2025

I actually also ran into this once but forgot to report it! The fix would probably be a checkColGe in the catch block.

@Rob23oba Rob23oba linked a pull request May 6, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants