JuliaLang / JuliaSyntax.jl

The Julia compiler frontend
Other
267 stars 32 forks source link

`"a +\n\n>:"` and related expressions with `>:` parse incorrectly #392

Closed c42f closed 7 months ago

c42f commented 7 months ago

Probably related to the case parseall(Expr, "for\n\n<:", ignore_errors=true) in #380, we have this case of misparsing, but without an error:

julia> parseall(Expr, "a +\n\n>:", ignore_errors=true)
:($(Expr(:toplevel, :(#= line 1 =#), :(+a), :(#= line 3 =#), :>:)))

julia> parseall(SyntaxNode, "a +\n\n>:", ignore_errors=true)
line:col│ tree                                   │ file_name
   1:1  │[toplevel]
   1:1  │  [call-i]
   1:1  │    a
   1:3  │    +
   3:1  │  >:

This seems likely to be due to the special handling of >: and <: operators.

A second evil example where we produce incorrect output:

julia> parseall(SyntaxNode, "a +\n>:", ignore_errors=true)
line:col│ tree                                   │ file_name
   1:1  │[toplevel]
   1:1  │  [call-i]
   1:1  │    a
   1:3  │    +
   1:4  │    [>:-pre]
   2:1  │      >: