about summary refs log tree commit diff
path: root/src/libexpr/nixexpr.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr/nixexpr.cc')
-rw-r--r--src/libexpr/nixexpr.cc19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc
index 8fe5d379af71..0d14623ccca0 100644
--- a/src/libexpr/nixexpr.cc
+++ b/src/libexpr/nixexpr.cc
@@ -194,10 +194,18 @@ Expr substitute(const ATermMap & subs, Expr e)
                 abort();
             subs2.remove(name);
         }
-        return ATmake("Function(<term>, <term>)", formals,
+        return ATmake("Function(<term>, <term>)",
+            substitute(subs, (ATerm) formals),
             substitute(subs2, body));
     }
 
+    if (atMatch(m, e) >> "Function" >> name >> body) {
+        ATermMap subs2(subs);
+        subs2.remove(name);
+        return ATmake("Function1(<term>, <term>)", name,
+            substitute(subs2, body));
+    }
+        
     /* Idem for a mutually recursive attribute set. */
     ATermList rbnds, nrbnds;
     if (atMatch(m, e) >> "Rec" >> rbnds >> nrbnds) {
@@ -249,7 +257,6 @@ void checkVarDefs(const ATermMap & defs, Expr e)
         if (!defs.get(name))
             throw Error(format("undefined variable `%1%'")
                 % aterm2String(name));
-        return;
     }
 
     else if (atMatch(m, e) >> "Function" >> formals >> body) {
@@ -263,7 +270,13 @@ void checkVarDefs(const ATermMap & defs, Expr e)
                     abort();
             defs2.set(name, (ATerm) ATempty);
         }
-        return checkVarDefs(defs2, body);
+        checkVarDefs(defs2, body);
+    }
+        
+    else if (atMatch(m, e) >> "Function1" >> name >> body) {
+        ATermMap defs2(defs);
+        defs2.set(name, (ATerm) ATempty);
+        checkVarDefs(defs2, body);
     }
         
     else if (atMatch(m, e) >> "Rec" >> rbnds >> nrbnds) {