mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
Merge pull request #11123 from tweag/fix-non-det-parser-printing
Fix non-deterministic inherit printing
This commit is contained in:
commit
56757e15cf
1 changed files with 5 additions and 3 deletions
|
@ -82,7 +82,9 @@ void ExprAttrs::showBindings(const SymbolTable & symbols, std::ostream & str) co
|
||||||
return sa < sb;
|
return sa < sb;
|
||||||
});
|
});
|
||||||
std::vector<Symbol> inherits;
|
std::vector<Symbol> inherits;
|
||||||
std::map<ExprInheritFrom *, std::vector<Symbol>> inheritsFrom;
|
// We can use the displacement as a proxy for the order in which the symbols were parsed.
|
||||||
|
// The assignment of displacements should be deterministic, so that showBindings is deterministic.
|
||||||
|
std::map<Displacement, std::vector<Symbol>> inheritsFrom;
|
||||||
for (auto & i : sorted) {
|
for (auto & i : sorted) {
|
||||||
switch (i->second.kind) {
|
switch (i->second.kind) {
|
||||||
case AttrDef::Kind::Plain:
|
case AttrDef::Kind::Plain:
|
||||||
|
@ -93,7 +95,7 @@ void ExprAttrs::showBindings(const SymbolTable & symbols, std::ostream & str) co
|
||||||
case AttrDef::Kind::InheritedFrom: {
|
case AttrDef::Kind::InheritedFrom: {
|
||||||
auto & select = dynamic_cast<ExprSelect &>(*i->second.e);
|
auto & select = dynamic_cast<ExprSelect &>(*i->second.e);
|
||||||
auto & from = dynamic_cast<ExprInheritFrom &>(*select.e);
|
auto & from = dynamic_cast<ExprInheritFrom &>(*select.e);
|
||||||
inheritsFrom[&from].push_back(i->first);
|
inheritsFrom[from.displ].push_back(i->first);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +107,7 @@ void ExprAttrs::showBindings(const SymbolTable & symbols, std::ostream & str) co
|
||||||
}
|
}
|
||||||
for (const auto & [from, syms] : inheritsFrom) {
|
for (const auto & [from, syms] : inheritsFrom) {
|
||||||
str << "inherit (";
|
str << "inherit (";
|
||||||
(*inheritFromExprs)[from->displ]->show(symbols, str);
|
(*inheritFromExprs)[from]->show(symbols, str);
|
||||||
str << ")";
|
str << ")";
|
||||||
for (auto sym : syms) str << " " << symbols[sym];
|
for (auto sym : syms) str << " " << symbols[sym];
|
||||||
str << "; ";
|
str << "; ";
|
||||||
|
|
Loading…
Reference in a new issue