-
Notifications
You must be signed in to change notification settings - Fork 18k
reflect: should DeepEqual handle cyclic references? #15610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I suspect we're done making changes to DeepEqual, but I'll keep this bug open for us to decide later, during the Go 1.8 dev cycle. |
This seems like a legit, albeit niche, inconsistency to me. If Test's declaration is changed from The obvious fix is to simply relax the deepEqualValue's "hard" predicate to include Ptr-Kinded Values. Downside is this would probably grow the number of entries needed in the visited map for typical programs that don't create cycles using only pointer types. I suspect we can fix it somehow without regressing typical programs though. @gavv How did you discover this problem? Do you have a real-world application that's negatively affected by it? |
Yes, this does work, just checked.
It was a failing test for deepcopy module found on github. Not a real-world application though, but I assume this test worked before so it's probably a regression. |
Yes, this is a bug, since type Test struct { X *Test } works fine. It's a bug that's been there since the initial Go release, but still a bug. Another failing case:
In the implementation, the goal of the 'hard' predicate is to avoid making visited too big. I think it should work to change hard to be
|
CL https://golang.org/cl/31588 mentions this issue. |
Hi!
Here is a test case:
I'm using go 1.6.1 on Linux and this test fails with a stack overflow.
It seems that
reflect.DeepEqual
could theoretically handle cyclic references, but it doesn't checkvisited
map for pointers.Is this a bug (probably regression) of feature? If it's a feature, it will be nice if it would be documented.
The text was updated successfully, but these errors were encountered: