about summary refs log tree commit diff
path: root/src/libexpr/eval.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2009-05-12T11·06+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2009-05-12T11·06+0000
commit50d11b90caf6545556fc090858c694e19f3c7683 (patch)
treed02d64d1162c489ff52c225612f2e9d4600602bb /src/libexpr/eval.cc
parentc34e6d71bc62bb83f3bfed69f781ded4d5a46d3a (diff)
* Allow unsafe (unspecified) comparisons between attrsets unless
  NIX_NO_UNSAFE_EQ is set, for now.

Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r--src/libexpr/eval.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 2b9b96559d7d..cd9c64594747 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -23,6 +23,8 @@ EvalState::EvalState()
     initNixExprHelpers();
 
     addPrimOps();
+
+    allowUnsafeEquality = getEnv("NIX_NO_UNSAFE_EQ", "") == "";
 }
 
 
@@ -661,9 +663,13 @@ LocalNoInline(bool areEqual(EvalState & state, Expr e1, Expr e2))
     /* Functions are incomparable. */
     if (sym1 == symFunction || sym1 == symPrimOp) return false;
 
-    if (sym1 == symAttrs)
+    if (!state.allowUnsafeEquality && sym1 == symAttrs)
         throw EvalError("comparison of attribute sets is not implemented");
 
+    /* !!! This allows comparisons of infinite data structures to
+       succeed, such as `let x = [x]; in x == x'.  This is
+       undesirable, since equivalent (?) terms such as `let x = [x]; y
+       = [y]; in x == y' don't terminate. */
     if (e1 == e2) return true;
     
     if (sym1 == symList) {