From a040bc971ab19b94f2bdcebc64a16ce5b8341d5b Mon Sep 17 00:00:00 2001 From: Folkert Date: Sat, 21 Mar 2020 14:58:28 +0100 Subject: [PATCH] don't drop guard, and desugar it --- compiler/can/src/operator.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/can/src/operator.rs b/compiler/can/src/operator.rs index c4cd0cb0e8..2c1bdf3745 100644 --- a/compiler/can/src/operator.rs +++ b/compiler/can/src/operator.rs @@ -179,13 +179,19 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located>) -> &'a }) } + let desugared_guard = if let Some(guard) = &branch.guard { + Some(desugar_expr(arena, guard).clone()) + } else { + None + }; + desugared_branches.push(&*arena.alloc(WhenBranch { patterns: alternatives, value: Located { region: desugared.region, value: Nested(&desugared.value), }, - guard: None, + guard: desugared_guard, })); }