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

definition throws error on (Pair{A, B})(a, b)

Open Zentrik opened this issue 10 months ago • 0 comments

The method is defined as

@eval function (P::Type{Pair{A, B}})(@nospecialize(a), @nospecialize(b)) where {A, B}
    @inline
    return $(Expr(:new, :P, :(convert(A, a)), :(convert(B, b))))
end
(CodeTracking) julia> method = @which Pair{Int, Int}(1, 1)
Pair{A, B}(a, b) where {A, B}
     @ Base ~/.julia/juliaup/julia-1.9.2+0.x64.linux.gnu/share/julia/base/Base.jl:138

(CodeTracking) julia> definition(String, method)
ERROR: AssertionError: isexpr(wheretyp, :<:)
Stacktrace:
 [1] is_func_expr(ex::Any, meth::Method)
   @ CodeTracking /media/rag/NVME/Code/CodeTracking.jl/src/utils.jl:103
 [2] definition(#unused#::Type{String}, method::Method)
   @ CodeTracking /media/rag/NVME/Code/CodeTracking.jl/src/CodeTracking.jl:261
 [3] top-level scope
   @ REPL[208]:1

It seems like the problem is the fname is :(P::Type{Pair{A, B}}) at https://github.com/timholy/CodeTracking.jl/blob/9db8d0ea32d526cbbd5c09e6246db7c60f77774d/src/utils.jl#L76 but is :Type at https://github.com/timholy/CodeTracking.jl/blob/9db8d0ea32d526cbbd5c09e6246db7c60f77774d/src/utils.jl#L99 strip_gensym(meth.name) is :Pair.

Zentrik avatar Aug 10 '23 19:08 Zentrik