Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Support class constraints with multiple dependencies #1402

Merged
merged 12 commits into from
Apr 7, 2022

Conversation

bamarsha
Copy link
Contributor

@bamarsha bamarsha commented Apr 2, 2022

During type inference, the compiler accumulates classes that a type needs to be part of. If the type is a variable, it waits until the variable has a substitution before checking if the class constraint is satisfied. Before this PR, the compiler only knew how to wait for one variable to be ready before checking a constraint. This has been generalized so that each class constraint can depend on an arbitrary number of types.

In particular, Index<'container, 'index, 'item> needs to know both 'container and 'index before it can determine 'item. Before this PR, Index was checked as soon as 'container was known, even if 'index was not known. This resolves #1377.

Also did some refactoring within the TypeInference folder, including moving some things out of InferenceContext.fs to keep the file from getting too big, as well as treating subtype/equal/supertype assertions as another type of constraint (so the Match method was absorbed into Constrain).

@bamarsha bamarsha marked this pull request as ready for review April 4, 2022 18:38
@bamarsha bamarsha requested a review from cesarzc April 4, 2022 22:14
@cesarzc
Copy link
Contributor

cesarzc commented Apr 6, 2022

@samarsha from our conversation and looking at this PR, it doesn't seem like there's any breaking chance but just wanted to double check, is this correct?

@bamarsha
Copy link
Contributor Author

bamarsha commented Apr 6, 2022

Yes, I don't think it's breaking.

@bamarsha bamarsha merged commit 59be764 into main Apr 7, 2022
@bamarsha bamarsha deleted the samarsha/constraint-multi branch April 7, 2022 16:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Array indexing doesn't work when the index is a lambda parameter
2 participants