aboutsummaryrefslogtreecommitdiff
path: root/builtin.cpp
diff options
context:
space:
mode:
authorTeddy <ted.sybil@gmail.com>2013-08-07 16:15:17 +0800
committerTeddy <ted.sybil@gmail.com>2013-08-07 16:15:17 +0800
commitc5f2c8fa951100d6c3ee13e551c4ec78b7a4a616 (patch)
treec56b7b686b0f915d2f1be868803c18b8ef792421 /builtin.cpp
parente0c274fc6b7dc1c500ceb1375c2a8c4a09c1018c (diff)
more than three arguments aren't allowed in `if`
Diffstat (limited to 'builtin.cpp')
-rw-r--r--builtin.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/builtin.cpp b/builtin.cpp
index 2c951b6..0228b45 100644
--- a/builtin.cpp
+++ b/builtin.cpp
@@ -537,7 +537,7 @@ SpecialOptIf::SpecialOptIf() : SpecialOptObj("if") {}
void SpecialOptIf::prepare(Cons *pc) {
#define IF_EXP_ERR \
- throw TokenError("if", RUN_ERR_WRONG_NUM_OF_ARGS)
+ throw TokenError(name, RUN_ERR_WRONG_NUM_OF_ARGS)
state = 0; // Prepared
if (pc->cdr->is_cons_obj())
@@ -560,7 +560,11 @@ void SpecialOptIf::prepare(Cons *pc) {
if (pc->cdr != empty_list)
{
if (pc->cdr->is_cons_obj())
+ {
TO_CONS(pc->cdr)->skip = true;
+ if (TO_CONS(pc->cdr)->cdr != empty_list)
+ IF_EXP_ERR;
+ }
else
IF_EXP_ERR;
}