I just tried to parse the file:
file_path = ~/.julia/packages/Makie/rEu75/src/Makie.jl
@info "Processing file: $file_path"
s = read(file_path, String)
@time expr2 = parsestmt(JuliaSyntax.SyntaxNode, "begin\n"*s*"\nend", filename=file_path)
And I am getting this error:
[ Info: Processing file: ~/.julia/packages/Makie/rEu75/src/Makie.jl
ERROR: ParseError:
# Warning @ ~/.julia/packages/Makie/rEu75/src/Makie.jl:68:35
using IntervalSets: IntervalSets, (..), OpenInterval, ClosedInterval, AbstractInterval, Interval, endpoints, leftendpoint, rightendpoint
# ββββ ββ parentheses are not required here
# Warning @ /home/six/.julia/packages/Makie/rEu75/src/Makie.jl:303:8
export Vec, Vec2, Vec3, Vec4, Point, Point2, Point3, Point4
export (..)
Shouldnβt JuliaSyntax be able to parse all julia files? Or am I missing something?
nsajko
August 9, 2024, 1:53pm
2
Complete example:
julia> using JuliaSyntax; file_path = "/tmp/Makie.jl/src/Makie.jl"; s = read(file_path, String);
Precompiling JuliaSyntax...
1 dependency successfully precompiled in 14 seconds
julia> parsestmt(JuliaSyntax.SyntaxNode, s, filename=file_path)
ERROR: ParseError:
# Warning @ /tmp/Makie.jl/src/Makie.jl:67:35
using IntervalSets: IntervalSets, (..), OpenInterval, ClosedInterval, AbstractInterval, Interval, endpoints, leftendpoint, rightendpoint
# ββββ ββ parentheses are not required here
# Warning @ /tmp/Makie.jl/src/Makie.jl:303:8
export Vec, Vec2, Vec3, Vec4, Point, Point2, Point3, Point4
export (..)
# ββββ ββ parentheses are not required here
Stacktrace:
[1] _parse(rule::Symbol, need_eof::Bool, ::Type{β¦}, text::String, index::Int64; version::VersionNumber, ignore_trivia::Bool, filename::String, first_line::Int64, ignore_errors::Bool, ignore_warnings::Bool, kws::@Kwargs{})
@ JuliaSyntax ~/.julia/packages/JuliaSyntax/irSvg/src/parser_api.jl:87
[2] _parse (repeats 2 times)
@ ~/.julia/packages/JuliaSyntax/irSvg/src/parser_api.jl:71 [inlined]
[3] #parsestmt#95
@ ~/.julia/packages/JuliaSyntax/irSvg/src/parser_api.jl:134 [inlined]
[4] top-level scope
@ REPL[2]:1
Some type information was truncated. Use `show(err)` to see complete types.
Reproduces with all versions of JuliaSyntax.jl from v0.4.5 to v0.4.9. @c42f is this a bug?
savq
August 9, 2024, 10:32pm
3
This was fixed a couple of weeks ago: JuliaLang/JuliaSyntax.jl#477
TL;DR: Allowing parentheses in imports is bad, but the operator ..
conflicts with import paths like ..SibilingModule
. Ideally, it should be imported as var".."
, but for now, an exception was made to allow (..)
.
2 Likes
c42f
August 10, 2024, 12:02pm
4
Actually this is just a warning, but warnings are set to become errors by default in parsestmt()
. You can use parsestmt(..., ignore_warnings=true)
to get the behavior used by Base
Julia (currently used because thereβs no way to emit parser warnings from the Julia runtime).
This particular warning was a bug and has been fixed as pointed out by @savq .
5 Likes