diff options
Diffstat (limited to 'src/expand.cpp')
-rw-r--r-- | src/expand.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/expand.cpp b/src/expand.cpp index ec55e39..c2a5ad6 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -29,6 +29,7 @@ expand_list(PEnv& penv, const ATuple* e) List ret; FOREACHP(ATuple::const_iterator, i, e) ret.push_back(penv.expand(*i)); + ret.head->loc = e->loc; return ret.head; } @@ -51,11 +52,10 @@ static inline const AST* expand_def(PEnv& penv, const AST* exp, void* arg) { const ATuple* tup = exp->as_tuple(); + THROW_IF(tup->list_len() != 3, tup->loc, "`def' requires exactly 2 arguments"); - ATuple::const_iterator i = tup->begin(); - THROW_IF(i == tup->end(), tup->loc, "Unexpected end of `def' form"); - const AST* arg1 = *(++i); - THROW_IF(i == tup->end(), arg1->loc, "Unexpected end of `def' form"); + ATuple::const_iterator i = tup->begin(); + const AST* arg1 = *(++i); if (arg1->to_tuple()) { // (def (f x) y) => (def f (fn (x) y)) const ATuple* pat = arg1->to_tuple(); |