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

Opaque Closures not supported. #537

Closed
oscardssmith opened this issue Jun 29, 2022 · 3 comments · Fixed by #593
Closed

Opaque Closures not supported. #537

oscardssmith opened this issue Jun 29, 2022 · 3 comments · Fixed by #593

Comments

@oscardssmith
Copy link
Contributor

oscardssmith commented Jun 29, 2022

The following code

isa_control_flow(::Type{T}, x) where {T} = isa(x, T) ? x : T(x)
@interpret Diffractor.PrimeDerivativeBack(x->sum(isa_control_flow(Matrix{Float64}, x)))(Float32[1 2;])

fails with

ERROR: BoundsError: attempt to access Core.Argument at index [2]
Stacktrace:
  [1] maybe_evaluate_builtin(frame::Frame, call_expr::Expr, expand::Bool)
    @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/builtins.jl:177
  [2] evaluate_call_recurse!(recurse::Any, frame::Frame, call_expr::Expr; enter_generated::Bool)
    @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:230
  [3] evaluate_call_recurse!(recurse::Any, frame::Frame, call_expr::Expr)
    @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:226
  [4] eval_rhs(recurse::Any, frame::Frame, node::Expr)
    @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:399
  [5] step_expr!(recurse::Any, frame::Frame, node::Any, istoplevel::Bool)
    @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:552
  [6] step_expr!(recurse::Any, frame::Frame, istoplevel::Bool)
    @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:602
  [7] finish!(recurse::Any, frame::Frame, istoplevel::Bool)
    @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/commands.jl:14
  [8] finish_and_return!(recurse::Any, frame::Frame, istoplevel::Bool)
    @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/commands.jl:30
  [9] evaluate_call_recurse!(recurse::Any, frame::Frame, call_expr::Expr; enter_generated::Bool)
    @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:266
 [10] evaluate_call_recurse!(recurse::Any, frame::Frame, call_expr::Expr)
    @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:226
 [11] eval_rhs(recurse::Any, frame::Frame, node::Expr)
    @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:399
 [12] step_expr!(recurse::Any, frame::Frame, node::Any, istoplevel::Bool)
    @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:552
 [13] step_expr!(recurse::Any, frame::Frame, istoplevel::Bool)
    @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:602
 [14] finish!(recurse::Any, frame::Frame, istoplevel::Bool)
    @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/commands.jl:14
 [15] finish_and_return!(recurse::Any, frame::Frame, istoplevel::Bool)
    @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/commands.jl:30
 [16] evaluate_call_recurse!(recurse::Any, frame::Frame, call_expr::Expr; enter_generated::Bool)
    @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:266
 [17] evaluate_call_recurse!(recurse::Any, frame::Frame, call_expr::Expr)
    @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:226
 [18] eval_rhs(recurse::Any, frame::Frame, node::Expr)
    @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:399
 [19] step_expr!(recurse::Any, frame::Frame, node::Any, istoplevel::Bool)
    @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:473
 [20] step_expr!(recurse::Any, frame::Frame, istoplevel::Bool)
    @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/interpret.jl:602
 [21] finish!(recurse::Any, frame::Frame, istoplevel::Bool)
    @ JuliaInterpreter ~/.julia/dev/JuliaInterpreter/src/commands.jl:14
 [22] finish_and_return!
    @ ~/.julia/dev/JuliaInterpreter/src/commands.jl:30 [inlined]
 [23] finish_and_return! (repeats 2 times)
    @ ~/.julia/dev/JuliaInterpreter/src/commands.jl:34 [inlined]
 [24] macro expansion
    @ ~/.julia/dev/JuliaInterpreter/src/construct.jl:748 [inlined]
 [25] top-level scope
    @ REPL[23]:2

while without the @interpret it runs correctly.

(this behavior can be seen on both 1.7 and master versions of Julia).

@oscardssmith oscardssmith changed the title Bounds error running @interpret with Revise. Bounds error running @interpret with Diffractor. Jun 29, 2022
@simeonschaub
Copy link
Collaborator

I'm not sure if it's the cause for this particular error, but note that there currently isn't any support for opaque closures in JuliaInterpreter. Would be good to add that eventually

@oscardssmith
Copy link
Contributor Author

ah, that very well might be the problem.

@oscardssmith
Copy link
Contributor Author

theoretically, you could just convert them into regular closures, right?

@oscardssmith oscardssmith changed the title Bounds error running @interpret with Diffractor. Opaque Closures not supported. Aug 17, 2022
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 a pull request may close this issue.

2 participants