mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 08:34:33 +00:00
improvements to reset reuse
This commit is contained in:
parent
bcf23d5699
commit
26b05d18f2
1 changed files with 11 additions and 4 deletions
|
@ -298,11 +298,16 @@ fn function_d_main<'a, 'i>(
|
||||||
_ => {
|
_ => {
|
||||||
let (b, found) = function_d_main(env, x, c, continuation);
|
let (b, found) = function_d_main(env, x, c, continuation);
|
||||||
|
|
||||||
|
// NOTE the &b != continuation is not found in the Lean source, but is required
|
||||||
|
// otherwise we observe the same symbol being reset twice
|
||||||
let mut result = MutSet::default();
|
let mut result = MutSet::default();
|
||||||
if found || {
|
if found
|
||||||
|
|| {
|
||||||
occurring_variables_expr(expr, &mut result);
|
occurring_variables_expr(expr, &mut result);
|
||||||
!result.contains(&x)
|
!result.contains(&x)
|
||||||
} {
|
}
|
||||||
|
|| &b != continuation
|
||||||
|
{
|
||||||
let let_stmt = Let(*symbol, expr.clone(), *layout, b);
|
let let_stmt = Let(*symbol, expr.clone(), *layout, b);
|
||||||
|
|
||||||
(arena.alloc(let_stmt), found)
|
(arena.alloc(let_stmt), found)
|
||||||
|
@ -478,6 +483,7 @@ fn function_r<'a, 'i>(env: &mut Env<'a, 'i>, stmt: &'a Stmt<'a>) -> &'a Stmt<'a>
|
||||||
layout,
|
layout,
|
||||||
tag_id,
|
tag_id,
|
||||||
} => match layout {
|
} => match layout {
|
||||||
|
Layout::Union(UnionLayout::NonRecursive(_)) => temp,
|
||||||
Layout::Union(union_layout) if !union_layout.tag_is_null(*tag_id) => {
|
Layout::Union(union_layout) if !union_layout.tag_is_null(*tag_id) => {
|
||||||
let ctor_info = CtorInfo {
|
let ctor_info = CtorInfo {
|
||||||
layout: *union_layout,
|
layout: *union_layout,
|
||||||
|
@ -503,6 +509,7 @@ fn function_r<'a, 'i>(env: &mut Env<'a, 'i>, stmt: &'a Stmt<'a>) -> &'a Stmt<'a>
|
||||||
layout,
|
layout,
|
||||||
tag_id,
|
tag_id,
|
||||||
} => match layout {
|
} => match layout {
|
||||||
|
Layout::Union(UnionLayout::NonRecursive(_)) => temp,
|
||||||
Layout::Union(union_layout) if !union_layout.tag_is_null(*tag_id) => {
|
Layout::Union(union_layout) if !union_layout.tag_is_null(*tag_id) => {
|
||||||
let ctor_info = CtorInfo {
|
let ctor_info = CtorInfo {
|
||||||
layout: *union_layout,
|
layout: *union_layout,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue