shithub: femtolisp

Download patch

ref: 8cb08f4c2751dab26235520448307fcdbfc257bd
parent: 0d5459f1f08ef367cd8849fc733b64bbdd9fd552
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sat Dec 28 20:24:45 EST 2024

array, array-alloc: disallow values that aren't numbers

--- a/cvalues.c
+++ b/cvalues.c
@@ -515,6 +515,8 @@
 	char *dest = cvalue_data(cv);
 	uint32_t i;
 	FOR_ARGS(i, 1, arg, args){
+		if(!fl_isnumber(arg))
+			type_error("number", arg);
 		cvalue_init(type->eltype, arg, dest);
 		dest += elsize;
 	}
@@ -540,7 +542,10 @@
 	char *dest = cvalue_data(cv);
 	a = 2;
 	for(i = 0; i < cnt; i++){
-		cvalue_init(type->eltype, args[a], dest);
+		value_t arg = args[a];
+		if(!fl_isnumber(arg))
+			type_error("number", arg);
+		cvalue_init(type->eltype, arg, dest);
 		dest += elsize;
 		if((a = (a + 1) % nargs) < 2)
 			a = 2;