-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem parsing in JuliaFormatter #365
Comments
This looks like a bug in JuliaFormatter to me. As far as I can tell it seems to reformat the code to
which is not valid Julia code because of the CC @domluna Closing for now, if I'm wrong just let me know here :) |
julia> s = """
+x[1] + x[2] <= 2
"""
"+x[1] + x[2] <= 2\n"
julia> x = CSTParser.parse(s)
1:18 call
1:3 OP: <=
4:16 call
4:4 OP: +
5:9 ref
5:5 x
6:6 INTEGER: 1
10:14 ref
10:10 x
11:11 INTEGER: 2
17:18 INTEGER: 2
julia> x[1]
1:13 call
1:1 OP: +
2:6 ref
2:2 x
3:3 INTEGER: 1
7:11 ref
7:7 x
8:8 INTEGER: 2
julia> collect(x[1])
4-element Vector{Any}:
1:5 ref
1:1 x
2:2 INTEGER: 1
1:1 OP: +
1:5 ref
1:1 x
2:2 INTEGER: 2
1:2 OP: +
julia> s = """
+x[1] + x[2] <= 2
"""
"+x[1] + x[2] <= 2\n"
julia> x = CSTParser.parse(s)
1:18 call
1:3 OP: <=
4:16 call
4:4 OP: +
5:9 ref
5:5 x
6:6 INTEGER: 1
10:14 ref
10:10 x
11:11 INTEGER: 2
17:18 INTEGER: 2
julia> collect(x[1])
4-element Vector{Any}:
1:5 ref
1:1 x
2:2 INTEGER: 1
1:1 OP: +
1:5 ref
1:1 x
2:2 INTEGER: 2
1:2 OP: +
julia> The issue appears to be that CSTParser moves the |
Possibly simpler reproduction case:
which leads to
while instead, most notably
and
|
I had an error in JuliaFormatter and it might be a problem with the parser domluna/JuliaFormatter.jl#642 (comment)
The text was updated successfully, but these errors were encountered: