feat(tvix/eval): implement attrset update (//) operator

The underlying implementation does a few tricks based on which pair of
attrset representations is encountered.

Particularly the effect of short-circuiting the empty cases might be
relevant in nixpkgs/NixOS, due to the use of lib.optionalAttrs.

Change-Id: I22b978b1c69af12926489a71087c6a6219c012f3
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6140
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2022-08-10 21:01:15 +03:00 committed by tazjin
parent fa2d250d1a
commit 058e77bab2
13 changed files with 87 additions and 1 deletions

View file

@ -0,0 +1 @@
{ a = "ok"; }

View file

@ -0,0 +1 @@
{} // { a = "ok"; }

View file

@ -0,0 +1 @@
{ a = "ok"; }

View file

@ -0,0 +1 @@
{ a = "ok"; } // {}

View file

@ -0,0 +1 @@
{ name = "foo"; other = 42; value = "bar"; }

View file

@ -0,0 +1 @@
{ name = "foo"; value = "bar"; } // { other = 42; }

View file

@ -0,0 +1 @@
{ a = 15; b = "works"; }

View file

@ -0,0 +1 @@
{ a = 15; } // { b = "works"; }