This patch causes an error to be thrown if an output is given the same name as a derivation attribute. This will allow unambiguous referencing of outputs once the packageName.outputName method of referencing alternate outputs is put into place. This patch won't apply properly if my previous patch is not applied, but that patch has less potential problems from what I can see, so I decided to submit them separately.
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index b093e7f..686eedf 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -298,6 +298,10 @@ static void prim_derivationStrict(EvalState & state, Value 
* * args, Value & v)
                 }
             }
 
+            /* Attributes can't have the same name as outputs */
+            else if (outputs.find(key) != outputs.end())
+                throw EvalError(format("attribute name `%1%' is also a 
derivation output name") % key);
+
             /* All other attributes are passed to the builder through
                the environment. */
             else {
@@ -328,6 +332,9 @@ static void prim_derivationStrict(EvalState & state, Value 
* * args, Value & v)
                            to all of the outputs of a derivation */
                         if (*j == "drv" || *j == "all")
                             throw EvalError(format("invalid derivation output 
name `%1%'") % *j);
+                        /* Outputs can't have the same name as attributes */
+                        else if (drv.env.find(*j) != drv.env.end())
+                            throw EvalError(format("derivation output name 
`%1%' is also an attribute name") % *j);
                         outputs.insert(*j);
                     }
                     if (outputs.empty())
_______________________________________________
nix-dev mailing list
[email protected]
https://mail.cs.uu.nl/mailman/listinfo/nix-dev

Reply via email to