From 76839e39bc19e3cf240f2c1a167ebcd3c37c499f Mon Sep 17 00:00:00 2001 From: Lionel Zoubritzky Date: Tue, 31 Oct 2023 03:55:42 +0100 Subject: [PATCH] Fix Expr conversion of erroneous operator dot call (#374) --- src/expr.jl | 7 +++++-- test/expr.jl | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/expr.jl b/src/expr.jl index ef5fedd0..27cadb0a 100644 --- a/src/expr.jl +++ b/src/expr.jl @@ -251,13 +251,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 elseif k == K"." && length(args) == 1 && is_operator(childheads[1]) diff --git a/test/expr.jl b/test/expr.jl index c24328e9..c9029d7b 100644 --- a/test/expr.jl +++ b/test/expr.jl @@ -428,6 +428,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