From 0a623a10c7e89a80b6dc74445a0ae6240f65723e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 13 Jul 2011 12:19:57 +0000 Subject: * Allow a default value in attribute selection by writing x.y.z or default (as originally proposed in https://mail.cs.uu.nl/pipermail/nix-dev/2009-September/002989.html). For instance, an expression like stdenv.lib.attrByPath ["features" "ckSched"] false args can now be written as args.features.ckSched or false --- src/libexpr/nixexpr.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/libexpr/nixexpr.cc') diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc index 2632d9f3ff8b..c52a413916a7 100644 --- a/src/libexpr/nixexpr.cc +++ b/src/libexpr/nixexpr.cc @@ -44,6 +44,7 @@ void ExprVar::show(std::ostream & str) void ExprSelect::show(std::ostream & str) { str << "(" << *e << ")." << showAttrPath(attrPath); + if (def) str << " or " << *def; } void ExprOpHasAttr::show(std::ostream & str) @@ -211,6 +212,7 @@ void ExprVar::bindVars(const StaticEnv & env) void ExprSelect::bindVars(const StaticEnv & env) { e->bindVars(env); + if (def) def->bindVars(env); } void ExprOpHasAttr::bindVars(const StaticEnv & env) -- cgit 1.4.1