aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorAdam Joseph <adam@westernsemico.com>2022-09-24 23:51:09 -0700
committerAdam Joseph <adam@westernsemico.com>2022-09-24 23:51:09 -0700
commitdc205c75a24f4159ef92905b08cb59179d78c345 (patch)
tree3189c391bb2b5441bd276368303d046918917a6f /src/libexpr
parent371013c08dc68d90c003ac677045ecbc9b463e8c (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 'src/libexpr')
-rw-r--r--src/libexpr/primops.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index bc253d0a3..28b998474 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -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,
});