-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Slurped kwargs with a type are an error in Julia 1.7 #43625
Comments
This was definitely a bug before; for example
The declaration expression got stringified and used as the name of the argument! So this really ought to be an error. |
Could we not just support this properly though? |
Looks like it was only a method printing bug, because it worked fine nevertheless... julia> f(;kwargs::Any...) = kwargs;
julia> f(; x=1)
pairs(::NamedTuple) with 1 entry:
:x => 1
julia> methods(f)
# 1 method for generic function "f":
[1] f(; (:: kwargs Any)...) in Main at REPL[5]:1 On Julia 1.5 |
For reference, caused by #39593. But it looks like this was a side effect and not an explicitly intended change there.
I think that would be a bit odd and not very useful... how do you imagine it working? It would be easy enough to put in a shim to ignore the type declaration. It's still a bug though; we used to let you put any type whatsoever there and it had no effect. Is it really that difficult to fix the macro? |
We have to either make a breaking MacroTools release, or minimally add a |
We've fixed the macro, so this is just for the record. If we're looking for a behavior for I feel this is a consistent behavior that would simplify expression manipulation. |
Well, this is really a discussion for julialang, right? Personally, I can't think of a situation where |
It is slightly uncertain right now if the |
And that meaning is further complicated by invariance, since it is currently ambiguous (for Tuples) which subtyping definition is being used. So (to agree with the behavior of Tuple), it is potentially the case that |
On Julia 1.7.1, slurped kwargs can no longer have a type declaration:
This is a headache for us at FluxML/MacroTools.jl#177. Was that intentional? I wonder if this wasn't an unintended side-effect of #40977
The text was updated successfully, but these errors were encountered: