Skip to content

Fix spec for GC.config on Ruby 4.0 - #1307

Merged
eregon merged 1 commit into
ruby:masterfrom
trinistr:4.0-gc.config
Nov 23, 2025
Merged

Fix spec for GC.config on Ruby 4.0#1307
eregon merged 1 commit into
ruby:masterfrom
trinistr:4.0-gc.config

Conversation

@trinistr

@trinistr trinistr commented Nov 23, 2025

Copy link
Copy Markdown
Contributor

There was a subtle change on master which I didn't notice making #1306: GC.config(hash) now also returns :implementation (commit). This PR makes both behaviors pass tests (and improves tests a tiny bit). However, there is no versioning: this method is rather experimental and forcing other implementations to also closely follow MRI's behavior is probably unneeded, I think, similar to treatment of ruby_bug (this effectively was a bug judging by commit message).

In this way, compatible method would be:

def GC.config(options = nil)
  raise ArgumentError unless options.nil? || Hash === options

  if Hash === options && options.key?(:implementation)
    raise ArgumentError, 'Attempting to set read-only key "Implementation"'
  end

 { implementation: "none" }
end

@trinistr

Copy link
Copy Markdown
Contributor Author

@eregon Could you review this?

@eregon eregon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.
I was surprised the implementation key was not included for GC.config({}), glad that got fixed.

@eregon
eregon merged commit c8a6beb into ruby:master Nov 23, 2025
13 checks passed
@trinistr
trinistr deleted the 4.0-gc.config branch December 17, 2025 14:50
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