Skip to content

Commit 76839e3

Browse files
Liozouc42f
authored andcommitted
Fix Expr conversion of erroneous operator dot call (#374)
1 parent d04b1c6 commit 76839e3

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
@@ -251,13 +251,16 @@ function _internal_node_to_Expr(source, srcrange, head, childranges, childheads,
251251
# Move parameters blocks to args[2]
252252
_reorder_parameters!(args, 2)
253253
if headsym === :dotcall
254+
funcname = args[1]
254255
if is_prefix_call(head)
255256
headsym = :.
256-
args = Any[args[1], Expr(:tuple, args[2:end]...)]
257+
args = Any[funcname, Expr(:tuple, args[2:end]...)]
257258
else
258259
# operator calls
259260
headsym = :call
260-
args[1] = Symbol(".", args[1])
261+
if funcname isa Symbol
262+
args[1] = Symbol(:., funcname)
263+
end # else funcname could be an Expr(:error), just propagate it
261264
end
262265
end
263266
elseif k == K"." && length(args) == 1 && is_operator(childheads[1])

test/expr.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,9 @@
428428
@test parsestmt("f(.+)") == Expr(:call, :f, Expr(:., :+))
429429
@test parsestmt("(a, .+)") == Expr(:tuple, :a, Expr(:., :+))
430430
@test parsestmt("A.:.+") == Expr(:., :A, QuoteNode(Symbol(".+")))
431+
432+
# Issue #341
433+
@test parsestmt("./x", ignore_errors=true) == Expr(:call, Expr(:error, Expr(:., :/)), :x)
431434
end
432435

433436
@testset "let" begin

0 commit comments

Comments
 (0)