Commit 77a3863a authored by Takeshi Watanabe's avatar Takeshi Watanabe

Return nil if type differ in `String#<=>`.

parent 8e8bc9e4
......@@ -926,7 +926,7 @@ mrb_str_cmp_m(mrb_state *mrb, mrb_value str1)
else {
mrb_value tmp = mrb_funcall(mrb, str2, "<=>", 1, str1);
if (!mrb_nil_p(tmp)) return mrb_nil_value();
if (mrb_nil_p(tmp)) return mrb_nil_value();
if (!mrb_fixnum_p(tmp)) {
return mrb_funcall(mrb, mrb_fixnum_value(0), "-", 1, tmp);
}
......
......@@ -20,6 +20,7 @@ assert('String#<=>', '15.2.10.5.1') do
assert_equal 1, c
assert_equal(-1, d)
assert_equal 1, e
assert_nil 'a' <=> 1024
end
assert('String#==', '15.2.10.5.2') do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment