aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-01-13 04:26:59 +0000
committerDavid Robillard <d@drobilla.net>2011-01-13 04:26:59 +0000
commit4e6597947b98cf8e695bbdd7949b9c115fd7869a (patch)
treedd96975b42b5575d284d9ccc142d310fb42687ca /src
parent206c01b4ba4c5e674e313d7ed7fe21c2b93f2d12 (diff)
downloadresp-4e6597947b98cf8e695bbdd7949b9c115fd7869a.tar.gz
resp-4e6597947b98cf8e695bbdd7949b9c115fd7869a.tar.bz2
resp-4e6597947b98cf8e695bbdd7949b9c115fd7869a.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/expand.cpp8
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();