-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Export at-invoke
and make it use Core.Typeof
instead of Any
#45807
Conversation
Converting to draft until I figure out what's up with the build failure this causes. My guess is I need to pull some particular symbol into |
Related to #44902? |
Ah, yes indeed! Thanks for the link. |
Currently this breaks a test:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we also want to export Base.@invokelatest
also
on this opportunity?
We could, although the corresponding function, |
Makes sense. Let's leave it as is for now, I don't want to block this PR by that. |
The macro was introduced in Julia 1.7 but was not exported. Previously, when an argument's type was unspecified, the type used was `Any`. This doesn't play well with types passed as arguments: for example, `x % T` has different meanings for `T` a type or a value, so if `T` is left untyped in `at-invoke rem(x::S, T)`, the method to call is ambiguous. On the other hand, if the macro expands `rem(x::S, T)` to use `Core.Typeof(T)`, the resulting expression will interpret `T` as a type and the likelihood of method ambiguities is significantly decreased.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retriggered CI. Once they pass this should be good to go.
`@invoke f(arg1::T, arg2)` will be expanded into `invoke(f, Tuple{T,Any}, arg1, arg2)`. | ||
Provides a convenient way to call [`invoke`](@ref) by expanding | ||
`@invoke f(arg1::T1, arg2::T2; kwargs...)` to `invoke(f, Tuple{T1,T2}, arg1, arg2; kwargs...)`. | ||
When an argument's type annotation is omitted, it's replaced with `Core.Typeof` that argument. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This documentation is not particularly helpful, since Core.Typeof
is currently undocumented.
…liaLang#45807) The macro was introduced in Julia 1.7 but was not exported. Previously, when an argument's type was unspecified, the type used was `Any`. This doesn't play well with types passed as arguments: for example, `x % T` has different meanings for `T` a type or a value, so if `T` is left untyped in `at-invoke rem(x::S, T)`, the method to call is ambiguous. On the other hand, if the macro expands `rem(x::S, T)` to use `Core.Typeof(T)`, the resulting expression will interpret `T` as a type and the likelihood of method ambiguities is significantly decreased.
The macro was introduced in Julia 1.7 but was not exported. Previously, when an argument's type was unspecified, the type used was
Any
. This doesn't play well with types passed as arguments: for example,x % T
has different meanings forT
a type or a value, so ifT
is left untyped in@invoke rem(x::S, T)
, the method to call is ambiguous. On the other hand, if the macro expandsrem(x::S, T)
to useCore.Typeof(T)
, the resulting expression will interpretT
as a type and the likelihood of method ambiguities is significantly decreased.As pointed out by Stefan in Slack.