* Allow unsafe (unspecified) comparisons between attrsets unless

NIX_NO_UNSAFE_EQ is set, for now.
This commit is contained in:
Eelco Dolstra 2009-05-12 11:06:24 +00:00
parent c34e6d71bc
commit 50d11b90ca
2 changed files with 9 additions and 1 deletions

View File

@ -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) {

View File

@ -38,6 +38,8 @@ struct EvalState
unsigned int nrEvaluated;
unsigned int nrCached;
bool allowUnsafeEquality;
EvalState();
void addPrimOps();