about summary refs log tree commit diff
path: root/src/libexpr/nixexpr.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2008-08-14T12·53+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2008-08-14T12·53+0000
commit1b962fc7206bf3134b2a2097d3db0ee6d2863c47 (patch)
tree9e259b7df5f0fa3ca748fa9b9035f2dd35b1a44d /src/libexpr/nixexpr.cc
parente8188384129bda7c8cdd5e17023ab05047551e6e (diff)
* @-patterns as in Haskell. For instance, in a function definition
    f = args @ {x, y, z}: ...;

  `args' refers to the argument as a whole, which is further
  pattern-matched against the attribute set pattern {x, y, z}.

Diffstat (limited to 'src/libexpr/nixexpr.cc')
-rw-r--r--src/libexpr/nixexpr.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc
index 4744cdde39ad..b2d775abbcc2 100644
--- a/src/libexpr/nixexpr.cc
+++ b/src/libexpr/nixexpr.cc
@@ -114,6 +114,7 @@ static void varsBoundByPattern(ATermMap & map, Pattern pat)
 {
     ATerm name;
     ATermList formals;
+    Pattern pat1, pat2;    
     /* Use makeRemoved() so that it can be used directly in
        substitute(). */
     if (matchVarPat(pat, name))
@@ -125,6 +126,10 @@ static void varsBoundByPattern(ATermMap & map, Pattern pat)
             map.set(name, makeRemoved());
         }
     }
+    else if (matchAtPat(pat, pat1, pat2)) {
+        varsBoundByPattern(map, pat1);
+        varsBoundByPattern(map, pat2);
+    }
     else abort();
 }
 
@@ -354,7 +359,7 @@ Expr makeStr(const string & s, const PathSet & context)
 
 string showType(Expr e)
 {
-    ATerm t1, t2, t3;
+    ATerm t1, t2;
     ATermList l1;
     ATermBlob b1;
     int i1;