Skip to content

Commit aa16334

Browse files
committed
Added number checks to plus
1 parent 6f2878a commit aa16334

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

standard_library.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ static Object *plus(Object *arguments, ErrorHandler error, Dictionary *dictionar
2626
Object *tail;
2727
while (! is_nil(arguments)) {
2828
tail = clone(cdr(arguments));
29+
if (! is_number(car(arguments))) {
30+
Object *bad_number = clone(car(arguments));
31+
destroy(arguments);
32+
destroy(tail);
33+
error("Not a number", (void *)bad_number);
34+
}
2935
total = total + *(long *)value(car(arguments));
3036
destroy(arguments);
3137
arguments = tail;

0 commit comments

Comments
 (0)