mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-02-16 23:27:17 +02:00
Merge pull request #10994 from hercules-ci/fix-value-print-elided
Fix underflow in `printAttrs`, `printList`
This commit is contained in:
commit
dc538ad2f7
4 changed files with 38 additions and 11 deletions
|
@ -163,8 +163,8 @@ private:
|
||||||
EvalState & state;
|
EvalState & state;
|
||||||
PrintOptions options;
|
PrintOptions options;
|
||||||
std::optional<ValuesSeen> seen;
|
std::optional<ValuesSeen> seen;
|
||||||
size_t attrsPrinted = 0;
|
size_t totalAttrsPrinted = 0;
|
||||||
size_t listItemsPrinted = 0;
|
size_t totalListItemsPrinted = 0;
|
||||||
std::string indent;
|
std::string indent;
|
||||||
|
|
||||||
void increaseIndent()
|
void increaseIndent()
|
||||||
|
@ -345,11 +345,13 @@ private:
|
||||||
|
|
||||||
auto prettyPrint = shouldPrettyPrintAttrs(sorted);
|
auto prettyPrint = shouldPrettyPrintAttrs(sorted);
|
||||||
|
|
||||||
|
size_t currentAttrsPrinted = 0;
|
||||||
|
|
||||||
for (auto & i : sorted) {
|
for (auto & i : sorted) {
|
||||||
printSpace(prettyPrint);
|
printSpace(prettyPrint);
|
||||||
|
|
||||||
if (attrsPrinted >= options.maxAttrs) {
|
if (totalAttrsPrinted >= options.maxAttrs) {
|
||||||
printElided(sorted.size() - attrsPrinted, "attribute", "attributes");
|
printElided(sorted.size() - currentAttrsPrinted, "attribute", "attributes");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,7 +359,8 @@ private:
|
||||||
output << " = ";
|
output << " = ";
|
||||||
print(*i.second, depth + 1);
|
print(*i.second, depth + 1);
|
||||||
output << ";";
|
output << ";";
|
||||||
attrsPrinted++;
|
totalAttrsPrinted++;
|
||||||
|
currentAttrsPrinted++;
|
||||||
}
|
}
|
||||||
|
|
||||||
decreaseIndent();
|
decreaseIndent();
|
||||||
|
@ -402,11 +405,14 @@ private:
|
||||||
output << "[";
|
output << "[";
|
||||||
auto listItems = v.listItems();
|
auto listItems = v.listItems();
|
||||||
auto prettyPrint = shouldPrettyPrintList(listItems);
|
auto prettyPrint = shouldPrettyPrintList(listItems);
|
||||||
|
|
||||||
|
size_t currentListItemsPrinted = 0;
|
||||||
|
|
||||||
for (auto elem : listItems) {
|
for (auto elem : listItems) {
|
||||||
printSpace(prettyPrint);
|
printSpace(prettyPrint);
|
||||||
|
|
||||||
if (listItemsPrinted >= options.maxListItems) {
|
if (totalListItemsPrinted >= options.maxListItems) {
|
||||||
printElided(listItems.size() - listItemsPrinted, "item", "items");
|
printElided(listItems.size() - currentListItemsPrinted, "item", "items");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,7 +421,8 @@ private:
|
||||||
} else {
|
} else {
|
||||||
printNullptr();
|
printNullptr();
|
||||||
}
|
}
|
||||||
listItemsPrinted++;
|
totalListItemsPrinted++;
|
||||||
|
currentListItemsPrinted++;
|
||||||
}
|
}
|
||||||
|
|
||||||
decreaseIndent();
|
decreaseIndent();
|
||||||
|
@ -588,8 +595,8 @@ public:
|
||||||
|
|
||||||
void print(Value & v)
|
void print(Value & v)
|
||||||
{
|
{
|
||||||
attrsPrinted = 0;
|
totalAttrsPrinted = 0;
|
||||||
listItemsPrinted = 0;
|
totalListItemsPrinted = 0;
|
||||||
indent.clear();
|
indent.clear();
|
||||||
|
|
||||||
if (options.trackRepeated) {
|
if (options.trackRepeated) {
|
||||||
|
|
|
@ -6,4 +6,4 @@ error:
|
||||||
| ^
|
| ^
|
||||||
10|
|
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» }
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
error:
|
||||||
|
… while evaluating a path segment
|
||||||
|
at /pwd/lang/eval-fail-nested-list-items.nix:11:6:
|
||||||
|
10|
|
||||||
|
11| "" + (let v = [ [ 1 2 3 4 5 6 7 8 ] [1 2 3 4]]; in builtins.deepSeq v v)
|
||||||
|
| ^
|
||||||
|
12|
|
||||||
|
|
||||||
|
error: cannot coerce a list to a string: [ [ 1 2 3 4 5 6 7 8 ] [ 1 «3 items elided» ] ]
|
11
tests/functional/lang/eval-fail-nested-list-items.nix
Normal file
11
tests/functional/lang/eval-fail-nested-list-items.nix
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# This reproduces https://github.com/NixOS/nix/issues/10993, for lists
|
||||||
|
# $ nix run nix/2.23.1 -- eval --expr '"" + (let v = [ [ 1 2 3 4 5 6 7 8 ] [1 2 3 4]]; in builtins.deepSeq v v)'
|
||||||
|
# error:
|
||||||
|
# … while evaluating a path segment
|
||||||
|
# at «string»:1:6:
|
||||||
|
# 1| "" + (let v = [ [ 1 2 3 4 5 6 7 8 ] [1 2 3 4]]; in builtins.deepSeq v v)
|
||||||
|
# | ^
|
||||||
|
#
|
||||||
|
# error: cannot coerce a list to a string: [ [ 1 2 3 4 5 6 7 8 ] [ 1 «4294967290 items elided» ] ]
|
||||||
|
|
||||||
|
"" + (let v = [ [ 1 2 3 4 5 6 7 8 ] [1 2 3 4]]; in builtins.deepSeq v v)
|
Loading…
Add table
Reference in a new issue