mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
Mask out union tag ID from pointer when calculating refcount address
This commit is contained in:
parent
94dea1df9f
commit
5e642c880c
3 changed files with 108 additions and 30 deletions
|
@ -206,21 +206,54 @@ fn union_recursive_inc() {
|
|||
r#"
|
||||
Expr : [ Sym Str, Add Expr Expr ]
|
||||
|
||||
s = Str.concat "heap_allocated_" "symbol_name"
|
||||
s = Str.concat "heap_allocated" "_symbol_name"
|
||||
|
||||
x : Expr
|
||||
x = Sym s
|
||||
|
||||
e : Expr
|
||||
e = Add (Sym s) (Sym s)
|
||||
e = Add x x
|
||||
|
||||
[e, e]
|
||||
"#
|
||||
),
|
||||
RocStr,
|
||||
// test_wrapper receives a List, doesn't matter kind of elements it points to
|
||||
RocList<usize>,
|
||||
&[
|
||||
4, // s
|
||||
1, // Sym
|
||||
1, // Sym
|
||||
2, // Add
|
||||
4, // sym
|
||||
2, // e
|
||||
1 // list
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-wasm"))]
|
||||
fn union_recursive_dec() {
|
||||
assert_refcounts!(
|
||||
indoc!(
|
||||
r#"
|
||||
Expr : [ Sym Str, Add Expr Expr ]
|
||||
|
||||
s = Str.concat "heap_allocated" "_symbol_name"
|
||||
|
||||
x : Expr
|
||||
x = Sym s
|
||||
|
||||
e : Expr
|
||||
e = Add x x
|
||||
|
||||
when e is
|
||||
Add y _ -> y
|
||||
Sym _ -> e
|
||||
"#
|
||||
),
|
||||
&RocStr,
|
||||
&[
|
||||
1, // s
|
||||
1, // sym
|
||||
0 // e
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue