Skip to content

rb_cmpint difference from MRI #2716

@nirvdrum

Description

@nirvdrum

This probably doesn't affect anyone in the wild, but our rb_cmpint implementation differs from MRI. MRI always normalizes to {-1, 0, 1}. We do that for Bignum, but not Fixnum.

Example:

$ ruby -v
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]

$ ruby -e 'class X; def <=>(other); 99999; end; end; p "abc" <=> X.new'
-1
$ bin/jruby -v
jruby 9.0.0.0-SNAPSHOT (2.2.1) 2015-03-17 6a83754 Java HotSpot(TM) 64-Bit Server VM 24.76-b04 on 1.7.0_76-b13 +jit [linux-amd64]

$ bin/jruby -e 'class X; def <=>(other); 99999; end; end; p "abc" <=> X.new'
-99999

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions