Merge pull request #9926 from 9999years/fix-cycle-detection-in-nix-repl

Fix cycle detection in `nix repl`

(cherry picked from commit e190c20c33)
Change-Id: Ie385e781b9f0b7171ca653bcd53a990bb41f9e4b
This commit is contained in:
eldritch horrors 2024-03-08 06:26:06 +01:00
parent 1bb8fe48a2
commit b6b31d255a
2 changed files with 4 additions and 4 deletions

View file

@ -150,7 +150,7 @@ struct ImportantFirstAttrNameCmp
} }
}; };
typedef std::set<Value *> ValuesSeen; typedef std::set<const void *> ValuesSeen;
class Printer class Printer
{ {
@ -260,7 +260,7 @@ private:
void printAttrs(Value & v, size_t depth) void printAttrs(Value & v, size_t depth)
{ {
if (seen && !seen->insert(&v).second) { if (seen && !seen->insert(v.attrs).second) {
printRepeated(); printRepeated();
return; return;
} }

View file

@ -161,7 +161,7 @@ testReplResponseNoRegex '
# Same for let expressions # Same for let expressions
testReplResponseNoRegex ' testReplResponseNoRegex '
let x = { y = { a = 1; }; inherit x; }; in x let x = { y = { a = 1; }; inherit x; }; in x
' '{ x = { ... }; y = { ... }; }' ' '{ x = «repeated»; y = { ... }; }'
# The :p command should recursively print sets, but prevent infinite recursion # The :p command should recursively print sets, but prevent infinite recursion
testReplResponseNoRegex ' testReplResponseNoRegex '
@ -176,4 +176,4 @@ testReplResponseNoRegex '
# Same for let expressions # Same for let expressions
testReplResponseNoRegex ' testReplResponseNoRegex '
:p let x = { y = { a = 1; }; inherit x; }; in x :p let x = { y = { a = 1; }; inherit x; }; in x
' '{ x = { x = «repeated»; y = { a = 1; }; }; y = «repeated»; }' ' '{ x = «repeated»; y = { a = 1; }; }'