From 5dba94ed1eec7a808cab022a23480b4d39518307 Mon Sep 17 00:00:00 2001 From: Teddy Date: Mon, 5 Aug 2013 10:14:07 +0800 Subject: empty-list fix --- builtin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin.cpp b/builtin.cpp index 17c5e94..79ecdfb 100644 --- a/builtin.cpp +++ b/builtin.cpp @@ -280,7 +280,7 @@ EvalObj *builtin_car(ArgList *args) { if (args == empty_list || args->cdr != empty_list) throw TokenError("car", RUN_ERR_WRONG_NUM_OF_ARGS); - if (!args->car->is_cons_obj()) + if (args->car == empty_list || !args->car->is_cons_obj()) throw TokenError("pair", RUN_ERR_WRONG_TYPE); return TO_CONS(args->car)->car; @@ -290,7 +290,7 @@ EvalObj *builtin_cdr(ArgList *args) { if (args == empty_list || args->cdr != empty_list) throw TokenError("cdr", RUN_ERR_WRONG_NUM_OF_ARGS); - if (!args->car->is_cons_obj()) + if (args->car == empty_list || !args->car->is_cons_obj()) throw TokenError("pair", RUN_ERR_WRONG_TYPE); return TO_CONS(args->car)->cdr; -- cgit v1.2.3-70-g09d2