Add symbols' localized type variable to the AST

This commit is contained in:
Ayaz Hafiz 2022-10-17 17:28:54 -05:00
parent 9d9053c2d1
commit 8aee32830a
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
11 changed files with 230 additions and 167 deletions

View file

@ -351,7 +351,7 @@ pub fn constrain_expr(
let (fn_var, loc_fn, closure_var, ret_var) = &**boxed;
// The expression that evaluates to the function being called, e.g. `foo` in
// (foo) bar baz
let opt_symbol = if let Var(symbol) | AbilityMember(symbol, _, _) = loc_fn.value {
let opt_symbol = if let Var(symbol, _) | AbilityMember(symbol, _, _) = loc_fn.value {
Some(symbol)
} else {
None
@ -425,9 +425,13 @@ pub fn constrain_expr(
let and_constraint = constraints.and_constraint(and_cons);
constraints.exists(vars, and_constraint)
}
Var(symbol) => {
// make lookup constraint to lookup this symbol's type in the environment
constraints.lookup(*symbol, expected, region)
Var(symbol, variable) => {
// Save the expectation in the variable, then lookup the symbol's type in the environment
let store_expected =
constraints.store(expected.get_type_ref().clone(), *variable, file!(), line!());
let lookup_constr =
constraints.lookup(*symbol, expected.replace(Type::Variable(*variable)), region);
constraints.and_constraint([store_expected, lookup_constr])
}
&AbilityMember(symbol, specialization_id, specialization_var) => {
// Save the expectation in the `specialization_var` so we know what to specialize, then