diff --git a/lix/libexpr/eval.cc b/lix/libexpr/eval.cc index 564b0ab8a..83bc533a4 100644 --- a/lix/libexpr/eval.cc +++ b/lix/libexpr/eval.cc @@ -1259,6 +1259,14 @@ void ExprVar::eval(EvalState & state, Env & env, Value & v) } +void ExprInheritFrom::eval(EvalState & state, Env & env, Value & v) +{ + Value * v2 = env.values[displ]; + state.forceValue(*v2, pos); + v = *v2; +} + + static std::string showAttrPath(EvalState & state, Env & env, const AttrPath & attrPath) { std::ostringstream out; diff --git a/lix/libexpr/nixexpr.hh b/lix/libexpr/nixexpr.hh index 663f48cb0..efefa190d 100644 --- a/lix/libexpr/nixexpr.hh +++ b/lix/libexpr/nixexpr.hh @@ -138,20 +138,17 @@ struct ExprVar : Expr * Unlike normal variable references, the displacement is set during parsing, and always refers to * `ExprAttrs::inheritFromExprs` (by itself or in `ExprLet`), whose values are put into their own `Env`. */ -struct ExprInheritFrom : ExprVar +struct ExprInheritFrom : Expr { ref fromExpr; + Displacement displ; ExprInheritFrom(PosIdx pos, Displacement displ, ref fromExpr) - : ExprVar(pos, {}), fromExpr(fromExpr) + : Expr(pos), fromExpr(fromExpr), displ(displ) { - this->level = 0; - this->displ = displ; - this->fromWith = nullptr; } - JSON toJSON(SymbolTable const & symbols) const override; - void bindVars(Evaluator & es, const std::shared_ptr & env) override; + COMMON_METHODS }; struct ExprSelect : Expr