Fix infinite recursive call bugs in integer division.

parent 3deb62d6
......@@ -304,6 +304,7 @@ int_div(mrb_state *mrb, mrb_value x)
}
switch (mrb_type(y)) {
case MRB_TT_COMPLEX:
x = complex_new(mrb, (mrb_float)a, 0);
return mrb_funcall_id(mrb, x, MRB_OPSYM(div), 1, y);
default:
return mrb_float_value(mrb, (mrb_float)a * mrb_to_flo(mrb, y));
......@@ -323,6 +324,7 @@ int_quo(mrb_state *mrb, mrb_value x)
switch (mrb_type(y)) {
case MRB_TT_COMPLEX:
x = complex_new(mrb, (mrb_float)a, 0);
return mrb_funcall_id(mrb, x, MRB_OPSYM(div), 1, y);
default:
return mrb_float_value(mrb, (mrb_float)a * mrb_to_flo(mrb, y));
......
......@@ -428,6 +428,7 @@ int_div(mrb_state *mrb, mrb_value x)
return mrb_funcall_id(mrb, x, MRB_OPSYM(div), 1, y);
#if defined(MRB_USE_COMPLEX)
case MRB_TT_COMPLEX:
x = mrb_complex_new(mrb, (mrb_float)a, 0);
return mrb_funcall_id(mrb, x, MRB_OPSYM(div), 1, y);
#endif
case MRB_TT_FLOAT:
......@@ -460,6 +461,7 @@ int_quo(mrb_state *mrb, mrb_value x)
return mrb_funcall_id(mrb, x, MRB_OPSYM(div), 1, y);
#if defined(MRB_USE_COMPLEX)
case MRB_TT_COMPLEX:
x = mrb_complex_new(mrb, (mrb_float)a, 0);
return mrb_funcall_id(mrb, x, MRB_OPSYM(div), 1, y);
#endif
default:
......
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