Skip to content

[fix] Bignum#eql?: use type-strict comparison (not ==)#9336

Merged
headius merged 1 commit intojruby:jruby-10.0from
kares:bignum-eql-10
Mar 28, 2026
Merged

[fix] Bignum#eql?: use type-strict comparison (not ==)#9336
headius merged 1 commit intojruby:jruby-10.0from
kares:bignum-eql-10

Conversation

@kares
Copy link
Copy Markdown
Member

@kares kares commented Mar 28, 2026

RubyBignum overrode eql_p to delegate to op_equal (==), which accepts Floats and Rationals. In Ruby, eql? must be type-strict: (2**100).eql?((2**100).to_f) should return false.

Remove the override so the parent RubyNumeric.eql_p handles it correctly with a getClass() check before value comparison.

@kares kares changed the title [fix] Bignum#eql?: use type-strict comparison not == [fix] Bignum#eql?: use type-strict comparison (not ==) Mar 28, 2026
@kares kares changed the base branch from master to jruby-10.0 March 28, 2026 15:08
RubyBignum overrode eql_p to delegate to op_equal (==), which
accepts Floats and Rationals. In Ruby, eql? must be type-strict:
(2**100).eql?((2**100).to_f) should return false.

Remove the override so the parent RubyNumeric.eql_p handles it
correctly with a getClass() check before value comparison.
@kares kares added this to the JRuby 10.0.5.0 milestone Mar 28, 2026
Copy link
Copy Markdown
Member

@headius headius left a comment

Choose a reason for hiding this comment

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

Consider moving specs to ruby/spec.

@headius headius merged commit 4fb0bbe into jruby:jruby-10.0 Mar 28, 2026
304 of 307 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