about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2014-03-09T18·24-0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-03-10T09·14+0100
commit908e9ce259710037ae9824a3246143e46e27e867 (patch)
treee4cd887779b88b20e224cc4baff1145490743e74 /src
parent2caab8166045135bb78fd93dc9778a4d25d9499f (diff)
If a dynamic attribute name evaluates to null, remove it from the set
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/eval.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 350a4fbe141f..730b431cf255 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -642,7 +642,15 @@ void ExprAttrs::eval(EvalState & state, Env & env, Value & v)
     /* dynamic attrs apply *after* rec and __overrides */
     foreach (DynamicAttrDefs::iterator, i, dynamicAttrs) {
         Value nameVal;
-        i->nameExpr->eval(state, *dynamicEnv, nameVal);
+        assert(dynamic_cast<ExprConcatStrings *>(i->nameExpr));
+        ExprConcatStrings * nameExpr = static_cast<ExprConcatStrings *>(i->nameExpr);
+        if (nameExpr->es->size() == 1) {
+            nameExpr->es->front()->eval(state, *dynamicEnv, nameVal);
+            state.forceValue(nameVal);
+            if (nameVal.type == tNull)
+                continue;
+        }
+        nameExpr->eval(state, *dynamicEnv, nameVal);
         state.forceStringNoCtx(nameVal);
         Symbol nameSym = state.symbols.create(nameVal.string.s);
         Bindings::iterator j = v.attrs->find(nameSym);