Open oxinabox opened 5 years ago
Workaround:
textwalk(code) do expr
@capture(expr, Rule(v_)) && return MacroTools.postwalk(MacroTools.unblock, v)
return expr
end
Though that still changes spacing,
and adds extra backets arround sin(x)
and arraound the whole expression
(x->-(sin(x)))
(x->1 + tan(x) ^ 2)
This is unfortunately due to Base's default parsing/printing of lambdas:
julia> :(x->1)
:(x->begin
#= REPL[1]:1 =#
1
end)
Would be great to fix, but unfortunately might require a fork of the Expr printing code (though there are likely several reasons to do this).
Alternatively, since Expr(:->, :x, 1)
seems to do the right thing, maybe we can just tweak CSTParser to not insert the block / line number.
MWE:
Output: