mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
Define inline expects defs in their definition order
When we transform a top-level expect into an inline expect, we collect all intermediate defs before the expect condition, then layer the defs back on. Because the layering procedure builds an expression bottom-up, we must layer on defs in reverse definition order. Closes #4705
This commit is contained in:
parent
935255d06b
commit
42fe19541e
2 changed files with 18 additions and 1 deletions
|
@ -2995,7 +2995,7 @@ fn toplevel_expect_to_inline_expect_help(mut loc_expr: Loc<Expr>, has_effects: b
|
|||
|
||||
let mut loc_expr = Loc::at(expect_region, expect);
|
||||
|
||||
for stored in stack {
|
||||
for stored in stack.into_iter().rev() {
|
||||
match stored {
|
||||
StoredDef::NonRecursive(region, boxed_def) => {
|
||||
loc_expr = Loc::at(region, Expr::LetNonRec(boxed_def, Box::new(loc_expr)));
|
||||
|
|
|
@ -2139,3 +2139,20 @@ fn list_one_vs_one_spread_issue_4685() {
|
|||
"#
|
||||
)
|
||||
}
|
||||
|
||||
#[mono_test(mode = "test")]
|
||||
fn issue_4705() {
|
||||
indoc!(
|
||||
r###"
|
||||
interface Test exposes [] imports []
|
||||
|
||||
go : {} -> Bool
|
||||
go = \{} -> Bool.true
|
||||
|
||||
expect
|
||||
input = {}
|
||||
x = go input
|
||||
x
|
||||
"###
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue