aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/eval.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-08 14:45:36 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-08 14:45:36 +0200
commitb1e3b1a4ac8c276f503713f6002c3b42efef2ae8 (patch)
tree9cb4941efd09e0ec8c962c81d9907ee8e19a5787 /src/libexpr/eval.cc
parent6b47de580ffe6101863a1054d9d47f9cbe691214 (diff)
Treat undefined variable errors consistently
Previously, a undefined variable inside a "with" caused an EvalError (which can be caught), while outside, it caused a ParseError (which cannot be caught). Now both cause an UndefinedVarError (which cannot be caught).
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r--src/libexpr/eval.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 3d77b94e7..b54f32faf 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -258,6 +258,11 @@ LocalNoInlineNoReturn(void throwAssertionError(const char * s, const Pos & pos))
throw AssertionError(format(s) % pos);
}
+LocalNoInlineNoReturn(void throwUndefinedVarError(const char * s, const string & s1, const Pos & pos))
+{
+ throw UndefinedVarError(format(s) % s1 % pos);
+}
+
LocalNoInline(void addErrorPrefix(Error & e, const char * s, const string & s2))
{
e.addPrefix(format(s) % s2);
@@ -315,7 +320,7 @@ inline Value * EvalState::lookupVar(Env * env, const ExprVar & var, bool noEval)
return j->value;
}
if (!env->prevWith)
- throw EvalError(format("undefined variable `%1%' at %2%") % var.name % var.pos);
+ throwUndefinedVarError("undefined variable `%1%' at %2%", var.name, var.pos);
for (unsigned int l = env->prevWith; l; --l, env = env->up) ;
}
}