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

Remove coercion with 2 types, which is only supported in ml syntax. #6829

Merged
merged 3 commits into from
Jul 2, 2024

Conversation

cristianoc
Copy link
Collaborator

There are two forms of type coercion:
1 e: t0 :> t
2 e :> t

The first form was never supported in .res syntax, and is now removed from parsed and typed tree.

That said, coercion 1 is the only one that ever supported coercion with free variables. So this is subject to more investigation.

See #6828

Copy link
Collaborator

@zth zth left a comment

Choose a reason for hiding this comment

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

Will this be problematic for the editor tooling/other things that read the compiler artifacts?

| Texp_coerce of core_type option * core_type
(** E :> T [Texp_coerce (None, T)]
E : T0 :> T [Texp_coerce (Some T0, T)]
| Texp_coerce of core_type
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will this be problematic for the editor tooling/other things that read the compiler artifacts?

@zth good question.
This should be Texp_coerce of unit * core_type so for old compiler versions will produce a .cmt that has the rhs core_type in the right place (and the lhs apparing to be None).

Copy link
Collaborator

Choose a reason for hiding this comment

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

That'll make it work I take it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I have no idea how things are represented in OCaml and what can break.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

At runtime unit is 0 just like None, so the new representation will generate files that appear as valid also in the old representation.

There are two forms of type coercion:
1 `e: t0 :> t`
2 `e :> t`

The first form was never supported in .res syntax, and is now removed from parsed and typed tree.

That said, coercion 1 is the only one that ever supported coercion with free variables. So this is subject to more investigation.

See #6828
@cristianoc cristianoc force-pushed the remove_coercion_two_types branch 2 times, most recently from 3beb1fa to 0a39286 Compare July 2, 2024 09:19
By adding a unit argument to the payload.
@cristianoc cristianoc force-pushed the remove_coercion_two_types branch from 0a39286 to 8af7d6c Compare July 2, 2024 09:20
@cristianoc cristianoc merged commit 83ef108 into master Jul 2, 2024
19 checks passed
@cristianoc cristianoc deleted the remove_coercion_two_types branch July 2, 2024 09:29
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