Skip to content

signature(::Method) on a generated function errors #23

@oxinabox

Description

@oxinabox

However, signature(type_tuple) works.

julia> @generated foo(x) = :(1+1)
foo (generic function with 1 method)

julia> signature(only(methods(foo)).sig)
Dict{Symbol, Any} with 2 entries:
  :name => :(op::typeof(foo))
  :args => Expr[:(x1::Any)]

julia> signature(only(methods(foo)))
ERROR: Method is @generated; try `code_lowered` instead.
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] uncompressed_ir(m::Method)
   @ Base ./reflection.jl:988
 [3] slot_names
   @ ~/JuliaEnvs/ChainRulesWorld/ExprTools.jl/src/method.jl:106 [inlined]
 [4] argument_names(m::Method)
   @ ExprTools ~/JuliaEnvs/ChainRulesWorld/ExprTools.jl/src/method.jl:111
 [5] arguments(m::Method, sig::Type)
   @ ExprTools ~/JuliaEnvs/ChainRulesWorld/ExprTools.jl/src/method.jl:182
 [6] signature(m::Method; extra_hygiene::Bool)
   @ ExprTools ~/JuliaEnvs/ChainRulesWorld/ExprTools.jl/src/method.jl:45
 [7] signature(m::Method)
   @ ExprTools ~/JuliaEnvs/ChainRulesWorld/ExprTools.jl/src/method.jl:40
 [8] top-level scope
   @ REPL[38]:1

The error is to do with how we are finding the names of the arguments.
which is not done for if we are doing it from the type-tuple.
However, there must be another way since the names are displayed by methods

julia> methods(foo)
# 1 method for generic function "foo":
[1] foo(x) in Main at REPL[36]:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions