aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin.cpp4
1 files 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;