pattern-matching refactoring: refine the type of complete_constrs#9599
Merged
gasche merged 2 commits intoocaml:trunkfrom May 27, 2020
Merged
pattern-matching refactoring: refine the type of complete_constrs#9599gasche merged 2 commits intoocaml:trunkfrom
complete_constrs#9599gasche merged 2 commits intoocaml:trunkfrom
Conversation
This loses no information (descriptions contain the tag), but it will make it easier to obtain the descriptions inside `combine_constructor` without doing a dynamic check on the patterns. This will in turn help simplify the interaction with `Parmatch.complete_constrs`. Note: after this patch we use `Types.equal_tag` instead of `( = )` to compare tags during pattern-matching compilation. This is better code, and we believe that it does not change the behavior: `Types.equal_tag` is mostly similar to a type-specialized version of `( = )`, except that it calls `Ident.same` that just compares the stamps and ignore the names, which (assuming well-formedness of idents) is equivalent and slightly faster.
This simplifies this particular interface boundary between Matching and Parmatch. (Suggested by Florian Angeletti)
b3b5ab6 to
bf95a24
Compare
Member
Author
|
Thanks for the review! I ran |
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 is an offspring of #9563 (the n-th piece of the big pattern-matching refactoring #9321) that was suggested by @Octachron during review.
We change the amount of information carried about variant constructors during pattern-matching compilation, to be able to refine the type of the function
complete_constrsthat sits at the Matching/Parmatch boundary, which would previously accept any pattern statically, and do a dynamic check that fails unless it is in fact a variant constructor pattern.