Skip to content

Commit 17c35da

Browse files
committed
Don't crash on Ruby 4.1, which removed ObjectSpace._id2ref
objectspace/op_fetch.rb aliases ObjectSpace[] to _id2ref, which Ruby head (4.1) no longer has. The alias raised NameError at load time, and since facets/objectspace loads it, so did `require 'facets'`. The unit tests never load that file, so only the new qed step caught it. ObjectSpace[] is now only defined where _id2ref exists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E2Njj4j1r9twkVcXsMySLW
1 parent 0de0722 commit 17c35da

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎HISTORY.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,13 @@ Changes:
3838
quietly changed both.
3939
* `Enumerable::Argumentable#min` and `#max` now pass their arguments to
4040
`#each`, as documented, rather than to Ruby's own `min(n)`/`max(n)`.
41+
* `require 'facets'` no longer crashes on Ruby 4.1, which removed
42+
`ObjectSpace._id2ref`. `ObjectSpace[]` is only defined where `_id2ref`
43+
exists.
4144

4245
* Internal
4346

47+
* Run the qed demos in CI.
4448
* Fix the qed demos, which had 8 failures and 2 errors. Most were stale
4549
expectations (`Array#from`, `#step`, `#arrange`, `String#similarity`)
4650
and the date demo held pasted irb output.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
class << ObjectSpace
2-
alias_method :[], :_id2ref
2+
# Ruby 4.1 removed ObjectSpace._id2ref, so there is nothing to alias there.
3+
alias_method :[], :_id2ref if method_defined?(:_id2ref)
34
end

0 commit comments

Comments
 (0)