diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2009-05-15 13:46:13 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2009-05-15 13:46:13 +0000 |
commit | a64bbe049e19618c33a878154f2e69029d45ecd7 (patch) | |
tree | 678788b5dc60db823e065d7ac1a33aba232b79d2 /src/libexpr | |
parent | d407d572fdc72f4eb14cc0f37d7d61446425b663 (diff) | |
download | guix-a64bbe049e19618c33a878154f2e69029d45ecd7.tar.gz |
* Change the scoping of "inherit (e) ..." in recs so that the
attributes of the rec are in scope of `e'. This is useful in expressions such as rec { lib = import ./lib; inherit (lib) concatStrings; } It does change the semantics of expressions such as let x = {y = 1;}; in rec { x = {y = 2;}; inherit (x) y; }.y This now returns 2 instead of 1. However, no code in Nixpkgs or NixOS seems to rely on the old behaviour.
Diffstat (limited to 'src/libexpr')
-rw-r--r-- | src/libexpr/parser.y | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index 2ee3833fe6..c4afb72eac 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -91,12 +91,13 @@ static Expr fixAttrs(bool recursive, ATermList as) if (matchInherit(*i, src, names, pos)) { bool fromScope = matchScope(src); for (ATermIterator j(names); j; ++j) { - Expr rhs = fromScope ? makeVar(*j) : makeSelect(src, *j); if (attrs.children.find(*j) != attrs.children.end()) throw ParseError(format("duplicate definition of attribute `%1%' at %2%") % showAttrPath(ATmakeList1(*j)) % showPos(pos)); Tree & t(attrs.children[*j]); - t.leaf = rhs; t.pos = pos; if (recursive) t.recursive = false; + t.leaf = fromScope ? makeVar(*j) : makeSelect(src, *j); + t.pos = pos; + if (recursive && fromScope) t.recursive = false; } } |