mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 00:24:34 +00:00
Merge branch 'trunk' into mono-display
This commit is contained in:
commit
e1d990896a
11 changed files with 87 additions and 98 deletions
|
@ -1809,33 +1809,9 @@ fn patterns_to_when<'a>(
|
|||
for (pattern_var, pattern) in patterns.into_iter() {
|
||||
let context = crate::exhaustive::Context::BadArg;
|
||||
let mono_pattern = match from_can_pattern(env, layout_cache, &pattern.value) {
|
||||
Ok((pat, assignments)) => {
|
||||
for (symbol, variable, expr) in assignments.into_iter().rev() {
|
||||
if let Ok(old_body) = body {
|
||||
let def = roc_can::def::Def {
|
||||
annotation: None,
|
||||
expr_var: variable,
|
||||
loc_expr: Loc::at(pattern.region, expr),
|
||||
loc_pattern: Loc::at(
|
||||
pattern.region,
|
||||
roc_can::pattern::Pattern::Identifier(symbol),
|
||||
),
|
||||
pattern_vars: std::iter::once((symbol, variable)).collect(),
|
||||
};
|
||||
let new_expr = roc_can::expr::Expr::LetNonRec(
|
||||
Box::new(def),
|
||||
Box::new(old_body),
|
||||
variable,
|
||||
);
|
||||
let new_body = Loc {
|
||||
region: pattern.region,
|
||||
value: new_expr,
|
||||
};
|
||||
|
||||
body = Ok(new_body);
|
||||
}
|
||||
}
|
||||
|
||||
Ok((pat, _assignments)) => {
|
||||
// Don't apply any assignments (e.g. to initialize optional variables) yet.
|
||||
// We'll take care of that later when expanding the new "when" branch.
|
||||
pat
|
||||
}
|
||||
Err(runtime_error) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue