diff --git a/src/object.c b/src/object.c index b899427..b6553a8 100644 --- a/src/object.c +++ b/src/object.c @@ -35,10 +35,6 @@ void* scalloc(size_t size, size_t count) */ int listLength(const Object* listObj) { - if (!listObj || !isListy(*listObj)) { - return -1; - } - int len = 0; FOR_POINTER_IN_LIST(listObj) { len++; diff --git a/src/plfunc.c b/src/plfunc.c index bf12a31..3762c6a 100644 --- a/src/plfunc.c +++ b/src/plfunc.c @@ -307,10 +307,10 @@ Object len(Object* params, int length, struct Environment* env) { Object obj1 = params[0]; - Object o = numberObject(listLength(&obj1)); - if (o.number < 0) { + if (!isListy(obj1)) { return errorObject(NOT_A_LIST); } + Object o = numberObject(listLength(&obj1)); return o; }