diff options
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r-- | src/libexpr/eval.cc | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 949f45e787..c307f2a420 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -656,9 +656,25 @@ void ExprSelect::eval(EvalState & state, Env & env, Value & v) void ExprOpHasAttr::eval(EvalState & state, Env & env, Value & v) { - Value vAttrs; - state.evalAttrs(env, e, vAttrs); - mkBool(v, vAttrs.attrs->find(name) != vAttrs.attrs->end()); + Value vTmp; + Value * vAttrs = &vTmp; + + state.eval(env, e, vTmp); + + foreach (AttrPath::const_iterator, i, attrPath) { + state.forceValue(*vAttrs); + Bindings::iterator j; + if (vAttrs->type != tAttrs || + (j = vAttrs->attrs->find(*i)) == vAttrs->attrs->end()) + { + mkBool(v, false); + return; + } else { + vAttrs = j->value; + } + } + + mkBool(v, true); } |