aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libexpr/eval-inline.hh8
-rw-r--r--src/libexpr/eval.cc22
2 files changed, 17 insertions, 13 deletions
diff --git a/src/libexpr/eval-inline.hh b/src/libexpr/eval-inline.hh
index ec0206eb0..5801a20c3 100644
--- a/src/libexpr/eval-inline.hh
+++ b/src/libexpr/eval-inline.hh
@@ -12,9 +12,9 @@ LocalNoInlineNoReturn(void throwEvalError(const char * s))
throw EvalError(s);
}
-LocalNoInlineNoReturn(void throwTypeError(const char * s, const string & s2))
+LocalNoInlineNoReturn(void throwTypeError(const char * s, const Value & v))
{
- throw TypeError(format(s) % s2);
+ throw TypeError(format(s) % showType(v));
}
@@ -45,7 +45,7 @@ inline void EvalState::forceAttrs(Value & v)
{
forceValue(v);
if (v.type != tAttrs)
- throwTypeError("value is %1% while a set was expected", showType(v));
+ throwTypeError("value is %1% while a set was expected", v);
}
@@ -53,7 +53,7 @@ inline void EvalState::forceList(Value & v)
{
forceValue(v);
if (v.type != tList)
- throwTypeError("value is %1% while a list was expected", showType(v));
+ throwTypeError("value is %1% while a list was expected", v);
}
}
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 4c448ff51..18b7ef701 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -249,6 +249,11 @@ LocalNoInlineNoReturn(void throwTypeError(const char * s))
throw TypeError(s);
}
+LocalNoInlineNoReturn(void throwTypeError(const char * s, const string & s1))
+{
+ throw TypeError(format(s) % s1);
+}
+
LocalNoInlineNoReturn(void throwTypeError(const char * s, const string & s1, const string & s2))
{
throw TypeError(format(s) % s1 % s2);
@@ -480,7 +485,7 @@ inline bool EvalState::evalBool(Env & env, Expr * e)
Value v;
e->eval(*this, env, v);
if (v.type != tBool)
- throwTypeError("value is %1% while a Boolean was expected", showType(v));
+ throwTypeError("value is %1% while a Boolean was expected", v);
return v.boolean;
}
@@ -489,7 +494,7 @@ inline void EvalState::evalAttrs(Env & env, Expr * e, Value & v)
{
e->eval(*this, env, v);
if (v.type != tAttrs)
- throwTypeError("value is %1% while a set was expected", showType(v));
+ throwTypeError("value is %1% while a set was expected", v);
}
@@ -734,8 +739,7 @@ void EvalState::callFunction(Value & fun, Value & arg, Value & v)
}
if (fun.type != tLambda)
- throwTypeError("attempt to call something which is not a function but %1%",
- showType(fun));
+ throwTypeError("attempt to call something which is not a function but %1%", fun);
unsigned int size =
(fun.lambda.fun->arg.empty() ? 0 : 1) +
@@ -1019,7 +1023,7 @@ NixInt EvalState::forceInt(Value & v)
{
forceValue(v);
if (v.type != tInt)
- throwTypeError("value is %1% while an integer was expected", showType(v));
+ throwTypeError("value is %1% while an integer was expected", v);
return v.integer;
}
@@ -1028,7 +1032,7 @@ bool EvalState::forceBool(Value & v)
{
forceValue(v);
if (v.type != tBool)
- throwTypeError("value is %1% while a Boolean was expected", showType(v));
+ throwTypeError("value is %1% while a Boolean was expected", v);
return v.boolean;
}
@@ -1037,7 +1041,7 @@ void EvalState::forceFunction(Value & v)
{
forceValue(v);
if (v.type != tLambda && v.type != tPrimOp && v.type != tPrimOpApp)
- throwTypeError("value is %1% while a function was expected", showType(v));
+ throwTypeError("value is %1% while a function was expected", v);
}
@@ -1045,7 +1049,7 @@ string EvalState::forceString(Value & v)
{
forceValue(v);
if (v.type != tString)
- throwTypeError("value is %1% while a string was expected", showType(v));
+ throwTypeError("value is %1% while a string was expected", v);
return string(v.string.s);
}
@@ -1152,7 +1156,7 @@ string EvalState::coerceToString(Value & v, PathSet & context,
}
}
- throwTypeError("cannot coerce %1% to a string", showType(v));
+ throwTypeError("cannot coerce %1% to a string", v);
}