1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 10:41:16 +02:00

* Added an operator `?' to test for attribute existence, e.g.,

`attrs ? x' yields true iff `attrs' has an attribute named `x'.
This commit is contained in:
Eelco Dolstra 2004-03-28 21:15:01 +00:00
parent f958bcdf1f
commit ac4d39f9db
2 changed files with 10 additions and 1 deletions

View file

@ -288,10 +288,17 @@ Expr evalExpr2(EvalState & state, Expr e)
if (atMatch(m, e) >> "OpOr" >> e1 >> e2)
return makeBool(evalBool(state, e1) || evalBool(state, e2));
/* Attribut set update (//). */
/* Attribute set update (//). */
if (atMatch(m, e) >> "OpUpdate" >> e1 >> e2)
return updateAttrs(evalExpr(state, e1), evalExpr(state, e2));
/* Attribute existence test (?). */
if (atMatch(m, e) >> "OpHasAttr" >> e1 >> name) {
ATermMap attrs;
queryAllAttrs(evalExpr(state, e1), attrs);
return makeBool(attrs.get(name) != 0);
}
/* Barf. */
throw badTerm("invalid expression", e);
}