Skip to content

Unflag a splatted flagged hash if the method doesn't use ruby2_keywords#5645

Closed
jeremyevans wants to merge 1 commit into
ruby:masterfrom
jeremyevans:unflag-splatted-flagged-hash-18625
Closed

Unflag a splatted flagged hash if the method doesn't use ruby2_keywords#5645
jeremyevans wants to merge 1 commit into
ruby:masterfrom
jeremyevans:unflag-splatted-flagged-hash-18625

Conversation

@jeremyevans

Copy link
Copy Markdown
Contributor

For a method such as:

def foo(*callee_args) end

If this method is called with a flagged hash (created by a method
flagged with ruby2_keywords), this previously passed the hash
through without modification. With this change, it acts as if the
last hash was passed as keywords, so a call to:

foo(*caller_args)

where the last element of caller_args is a flagged hash, will be
treated as:

foo(*caller_args[0...-1], **caller_args[-1])

As a result, inside foo, callee_args[-1] is an unflagged duplicate
of caller_args[-1] (all other elements of callee_args match
caller_args).

Fixes [Bug #18625]

For a method such as:

  def foo(*callee_args) end

If this method is called with a flagged hash (created by a method
flagged with ruby2_keywords), this previously passed the hash
through without modification.  With this change, it acts as if the
last hash was passed as keywords, so a call to:

  foo(*caller_args)

where the last element of caller_args is a flagged hash, will be
treated as:

  foo(*caller_args[0...-1], **caller_args[-1])

As a result, inside foo, callee_args[-1] is an unflagged duplicate
of caller_args[-1] (all other elements of callee_args match
caller_args).

Fixes [Bug #18625]
@jeremyevans jeremyevans force-pushed the unflag-splatted-flagged-hash-18625 branch from 7817cfb to 330dcbf Compare March 24, 2022 17:53
@eregon

eregon commented Mar 30, 2022

Copy link
Copy Markdown
Member

I wonder why the CI didn't run on the latest commit.
I updated #5684 to use rspec main for all rspec gems, hopefully that works (updating just one gem fails at bundle time).

@eregon

eregon commented Apr 4, 2022

Copy link
Copy Markdown
Member

@jeremyevans CI passes now on #5684, could you cherry-pick that commit here and then I'll close my PR?

@jeremyevans

Copy link
Copy Markdown
Contributor Author

@eregon I think it's better to merge #5684 instead, and close this. What are your thoughts on that?

@eregon

eregon commented Apr 5, 2022

Copy link
Copy Markdown
Member

OK, let's do that.

@eregon

eregon commented Apr 5, 2022

Copy link
Copy Markdown
Member

Merged in #5684

@eregon eregon closed this Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants