timholy / Rebugger.jl

An expression-level debugger for Julia with a provocative command-line (REPL) user interface
Other
171 stars 18 forks source link

Cannot step into broadcasted functions. #67

Open roberthoenig opened 5 years ago

roberthoenig commented 5 years ago
julia> x = [1,2,3]
3-element Array{Int64,1}:
 1
 2
 3

julia> sin.(x)
3-element Array{Float64,1}:
 0.8414709848078965
 0.9092974268256817
 0.1411200080598672

# This is where I try to do `sin.(x)` in interpret mode.
interpret> ┌ Error: Error in the keymap
│   exception =
│    MethodError: no method matching getproperty(::typeof(sin), ::Tuple{Array{Int64,1}})
│    Closest candidates are:
│      getproperty(::Any, ::Symbol) at sysimg.jl:18
│    Stacktrace:
│     [1] #prepare_call#14(::Bool, ::Function, ::Any, ::Array{Any,1}) at /home/robert/.julia/packages/JuliaInterpreter/rYo68/src/construct.jl:228
│     [2] (::getfield(JuliaInterpreter, Symbol("#kw##prepare_call")))(::NamedTuple{(:enter_generated,),Tuple{Bool}}, ::typeof(JuliaInterpreter.prepare_call), ::Function, ::Array{Any,1}) at ./none:0
│     [3] #determine_method_for_expr#21(::Bool, ::Function, ::Expr) at /home/robert/.julia/packages/JuliaInterpreter/rYo68/src/construct.jl:490
│     [4] #determine_method_for_expr at ./none:0 [inlined]
│     [5] #enter_call_expr#22(::Bool, ::Function, ::Expr) at /home/robert/.julia/packages/JuliaInterpreter/rYo68/src/construct.jl:531
│     [6] enter_call_expr(::Expr) at /home/robert/.julia/packages/JuliaInterpreter/rYo68/src/construct.jl:530
│     [7] interpret(::REPL.LineEdit.MIState) at /home/robert/.julia/packages/Rebugger/h2LID/src/ui.jl:202
│     [8] (::getfield(Rebugger, Symbol("##24#27")))(::REPL.LineEdit.MIState, ::REPL.LineEditREPL, ::Vararg{Any,N} where N) at /home/robert/.julia/packages/Rebugger/h2LID/src/ui.jl:474
│     [9] #invokelatest#1 at ./essentials.jl:686 [inlined]
│     [10] invokelatest at ./essentials.jl:685 [inlined]
│     [11] (::getfield(REPL.LineEdit, Symbol("##27#28")){getfield(Rebugger, Symbol("##24#27")),String})(::Any, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/LineEdit.jl:1319
│     [12] prompt!(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/LineEdit.jl:2353
│     [13] run_interface(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/LineEdit.jl:2256
│     [14] run_frontend(::REPL.LineEditREPL, ::REPL.REPLBackendRef) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:1029
│     [15] run_repl(::REPL.AbstractREPL, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:191
│     [16] (::getfield(Base, Symbol("##720#722")){Bool,Bool,Bool,Bool})(::Module) at ./logging.jl:311
│     [17] #invokelatest#1 at ./essentials.jl:686 [inlined]
│     [18] invokelatest at ./essentials.jl:685 [inlined]
│     [19] macro expansion at ./logging.jl:308 [inlined]
│     [20] run_main_repl(::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at ./client.jl:330
│     [21] exec_options(::Base.JLOptions) at ./client.jl:242
│     [22] _start() at ./client.jl:421
timholy commented 5 years ago

You also can't do @which sin.(x), and it turns out to be the same issue in both cases. Just do

g(x) = sin.(x)

and then step into g(x).

kimikage commented 4 years ago

BTW, I accept that I can't step into broadcasted functions directly. However is it difficult to skip them, i.e., to avoid the errors? Probably the problem should be solved within JuliaInterpreter, but I can easily imagine the performance degradation.