Skip to content

Rework jkind default #2158

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

Merged
merged 13 commits into from
Dec 18, 2023
Merged

Conversation

alanechang
Copy link
Contributor

No description provided.

@alanechang alanechang force-pushed the aec/rework-jkind-default branch 2 times, most recently from ae288cf to b056c36 Compare December 13, 2023 21:00
@alanechang
Copy link
Contributor Author

alanechang commented Dec 13, 2023

This follows #2107 and reworks how type variables get their jkinds.

Prior to #2107, type variables start with jkind any and -> (Tarrow) forces argument and result types to concrete jkinds (represented as sort vars).

#2107 passes the tests by changing type variables to all start with concrete jkinds.

This PR makes the type variable jkind initialization controllable through a new field in TyVarEnv.policy (either Sort or Any) and uses different policies depending on the typing context.

The general rule it follows is that

  • calls from typecore initialize with Any
  • calls from typedecl mostly initialize with Sort. Any is used for type manifests where the variables get unified with type parameters of concrete jkinds in the end and the right (update: left) hand side of constraint clauses.
  • calls from typeclass initialize with Sort

This PR also contains a change to Typetexp.transl_type_var that makes jkind annotation on type variables behave as upper bounds.

How to review

Might be best to first review the changes in typetexp and then look at the various call sites of transl_simple_type.

@alanechang alanechang marked this pull request as ready for review December 13, 2023 21:39
Copy link
Collaborator

@goldfirere goldfirere left a comment

Choose a reason for hiding this comment

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

A few changes requested on choices of policy.

I did not review testsuite changes, as I wish to review them in #2107.

@goldfirere goldfirere merged commit 0049c4e into aec/allow-any-in-tarrow Dec 18, 2023
@goldfirere goldfirere deleted the aec/rework-jkind-default branch December 18, 2023 22:09
alanechang added a commit that referenced this pull request Dec 19, 2023
* extend policy to control ty var jkind init

* annotation on type vars should be upper bounds

* proper jkind reason

* sort init rhs of constraints for backward compatibility

* add comment&rename to jkind_initialization_choice

* refactor policy

* comment about transl_simple_type_delayed

* use Any more in typeclass

* add new_var_jkind param and thread it through

* use Any for with constraint

* add note

* more tests

* more tests
goldfirere added a commit that referenced this pull request Dec 27, 2023
* wip

* change Wildcard and Unification_var to sort vars

* test changes

* more tests

* fix test

* test changes

* Rework jkind default (#2158)

* extend policy to control ty var jkind init

* annotation on type vars should be upper bounds

* proper jkind reason

* sort init rhs of constraints for backward compatibility

* add comment&rename to jkind_initialization_choice

* refactor policy

* comment about transl_simple_type_delayed

* use Any more in typeclass

* add new_var_jkind param and thread it through

* use Any for with constraint

* add note

* more tests

* more tests

* rebase over type var print order change

* Add a bunch of tests

* check instead of constrain

* jkind check in unify_univar

* update test outputs

* change unify_univar to take jkinds

* Testing representability of function argument

* More tests

* Yet more tests

* Accept test output

* Propagate new test to _alpha

* More tests, this time about inference

* add tests to _alpha

* small test changes

* relax approx_type

* reword history message

* add cr for bad error message

* fix test

* rename layout to jkind

* add comments about check_type_jkind_exn

* add comment about unify_univar invariant

---------

Co-authored-by: Richard Eisenberg <reisenberg@janestreet.com>
lukemaurer pushed a commit to lukemaurer/flambda-backend that referenced this pull request Oct 23, 2024
…a#2107)

* wip

* change Wildcard and Unification_var to sort vars

* test changes

* more tests

* fix test

* test changes

* Rework jkind default (ocaml-flambda#2158)

* extend policy to control ty var jkind init

* annotation on type vars should be upper bounds

* proper jkind reason

* sort init rhs of constraints for backward compatibility

* add comment&rename to jkind_initialization_choice

* refactor policy

* comment about transl_simple_type_delayed

* use Any more in typeclass

* add new_var_jkind param and thread it through

* use Any for with constraint

* add note

* more tests

* more tests

* rebase over type var print order change

* Add a bunch of tests

* check instead of constrain

* jkind check in unify_univar

* update test outputs

* change unify_univar to take jkinds

* Testing representability of function argument

* More tests

* Yet more tests

* Accept test output

* Propagate new test to _alpha

* More tests, this time about inference

* add tests to _alpha

* small test changes

* relax approx_type

* reword history message

* add cr for bad error message

* fix test

* rename layout to jkind

* add comments about check_type_jkind_exn

* add comment about unify_univar invariant

---------

Co-authored-by: Richard Eisenberg <reisenberg@janestreet.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants