mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Fix opt_eq for overridden equality
This commit is contained in:
parent
554d76afb4
commit
5092d6129a
2 changed files with 28 additions and 6 deletions
|
@ -1965,7 +1965,7 @@ assert_equal '[true, false, false, false]', %q{
|
|||
]
|
||||
}
|
||||
|
||||
# Redefined eq
|
||||
# Redefined String eq
|
||||
assert_equal 'true', %q{
|
||||
class String
|
||||
def ==(other)
|
||||
|
@ -1973,6 +1973,26 @@ assert_equal 'true', %q{
|
|||
end
|
||||
end
|
||||
|
||||
"foo" == "bar"
|
||||
"foo" == "bar"
|
||||
def eq(a, b)
|
||||
a == b
|
||||
end
|
||||
|
||||
eq("foo", "bar")
|
||||
eq("foo", "bar")
|
||||
}
|
||||
|
||||
# Redefined Integer eq
|
||||
assert_equal 'true', %q{
|
||||
class Integer
|
||||
def ==(other)
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
def eq(a, b)
|
||||
a == b
|
||||
end
|
||||
|
||||
eq(1, 2)
|
||||
eq(1, 2)
|
||||
}
|
||||
|
|
|
@ -2048,7 +2048,8 @@ gen_equality_specialized(jitstate_t* jit, ctx_t* ctx, uint8_t *side_exit)
|
|||
|
||||
if (FIXNUM_P(comptime_a) && FIXNUM_P(comptime_b)) {
|
||||
if (!assume_bop_not_redefined(jit->block, INTEGER_REDEFINED_OP_FLAG, BOP_EQ)) {
|
||||
return YJIT_CANT_COMPILE;
|
||||
// if overridden, emit the generic version
|
||||
return false;
|
||||
}
|
||||
|
||||
guard_two_fixnums(ctx, side_exit);
|
||||
|
@ -2067,9 +2068,10 @@ gen_equality_specialized(jitstate_t* jit, ctx_t* ctx, uint8_t *side_exit)
|
|||
|
||||
return true;
|
||||
} else if (CLASS_OF(comptime_a) == rb_cString &&
|
||||
CLASS_OF(comptime_b) == rb_cString) {
|
||||
CLASS_OF(comptime_b) == rb_cString) {
|
||||
if (!assume_bop_not_redefined(jit->block, STRING_REDEFINED_OP_FLAG, BOP_EQ)) {
|
||||
return YJIT_CANT_COMPILE;
|
||||
// if overridden, emit the generic version
|
||||
return false;
|
||||
}
|
||||
|
||||
// Load a and b in preparation for call later
|
||||
|
|
Loading…
Add table
Reference in a new issue