Skip to content

Commit 48ddfc6

Browse files
authored
Fix Expr conversion of erroneous operator dot call (#374)
1 parent 4d990b6 commit 48ddfc6

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/expr.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,16 @@ 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+
funcname = args[1]
269270
if is_prefix_call(head)
270271
headsym = :.
271-
args = Any[args[1], Expr(:tuple, args[2:end]...)]
272+
args = Any[funcname, Expr(:tuple, args[2:end]...)]
272273
else
273274
# operator calls
274275
headsym = :call
275-
args[1] = Symbol(".", args[1])
276+
if funcname isa Symbol
277+
args[1] = Symbol(:., funcname)
278+
end # else funcname could be an Expr(:error), just propagate it
276279
end
277280
end
278281
if do_lambda isa Expr

test/expr.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,9 @@
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("./x", ignore_errors=true) == Expr(:call, Expr(:error, Expr(:., :/)), :x)
466469
end
467470

468471
@testset "let" begin

0 commit comments

Comments
 (0)