mirror of
https://github.com/roc-lang/roc.git
synced 2025-11-01 13:34:15 +00:00
Merge pull request #5167 from roc-lang/fix-closure-captures-recursive
Ensure that closures inside recursive closures capture correctly
This commit is contained in:
commit
6b3f3ba1a1
4 changed files with 87 additions and 18 deletions
|
|
@ -0,0 +1,18 @@
|
|||
procedure Test.1 (Test.2, Test.3):
|
||||
let Test.14 : [] = CallByName Test.6 Test.2 Test.3;
|
||||
ret Test.14;
|
||||
|
||||
procedure Test.5 (Test.8, Test.4):
|
||||
let Test.12 : [] = CallByName Test.1 Test.4 Test.4;
|
||||
ret Test.12;
|
||||
|
||||
procedure Test.6 (Test.15, Test.4):
|
||||
let Test.18 : {} = Struct {};
|
||||
let Test.17 : [] = CallByName Test.5 Test.18 Test.4;
|
||||
ret Test.17;
|
||||
|
||||
procedure Test.0 (Test.7):
|
||||
let Test.4 : U16 = 10i64;
|
||||
let Test.10 : {} = Struct {};
|
||||
let Test.9 : [] = CallByName Test.5 Test.10 Test.4;
|
||||
ret Test.9;
|
||||
|
|
@ -2769,3 +2769,23 @@ fn inline_return_joinpoints_in_union_lambda_set() {
|
|||
"#
|
||||
)
|
||||
}
|
||||
|
||||
#[mono_test]
|
||||
fn recursive_closure_with_transiently_used_capture() {
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [f] to "./platform"
|
||||
|
||||
thenDo = \x, callback ->
|
||||
callback x
|
||||
|
||||
f = \{} ->
|
||||
code = 10u16
|
||||
|
||||
bf = \{} ->
|
||||
thenDo code \_ -> bf {}
|
||||
|
||||
bf {}
|
||||
"#
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue