Skip to content

Parse issue involving try-catch-catch #8220

Open
@digama0

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P-mediumWe may work on this issue if we find the timebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions