You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 12, 2019. It is now read-only.
I have searched existing issues and this is not a duplicate.
General information
Library version: 2.0.1
Expected behavior
The depth of the description of a reference cycled object should be limited.
Actual behavior
Obviously, it is not, which causes stack overflow.
Steps to reproduce
classA:CustomStringConvertible{varb:Binit(b:B){self.b = b
}}classB:CustomStringConvertible{
weak vara:A?init(){}}letb=B()leta=A(b: b)
b.a = a
print(a.description)
The text was updated successfully, but these errors were encountered:
@jessesquires well, I've just tried to fix it, but have come up with nothing.
The first idea that comes to mind is to add the currentDepth argument to the generateDefaultDescription and generateDeepDescription and decrease it when calling this function recursively. However we don't and can't always call it explicitly. For example, if an object contains a property of some value type, we cannot determine if this value type provides its description using DefaultStringConvertible implementation or its own, custom description. So we must fetch its description using not the generateDefaultDescription method, but String(describing:) function (or string interpolation, which is the equivalent). So depth counting using recursive calls with a decreasing currentDepth argument is quite difficult if not impossible.
Well we could use completely different solution, which is yet to be developed (and as I said I couldn't come up with one). But I'm afraid it won't be that elegant at all.
I feel that this situation is exactly the reason why classes don't provide any default description.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Uh oh!
There was an error while loading. Please reload this page.
New issue checklist
README
and documentation.General information
Expected behavior
The depth of the description of a reference cycled object should be limited.
Actual behavior
Obviously, it is not, which causes stack overflow.
Steps to reproduce
The text was updated successfully, but these errors were encountered: