Skip to content

Set operations retain compare_by_identity flag - #1403

Merged
andrykonchin merged 1 commit into
ruby:masterfrom
mrhoribu:set-compare-by-identity-4.0.8
Oct 24, 2026
Merged

andrykonchin merged 1 commit into
ruby:masterfrom
mrhoribu:set-compare-by-identity-4.0.8

Conversation

@mrhoribu

@mrhoribu mrhoribu commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Since the fix for Bug #22174 (ruby/ruby@f069efc3f6), Set#&, #classify, #divide, #flatten, #flatten! and #map! keep the receiver's compare_by_identity flag. The current specs expect false unconditionally, so they fail on 4.0.9 and 4.1.

This PR applies the spec changes from ruby/ruby#18848 as is: "retains" under ruby_version_is "4.1" and "does not retain" under ""..."4.0". That keeps CI green on the current 4.0.7 matrix.

Merge order, as suggested in the review:

  1. This PR
  2. Update to latest CRuby releases #1405, which updates the CI matrix to 4.0.9
  3. A follow-up PR that changes the "4.1" guards to "4.0", since the fix was backported in 4.0.8 (ruby/ruby@1533c10971)

Seen in RubyInstaller2 CI on 4.0.9: https://github.com/oneclick/rubyinstaller2/actions/runs/39949977572/job/120434751465

Checked with mspec-run core/set: 4.0.5, 4.0.9 and 4.1.0-preview1 all pass.

🤖 Generated with Claude Code

@andrykonchin

Copy link
Copy Markdown
Member

The relevant changes are already made in ruby/ruby and will be synchronized soon (ruby/ruby#18848).

The only change that will be needed to do is to adjust version guards for new behavior and raplace "4.1" with "4.0" as far as the changes were backported to 4.0.8.

@mrhoribu
mrhoribu force-pushed the set-compare-by-identity-4.0.8 branch from f72222e to 50109a6 Compare October 23, 2026 19:32
@mrhoribu

Copy link
Copy Markdown
Contributor Author

Thanks! I've rebased this onto the layout from ruby/ruby#18848, so once the sync lands, the only difference should be the guard versions.

I used "4.0.8" / ""..."4.0.8" instead of "4.0" because the backport (ruby/ruby@1533c10971) first shipped in 4.0.8. 4.0.0 through 4.0.7 still drop the flag, so a "4.0" guard would fail on them, including the 4.0.7 in this repo's CI matrix. This uses the same patch-level guard style as af6351a ("3.4.11" for the ENV.keys backport).

Checked with mspec-run core/set: 4.0.5, 4.0.9 and 4.1.0-preview1 all pass. On 4.0.5 the "does not retain" examples run; on 4.0.9 and 4.1 the "retains" examples run.

In flatten_spec.rb, I kept the Set-like context under its existing ""..."4.0" guard and gave the "does not retain" example its own ""..."4.0.8" block. In ruby/ruby#18848 the two share one block, but that would skip the example on 4.0.0 through 4.0.7.

🤖 Generated with Claude Code

@mrhoribu
mrhoribu force-pushed the set-compare-by-identity-4.0.8 branch from 50109a6 to 75cfad3 Compare October 23, 2026 19:52
@mrhoribu mrhoribu changed the title Set operations retain compare_by_identity flag since 4.0.8 Set operations retain compare_by_identity flag on 4.0 Oct 23, 2026
@mrhoribu

Copy link
Copy Markdown
Contributor Author

Sorry, I misread your earlier comment. As the README says, ruby/spec targets the latest stable release of each series, so "4.0" is the right guard. I've updated the branch to the specs from ruby/ruby#18848, with only "4.1" changed to "4.0". It passes core/set on 4.0.9 and 4.1.0-preview1.

One note: the CI matrix is still on 4.0.7, which doesn't have the backport, so the new "retains" examples will fail there until it moves to 4.0.9.

🤖 Generated with Claude Code

@andrykonchin

Copy link
Copy Markdown
Member

Neither PR (this one nor #1405) can be merged right now as far as they fail CI checks.

I would propose the following scenario:

  1. in this PR keep ruby_version_is "4.1" do guards for the "retains compare_by_identity flag" cases
  2. merge it first
  3. merge Update to latest CRuby releases #1405 (that should keep CI green)
  4. change ruby_version_is "4.1" do to ruby_version_is "4.0" do (that keeps CI green too)

Set#&, #classify, #divide, #flatten, #flatten! and #map! keep the
receiver's compare_by_identity flag since the fix for [Bug #22174].
See https://bugs.ruby-lang.org/issues/22174

Same as the specs from ruby/ruby#18848.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mrhoribu mrhoribu changed the title Set operations retain compare_by_identity flag on 4.0 Set operations retain compare_by_identity flag Oct 24, 2026
@mrhoribu
mrhoribu force-pushed the set-compare-by-identity-4.0.8 branch from 75cfad3 to e2faa6a Compare October 24, 2026 15:25
@mrhoribu

Copy link
Copy Markdown
Contributor Author

Sounds good. I've updated this PR to keep the ruby_version_is "4.1" guards, so it now matches ruby/ruby#18848 exactly. I'll open the "4.1" → "4.0" follow-up after #1405 is merged.

🤖 Generated with Claude Code

@andrykonchin

Copy link
Copy Markdown
Member

Thank you!

@andrykonchin
andrykonchin merged commit 484c424 into ruby:master Oct 24, 2026
14 checks passed
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