Skip to content
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

Add an option (possibly the default?) for DeepCollectionEquality to handle self-referential structures #18729

Closed
nex3 opened this issue May 8, 2014 · 5 comments
Labels
area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. type-enhancement A request for a change that isn't a bug

Comments

@nex3
Copy link
Member

nex3 commented May 8, 2014

Sometimes it's useful to be able to compare nested object structures that can contain self-referential loops. Currently DeepCollectionEquality causes a stack overflow when passed such structures, but it would be nice if it could handle them. This could be done either as a configuration option or as the default if the prospect of storing back-references isn't too worrisome.

Currently the YAML package has its own custom implementation of deep equality, but it would be nice if it could use the standard implementation instead.

@lrhn
Copy link
Member

lrhn commented May 13, 2014

That should be doable. For each operand, remember each object it is currently being compared to, and if you see that combination again, return true.
It's not fool-proof, but it will catch most simple self-referential structures.

@nex3
Copy link
Member Author

nex3 commented May 13, 2014

I believe YAML's deepEquals operation works like that, but it remembers the order of the objects it's being compared to as well.

@kevmoo
Copy link
Member

kevmoo commented May 13, 2014

Aligning w/ the bits offered from matcher would be nice, too.

Fewer implementations FTW

@nex3
Copy link
Member Author

nex3 commented May 13, 2014

Matcher's use case is a little different, because it needs to track a bunch of extra information to provide useful messaging when the equality fails.

@DartBot
Copy link

DartBot commented Jun 4, 2015

This issue has been moved to dart-lang/collection#6.

@DartBot DartBot closed this as completed Jun 4, 2015
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed triaged labels Mar 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants