If a dynamic attribute name evaluates to null, remove it from the set

This commit is contained in:
Shea Levy 2014-03-09 14:24:47 -04:00 committed by Eelco Dolstra
parent 2caab81660
commit 908e9ce259
3 changed files with 11 additions and 1 deletions

View File

@ -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);

View File

@ -0,0 +1 @@
true

View File

@ -0,0 +1 @@
{ ${null} = true; } == {}