Skip to content

Allow type_argument to weaken return modes of expected function types#24

Merged
stedolan merged 2 commits intomainfrom
loose-modes-in-arguments
Jun 8, 2022
Merged

Allow type_argument to weaken return modes of expected function types#24
stedolan merged 2 commits intomainfrom
loose-modes-in-arguments

Conversation

@stedolan
Copy link
Copy Markdown
Collaborator

@stedolan stedolan commented Jun 6, 2022

If e.g. fold_left accepts a local closure, then (+) stops being a valid thing to pass to fold_left, as its intermediate return mode is global rather than local. This patch makes type_argument introduce fresh mode variables for return modes to allow this case to go through.

@stedolan stedolan force-pushed the loose-modes-in-arguments branch from 8edb70b to fc59848 Compare June 6, 2022 14:08
Copy link
Copy Markdown
Contributor

@lpw25 lpw25 left a comment

Choose a reason for hiding this comment

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

I don't love this. The type_argument stuff is already a hack that confuses people, and I don't like that we're only doing it down the return side. However, I assume we can probably ditch this once arity/currying is sorted out, so it seems fine to have for now. Also, whilst type_argument is a hack, it was designed for exactly this problem with higher-order functions and multiple arrow types, so we're not making things worse.

@stedolan
Copy link
Copy Markdown
Collaborator Author

stedolan commented Jun 6, 2022

I don't love this. The type_argument stuff is already a hack that confuses people, and I don't like that we're only doing it down the return side. However, I assume we can probably ditch this once arity/currying is sorted out, so it seems fine to have for now. Also, whilst type_argument is a hack, it was designed for exactly this problem with higher-order functions and multiple arrow types, so we're not making things worse.

My thoughts exactly.

@stedolan stedolan force-pushed the loose-modes-in-arguments branch from fc59848 to 43af31a Compare June 6, 2022 15:09
@stedolan
Copy link
Copy Markdown
Collaborator Author

stedolan commented Jun 6, 2022

Pushed updated tests.

@stedolan stedolan force-pushed the loose-modes-in-arguments branch from 0d40cd8 to 9729d8f Compare June 8, 2022 09:46
@stedolan stedolan merged commit 28a6243 into main Jun 8, 2022
antalsz pushed a commit to antalsz/ocaml-jst that referenced this pull request Mar 29, 2023
* Comballoc bugfix for local types.

When Comballoc does an actual allocation, the state of the other
allocation must must be preserved, as there are two independent
allocation combining sequences.

* Bugfix for type_function: check return modes of curried lambdas

* Print total local allocations under v=0x400

* Rudimentary GC scanning for local types
@riaqn riaqn mentioned this pull request Jun 16, 2023
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