diff --git a/src/libexpr/print.cc b/src/libexpr/print.cc index 7ef21dfa9..71ab1edbf 100644 --- a/src/libexpr/print.cc +++ b/src/libexpr/print.cc @@ -337,11 +337,12 @@ private: auto prettyPrint = shouldPrettyPrintAttrs(sorted); + size_t printedHere = 0; for (auto & i : sorted) { printSpace(prettyPrint); if (attrsPrinted >= options.maxAttrs) { - printElided(sorted.size() - attrsPrinted, "attribute", "attributes"); + printElided(sorted.size() - printedHere, "attribute", "attributes"); break; } @@ -350,6 +351,7 @@ private: print(*i.second, depth + 1); output << ";"; attrsPrinted++; + printedHere++; } decreaseIndent(); @@ -394,11 +396,12 @@ private: output << "["; auto listItems = v.listItems(); auto prettyPrint = shouldPrettyPrintList(listItems); + size_t printedHere = 0; for (auto elem : listItems) { printSpace(prettyPrint); if (listItemsPrinted >= options.maxListItems) { - printElided(v.listSize() - listItemsPrinted, "item", "items"); + printElided(v.listSize() - printedHere, "item", "items"); break; } @@ -408,6 +411,7 @@ private: printNullptr(); } listItemsPrinted++; + printedHere++; } decreaseIndent(); diff --git a/tests/functional/lang/eval-fail-bad-string-interpolation-4.err.exp b/tests/functional/lang/eval-fail-bad-string-interpolation-4.err.exp index 6f907106b..b262e814d 100644 --- a/tests/functional/lang/eval-fail-bad-string-interpolation-4.err.exp +++ b/tests/functional/lang/eval-fail-bad-string-interpolation-4.err.exp @@ -6,4 +6,4 @@ error: | ^ 10| - error: cannot coerce a set to a string: { a = { a = { a = { a = "ha"; b = "ha"; c = "ha"; d = "ha"; e = "ha"; f = "ha"; g = "ha"; h = "ha"; j = "ha"; }; «4294967295 attributes elided» }; «4294967294 attributes elided» }; «4294967293 attributes elided» } + error: cannot coerce a set to a string: { a = { a = { a = { a = "ha"; b = "ha"; c = "ha"; d = "ha"; e = "ha"; f = "ha"; g = "ha"; h = "ha"; j = "ha"; }; «8 attributes elided» }; «8 attributes elided» }; «8 attributes elided» } diff --git a/tests/functional/lang/eval-fail-print-limit-list.err.exp b/tests/functional/lang/eval-fail-print-limit-list.err.exp new file mode 100644 index 000000000..2f347d15a --- /dev/null +++ b/tests/functional/lang/eval-fail-print-limit-list.err.exp @@ -0,0 +1,12 @@ +error: + … in the condition of the assert statement + at /pwd/lang/eval-fail-print-limit-list.nix:1:1: + 1| assert ( + | ^ + 2| let x = [ 1 [ 2 3 4 5 6 7 8 9 x 10 11 ] 12 ]; + + error: expected a Boolean but found a list: [ 1 [ 2 3 4 5 6 7 8 9 [ 1 «2 items elided» ] «2 items elided» ] «1 item elided» ] + at /pwd/lang/eval-fail-print-limit-list.nix:1:1: + 1| assert ( + | ^ + 2| let x = [ 1 [ 2 3 4 5 6 7 8 9 x 10 11 ] 12 ]; diff --git a/tests/functional/lang/eval-fail-print-limit-list.nix b/tests/functional/lang/eval-fail-print-limit-list.nix new file mode 100644 index 000000000..14715f04d --- /dev/null +++ b/tests/functional/lang/eval-fail-print-limit-list.nix @@ -0,0 +1,4 @@ +assert ( + let x = [ 1 [ 2 3 4 5 6 7 8 9 x 10 11 ] 12 ]; + in builtins.deepSeq x x +); 1 diff --git a/tests/functional/lang/eval-fail-print-limit-set.err.exp b/tests/functional/lang/eval-fail-print-limit-set.err.exp new file mode 100644 index 000000000..c5086fb76 --- /dev/null +++ b/tests/functional/lang/eval-fail-print-limit-set.err.exp @@ -0,0 +1,12 @@ +error: + … in the condition of the assert statement + at /pwd/lang/eval-fail-print-limit-set.nix:1:1: + 1| assert ( + | ^ + 2| let x = { a.a.a.a.a.a.a.a.a = { a.a = 1; b = 2; }; a.b.c.x = 3; c = 4; }; + + error: expected a Boolean but found a set: { a = { a = { a = { a = { a = { a = { a = { a = { a = { a = { ... }; b = 2; }; }; }; }; }; }; }; }; «1 attribute elided» }; «1 attribute elided» } + at /pwd/lang/eval-fail-print-limit-set.nix:1:1: + 1| assert ( + | ^ + 2| let x = { a.a.a.a.a.a.a.a.a = { a.a = 1; b = 2; }; a.b.c.x = 3; c = 4; }; diff --git a/tests/functional/lang/eval-fail-print-limit-set.nix b/tests/functional/lang/eval-fail-print-limit-set.nix new file mode 100644 index 000000000..b268cb7f7 --- /dev/null +++ b/tests/functional/lang/eval-fail-print-limit-set.nix @@ -0,0 +1,4 @@ +assert ( + let x = { a.a.a.a.a.a.a.a.a = { a.a = 1; b = 2; }; a.b.c.x = 3; c = 4; }; + in builtins.deepSeq x x +); 1