From 2e0acd6057bd65b0b872356c51c1b7b1a06c89b9 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 5 Aug 2017 21:46:08 -0700 Subject: bugfix: n-ary arith functions must check single arg. We are allowing calls like (* "a") and (+ "a") without diagnosing that the argument isn't of a valid type. Note that (max "a") is fine beacause min and max use the less function; they are not strictly numeric. * lib.c (nary_op): Beef up function with additional argument for type checking the unary case. (unary_num, unary_arith, unary_int): New static functions. (plusv, mulv, logandv, logiorv): Use new nary_op interface. (gtv, ltv, gev, lev, numeqv, numneq): Check the first number. * lib.c (nary_op): Declaration updated. --- lib.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib.h') diff --git a/lib.h b/lib.h index 6df5a914..39ac5175 100644 --- a/lib.h +++ b/lib.h @@ -654,7 +654,9 @@ val bignump(val num); val floatp(val num); val integerp(val num); val numberp(val num); -val nary_op(val (*cfunc)(val, val), struct args *args, val emptyval); +val nary_op(val self, val (*bfun)(val, val), + val (*ufun)(val self, val), + struct args *args, val emptyval); val plus(val anum, val bnum); val plusv(struct args *); val minus(val anum, val bnum); -- cgit v1.2.3