Remove spaces around var in record update

Closes #2534
This commit is contained in:
ayazhafiz 2022-02-20 20:17:29 -05:00
parent 1b664741db
commit 543ca97a1c
2 changed files with 21 additions and 2 deletions

View File

@ -170,7 +170,10 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Loc<Expr<'a>>) -> &'a Loc
}),
RecordUpdate { fields, update } => {
// NOTE the `update` field is always a `Var { .. }` and does not need to be desugared
// NOTE the `update` field is always a `Var { .. }`, we only desugar it to get rid of
// any spaces before/after
let new_update = desugar_expr(arena, update);
let new_fields = fields.map_items(arena, |field| {
let value = desugar_field(arena, &field.value);
Loc {
@ -182,7 +185,7 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Loc<Expr<'a>>) -> &'a Loc
arena.alloc(Loc {
region: loc_expr.region,
value: RecordUpdate {
update: *update,
update: new_update,
fields: new_fields,
},
})

View File

@ -1063,6 +1063,22 @@ mod test_can {
assert_eq!(problems, Vec::new());
}
#[test]
fn issue_2534() {
let src = indoc!(
r#"
x = { a: 1 }
{
x & a: 2
}
"#
);
let arena = Bump::new();
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
assert_eq!(problems, Vec::new());
}
//#[test]
//fn closing_over_locals() {
// // "local" should be used, because the closure used it.