From 3b53ef261db135c789ec26ca131a3c93458633ed Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Sun, 18 Jul 2021 06:39:48 -0500 Subject: [PATCH 1/3] Don't splat in call to `append_any` Fixes https://github.com/timholy/Revise.jl/issues/625 --- Project.toml | 2 +- src/builtins.jl | 2 +- test/dummy_file.jl | 2 ++ test/interpret.jl | 7 +++++++ 4 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 test/dummy_file.jl diff --git a/Project.toml b/Project.toml index 4537d7d7..b95f25ac 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "JuliaInterpreter" uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a" -version = "0.8.18" +version = "0.8.19" [deps] CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2" diff --git a/src/builtins.jl b/src/builtins.jl index ff85eb8e..6160e804 100644 --- a/src/builtins.jl +++ b/src/builtins.jl @@ -70,7 +70,7 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool) end new_expr = Expr(:call, argswrapped[1]) popfirst!(argswrapped) - argsflat = append_any(argswrapped...) + argsflat = append_any(argswrapped) for x in argsflat push!(new_expr.args, (isa(x, Symbol) || isa(x, Expr) || isa(x, QuoteNode)) ? QuoteNode(x) : x) end diff --git a/test/dummy_file.jl b/test/dummy_file.jl new file mode 100644 index 00000000..7c77efe6 --- /dev/null +++ b/test/dummy_file.jl @@ -0,0 +1,2 @@ +# Don't change the value below, it's used in an `include` test +55 diff --git a/test/interpret.jl b/test/interpret.jl index afd42845..445203c9 100644 --- a/test/interpret.jl +++ b/test/interpret.jl @@ -811,3 +811,10 @@ end JuliaInterpreter.finish_and_return!(Frame(m, ex), true) @test isdefined(m, :foo) end + +# Related to fixing https://github.com/timholy/Revise.jl/issues/625 +module ForInclude end +@testset "include" begin + ex = :(include("dummy_file.jl")) + @test JuliaInterpreter.finish_and_return!(Frame(ForInclude, ex), true) == 55 +end From dc77b1976c696309e612f33bd7101702ed829de6 Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Tue, 20 Jul 2021 09:31:25 +0200 Subject: [PATCH 2/3] preempt args iteration only for _apply_iterate --- bin/generate_builtins.jl | 11 +++++------ src/builtins.jl | 33 +++++++++++++++------------------ 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/bin/generate_builtins.jl b/bin/generate_builtins.jl index 1b860547..40393cec 100644 --- a/bin/generate_builtins.jl +++ b/bin/generate_builtins.jl @@ -146,14 +146,13 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool) print(io, """ $head f === $fstr - argswrapped = getargs(args, frame) + args = getargs(args, frame) if !expand - return Some{Any}($fstr(argswrapped...)) + return Some{Any}($fstr(args...)) end - new_expr = Expr(:call, argswrapped[1]) - popfirst!(argswrapped) - argsflat = append_any(argswrapped...) - for x in argsflat + new_expr = Expr(:call, args[1]) + popfirst!(args) + for x in args push!(new_expr.args, (isa(x, Symbol) || isa(x, Expr) || isa(x, QuoteNode)) ? QuoteNode(x) : x) end return new_expr diff --git a/src/builtins.jl b/src/builtins.jl index 6160e804..599f6604 100644 --- a/src/builtins.jl +++ b/src/builtins.jl @@ -52,38 +52,35 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool) return Some{Any}(===(getargs(args, frame)...)) end elseif f === Core._apply - argswrapped = getargs(args, frame) + args = getargs(args, frame) if !expand - return Some{Any}(Core._apply(argswrapped...)) + return Some{Any}(Core._apply(args...)) end - new_expr = Expr(:call, argswrapped[1]) - popfirst!(argswrapped) - argsflat = append_any(argswrapped...) - for x in argsflat + new_expr = Expr(:call, args[1]) + popfirst!(args) + for x in args push!(new_expr.args, (isa(x, Symbol) || isa(x, Expr) || isa(x, QuoteNode)) ? QuoteNode(x) : x) end return new_expr elseif @static isdefined(Core, :_call_latest) ? f === Core._call_latest : false - argswrapped = getargs(args, frame) + args = getargs(args, frame) if !expand - return Some{Any}(Core._call_latest(argswrapped...)) + return Some{Any}(Core._call_latest(args...)) end - new_expr = Expr(:call, argswrapped[1]) - popfirst!(argswrapped) - argsflat = append_any(argswrapped) - for x in argsflat + new_expr = Expr(:call, args[1]) + popfirst!(args) + for x in args push!(new_expr.args, (isa(x, Symbol) || isa(x, Expr) || isa(x, QuoteNode)) ? QuoteNode(x) : x) end return new_expr elseif @static isdefined(Core, :_apply_latest) ? f === Core._apply_latest : false - argswrapped = getargs(args, frame) + args = getargs(args, frame) if !expand - return Some{Any}(Core._apply_latest(argswrapped...)) + return Some{Any}(Core._apply_latest(args...)) end - new_expr = Expr(:call, argswrapped[1]) - popfirst!(argswrapped) - argsflat = append_any(argswrapped...) - for x in argsflat + new_expr = Expr(:call, args[1]) + popfirst!(args) + for x in args push!(new_expr.args, (isa(x, Symbol) || isa(x, Expr) || isa(x, QuoteNode)) ? QuoteNode(x) : x) end return new_expr From 84bd33fdead335e4bb1bb80151052e12bbc0b6dd Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Tue, 20 Jul 2021 09:46:32 +0200 Subject: [PATCH 3/3] Fix Core._apply --- src/builtins.jl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/builtins.jl b/src/builtins.jl index 599f6604..2aa9319d 100644 --- a/src/builtins.jl +++ b/src/builtins.jl @@ -52,13 +52,14 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool) return Some{Any}(===(getargs(args, frame)...)) end elseif f === Core._apply - args = getargs(args, frame) + argswrapped = getargs(args, frame) if !expand - return Some{Any}(Core._apply(args...)) + return Some{Any}(Core._apply(argswrapped...)) end - new_expr = Expr(:call, args[1]) - popfirst!(args) - for x in args + new_expr = Expr(:call, argswrapped[1]) + popfirst!(argswrapped) + argsflat = append_any(argswrapped...) + for x in argsflat push!(new_expr.args, (isa(x, Symbol) || isa(x, Expr) || isa(x, QuoteNode)) ? QuoteNode(x) : x) end return new_expr