about summary refs log tree commit diff
path: root/src/libexpr/parser.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr/parser.cc')
-rw-r--r--src/libexpr/parser.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/libexpr/parser.cc b/src/libexpr/parser.cc
index 68b367340acf..c300a0d07bc4 100644
--- a/src/libexpr/parser.cc
+++ b/src/libexpr/parser.cc
@@ -50,11 +50,16 @@ ATerm fixAttrs(int recursive, ATermList as)
     ATermList * is = recursive ? &cs : &bs;
     for (ATermIterator i(as); i; ++i) {
         ATermList names;
-        if (atMatch(m, *i) >> "Inherit" >> names)
-            for (ATermIterator j(names); j; ++j)
-                *is = ATinsert(*is,
-                    ATmake("Bind(<term>, Var(<term>))", *j, *j));
-        else bs = ATinsert(bs, *i);
+        Expr src;
+        if (atMatch(m, *i) >> "Inherit" >> src >> names) {
+            bool fromScope = atMatch(m, src) >> "Scope";
+            for (ATermIterator j(names); j; ++j) {
+                Expr rhs = fromScope
+                    ? ATmake("Var(<term>)", *j)
+                    : ATmake("Select(<term>, <term>)", src, *j);
+                *is = ATinsert(*is, ATmake("Bind(<term>, <term>)", *j, rhs));
+            }
+        } else bs = ATinsert(bs, *i);
     }
     if (recursive)
         return ATmake("Rec(<term>, <term>)", bs, cs);