Fixes #6564. Passing **kw to def with no args should work#6623
Merged
enebo merged 4 commits intojruby:masterfrom Mar 24, 2021
Merged
Fixes #6564. Passing **kw to def with no args should work#6623enebo merged 4 commits intojruby:masterfrom
enebo merged 4 commits intojruby:masterfrom
Conversation
and the kwargs rest check was duplicated...no more.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes the problem reported in #6564.
It introduces a problem by not passing:
In Ruby 2.6 this will receive the empty hash as parameter 'a' in 'bar'. In Ruby 3.0 this will be an arity mismatch. I opted to break 2.6 compatibility because bar(**{}, **{}) will arity error (which is inconsistent) and 3.0 corrects this inconsistency. I am comfortable with encouraging people to not expect this behaviour. Anyone doing this will need to update their library/application anyways.
The mechanics of the fix is to look at any **a passed at the callsite and if it is empty we will not pass it along. If it is not empty we do. This is option number 2 in #6564. Not ideal in that we add some more interpreted logic for callsites with **a and it will generate more bytecode as well. It is ideal in that it did not require us to rewrite all keyword argument processing. Later work (like the other two options discussed in the issue) can eventually end up removing this.
As a note of other futures: