[refactor] equal_tag => equal_constr#13467
Merged
gasche merged 2 commits intoocaml:trunkfrom Sep 25, 2024
Merged
Conversation
47cc9c9 to
e585ed7
Compare
This was referenced Sep 25, 2024
e585ed7 to
420b2a2
Compare
If two extension constructors have the same path, then they correspond to the same declaration, and they must have the same constantness.
420b2a2 to
c40f773
Compare
Member
Author
|
I rebased this now that #13466 is merged. @Octachron remarked that I performed a slight simplification of the equality check in the extension-constructor case, and I added a commit that does this explicitly (rather than inside a refactoring commit) to clarify things. |
Octachron
approved these changes
Sep 25, 2024
Member
Octachron
left a comment
There was a problem hiding this comment.
This is a clear simplification for all call sites.
c40f773 to
be4b164
Compare
Member
Author
|
Thanks! Merging. |
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.
(This PR is on top of #13466.)
The type-checker and pattern-matching compiler rely on a check that the "tags" of two constructors are equal. This check is hard to extend to new/funky sorts of constructors (extension constructor (existing), unboxed constructors (upcoming!)), and is also performance-sensitive ( #406 ).
Most uses in the codebase are not actually trying to check tag equality, but just whether two constructors are equal. We refactor the codebase to introduce a new
equal_constrfunction and use it directly. This makes the intent clearer, it will be easier to extend with newer kinds of constructors, and it would probably help to make the check more efficient.