about summary refs log tree commit diff
path: root/src/libexpr/nixexpr.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr/nixexpr.hh')
-rw-r--r--src/libexpr/nixexpr.hh9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh
index 9e5a262d7f46..4da77ee5861a 100644
--- a/src/libexpr/nixexpr.hh
+++ b/src/libexpr/nixexpr.hh
@@ -128,6 +128,7 @@ struct ExprAttrs : Expr
     typedef std::map<Symbol, Expr *> Attrs;
     Attrs attrs;
     list<VarRef> inherited;
+    set<Symbol> attrNames; // used during parsing
     ExprAttrs() : recursive(false) { };
     COMMON_METHODS
 };
@@ -150,6 +151,7 @@ struct Formals
 {
     typedef std::list<Formal> Formals_;
     Formals_ formals;
+    std::set<Symbol> argNames; // used during parsing
     bool ellipsis;
 };
 
@@ -161,7 +163,12 @@ struct ExprLambda : Expr
     Formals * formals;
     Expr * body;
     ExprLambda(const Pos & pos, const Symbol & arg, bool matchAttrs, Formals * formals, Expr * body)
-        : pos(pos), arg(arg), matchAttrs(matchAttrs), formals(formals), body(body) { };
+        : pos(pos), arg(arg), matchAttrs(matchAttrs), formals(formals), body(body)
+    {
+        if (!arg.empty() && formals && formals->argNames.find(arg) != formals->argNames.end())
+            throw ParseError(format("duplicate formal function argument `%1%' at %2%")
+                % arg % pos);
+    };
     COMMON_METHODS
 };