fix(tvix/eval): nix_eq() must recurse

The current implementation of nix_eq will force one level of thunks
and then switch to the (non-forcing) rust Eq::eq() method.  This
gives incorrect results for lists-of-thunks.

This commit changes nix_eq() to be recursive.

A regression test (which fails prior to this commit) is included.

This fix also causes nix_tests/eval-okay-fromjson.nix to pass, so it
is moved out of notyetpassing.

Change-Id: I655fd7a5294208a7b39df8e2c3c12a8b9768292f
Signed-off-by: Adam Joseph <adam@westernsemico.com>
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7142
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
Adam Joseph 2022-10-31 03:35:28 -07:00 committed by clbot
parent 98a981a737
commit 9ada456260
5 changed files with 5 additions and 3 deletions

View file

@ -0,0 +1 @@
true

View file

@ -0,0 +1 @@
[["f" ""]] == [["f" ""]]

View file

@ -332,15 +332,15 @@ impl Value {
lhs.force(vm)?; lhs.force(vm)?;
rhs.force(vm)?; rhs.force(vm)?;
Ok(*lhs.value() == *rhs.value()) lhs.value().nix_eq(&*rhs.value(), vm)
} }
(Value::Thunk(lhs), rhs) => { (Value::Thunk(lhs), rhs) => {
lhs.force(vm)?; lhs.force(vm)?;
Ok(&*lhs.value() == rhs) lhs.value().nix_eq(rhs, vm)
} }
(lhs, Value::Thunk(rhs)) => { (lhs, Value::Thunk(rhs)) => {
rhs.force(vm)?; rhs.force(vm)?;
Ok(lhs == &*rhs.value()) lhs.nix_eq(&*rhs.value(), vm)
} }
// Everything else is either incomparable (e.g. internal // Everything else is either incomparable (e.g. internal