diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-09-14 09:00:21 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-09-14 09:05:32 +0900 |
| commit | fcd3f8450d75033af8a0c472ee9c1352e1a8186e (patch) | |
| tree | 7acc68dea7e035a136933d7d0602f4fbd14e6bd6 /src/string.c | |
| parent | 34cdff5ee4eab5d2da767b9fb7ddb7a42f8c8334 (diff) | |
| download | mruby-fcd3f8450d75033af8a0c472ee9c1352e1a8186e.tar.gz mruby-fcd3f8450d75033af8a0c472ee9c1352e1a8186e.zip | |
Raise an error from `String#<=>` with a non string operand.
Diffstat (limited to 'src/string.c')
| -rw-r--r-- | src/string.c | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/src/string.c b/src/string.c index 35c7f8e7c..2454eb0fb 100644 --- a/src/string.c +++ b/src/string.c @@ -1036,21 +1036,7 @@ mrb_str_cmp_m(mrb_state *mrb, mrb_value str1) mrb_get_args(mrb, "o", &str2); if (!mrb_string_p(str2)) { - if (!mrb_respond_to(mrb, str2, mrb_intern_lit(mrb, "to_s"))) { - return mrb_nil_value(); - } - else if (!mrb_respond_to(mrb, str2, mrb_intern_lit(mrb, "<=>"))) { - return mrb_nil_value(); - } - else { - mrb_value tmp = mrb_funcall(mrb, str2, "<=>", 1, str1); - - if (mrb_nil_p(tmp)) return mrb_nil_value(); - if (!mrb_fixnum_p(tmp)) { - return mrb_funcall(mrb, mrb_fixnum_value(0), "-", 1, tmp); - } - result = -mrb_fixnum(tmp); - } + return mrb_nil_value(); } else { result = mrb_str_cmp(mrb, str1, str2); |
