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

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

Open
oxinabox opened this issue Jul 6, 2021 · 0 comments
Open

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

oxinabox opened this issue Jul 6, 2021 · 0 comments

Comments

@oxinabox
Copy link
Member

oxinabox commented Jul 6, 2021

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
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

No branches or pull requests

1 participant