From 4e6597947b98cf8e695bbdd7949b9c115fd7869a Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 13 Jan 2011 04:26:59 +0000 Subject: Fix crash on `(def)'. Fish error location reporting for list expressions. git-svn-id: http://svn.drobilla.net/resp/trunk@407 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- src/expand.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/expand.cpp') 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(); -- cgit v1.2.1