diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2008-07-24 14:52:25 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2008-07-24 14:52:25 +0000 |
commit | fc691e1cbdcddb8c553cba06d4089bc1b60e3d98 (patch) | |
tree | fc800e75698752af4e61b2f9109e1e0ce140d0f4 /src/libexpr | |
parent | 096198d11f14a1fff2eb335a572c0b20ae52dbf8 (diff) | |
download | guix-fc691e1cbdcddb8c553cba06d4089bc1b60e3d98.tar.gz |
* Print a better error message when a non-derivation attribute set is
coerced to a string.
Diffstat (limited to 'src/libexpr')
-rw-r--r-- | src/libexpr/eval.cc | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index a8a22e2f2c..6d8137d9b8 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -48,6 +48,11 @@ LocalNoInlineNoReturn(void throwEvalError(const char * s, const string & s2)) throw EvalError(format(s) % s2); } +LocalNoInlineNoReturn(void throwTypeError(const char * s)) +{ + throw TypeError(s); +} + LocalNoInlineNoReturn(void throwTypeError(const char * s, const string & s2)) { throw TypeError(format(s) % s2); @@ -305,9 +310,11 @@ string coerceToString(EvalState & state, Expr e, PathSet & context, } ATermList es; - if (matchAttrs(e, es)) - return coerceToString(state, makeSelect(e, toATerm("outPath")), - context, coerceMore, copyToStore); + if (matchAttrs(e, es)) { + Expr e2 = queryAttr(e, "outPath"); + if (!e2) throwTypeError("cannot coerce an attribute set (except a derivation) to a string"); + return coerceToString(state, e2, context, coerceMore, copyToStore); + } if (coerceMore) { |