mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
Add symbols' localized type variable to the AST
This commit is contained in:
parent
9d9053c2d1
commit
8aee32830a
11 changed files with 230 additions and 167 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue