GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Yield three values to the Hash#merge and #merge! block by taxor03 · Pull Request #10055 · jruby/jruby

Conversation

@taxor03

@taxor03 taxor03 commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #10053.

RubyHashLinkedBuckets#merge_bang (which merge, merge! and update use) yielded one Array [key, old_value, new_value] to the block. It now yields the three values with block.yieldValues, like the rb_yield_values(3, k, v, newvalue) call in CRuby's rb_hash_update_block_callback.

A block with exactly |key, old, new| works as before. Other blocks now get what CRuby gives them:

block before after (same as CRuby 4.0.9 and 3.4.12)
{ |*args| } [[key, old, new]] [key, old, new]
{ |key| } [key, old, new] key
&method(:m), m takes 3 arguments ArgumentError (given 1, expected 3) called with 3 arguments
&->(a) { } called with the Array ArgumentError (given 3, expected 1)
&:itself returns the Array ArgumentError (given 2, expected 0)

ENV.update and ENV.merge! with a block go through the same method, so they change the same way. CRuby yields three values there too (hash.c#L6798).

This adds an example for merge and one for merge! to spec/ruby/core/hash/merge_spec.rb. They fail before this change and pass after it, and pass on CRuby 4.0.9 and 3.4.12. Tested with spec/ruby/core/hash and spec/ruby/core/env (also with -Xjit.threshold=0 and -X-C), test/mri/ruby/test_hash.rb and test/mri/ruby/test_env.rb. No new failures.

This is the master version of #10054, which makes the same change in RubyHash on jruby-10.0. With this merged, the merge-forward of #10054 can keep master's side of RubyHash.java and merge_spec.rb.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@taxor03
Yield three values to the Hash#merge and #merge! block
c5a7eb1
@taxor03 taxor03 mentioned this pull request Nov 12, 2026
Yield three values to the Hash#merge and #merge! block #10054
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Hash#merge, #merge! and #update pass one Array to the block instead of three values

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@taxor03
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.