JuliaSyntax.jl
JuliaSyntax.jl copied to clipboard
Incorrect parsing of `import ..+`
Import paths with a prefixed pair of dots should parse as follows:
julia> JuliaSyntax.parse(SyntaxNode, "import ..A")
line:col│ tree │ file_name
1:1 │[import]
1:7 │ [.]
1:8 │ .
1:9 │ .
1:10 │ A
But for operators this doesn't work
julia> JuliaSyntax.parse(SyntaxNode, "import ..+")
line:col│ tree │ file_name
1:1 │[import]
1:7 │ [.]
1:8 │ ..+
This appears to be because the initial tokenize step picks the import path up as part of an invalid operator
julia> collect(JuliaSyntax.Tokenize.tokenize("..-"))
2-element Vector{JuliaSyntax.Tokenize.RawToken}:
0-2 ErrorInvalidOperator
3-2 EndMarker
Which is normally correct, but not helpful within import paths.
The reference parser also has this bug:
julia> dump(Meta.parse("import ..+"))
ERROR: Base.Meta.ParseError("invalid operator \"..+\" near column 9")