diff options
author | Griffin Smith <root@gws.fyi> | 2022-10-08T18·48-0400 |
---|---|---|
committer | grfn <grfn@gws.fyi> | 2022-10-08T19·02+0000 |
commit | f6bcd11cad1e370deb0580ae1a7f4d050cd75bab (patch) | |
tree | 795a5f3a57916147cd4916ce0749ae431375511f /tvix | |
parent | 167718614429322655fa352d20c754612da8d1a8 (diff) |
fix(tvix/eval): Force thunks when comparing against ground vals r/5066
Thunks correctly force when comparing for equality against other thunks, but weren't being forced correctly when comparing against non-thunk values, in either direction. Change-Id: Ia03702895ec4d70aed3445c1b0a9a7a641d1a300 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6897 Autosubmit: grfn <grfn@gws.fyi> Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix')
-rw-r--r-- | tvix/eval/src/tests/tvix_tests/eval-okay-lazy-equality.exp | 2 | ||||
-rw-r--r-- | tvix/eval/src/tests/tvix_tests/eval-okay-lazy-equality.nix | 4 | ||||
-rw-r--r-- | tvix/eval/src/value/mod.rs | 10 |
3 files changed, 13 insertions, 3 deletions
diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-lazy-equality.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-lazy-equality.exp index e6f2d1aaadd2..1c70d1bcf188 100644 --- a/tvix/eval/src/tests/tvix_tests/eval-okay-lazy-equality.exp +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-lazy-equality.exp @@ -1 +1 @@ -[ true true false ] +[ true true false true true ] diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-lazy-equality.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-lazy-equality.nix index b0ec8593a468..d19d1213d695 100644 --- a/tvix/eval/src/tests/tvix_tests/eval-okay-lazy-equality.nix +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-lazy-equality.nix @@ -4,8 +4,12 @@ let list1 = [ (1 + 2) ]; list2 = [ (2 + 1) ]; list3 = [ (2 + 2) ]; + list4 = [ (2 + 2) ]; + list5 = [ (2 + 2) ]; in [ (attrs1 == attrs2) (list1 == list2) (list3 == list2) + (list4 == [ 4 ]) + ([ 4 ] == list5) ] diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs index de59691f278f..e6a6052c21dd 100644 --- a/tvix/eval/src/value/mod.rs +++ b/tvix/eval/src/value/mod.rs @@ -288,8 +288,14 @@ impl Value { Ok(*lhs.value() == *rhs.value()) } - (Value::Thunk(lhs), rhs) => Ok(&*lhs.value() == rhs), - (lhs, Value::Thunk(rhs)) => Ok(lhs == &*rhs.value()), + (Value::Thunk(lhs), rhs) => { + lhs.force(vm)?; + Ok(&*lhs.value() == rhs) + } + (lhs, Value::Thunk(rhs)) => { + rhs.force(vm)?; + Ok(lhs == &*rhs.value()) + } // Everything else is either incomparable (e.g. internal // types) or false. |