-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
String keys should be allowed in **kwargs #554
Comments
PR accepted to improve this, note that it needs to still forbid hashes and only things that |
Is the PR merged? If so what version do I need to upgrade past to get this fix? |
The previous comment was a "a pr would be accepted", no one has worked on this as far as I know |
I've submitted a PR for fixing this. Verified the test case given in this issue passes on my branch and fails on main. |
Ok so after doing some more digging, this fix is really just reverting the changes made here #366, which was treating kw args differently based on whether they were symbol keys or not. And that was done to support a specific method signature/invocation that ruby doesn't allow anymore:
Another question I have is that ruby will happily accept pretty much anything as the hash key for a kw arg splat. You can pass kwarg params with keys of an integer ( |
This code is designed to seperate hash last arguments from keywords because Ruby 2.x did this, so there are parts of our verification for arguments that depend on the old behaviour. The PR you've made is a good start but the behaviour needs to be conditional based on Ruby version. |
Subject of the issue
Ruby 2.7 introduce the feature of last-argument non-specified keyword argument
**kwargs
in method signatures. In this particular kind of keyword argument, String keys are allowed. But in this library'sMethodSignature
logic, we're counting on keyword arguments of any kind always being Symbol keys (1, 2). So in the case of**kwargs
with String keys, we misinterpret them and treat them as intended for a positional argument.This issue is similar to #522, but I believe it's not addressed by the WIP #537, so I figured I'd open a separate issue to highlight it.
Your environment
Steps to reproduce
Run the following file:
Expected behavior
The spec should pass.
Actual behavior
Fails with the following error:
Note that this passes if I change
'foo' => 'bar'
to:foo => 'bar'
.The text was updated successfully, but these errors were encountered: