diff options
author | eldritch horrors <pennae@lix.systems> | 2024-01-29 06:19:23 +0100 |
---|---|---|
committer | eldritch horrors <pennae@lix.systems> | 2024-03-18 07:56:34 -0600 |
commit | d826427f022308f9ec2ee8f0ec9f7df85089fdf7 (patch) | |
tree | 43b7e234ed294b8f3d13db2eb4f4b5aa3d944e43 /src | |
parent | 314f044c2bbb8dd8799df6c76f6d81109bf35043 (diff) |
normalize formal order on ExprLambda::show
we already normalize attr order to lexicographic, doing the same for
formals makes sense. doubly so because the order of formals would
otherwise depend on the context of the expression, which is not quite as
useful as one might expect.
(cherry picked from commit 4147ecfb1c51f3fe3b4adcbd4e753fd487dab645)
Change-Id: I3fd0dbdef3ac7447a3a03ff20bb514a0d0f23fb1
Diffstat (limited to 'src')
-rw-r--r-- | src/libexpr/nixexpr.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc index 3bcd35fef..c591916e3 100644 --- a/src/libexpr/nixexpr.cc +++ b/src/libexpr/nixexpr.cc @@ -147,7 +147,10 @@ void ExprLambda::show(const SymbolTable & symbols, std::ostream & str) const if (hasFormals()) { str << "{ "; bool first = true; - for (auto & i : formals->formals) { + // the natural Symbol ordering is by creation time, which can lead to the + // same expression being printed in two different ways depending on its + // context. always use lexicographic ordering to avoid this. + for (auto & i : formals->lexicographicOrder(symbols)) { if (first) first = false; else str << ", "; str << symbols[i.name]; if (i.def) { |