Fix a bug introduced by the last commit.

Should have handled the case `to_a` returns `nil`.
parent 564372d7
...@@ -772,13 +772,20 @@ mrb_obj_ceqq(mrb_state *mrb, mrb_value self) ...@@ -772,13 +772,20 @@ mrb_obj_ceqq(mrb_state *mrb, mrb_value self)
if (mrb_array_p(self)) { if (mrb_array_p(self)) {
ary = self; ary = self;
} }
else if (!mrb_respond_to(mrb, v, mrb_intern_lit(mrb, "to_a"))) { else if (mrb_nil_p(self)) {
return mrb_false_value();
}
else if (!mrb_respond_to(mrb, self, mrb_intern_lit(mrb, "to_a"))) {
mrb_value c = mrb_funcall_argv(mrb, self, eqq, 1, &v); mrb_value c = mrb_funcall_argv(mrb, self, eqq, 1, &v);
if (mrb_test(c)) return mrb_true_value(); if (mrb_test(c)) return mrb_true_value();
return mrb_false_value(); return mrb_false_value();
} }
else { else {
ary = mrb_ary_splat(mrb, self); ary = mrb_funcall(mrb, self, "to_a", 0);
if (mrb_nil_p(ary)) {
return mrb_funcall_argv(mrb, self, eqq, 1, &v);
}
mrb_ensure_array_type(mrb, ary);
} }
len = RARRAY_LEN(ary); len = RARRAY_LEN(ary);
for (i=0; i<len; i++) { for (i=0; i<len; i++) {
......
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