mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-19 10:09:47 +00:00
Merge pull request #6651 from roc-lang/fix-nesting-suffix
Fix recursion for suffixed `!` in top-level def
This commit is contained in:
commit
6059f7afcb
2 changed files with 48 additions and 23 deletions
|
@ -189,14 +189,17 @@ pub fn desugar_value_def_suffixed<'a>(arena: &'a Bump, value_def: ValueDef<'a>)
|
||||||
sub_arg,
|
sub_arg,
|
||||||
sub_pat,
|
sub_pat,
|
||||||
sub_new,
|
sub_new,
|
||||||
}) => Body(
|
}) => desugar_value_def_suffixed(
|
||||||
loc_pattern,
|
arena,
|
||||||
apply_task_await(
|
Body(
|
||||||
arena,
|
loc_pattern,
|
||||||
loc_expr.region,
|
apply_task_await(
|
||||||
sub_arg,
|
arena,
|
||||||
sub_pat,
|
loc_expr.region,
|
||||||
wrap_in_task_ok(arena, sub_new),
|
sub_arg,
|
||||||
|
sub_pat,
|
||||||
|
wrap_in_task_ok(arena, sub_new),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Err(..) => Body(
|
Err(..) => Body(
|
||||||
|
@ -226,19 +229,22 @@ pub fn desugar_value_def_suffixed<'a>(arena: &'a Bump, value_def: ValueDef<'a>)
|
||||||
sub_arg,
|
sub_arg,
|
||||||
sub_pat,
|
sub_pat,
|
||||||
sub_new,
|
sub_new,
|
||||||
}) => AnnotatedBody {
|
}) => desugar_value_def_suffixed(
|
||||||
ann_pattern,
|
arena,
|
||||||
ann_type,
|
AnnotatedBody {
|
||||||
comment,
|
ann_pattern,
|
||||||
body_pattern,
|
ann_type,
|
||||||
body_expr: apply_task_await(
|
comment,
|
||||||
arena,
|
body_pattern,
|
||||||
body_expr.region,
|
body_expr: apply_task_await(
|
||||||
sub_arg,
|
arena,
|
||||||
sub_pat,
|
body_expr.region,
|
||||||
wrap_in_task_ok(arena, sub_new),
|
sub_arg,
|
||||||
),
|
sub_pat,
|
||||||
},
|
wrap_in_task_ok(arena, sub_new),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
Err(..) => AnnotatedBody {
|
Err(..) => AnnotatedBody {
|
||||||
ann_pattern,
|
ann_pattern,
|
||||||
ann_type,
|
ann_type,
|
||||||
|
|
|
@ -420,6 +420,26 @@ mod suffixed_tests {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Nested suffixed expressions
|
||||||
|
```roc
|
||||||
|
run = line! (nextMsg!)
|
||||||
|
|
||||||
|
run = Task.await nextMsg \#!a0 -> line! (#!a0)
|
||||||
|
|
||||||
|
run = Task.await nextMsg \#!a0 -> line (#!a0)
|
||||||
|
```
|
||||||
|
*/
|
||||||
|
#[test]
|
||||||
|
fn nested_simple() {
|
||||||
|
run_test(
|
||||||
|
r#"
|
||||||
|
run = line! (nextMsg!)
|
||||||
|
"#,
|
||||||
|
r##"Defs { tags: [Index(2147483648)], regions: [@0-22], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-3 Identifier { ident: "run", suffixed: 0 }, @0-22 Apply(@0-22 Var { module_name: "Task", ident: "await", suffixed: 0 }, [Var { module_name: "", ident: "nextMsg", suffixed: 0 }, @0-22 Closure([Identifier { ident: "#!a0", suffixed: 0 }], @0-22 Apply(@0-22 Var { module_name: "", ident: "line", suffixed: 0 }, [@13-21 ParensAround(Var { module_name: "", ident: "#!a0", suffixed: 0 })], Space))], BangSuffix))] }"##,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nested suffixed expressions
|
* Nested suffixed expressions
|
||||||
```roc
|
```roc
|
||||||
|
@ -437,9 +457,8 @@ mod suffixed_tests {
|
||||||
Task.await [foo (#!a0) (blah stuff)] \z -> doSomething z
|
Task.await [foo (#!a0) (blah stuff)] \z -> doSomething z
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn nested_suffixed() {
|
fn nested_complex() {
|
||||||
run_test(
|
run_test(
|
||||||
r#"
|
r#"
|
||||||
main =
|
main =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue