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.
This commit is contained in:
parent
371013c08d
commit
dc205c75a2
|
@ -2454,8 +2454,8 @@ static RegisterPrimOp primop_intersectAttrs({
|
|||
.name = "__intersectAttrs",
|
||||
.args = {"e1", "e2"},
|
||||
.doc = R"(
|
||||
Return a set consisting of the attributes in the set *e2* that also
|
||||
exist in the set *e1*.
|
||||
Return a set consisting of the attributes in the set *e2* which have the
|
||||
same name as some attribute in *e1*.
|
||||
)",
|
||||
.fun = prim_intersectAttrs,
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue