Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't splat in call to append_any #490

Merged
merged 3 commits into from
Jul 28, 2021
Merged

Conversation

timholy
Copy link
Member

@timholy timholy commented Jul 18, 2021

@codecov
Copy link

codecov bot commented Jul 18, 2021

Codecov Report

Merging #490 (84bd33f) into master (841a613) will increase coverage by 0.06%.
The diff coverage is 80.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #490      +/-   ##
==========================================
+ Coverage   86.86%   86.93%   +0.06%     
==========================================
  Files          12       12              
  Lines        2338     2334       -4     
==========================================
- Hits         2031     2029       -2     
+ Misses        307      305       -2     
Impacted Files Coverage Δ
src/builtins.jl 76.56% <80.00%> (+0.78%) ⬆️
src/utils.jl 86.68% <0.00%> (-0.04%) ⬇️
src/interpret.jl 86.19% <0.00%> (-0.04%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 841a613...84bd33f. Read the comment docs.

@timholy
Copy link
Member Author

timholy commented Jul 18, 2021

Here's the full stacktrace on master with a @show argswrapped right before the call to append_any:

argswrapped = Any[Main.ForInclude, "dummy_file.jl"]
include: Error During Test at REPL[4]:3
  Test threw exception
  Expression: JuliaInterpreter.finish_and_return!(Frame(ForInclude, ex), true) == 55
  MethodError: no method matching iterate(::Module)
  Closest candidates are:
    iterate(::Union{LinRange, StepRangeLen}) at range.jl:664
    iterate(::Union{LinRange, StepRangeLen}, ::Int64) at range.jl:664
    iterate(::T) where T<:Union{Base.KeySet{var"#s79", var"#s78"} where {var"#s79", var"#s78"<:Dict}, Base.ValueIterator{var"#s77"} where var"#s77"<:Dict} at dict.jl:693
    ...
  Stacktrace:
    [1] append_any(::Any, ::Vararg{Any, N} where N)
      @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/packagedef.jl:31
    [2] maybe_evaluate_builtin(frame::Frame, call_expr::Expr, expand::Bool)
      @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/builtins.jl:74
    [3] evaluate_call_recurse!(recurse::Any, frame::Frame, call_expr::Expr; enter_generated::Bool)
      @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:204
    [4] evaluate_call_recurse!
      @ ~/.julia/dev/JuliaInterpreter/src/interpret.jl:201 [inlined]
    [5] eval_rhs(recurse::Any, frame::Frame, node::Expr)
      @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:400
    [6] step_expr!(recurse::Any, frame::Frame, node::Any, istoplevel::Bool)
      @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:546
    [7] step_expr!(recurse::Any, frame::Frame, istoplevel::Bool)
      @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:596
    [8] finish!(recurse::Any, frame::Frame, istoplevel::Bool)
      @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/commands.jl:14
    [9] finish_and_return!
      @ ~/.julia/dev/JuliaInterpreter/src/commands.jl:30 [inlined]
   [10] evaluate_call_recurse!(recurse::Any, frame::Frame, call_expr::Expr; enter_generated::Bool)
      @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:240
   [11] evaluate_call_recurse!
      @ ~/.julia/dev/JuliaInterpreter/src/interpret.jl:201 [inlined]
   [12] eval_rhs(recurse::Any, frame::Frame, node::Expr)
      @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:400
   [13] step_expr!(recurse::Any, frame::Frame, node::Any, istoplevel::Bool)
      @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:541
   [14] step_expr!(recurse::Any, frame::Frame, istoplevel::Bool)
      @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:596
   [15] finish!(recurse::Any, frame::Frame, istoplevel::Bool)
      @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/commands.jl:14
   [16] finish_and_return!
      @ ~/.julia/dev/JuliaInterpreter/src/commands.jl:30 [inlined]
   [17] finish_and_return!(frame::Frame, istoplevel::Bool)
      @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/commands.jl:34
   [18] macro expansion
      @ REPL[4]:3 [inlined]
   [19] macro expansion
      @ ~/src/julia-1/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
   [20] top-level scope
      @ REPL[4]:2
Test Summary: | Error  Total
include       |     1      1
ERROR: Some tests did not pass: 0 passed, 0 failed, 1 errored, 0 broken.

Do we need to remove more of those splats? I confess to not looking closely.

@pfitzseb
Copy link
Member

pfitzseb commented Jul 19, 2021

IIUC we only want the append_any(arargswrapped...) for _apply_iterate, because that's where we handle the implied iterate call ourselves. So

diff --git a/bin/generate_builtins.jl b/bin/generate_builtins.jl
index 1b86054..40393ce 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 6160e80..599f660 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

is probably correct, but unfortunately only the test added here actually hits any of that code.

@timholy
Copy link
Member Author

timholy commented Jul 20, 2021

Feel free to push that diff to this branch and I'll look into adding tests.

@pfitzseb
Copy link
Member

Can we get this merged?

@KristofferC
Copy link
Member

👍

@pfitzseb pfitzseb merged commit 38025d7 into master Jul 28, 2021
@pfitzseb pfitzseb deleted the teh/testfail_promote_typeof branch July 30, 2021 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ERROR: MethodError: no method matching iterate(::Module) when including in Julia 1.6.x
4 participants