Fix a bug introduced by the last commit.

Should have handled the case `to_a` returns `nil`.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2020-08-29 22:58:07 +09:00
parent 564372d7b9
commit f08f3c34be
+9 -2
View File
@@ -772,13 +772,20 @@ mrb_obj_ceqq(mrb_state *mrb, mrb_value self)
if (mrb_array_p(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);
if (mrb_test(c)) return mrb_true_value();
return mrb_false_value();
}
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);
for (i=0; i<len; i++) {