If a dynamic attribute name evaluates to null, remove it from the set
This commit is contained in:
parent
2caab81660
commit
908e9ce259
3 changed files with 11 additions and 1 deletions
|
@ -642,7 +642,15 @@ void ExprAttrs::eval(EvalState & state, Env & env, Value & v)
|
||||||
/* dynamic attrs apply *after* rec and __overrides */
|
/* dynamic attrs apply *after* rec and __overrides */
|
||||||
foreach (DynamicAttrDefs::iterator, i, dynamicAttrs) {
|
foreach (DynamicAttrDefs::iterator, i, dynamicAttrs) {
|
||||||
Value nameVal;
|
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);
|
state.forceStringNoCtx(nameVal);
|
||||||
Symbol nameSym = state.symbols.create(nameVal.string.s);
|
Symbol nameSym = state.symbols.create(nameVal.string.s);
|
||||||
Bindings::iterator j = v.attrs->find(nameSym);
|
Bindings::iterator j = v.attrs->find(nameSym);
|
||||||
|
|
1
tests/lang/eval-okay-null-dynamic-attrs.exp
Normal file
1
tests/lang/eval-okay-null-dynamic-attrs.exp
Normal file
|
@ -0,0 +1 @@
|
||||||
|
true
|
1
tests/lang/eval-okay-null-dynamic-attrs.nix
Normal file
1
tests/lang/eval-okay-null-dynamic-attrs.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ ${null} = true; } == {}
|
Loading…
Reference in a new issue