Add support for typer coercion for invariant type arguments such as a…#6518
Merged
Add support for typer coercion for invariant type arguments such as a…#6518
Conversation
…rray payloads. If type `t<'a>` is invariant in `'a` allow type coercion from `t<t1> ` to `t<t2>` if both `t1` can be coerced to `t2` and `t2` can be coerced to `t1`, which must imply that the runtime representations are the same.
cristianoc
commented
Dec 11, 2023
| newty2 t2.level (Ttuple[t2]), !univar_pairs) :: cstrs | ||
| (* Invariant type argument: check both ways *) | ||
| if | ||
| subtype_rec env ((t1, t2)::trace) t1 t2 [] = [] && |
Collaborator
Author
There was a problem hiding this comment.
This is using the special case cstrs = []. Not sure if there's a good way to use existing constraints collected up to now.
Member
|
So good 😍 ! This is going to be crazy useful for our coercions and spreads. Maybe we should add a few tests that cases that shouldn't be allowed still isn't? |
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.
…rray payloads.
If type
t<'a>is invariant in'aallow type coercion fromt<t1>tot<t2>if botht1can be coerced tot2andt2can be coerced tot1, which must imply that the runtime representations are the same.