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

Add support for typer coercion for invariant type arguments such as a… #6518

Merged
merged 1 commit into from
Dec 11, 2023

Conversation

cristianoc
Copy link
Collaborator

…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.

…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 cristianoc requested a review from zth December 11, 2023 08:56
newty2 t2.level (Ttuple[t2]), !univar_pairs) :: cstrs
(* Invariant type argument: check both ways *)
if
subtype_rec env ((t1, t2)::trace) t1 t2 [] = [] &&
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is using the special case cstrs = []. Not sure if there's a good way to use existing constraints collected up to now.

@zth
Copy link
Collaborator

zth commented Dec 11, 2023

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?

@zth zth merged commit 35e8c71 into master Dec 11, 2023
14 checks passed
@zth zth deleted the corce_invariant_type_args branch December 11, 2023 19:39
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