Skip to content

[fix] Bignum: use correct site for coerced comparisons#9338

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

[fix] Bignum: use correct site for coerced comparisons#9338
headius merged 1 commit intojruby:jruby-10.0from
kares:bignum-op-site-10

Conversation

@kares
Copy link
Copy Markdown
Member

@kares kares commented Mar 28, 2026

big_op() computed the correct CallSite for >, >=, <, <= in a switch but then ignored it and always passed sites(context).op_gt to coerceRelOp. This caused <, <=, and >= to all use > semantics when comparing a Bignum against a custom type implementing coerce.

(2**100) < MyCoercible.new(2**101) incorrectly returned false because it used > instead of < after coercion.

big_op() computed the correct CallSite for >, >=, <, <= in a switch
but then ignored it and always passed sites(context).op_gt to
coerceRelOp. This caused <, <=, and >= to all use > semantics when
comparing a Bignum against a custom type implementing coerce.

For example, (2**100) < MyCoercible.new(2**101) incorrectly returned
false because it used > instead of < after coercion.
@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.

Wow that's a silly mistake. Wonder if we should audit other places we use call sites. I'm open to suggestions on how to improve that.

Consider moving specs to ruby/spec.

@headius headius merged commit 9ae6172 into jruby:jruby-10.0 Mar 28, 2026
205 of 207 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