diff options
| -rw-r--r-- | src/string.c | 2 | ||||
| -rw-r--r-- | test/t/string.rb | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/src/string.c b/src/string.c index e8c60a660..469335bb9 100644 --- a/src/string.c +++ b/src/string.c @@ -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); } diff --git a/test/t/string.rb b/test/t/string.rb index a1277ce99..e91b915fe 100644 --- a/test/t/string.rb +++ b/test/t/string.rb @@ -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 |
