diff options
Diffstat (limited to 'src/libexpr/parser.y')
-rw-r--r-- | src/libexpr/parser.y | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index ae5723a6f..ee44a6d7a 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -319,14 +319,17 @@ binds } | binds INHERIT '(' expr ')' attrs ';' { $$ = $1; - /* !!! Should ensure sharing of the expression in $4. */ + if (!$$->inheritFromExprs) + $$->inheritFromExprs = std::make_unique<std::vector<Expr *>>(); + $$->inheritFromExprs->push_back($4); + auto from = new nix::ExprInheritFrom(state->at(@4), $$->inheritFromExprs->size() - 1); for (auto & i : *$6) { if ($$->attrs.find(i.symbol) != $$->attrs.end()) state->dupAttr(i.symbol, state->at(@6), $$->attrs[i.symbol].pos); $$->attrs.emplace( i.symbol, ExprAttrs::AttrDef( - new ExprSelect(CUR_POS, $4, i.symbol), + new ExprSelect(CUR_POS, from, i.symbol), state->at(@6), ExprAttrs::AttrDef::Kind::InheritedFrom)); } |