mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
save the stack
This commit is contained in:
parent
95fbc15373
commit
b01377f868
1 changed files with 31 additions and 15 deletions
|
@ -778,22 +778,38 @@ pub fn constrain_expr(
|
|||
)
|
||||
}
|
||||
LetNonRec(def, loc_ret, var) => {
|
||||
let body_con = constrain_expr(env, loc_ret.region, &loc_ret.value, expected.clone());
|
||||
let mut stack = Vec::with_capacity(1);
|
||||
|
||||
exists(
|
||||
vec![*var],
|
||||
And(vec![
|
||||
constrain_def(env, def, body_con),
|
||||
// Record the type of the entire def-expression in the variable.
|
||||
// Code gen will need that later!
|
||||
Eq(
|
||||
Type::Variable(*var),
|
||||
expected,
|
||||
Category::Storage(std::file!(), std::line!()),
|
||||
loc_ret.region,
|
||||
),
|
||||
]),
|
||||
)
|
||||
let mut loc_ret = loc_ret;
|
||||
|
||||
stack.push((def, var, loc_ret.region));
|
||||
|
||||
while let LetNonRec(def, new_loc_ret, var) = &loc_ret.value {
|
||||
stack.push((def, var, new_loc_ret.region));
|
||||
loc_ret = new_loc_ret;
|
||||
}
|
||||
|
||||
let mut body_con =
|
||||
constrain_expr(env, loc_ret.region, &loc_ret.value, expected.clone());
|
||||
|
||||
while let Some((def, var, ret_region)) = stack.pop() {
|
||||
body_con = exists(
|
||||
vec![*var],
|
||||
And(vec![
|
||||
constrain_def(env, def, body_con),
|
||||
// Record the type of the entire def-expression in the variable.
|
||||
// Code gen will need that later!
|
||||
Eq(
|
||||
Type::Variable(*var),
|
||||
expected.clone(),
|
||||
Category::Storage(std::file!(), std::line!()),
|
||||
ret_region,
|
||||
),
|
||||
]),
|
||||
)
|
||||
}
|
||||
|
||||
body_con
|
||||
}
|
||||
Tag {
|
||||
variant_var,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue