aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeddy <[email protected]>2013-08-05 10:14:07 +0800
committerTeddy <[email protected]>2013-08-05 10:14:07 +0800
commit5dba94ed1eec7a808cab022a23480b4d39518307 (patch)
treee15fa841e805f553a56a625b18a6ac6d5f229a09
parentc54fefd17fb54029bbb62c363197c808b0fecc6b (diff)
empty-list fix
-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;