A bug in ASTInterpreter2?


Here is a MWE:

macro add(num)
    addnum = parse("add"*string(num))
    return esc(quote
        $num(x...) = $addnum(x...)


function addone(k::Integer)
  k = k + 1
  return k

function addtwo(k::Integer)
  k = k + 2
  return k

I expected to be able to step into function addone. But, it was totally skipped.

julia> @enter one(2)
In one(x) at /home/chobbes/code/test_macro.jl:4
4         $num(x...) = $addnum(x...)
5     end)
6 end

About to run: (Core._apply)(addone, (2,))
1|debug > s
In one(x) at /home/chobbes/code/test_macro.jl:4
4         $num(x...) = $addnum(x...)
5     end)
6 end

About to run: return 3
1|debug > 


If the splatting ... is removed in the above code, the ASTInterpreter then would step in the function.


This problem wasn’t seen with v5.0 + ASTInterpreter.


What happens if you run julia as julia --inline=no?


Tried. No difference.


Today I found even more cases where ASTInterpreter2 fails to step in a function. I wish I could have time to work out a MWE for each case. Any fix (or botch) is much appreciated!


Just did some more experiments - 90% of the erroneous skippings of step-in are caused by misinterpretation of splatting ....


You are much more likely to get it fixed sooner if you make an effort to produce a MWE and open an issue.


This is fixed now: https://github.com/Keno/ASTInterpreter2.jl/commit/72b96acba8c9ccb1a52ef7f43e5c62bcd2fc3916

but @Tamas_Papp is right, issues are better, because that way I won’t forget.


Thanks a lot, @Keno. I wasn’t 100% sure if it is a bug. An issue can’t be deleted on Github. Don’t want to contaminate the repo by a false issue in case I misjudge.


After checking out the commits pushed to ASTInterpret2 and DebuggerFramework in the last few days, debugger ceased to work. Macro @enter throws an error message:

ERROR: UndefVarError: __module__ not defined

Am I missing something? Thanks!


No, I broke something. Please use the tagged version for your day to day needs.


Thanks, @Keno.


@Keno ASTInterpreter2 looks problematic with slurping too, like splatting, though I’m not 100% sure. Here is an MWE:

function add(a,b;AddOneMore::Int=0)
  s = a+b
  if AddOneMore ≠ 0
    s += 1
  return s

plus(a,b;kwds...) = add(a,b;kwds...)

When I try to @enter plus, I’m bounced:

@enter plus(1,2;AddOneMore=1)
ERROR: UndefRefError: access to undefined reference
 [1] lookup_var(::ASTInterpreter2.JuliaStackFrame, ::SSAValue) at /home/chobbes/Documents/git/ASTInterpreter2.jl/src/interpret.jl:3
 [2] evaluate_call(::ASTInterpreter2.JuliaStackFrame, ::Expr) at /home/chobbes/Documents/git/ASTInterpreter2.jl/src/interpret.jl:32
 [3] _step_expr(::ASTInterpreter2.JuliaStackFrame, ::ASTInterpreter2.JuliaProgramCounter) at /home/chobbes/Documents/git/ASTInterpreter2.jl/src/interpret.jl:87
 [4] next_until!(::ASTInterpreter2.##7#8, ::ASTInterpreter2.JuliaStackFrame, ::ASTInterpreter2.JuliaProgramCounter) at /home/chobbes/Documents/git/ASTInterpreter2.jl/src/interpret.jl:144
 [5] maybe_step_through_wrapper!(::Array{ASTInterpreter2.JuliaStackFrame,1}) at /home/chobbes/Documents/git/ASTInterpreter2.jl/src/ASTInterpreter2.jl:429


If you open issues on Github, they are less likely to get lost and you make them easier to manager for the author.