Skip to content

Commit

Permalink
Circular reference error info in ToJson (#3522)
Browse files Browse the repository at this point in the history
Co-authored-by: Shargon <[email protected]>
  • Loading branch information
Hecate2 and shargon authored Oct 10, 2024
1 parent 52393be commit 5d2d8da
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Neo/VM/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ private static JObject ToJson(StackItem item, HashSet<StackItem> context, ref in
case Array array:
{
context ??= new HashSet<StackItem>(ReferenceEqualityComparer.Instance);
if (!context.Add(array)) throw new InvalidOperationException();
if (!context.Add(array)) throw new InvalidOperationException("Circular reference.");
maxSize -= 2/*[]*/+ Math.Max(0, (array.Count - 1))/*,*/;
JArray a = new();
foreach (StackItem stackItem in array)
Expand Down Expand Up @@ -398,7 +398,7 @@ private static JObject ToJson(StackItem item, HashSet<StackItem> context, ref in
case Map map:
{
context ??= new HashSet<StackItem>(ReferenceEqualityComparer.Instance);
if (!context.Add(map)) throw new InvalidOperationException();
if (!context.Add(map)) throw new InvalidOperationException("Circular reference.");
maxSize -= 2/*[]*/+ Math.Max(0, (map.Count - 1))/*,*/;
JArray a = new();
foreach (var (k, v) in map)
Expand Down

0 comments on commit 5d2d8da

Please sign in to comment.