mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
numeric.c (mrb_cmp): should not raise NoMethodError.
Even when `obj1` does not have `<=>` method.
This commit is contained in:
@@ -1929,6 +1929,7 @@ mrb_cmp(mrb_state *mrb, mrb_value obj1, mrb_value obj2)
|
||||
return -2;
|
||||
return mrb_str_cmp(mrb, obj1, obj2);
|
||||
default:
|
||||
if (!mrb_respond_to(mrb, obj1, MRB_OPSYM(cmp))) return -2;
|
||||
v = mrb_funcall_id(mrb, obj1, MRB_OPSYM(cmp), 1, obj2);
|
||||
if (mrb_nil_p(v) || !mrb_integer_p(v))
|
||||
return -2;
|
||||
|
||||
Reference in New Issue
Block a user