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

handle reference cycles in is_deep_equal to avoid stack overflow #4

Merged
merged 2 commits into from
Feb 14, 2023

Conversation

bandaloo
Copy link
Contributor

@bandaloo bandaloo commented Feb 6, 2023

i was scratching my head, thinking if it's just a "garbage in, garbage out" situation and it's best to ignore it. but i looked at some other assertion frameworks to see if they handle this sort of thing, and they typically do. since the code changes are minimal, and the extra memory it uses to keep track of visited tables is bounded by the size of the tables being compared, i feel like it's worth it.

the first test i added actually passes in the original is_deep_equal implementation, but i thought it is just a good test to have. the last two tests would go into infinite recursion without this fix.

@EvandroLG
Copy link
Owner

Another really good catch, @bandaloo! Thanks a million, man!

@EvandroLG EvandroLG merged commit d34b625 into EvandroLG:master Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants