FluxML / MacroTools.jl

MacroTools provides a library of tools for working with Julia code and expressions.
https://fluxml.ai/MacroTools.jl/stable/
Other
310 stars 79 forks source link

flatten of `try ...; catch; false; end` does not work #196

Closed Krastanov closed 1 year ago

Krastanov commented 1 year ago

Even with #195 the following still does not work:

quote; try; error(); catch; false; finally; println(123); end; end |> striplines |> flatten |> eval

The flattening of the catch leads to a false becoming the third argument of the try expression, which can not be distinguished from a try ...; finally block without a catch statement. Previously this was a silent bug. With #195 now it explicitly raises an error with a suggestion for how to rework the statement.

A complete fix needs a different tree traversal strategy and a rewrite of flatten. This issue is submitted here in order to keep record of the implemented changes and steps necessary for a complete fix.