Skip to content

Commit d98b693

Browse files
authored
Merge pull request #295 from julia-vscode/sp/fix-legacy-dotcall-parsing
fix legacy parsing of dotops
2 parents 783aa41 + 12e796a commit d98b693

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

src/CSTParser.jl

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,19 @@ function parse_expression(ps::ParseState, esc_on_error = false)
5959
if both_symbol_and_op(ps.t)
6060
ret = EXPR(:IDENTIFIER, ps)
6161
else
62-
if ps.t.dotop && closer(ps) && !isassignmentop(ps.t)
63-
# Split dotted operator into dot-call
64-
v = val(ps.t, ps)[2:end]
65-
dot = EXPR(:OPERATOR, 1, 1, ".")
66-
op = EXPR(:OPERATOR, ps.nt.startbyte - ps.t.startbyte - 1, ps.t.endbyte - ps.t.startbyte, v)
67-
ret = EXPR(dot, EXPR[op], nothing)
68-
else
62+
@static if VERSION < v"1.6"
63+
# https://github.com/JuliaLang/julia/pull/37583
6964
ret = INSTANCE(ps)
65+
else
66+
if ps.t.dotop && closer(ps) && !isassignmentop(ps.t)
67+
# Split dotted operator into dot-call
68+
v = val(ps.t, ps)[2:end]
69+
dot = EXPR(:OPERATOR, 1, 1, ".")
70+
op = EXPR(:OPERATOR, ps.nt.startbyte - ps.t.startbyte - 1, ps.t.endbyte - ps.t.startbyte, v)
71+
ret = EXPR(dot, EXPR[op], nothing)
72+
else
73+
ret = INSTANCE(ps)
74+
end
7075
end
7176
end
7277
if is_colon(ret) && !(iscomma(ps.nt) || kindof(ps.ws) == SemiColonWS)

test/parser.jl

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,20 @@ end
124124
@test "::(a,b)" |> test_expr
125125
end
126126

127-
if VERSION >= v"1.6"
128-
@testset "dotted non-calls" begin
129-
@test "f(.+)" |> test_expr
130-
@test "f(.-)" |> test_expr
131-
@test "f(.!)" |> test_expr
132-
@test "f(.¬)" |> test_expr
127+
@testset "dotted non-calls" begin
128+
@test "f(.+)" |> test_expr
129+
@test "f(.-)" |> test_expr
130+
@test "f(.!)" |> test_expr
131+
@test "f(.¬)" |> test_expr
132+
if VERSION >= v"1.6"
133133
@test_broken "f(.~)" |> test_expr_broken
134-
@test "f(.√)" |> test_expr
135-
@test "f(:(.=))" |> test_expr
136-
@test "f(:(.+))" |> test_expr
137-
@test "f(:(.*))" |> test_expr
138134
end
135+
@test "f(.√)" |> test_expr
136+
@test "f(:(.=))" |> test_expr
137+
@test "f(:(.+))" |> test_expr
138+
@test "f(:(.*))" |> test_expr
139139
end
140+
140141
if VERSION >= v"1.6"
141142
@testset "comment parsing" begin
142143
@test "[1#==#2#==#3]" |> test_expr

0 commit comments

Comments
 (0)