Skip to content

Commit fc047f0

Browse files
committed
Fix Expr conversion of erroneous operator dot call
1 parent 1b048aa commit fc047f0

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/expr.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,15 @@ function _internal_node_to_Expr(source, srcrange, head, childranges, childheads,
266266
# Move parameters blocks to args[2]
267267
_reorder_parameters!(args, 2)
268268
if headsym === :dotcall
269+
startsym = args[1]
269270
if is_prefix_call(head)
270271
headsym = :.
271-
args = Any[args[1], Expr(:tuple, args[2:end]...)]
272-
else
272+
args = Any[startsym, Expr(:tuple, args[2:end]...)]
273+
elseif startsym isa Symbol
273274
# operator calls
274275
headsym = :call
275-
args[1] = Symbol(".", args[1])
276-
end
276+
args[1] = Symbol(:., startsym)
277+
end # else startsym could be an Expr(:error), just propagate it
277278
end
278279
if do_lambda isa Expr
279280
return Expr(:do, Expr(headsym, args...), do_lambda)

test/expr.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,12 @@
463463
@test parsestmt("f(.+)") == Expr(:call, :f, Expr(:., :+))
464464
@test parsestmt("(a, .+)") == Expr(:tuple, :a, Expr(:., :+))
465465
@test parsestmt("A.:.+") == Expr(:., :A, QuoteNode(Symbol(".+")))
466+
467+
# Issue #341
468+
@test parsestmt("f(./x)", ignore_errors=true) == Expr(:call, :f,
469+
Expr(:dotcall,
470+
Expr(:error, Expr(:., :/)),
471+
:x))
466472
end
467473

468474
@testset "let" begin

0 commit comments

Comments
 (0)