-
-
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
Better error needed for misuse of keyword args #9972
Comments
+1 for making this a parser error. Note that the |
Note the following is valid:
|
That does complicate it. Then maybe a couple runtime asserts can be added to check that whatever is passed is iterable with at least 2 elements, and the first is a symbol? I realize it's probably a rarely seen case but the current error really does confuse way more than help to debug. |
I just ran into this when generating function calls with named arguments from a macro. A minimal example: julia> f(;x=1) = x+1
f (generic function with 1 method)
julia> macro m(named...)
esc(:(f(;$(named...))))
end
julia> @m x=1
ERROR: BoundsError
in anonymous at no file
julia> @m :x=>1
2
julia> macroexpand(:(@m x=1))
:(f(; x = 1))
What makes the |
+1. I guess a parsing error makes the most sense. Mostly, I'd just like the error to remind me what the signature is vs what it received, cause I'm dumb and have been confused by this a couple times. |
I had a mental lapse and forgot to use the keyword argument name when invoking a function. I ended being baffled for a good five minutes before realizing what happened.
This seems like something the parser should be able to pick up instantly.
The text was updated successfully, but these errors were encountered: