diff options
-rw-r--r-- | src/libexpr/parser.y | 5 | ||||
-rw-r--r-- | tests/lang/eval-okay-scope-7.exp | 1 | ||||
-rw-r--r-- | tests/lang/eval-okay-scope-7.nix | 6 |
3 files changed, 10 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; } } diff --git a/tests/lang/eval-okay-scope-7.exp b/tests/lang/eval-okay-scope-7.exp new file mode 100644 index 0000000000..067d2b7461 --- /dev/null +++ b/tests/lang/eval-okay-scope-7.exp @@ -0,0 +1 @@ +Int(1) diff --git a/tests/lang/eval-okay-scope-7.nix b/tests/lang/eval-okay-scope-7.nix new file mode 100644 index 0000000000..4da02968f6 --- /dev/null +++ b/tests/lang/eval-okay-scope-7.nix @@ -0,0 +1,6 @@ +rec { + inherit (x) y; + x = { + y = 1; + }; +}.y |