From 0fab9d557e62a364b0d2d7563c502e07ed53c227 Mon Sep 17 00:00:00 2001 From: ksss Date: Sun, 16 Mar 2014 23:39:58 +0900 Subject: float + nil should be raise TypeError --- src/numeric.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/numeric.c') diff --git a/src/numeric.c b/src/numeric.c index 38a05ae92..e2af14b97 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -1306,15 +1306,14 @@ num_cmp(mrb_state *mrb, mrb_value self) * and other. */ static mrb_value -flo_plus(mrb_state *mrb, mrb_value self) +flo_plus(mrb_state *mrb, mrb_value x) { - mrb_float x, y; - - x = mrb_float(self); - mrb_get_args(mrb, "f", &y); + mrb_value y; - return mrb_float_value(mrb, x + y); + mrb_get_args(mrb, "o", &y); + return mrb_float_value(mrb, mrb_float(x) + mrb_to_flo(mrb, y)); } + /* ------------------------------------------------------------------------*/ void mrb_init_numeric(mrb_state *mrb) -- cgit v1.2.3