mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Do not fixup recursion pointers in non-recursive lambda sets
If a lambda set is non-recursive, but contains naked recursion pointers, we should not fill those naked pointers in with the slot of the lambda set during interning. Such naked pointers must belong to an encompassing lambda set that is in fact recursive, and will be filled in later. For example, `LambdaSet([Foo, LambdaSet(Bar, [<rec>])] as <rec>)` should not have the inner lambda set's capture be filled in with itself. Also, during reification of recursion pointers, we do not need to traverse re-inserted lambda sets again, since they were just fixed-up. Closes #5026
This commit is contained in:
parent
2321fa7504
commit
a3de22c88a
5 changed files with 114 additions and 21 deletions
|
@ -1,4 +1,5 @@
|
|||
use crate::ir::Parens;
|
||||
use crate::layout::intern::NeedsRecursionPointerFixup;
|
||||
use bitvec::vec::BitVec;
|
||||
use bumpalo::collections::Vec;
|
||||
use bumpalo::Bump;
|
||||
|
@ -1883,12 +1884,16 @@ impl<'a> LambdaSet<'a> {
|
|||
);
|
||||
cache_criteria.and(criteria);
|
||||
|
||||
let needs_recursive_fixup = NeedsRecursionPointerFixup(
|
||||
opt_recursion_var.is_some() && set_captures_have_naked_rec_ptr,
|
||||
);
|
||||
|
||||
let lambda_set = env.cache.interner.insert_lambda_set(
|
||||
env.arena,
|
||||
fn_args,
|
||||
ret,
|
||||
env.arena.alloc(set.into_bump_slice()),
|
||||
set_captures_have_naked_rec_ptr,
|
||||
needs_recursive_fixup,
|
||||
representation,
|
||||
);
|
||||
|
||||
|
@ -1902,7 +1907,7 @@ impl<'a> LambdaSet<'a> {
|
|||
fn_args,
|
||||
ret,
|
||||
&(&[] as &[(Symbol, &[InLayout])]),
|
||||
false,
|
||||
NeedsRecursionPointerFixup(false),
|
||||
Layout::UNIT,
|
||||
);
|
||||
Cacheable(Ok(lambda_set), cache_criteria)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue