v icon indicating copy to clipboard operation
v copied to clipboard

when <circular> printing does not show the number of item in the array

Open Eliyaan opened this issue 1 year ago • 2 comments

Describe the bug

When printing a struct with an array that prints as [<circular>], it does not show the number of items in the array.

Reproduction Steps

 struct Bar {
 mut:
         children []Bar
 }
 
 fn main() {
         mut a := Bar{}
         a.children << Bar{}
         a.children << Bar{}
         println(a)
         println(a.children)
}

Expected Behavior

Bar{
    children: [<circular>, <circular>]
}
[Bar{
    children: []
}, Bar{
    children: []
}]

Current Behavior

Bar{
    children: [<circular>]
}
[Bar{
    children: []
}, Bar{
    children: []
}]

Possible Solution

No response

Additional Information/Context

And maybe instead of <circular> the print could show <circular?> as it does not know whether or not it is circular.

V version

V full version: V 0.4.6 294f7e4.bebe943

Environment details (OS name and version, etc.)

V full version: V 0.4.6 294f7e4.bebe943
OS: linux, Linux version 6.7.11-200.fc39.x86_64 (mockbuild@bdb8d24f206645e2bda44c1cf867612d) (gcc (GCC) 13.2.1 20240316 (Red Hat 13.2.1-7), GNU ld version 2.40-14.fc39) #1 SMP PREEMPT_DYNAMIC Wed Mar 27 16:50:39 UTC 2024

[!NOTE] You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote. Other reactions and those to comments will not be taken into account.

Eliyaan avatar Jun 17 '24 13:06 Eliyaan

The problem it is reporting is circular references. Why would you need to know how many were in the same array?

JalonSolov avatar Jun 17 '24 13:06 JalonSolov

Because it is useful when debugging to know how many items are in the array. related conversation: https://discord.com/channels/592103645835821068/592106336838352923/1251933620214693978

Eliyaan avatar Jun 17 '24 13:06 Eliyaan