Correct refcounting check to be recursive through aggregate types

This commit is contained in:
Brendan Hansknecht 2024-04-07 11:08:27 -07:00
parent 951cb1ef3d
commit 9b6798ead1
No known key found for this signature in database
GPG key ID: 0EA784685083E75B
2 changed files with 3 additions and 1 deletions

View file

@ -104,7 +104,7 @@ pub(crate) fn layout_refcounted<'a, 'ctx>(
) -> BasicValueEnum<'ctx> {
let is_refcounted = layout_interner
.get_repr(layout)
.is_refcounted(layout_interner);
.contains_refcounted(layout_interner);
env.context
.bool_type()
.const_int(is_refcounted as u64, false)

View file

@ -556,6 +556,8 @@ impl Hash for U128 {
}
/// All Roc types that are refcounted must implement this trait.
///
/// For aggregate types, this must recurse down the structure.
pub trait RocRefcounted {
/// Increments the refcount n times.
fn inc(&mut self, n: usize);