More type checking -- expressions #243
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This starts type checking expressions.
It seems like the module envs are not quite right currently. Variables that refer to global things point to their definitions after the name resolving pass, so the module envs only need schemes, tycons etc. of things that they define, without the imported things. If I have a variable use
fooof type useFoo, regardless of how these are defined or imported I get a reference to the definition (defining module + name in the defining module).We should also document why we persist the name resolving state in
Program: we want to reuse the state of the modules that don't change.I'm also unsure why in the converted constructor field types we use a tree map instead of hash map:
fir/src/type_checker/ty.rs
Lines 91 to 95 in 6c15469
This is because these are used in
Funtypes (i.e. inTy), and we sort predicates of schemes when comparing two schemes for equality:fir/src/type_checker/ty.rs
Lines 398 to 406 in 6c15469
We do this comparison when comparing an impl method scheme with the trait's method scheme.
We should be able to just check for each predicate on the left each predicate on the right (quadratic), because the number of predicates will always be tiny (less than 5 for most applications, definitely less than 10 in general).