aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/eval.cc
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-08 09:51:40 +0100
committereldritch horrors <pennae@lix.systems>2024-03-10 03:18:32 -0600
commit1cf0fa06332712e41e132dd8fce1198c89351e6e (patch)
tree6bd76f019950a5f40c5420611bfe66a5df252da7 /src/libexpr/eval.cc
parent03f852b2c69233667de839a4777331114304c983 (diff)
add ExprAttrs::AttrDef::chooseByKind
in place of inherited() — not quite useful yet since we don't distinguish plain and inheritFrom attr kinds so far. (cherry picked from commit 1f542adb3e18e7078e6a589182a53a47d971748a) Change-Id: If948c9d43e875de18f213a73a06a36f7c335b536
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r--src/libexpr/eval.cc22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index bf4c917c6..e30c32d92 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -1240,9 +1240,9 @@ void ExprAttrs::eval(EvalState & state, Env & env, Value & v)
Value * vAttr;
if (hasOverrides && !i.second.inherited()) {
vAttr = state.allocValue();
- mkThunk(*vAttr, env2, i.second.e);
+ mkThunk(*vAttr, *i.second.chooseByKind(&env2, &env, &env2), i.second.e);
} else
- vAttr = i.second.e->maybeThunk(state, i.second.inherited() ? env : env2);
+ vAttr = i.second.e->maybeThunk(state, *i.second.chooseByKind(&env2, &env, &env2));
env2.values[displ++] = vAttr;
v.attrs->push_back(Attr(i.first, vAttr, i.second.pos));
}
@@ -1274,9 +1274,14 @@ void ExprAttrs::eval(EvalState & state, Env & env, Value & v)
}
}
- else
- for (auto & i : attrs)
- v.attrs->push_back(Attr(i.first, i.second.e->maybeThunk(state, env), i.second.pos));
+ else {
+ for (auto & i : attrs) {
+ v.attrs->push_back(Attr(
+ i.first,
+ i.second.e->maybeThunk(state, *i.second.chooseByKind(&env, &env, &env)),
+ i.second.pos));
+ }
+ }
/* Dynamic attrs apply *after* rec and __overrides. */
for (auto & i : dynamicAttrs) {
@@ -1312,8 +1317,11 @@ void ExprLet::eval(EvalState & state, Env & env, Value & v)
while the inherited attributes are evaluated in the original
environment. */
Displacement displ = 0;
- for (auto & i : attrs->attrs)
- env2.values[displ++] = i.second.e->maybeThunk(state, i.second.inherited() ? env : env2);
+ for (auto & i : attrs->attrs) {
+ env2.values[displ++] = i.second.e->maybeThunk(
+ state,
+ *i.second.chooseByKind(&env2, &env, &env2));
+ }
auto dts = state.debugRepl
? makeDebugTraceStacker(