Make sure we use compare by identity Sets properly#1735
Merged
Conversation
Morriar
approved these changes
Dec 18, 2023
vinistock
approved these changes
Dec 18, 2023
amomchilov
reviewed
Dec 18, 2023
| def processable_constants | ||
| @processable_constants ||= T.let( | ||
| T::Set[Module].new(gather_constants).compare_by_identity, | ||
| T::Set[Module].new.compare_by_identity.merge(gather_constants), |
Contributor
There was a problem hiding this comment.
Is this some kind of perf optimization?
Member
Author
There was a problem hiding this comment.
No. The constants that we are handed could be doing anything, like implementing self.hash method as in this example. If we don't use a compare_by_identity set to store them, then their hash method gets called (among others), which could raise, as it was happening on #1728.
If a constant implements `self.hash`, then Tapioca DSL compiler should be resilient against it.
There have been a few instances where we have not been using `Set`s with `compare_by_identity` properly. This commit fixes those instances so that the test added in the previous commit passes. Fixes #1728
4426ba2 to
c1333df
Compare
Sets properly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Fix #1728
Implementation
There were a few places where we have not been using
Sets withcompare_by_identityproperly. This commit fixes those instances so that the test added in the previous commit passes.Tests
Added a failing test that passes with the fix.