mirror of
https://github.com/NixOS/nix
synced 2025-06-26 15:51:15 +02:00
* In the ‘?’ operator, allow attribute paths. For instance, you can
write ‘attrs ? a.b’ to test whether ‘attrs’ has an attribute ‘a’ containing an attribute ‘b’. This is more convenient than ‘attrs ? a && attrs.a ? b’. Slight change in the semantics: it's no longer an error if the left-hand side of ‘?’ is not an attribute set. In that case it just returns false. So, ‘null ? foo’ no longer throws an error.
This commit is contained in:
parent
34f4b91820
commit
5637037802
4 changed files with 47 additions and 24 deletions
|
@ -40,6 +40,12 @@ struct EvalState;
|
|||
struct StaticEnv;
|
||||
|
||||
|
||||
/* An attribute path is a sequence of attribute names. */
|
||||
typedef vector<Symbol> AttrPath;
|
||||
|
||||
string showAttrPath(const AttrPath & attrPath);
|
||||
|
||||
|
||||
/* Abstract syntax of Nix expressions. */
|
||||
|
||||
struct Expr
|
||||
|
@ -124,8 +130,8 @@ struct ExprSelect : Expr
|
|||
struct ExprOpHasAttr : Expr
|
||||
{
|
||||
Expr * e;
|
||||
Symbol name;
|
||||
ExprOpHasAttr(Expr * e, const Symbol & name) : e(e), name(name) { };
|
||||
AttrPath attrPath;
|
||||
ExprOpHasAttr(Expr * e, const AttrPath & attrPath) : e(e), attrPath(attrPath) { };
|
||||
COMMON_METHODS
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue