JuliaInterpreter.jl icon indicating copy to clipboard operation
JuliaInterpreter.jl copied to clipboard

Fail with hcat and vcat

Open kuanxu opened this issue 8 years ago • 4 comments

julia> @enter [1; 2]
typeof(f) = Int64
1
Tuple{Int64}
ERROR: no method found for the specified argument types
Stacktrace:
 [1] which(::Any, ::Any) at ./reflection.jl:823
 [2] #determine_method_for_expr#23(::Bool, ::Function, ::Expr) at /home/kx/git/ASTInterpreter2.jl/src/ASTInterpreter2.jl:321
 [3] (::ASTInterpreter2.#kw##determine_method_for_expr)(::Array{Any,1}, ::ASTInterpreter2.#determine_method_for_expr, ::Expr) at ./<missing>:0
 [4] #enter_call_expr#26(::Bool, ::Function, ::Expr) at /home/kx/git/ASTInterpreter2.jl/src/ASTInterpreter2.jl:406
 [5] enter_call_expr(::Expr) at /home/kx/git/ASTInterpreter2.jl/src/ASTInterpreter2.jl:406

julia> @enter [1 2]
typeof(f) = Int64
1
Tuple{Int64}
ERROR: no method found for the specified argument types
Stacktrace:
 [1] which(::Any, ::Any) at ./reflection.jl:823
 [2] #determine_method_for_expr#23(::Bool, ::Function, ::Expr) at /home/kx/git/ASTInterpreter2.jl/src/ASTInterpreter2.jl:321
 [3] (::ASTInterpreter2.#kw##determine_method_for_expr)(::Array{Any,1}, ::ASTInterpreter2.#determine_method_for_expr, ::Expr) at ./<missing>:0
 [4] #enter_call_expr#26(::Bool, ::Function, ::Expr) at /home/kx/git/ASTInterpreter2.jl/src/ASTInterpreter2.jl:406
 [5] enter_call_expr(::Expr) at /home/kx/git/ASTInterpreter2.jl/src/ASTInterpreter2.jl:406

Don't have this issue with cc05800c. I guess it's introduced yesterday. Thanks.

kuanxu avatar Nov 29 '17 13:11 kuanxu

Still happens with #37

julia> ASTInterpreter2.@enter [1; 2]
typeof(f) = Int64
1
Tuple{Int64}
ERROR: no unique matching method found for the specified argument types
Stacktrace:
 [1] which(::Any, ::Any) at .\reflection.jl:1002
 [2] #prepare_call#24(::Bool, ::Function, ::Int64, ::Array{Any,1}) at C:\Users\Kristoffer\ASTInterpreter2.jl\src\ASTInterpreter2.jl:458
 [3] (::getfield(ASTInterpreter2, Symbol("#kw##prepare_call")))(::NamedTuple{(:enter_generated,),Tuple{Bool}}, ::typeof(ASTInterpreter2.prepare_call), ::Int64, ::Array{Any,1}) at
.\none:0
 [4] #determine_method_for_expr#25(::Bool, ::Function, ::Expr) at C:\Users\Kristoffer\ASTInterpreter2.jl\src\ASTInterpreter2.jl:523
 [5] #determine_method_for_expr at .\none:0 [inlined]
 [6] #enter_call_expr#28(::Bool, ::Function, ::Expr) at C:\Users\Kristoffer\ASTInterpreter2.jl\src\ASTInterpreter2.jl:766
 [7] enter_call_expr(::Expr) at C:\Users\Kristoffer\ASTInterpreter2.jl\src\ASTInterpreter2.jl:766
 [8] top-level scope at C:\Users\Kristoffer\ASTInterpreter2.jl\src\ASTInterpreter2.jl:903

KristofferC avatar Jan 27 '19 14:01 KristofferC

To solve this properly we need to basically reimplement the manual lowering like in:

https://github.com/JuliaLang/julia/blob/37e49ce22bbe81d9e30126c71ffda940839a0727/stdlib/InteractiveUtils/src/macros.jl#L9-L90

KristofferC avatar Feb 21 '19 14:02 KristofferC

If we just switched to

modexs, _ = JuliaInterpreter.prepare_toplevel(Main, ex)

and then did the "usual toplevel think" I think this is solved. The question, I guess, is what does @enter mean if ex is a :block like

x, y = 10, 20
gcd(x, y)

timholy avatar Feb 21 '19 20:02 timholy

On my current version I see

julia>  @enter [1; 2]
In ##thunk#281() at none:1
>1  1 ─ %1 = Base.vcat(1, 2)
 2  └──      return %1

About to run: (vcat)(1, 2)
1|debug> c
2-element Vector{Int64}:
 1
 2

julia>  @enter [1 2]
In ##thunk#282() at none:1
>1  1 ─ %1 = Base.hcat(1, 2)
 2  └──      return %1

About to run: (hcat)(1, 2)
1|debug> c
1×2 Matrix{Int64}:
 1  2

Is this OK?

goerch avatar Dec 08 '21 12:12 goerch