Merge pull request #1872 from ksss/numeric-mul

fix bug when `0 * other object`
This commit is contained in:
Yukihiro "Matz" Matsumoto
2014-03-17 00:14:16 +09:00
2 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -690,10 +690,10 @@ mrb_fixnum_mul(mrb_state *mrb, mrb_value x, mrb_value y)
mrb_int a;
a = mrb_fixnum(x);
if (a == 0) return x;
if (mrb_fixnum_p(y)) {
mrb_int b, c;
if (a == 0) return x;
b = mrb_fixnum(y);
if (FIT_SQRT_INT(a) && FIT_SQRT_INT(b))
return mrb_fixnum_value(a*b);
+3
View File
@@ -31,6 +31,9 @@ assert('Integer#*', '15.2.8.3.3') do
assert_equal 1, a
assert_equal 1.0, b
assert_raise(TypeError){ 0*nil }
assert_raise(TypeError){ 1*nil }
end
assert('Integer#/', '15.2.8.3.4') do