From 1b962fc7206bf3134b2a2097d3db0ee6d2863c47 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 14 Aug 2008 12:53:29 +0000 Subject: * @-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}. --- src/libexpr/nixexpr.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/libexpr/nixexpr.cc') 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; -- cgit 1.4.1