aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2014-05-15 11:30:46 -0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-05-15 17:56:24 +0200
commiteac5841970737b799c55ec78f6ace6d80762ff04 (patch)
tree8e087f70c8d032a8b1c4f5710c514ddac4d688c5
parent8d5f472f2c49c79a0d3ae2e506f4d4d76224b328 (diff)
Provide a more useful error message when a dynamic attr lookup fails
-rw-r--r--src/libexpr/eval.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 0f7e8e385..81abe5b61 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -757,8 +757,16 @@ void ExprSelect::eval(EvalState & state, Env & env, Value & v)
}
} else {
state.forceAttrs(*vAttrs, pos);
- if ((j = vAttrs->attrs->find(name)) == vAttrs->attrs->end())
- throwEvalError("attribute `%1%' missing, at %2%", showAttrPath(attrPath), pos);
+ if ((j = vAttrs->attrs->find(name)) == vAttrs->attrs->end()) {
+ AttrPath staticPath;
+ AttrPath::const_iterator j;
+ for (j = attrPath.begin(); j != i; ++j)
+ staticPath.push_back(AttrName(getName(*j, state, env)));
+ staticPath.push_back(AttrName(getName(*j, state, env)));
+ for (j = j + 1; j != attrPath.end(); ++j)
+ staticPath.push_back(*j);
+ throwEvalError("attribute `%1%' missing, at %2%", showAttrPath(staticPath), pos);
+ }
}
vAttrs = j->value;
pos2 = j->pos;