diff options
author | Adam Joseph <adam@westernsemico.com> | 2022-09-24 23:51:09 -0700 |
---|---|---|
committer | Adam Joseph <adam@westernsemico.com> | 2022-09-24 23:51:09 -0700 |
commit | dc205c75a24f4159ef92905b08cb59179d78c345 (patch) | |
tree | 3189c391bb2b5441bd276368303d046918917a6f /tests/lang/eval-okay-redefine-builtin.exp | |
parent | 371013c08dc68d90c003ac677045ecbc9b463e8c (diff) |
src/libexpr/primops.cc: correct definition for intersectAttrs
The current definition of `intersectAttrs` is incorrect:
> Return a set consisting of the attributes in the set e2 that also exist in the
> set e1.
Recall that (Nix manual, section 5.1):
> An attribute set is a collection of name-value-pairs (called attributes)
According to the existing description of `intersectAttrs`, the following should
evaluate to the empty set, since no key-value *pair* (i.e. attribute) exists in
both sets:
```
builtins.intersectAttrs { x=3; } {x="foo";}
```
And yet:
```
nix-repl> builtins.intersectAttrs { x=3; } {x="foo";}
{ x = "foo"; }
```
Clearly the intent here was for the *names* of the resulting attribute set to be
the intersection of the *names* of the two arguments, and for the values of the
resulting attribute set to be the values from the second argument.
This commit corrects the definition, making it match the implementation and intent.
Diffstat (limited to 'tests/lang/eval-okay-redefine-builtin.exp')
0 files changed, 0 insertions, 0 deletions