Skip to content

Commit

Permalink
Fix Expr conversion of erroneous operator dot call (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
Liozou committed Oct 31, 2023
1 parent 4d990b6 commit 48ddfc6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,16 @@ function _internal_node_to_Expr(source, srcrange, head, childranges, childheads,
# Move parameters blocks to args[2]
_reorder_parameters!(args, 2)
if headsym === :dotcall
funcname = args[1]
if is_prefix_call(head)
headsym = :.
args = Any[args[1], Expr(:tuple, args[2:end]...)]
args = Any[funcname, Expr(:tuple, args[2:end]...)]
else
# operator calls
headsym = :call
args[1] = Symbol(".", args[1])
if funcname isa Symbol
args[1] = Symbol(:., funcname)
end # else funcname could be an Expr(:error), just propagate it
end
end
if do_lambda isa Expr
Expand Down
3 changes: 3 additions & 0 deletions test/expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,9 @@
@test parsestmt("f(.+)") == Expr(:call, :f, Expr(:., :+))
@test parsestmt("(a, .+)") == Expr(:tuple, :a, Expr(:., :+))
@test parsestmt("A.:.+") == Expr(:., :A, QuoteNode(Symbol(".+")))

# Issue #341
@test parsestmt("./x", ignore_errors=true) == Expr(:call, Expr(:error, Expr(:., :/)), :x)
end

@testset "let" begin
Expand Down

0 comments on commit 48ddfc6

Please sign in to comment.