From 203916b44f6b09442c249e76c49729f28c82d53c Mon Sep 17 00:00:00 2001 From: dzaima Date: Thu, 1 Sep 2022 11:15:43 +0300 Subject: [PATCH] =?UTF-8?q?error=20on=20non-numbers=20in=20+=F0=9D=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins/arithm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/builtins/arithm.c b/src/builtins/arithm.c index 900a52ec..9f267ab4 100644 --- a/src/builtins/arithm.c +++ b/src/builtins/arithm.c @@ -46,7 +46,13 @@ B bit_negate(B x) { // consumes } -B add_c1(B t, B x) { return x; } +B add_c1(B t, B x) { + if (isF64(x)) return x; + if (!isArr(x)) thrM("+: Argument must consist of numbers"); + if (elNum(TI(x,elType))) return x; + dec(eachm_fn(m_f64(0), inc(x), add_c1)); + return x; +} GC1i("-", sub, -v, v== MIN, -v, {}, 0) // change icond to v==-v to support ¯0 (TODO that won't work for i8/i16) GC1i("|", stile, fabs(v), v== MIN, v<0?-v:v,{}, 0)