diff --git a/compiler/can/src/pattern.rs b/compiler/can/src/pattern.rs index 70dbae9c67..eef2b0532e 100644 --- a/compiler/can/src/pattern.rs +++ b/compiler/can/src/pattern.rs @@ -77,7 +77,12 @@ pub fn symbols_from_pattern_help(pattern: &Pattern, symbols: &mut Vec) { } RecordDestructure { destructs, .. } => { for destruct in destructs { - symbols.push(destruct.value.symbol); + // when a record field has a pattern guard, only symbols in the guard are introduced + if let DestructType::Guard(_, subpattern) = &destruct.value.typ { + symbols_from_pattern_help(&subpattern.value, symbols); + } else { + symbols.push(destruct.value.symbol); + } } } diff --git a/compiler/mono/src/expr.rs b/compiler/mono/src/expr.rs index 0e937046d7..68e1fe979a 100644 --- a/compiler/mono/src/expr.rs +++ b/compiler/mono/src/expr.rs @@ -451,6 +451,7 @@ impl<'a> Expr<'a> { .append(alloc.hardline()) .append(expr.to_doc(alloc, false)), + Store(stores, expr) if stores.is_empty() => expr.to_doc(alloc, false), Store(stores, expr) => { let doc_stores = stores .iter() diff --git a/compiler/mono/tests/test_mono.rs b/compiler/mono/tests/test_mono.rs index 298631fc6e..f13ccb80d6 100644 --- a/compiler/mono/tests/test_mono.rs +++ b/compiler/mono/tests/test_mono.rs @@ -868,11 +868,10 @@ mod test_mono { Store Test.1: Just 0i64 3i64 Store Test.1: Load Test.1 Store Test.3: Lowlevel.And (Lowlevel.Eq 0i64 (Access @0 Load Test.1)) true - if Test.3 then Reset Test.1 Reuse Test.1 - Just 0i64 *magic* + Just 0i64 (Call Num.14 (Load Test.2) 1i64) else Reset Test.1 Reuse Test.1 @@ -902,9 +901,7 @@ mod test_mono { Store Test.1: Just 0i64 Just 0i64 3i64 Store Test.1: Load Test.1 Store Test.5: Lowlevel.And (Lowlevel.Eq 0i64 (Access @0 Load Test.1)) true - if Test.5 then - if Test.4 then Just 0i64 Just 0i64 1i64 else @@ -937,7 +934,6 @@ mod test_mono { r#" Store Test.1: These 1i64 1i64 2i64 Store Test.1: Load Test.1 - switch Test.1: case 2: Reset Test.1 @@ -974,7 +970,7 @@ mod test_mono { Lowlevel.ListLen (Load #Attr.2) Store Test.0: [ 1i64, 2i64, 3i64 ] - *magic* + Call List.7 (Load Test.0) Dec Test.0 "# ),