mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 00:24:34 +00:00
Add mono tests to validate refcounts with early return
This commit is contained in:
parent
7518a2c5ab
commit
01369dc6d8
3 changed files with 152 additions and 0 deletions
53
crates/compiler/test_mono/generated/dec_refcount_for_usage_after_early_return_in_if.txt
generated
Normal file
53
crates/compiler/test_mono/generated/dec_refcount_for_usage_after_early_return_in_if.txt
generated
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
procedure Bool.11 (#Attr.2, #Attr.3):
|
||||||
|
let Bool.24 : Int1 = lowlevel Eq #Attr.2 #Attr.3;
|
||||||
|
ret Bool.24;
|
||||||
|
|
||||||
|
procedure Num.19 (#Attr.2, #Attr.3):
|
||||||
|
let Num.283 : I64 = lowlevel NumAdd #Attr.2 #Attr.3;
|
||||||
|
ret Num.283;
|
||||||
|
|
||||||
|
procedure Num.96 (#Attr.2):
|
||||||
|
let Num.282 : Str = lowlevel NumToStr #Attr.2;
|
||||||
|
ret Num.282;
|
||||||
|
|
||||||
|
procedure Str.3 (#Attr.2, #Attr.3):
|
||||||
|
let Str.247 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
|
||||||
|
ret Str.247;
|
||||||
|
|
||||||
|
procedure Test.1 (Test.2):
|
||||||
|
let Test.3 : Str = CallByName Num.96 Test.2;
|
||||||
|
joinpoint Test.12 Test.4:
|
||||||
|
let Test.10 : Str = ", ";
|
||||||
|
let Test.9 : Str = CallByName Str.3 Test.10 Test.4;
|
||||||
|
dec Test.4;
|
||||||
|
let Test.8 : Str = CallByName Str.3 Test.3 Test.9;
|
||||||
|
dec Test.9;
|
||||||
|
ret Test.8;
|
||||||
|
in
|
||||||
|
let Test.22 : I64 = 1i64;
|
||||||
|
let Test.20 : Int1 = CallByName Bool.11 Test.2 Test.22;
|
||||||
|
if Test.20 then
|
||||||
|
dec Test.3;
|
||||||
|
let Test.21 : Str = "early 1";
|
||||||
|
ret Test.21;
|
||||||
|
else
|
||||||
|
let Test.19 : I64 = 1i64;
|
||||||
|
let Test.18 : I64 = CallByName Num.19 Test.2 Test.19;
|
||||||
|
let Test.5 : Str = CallByName Num.96 Test.18;
|
||||||
|
joinpoint Test.14 Test.11:
|
||||||
|
jump Test.12 Test.11;
|
||||||
|
in
|
||||||
|
let Test.17 : I64 = 2i64;
|
||||||
|
let Test.15 : Int1 = CallByName Bool.11 Test.2 Test.17;
|
||||||
|
if Test.15 then
|
||||||
|
dec Test.3;
|
||||||
|
dec Test.5;
|
||||||
|
let Test.16 : Str = "early 2";
|
||||||
|
ret Test.16;
|
||||||
|
else
|
||||||
|
jump Test.14 Test.5;
|
||||||
|
|
||||||
|
procedure Test.0 ():
|
||||||
|
let Test.7 : I64 = 3i64;
|
||||||
|
let Test.6 : Str = CallByName Test.1 Test.7;
|
||||||
|
ret Test.6;
|
49
crates/compiler/test_mono/generated/dec_refcount_for_usage_after_early_return_in_when.txt
generated
Normal file
49
crates/compiler/test_mono/generated/dec_refcount_for_usage_after_early_return_in_when.txt
generated
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
procedure Num.19 (#Attr.2, #Attr.3):
|
||||||
|
let Num.283 : I64 = lowlevel NumAdd #Attr.2 #Attr.3;
|
||||||
|
ret Num.283;
|
||||||
|
|
||||||
|
procedure Num.96 (#Attr.2):
|
||||||
|
let Num.282 : Str = lowlevel NumToStr #Attr.2;
|
||||||
|
ret Num.282;
|
||||||
|
|
||||||
|
procedure Str.3 (#Attr.2, #Attr.3):
|
||||||
|
let Str.247 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
|
||||||
|
ret Str.247;
|
||||||
|
|
||||||
|
procedure Test.1 (Test.2):
|
||||||
|
let Test.3 : Str = CallByName Num.96 Test.2;
|
||||||
|
joinpoint Test.11 Test.4:
|
||||||
|
let Test.10 : Str = ", ";
|
||||||
|
let Test.9 : Str = CallByName Str.3 Test.10 Test.4;
|
||||||
|
dec Test.4;
|
||||||
|
let Test.8 : Str = CallByName Str.3 Test.3 Test.9;
|
||||||
|
dec Test.9;
|
||||||
|
ret Test.8;
|
||||||
|
in
|
||||||
|
let Test.23 : I64 = 1i64;
|
||||||
|
let Test.24 : Int1 = lowlevel Eq Test.23 Test.2;
|
||||||
|
if Test.24 then
|
||||||
|
dec Test.3;
|
||||||
|
let Test.13 : Str = "early 1";
|
||||||
|
ret Test.13;
|
||||||
|
else
|
||||||
|
let Test.22 : I64 = 1i64;
|
||||||
|
let Test.21 : I64 = CallByName Num.19 Test.2 Test.22;
|
||||||
|
let Test.5 : Str = CallByName Num.96 Test.21;
|
||||||
|
joinpoint Test.15 Test.14:
|
||||||
|
jump Test.11 Test.14;
|
||||||
|
in
|
||||||
|
let Test.19 : I64 = 2i64;
|
||||||
|
let Test.20 : Int1 = lowlevel Eq Test.19 Test.2;
|
||||||
|
if Test.20 then
|
||||||
|
dec Test.3;
|
||||||
|
dec Test.5;
|
||||||
|
let Test.17 : Str = "early 2";
|
||||||
|
ret Test.17;
|
||||||
|
else
|
||||||
|
jump Test.15 Test.5;
|
||||||
|
|
||||||
|
procedure Test.0 ():
|
||||||
|
let Test.7 : I64 = 3i64;
|
||||||
|
let Test.6 : Str = CallByName Test.1 Test.7;
|
||||||
|
ret Test.6;
|
|
@ -3672,3 +3672,53 @@ fn issue_6606_2() {
|
||||||
"
|
"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[mono_test]
|
||||||
|
fn dec_refcount_for_usage_after_early_return_in_if() {
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
displayN = \n ->
|
||||||
|
first = Num.toStr n
|
||||||
|
second =
|
||||||
|
if n == 1 then
|
||||||
|
return "early 1"
|
||||||
|
else
|
||||||
|
third = Num.toStr (n + 1)
|
||||||
|
if n == 2 then
|
||||||
|
return "early 2"
|
||||||
|
else
|
||||||
|
third
|
||||||
|
|
||||||
|
"$(first), $(second)"
|
||||||
|
|
||||||
|
displayN 3
|
||||||
|
"#
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[mono_test]
|
||||||
|
fn dec_refcount_for_usage_after_early_return_in_when() {
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
displayN = \n ->
|
||||||
|
first = Num.toStr n
|
||||||
|
second =
|
||||||
|
when n is
|
||||||
|
1 ->
|
||||||
|
return "early 1"
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
third = Num.toStr (n + 1)
|
||||||
|
when n is
|
||||||
|
2 ->
|
||||||
|
return "early 2"
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
third
|
||||||
|
|
||||||
|
"$(first), $(second)"
|
||||||
|
|
||||||
|
displayN 3
|
||||||
|
"#
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue