Skip to content

Commit 15a0c6f

Browse files
authored
Don't look up invoke args twice (#442)
`evaluate_call_recurse!` calls `maybe_evaluate_builtin`, and if that doesn't return a `Some{Any}`, it uses the output as the new `call_expr`. The next thing it does is look up the args. Consequently, to avoid double-lookup, our expansion of `invoke` should return the non-looked-up arguments. Fixes #441 Closes #440
1 parent 9062ee2 commit 15a0c6f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/builtins.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,11 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
177177
return Some{Any}(ifelse(getargs(args, frame)...))
178178
end
179179
elseif f === invoke
180-
argswrapped = getargs(args, frame)
181180
if !expand
181+
argswrapped = getargs(args, frame)
182182
return Some{Any}(invoke(argswrapped...))
183183
end
184-
return Expr(:call, invoke, argswrapped...)
184+
return Expr(:call, invoke, args[2:end]...)
185185
elseif f === isa
186186
if nargs == 2
187187
return Some{Any}(isa(@lookup(frame, args[2]), @lookup(frame, args[3])))

test/interpret.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,10 @@ end
693693
f(m::AbstractMatrix{T}) where {T} = T
694694
D = Diagonal([1.0, 2.0])
695695
@test @interpret(f(D)) === f(D)
696+
697+
# issue #441
698+
flog() = @info "logging macros"
699+
@test @interpret flog() === nothing
696700
end
697701

698702
struct A396

0 commit comments

Comments
 (0)