mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
if a function returns a record/tag, do the perceus thing
This commit is contained in:
parent
bbca98a4db
commit
c3af4522bf
1 changed files with 15 additions and 1 deletions
|
@ -421,7 +421,10 @@ fn expand_and_cancel<'a>(env: &mut Env<'a, '_>, stmt: &'a Stmt<'a>) -> &'a Stmt<
|
|||
// prevent long chains of `Let`s from blowing the stack
|
||||
let mut literal_stack = Vec::new_in(env.arena);
|
||||
|
||||
while !matches!(&expr, Expr::AccessAtIndex { .. } | Expr::Struct(_)) {
|
||||
while !matches!(
|
||||
&expr,
|
||||
Expr::AccessAtIndex { .. } | Expr::Struct(_) | Expr::Call(_)
|
||||
) {
|
||||
if let Stmt::Let(symbol1, expr1, layout1, cont1) = cont {
|
||||
literal_stack.push((symbol, expr.clone(), *layout));
|
||||
|
||||
|
@ -483,6 +486,17 @@ fn expand_and_cancel<'a>(env: &mut Env<'a, '_>, stmt: &'a Stmt<'a>) -> &'a Stmt<
|
|||
new_cont = expand_and_cancel(env, cont);
|
||||
}
|
||||
}
|
||||
Expr::Call(_) => {
|
||||
if let Layout::Struct(fields) = layout {
|
||||
env.insert_struct_info(symbol, fields);
|
||||
|
||||
new_cont = expand_and_cancel(env, cont);
|
||||
|
||||
env.remove_struct_info(symbol);
|
||||
} else {
|
||||
new_cont = expand_and_cancel(env, cont);
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
new_cont = expand_and_cancel(env, cont);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue