about summary refs log tree commit diff
path: root/src/libexpr/eval.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r--src/libexpr/eval.cc38
1 files changed, 26 insertions, 12 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index c307f2a4204e..4d3a369aa1ec 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -636,21 +636,35 @@ unsigned long nrLookupSize = 0;
 
 void ExprSelect::eval(EvalState & state, Env & env, Value & v)
 {
-    nrLookups++;
-    Value v2;
-    state.evalAttrs(env, e, v2);
-    nrLookupSize += v2.attrs->size();
-    Bindings::iterator i = v2.attrs->find(name);
-    if (i == v2.attrs->end())
-        throwEvalError("attribute `%1%' missing", name);
-    try {            
-        state.forceValue(*i->value);
+    Value vTmp;
+    Pos * pos = 0;
+    Value * vAttrs = &vTmp;
+
+    state.eval(env, e, vTmp);
+
+    try {
+        
+        foreach (AttrPath::const_iterator, i, attrPath) {
+            nrLookups++;
+            state.forceAttrs(*vAttrs);
+            nrLookupSize += vAttrs->attrs->size();
+            Bindings::iterator j;
+            if ((j = vAttrs->attrs->find(*i)) == vAttrs->attrs->end())
+                throwEvalError("attribute `%1%' missing", showAttrPath(attrPath));
+            vAttrs = j->value;
+            pos = j->pos;
+        }
+    
+        state.forceValue(*vAttrs);
+        
     } catch (Error & e) {
-        addErrorPrefix(e, "while evaluating the attribute `%1%' at %2%:\n",
-            name, *i->pos);
+        if (pos)
+            addErrorPrefix(e, "while evaluating the attribute `%1%' at %2%:\n",
+                showAttrPath(attrPath), *pos);
         throw;
     }
-    v = *i->value;
+    
+    v = *vAttrs;
 }