From 97c9677d7db805d95726875c043bb11b72a97f95 Mon Sep 17 00:00:00 2001 From: Chad Stearns Date: Mon, 20 Jan 2020 14:31:22 -0500 Subject: [PATCH] Include references in branch output --- src/can/expr.rs | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/can/expr.rs b/src/can/expr.rs index ac4af8ad69..86a41fbae8 100644 --- a/src/can/expr.rs +++ b/src/can/expr.rs @@ -795,24 +795,30 @@ fn canonicalize_when_branch<'a>( &mut shadowable_idents, ); - let loc_can_guard = match &loc_pattern.guard { + match &loc_pattern.guard { Some(guard) => { - let (can_guard, _) = + let (can_guard, guard_out) = canonicalize_expr(env, var_store, &mut scope, region, &guard.value); - Some(can_guard) + + ( + WhenPattern { + pattern: loc_can_pattern, + guard: Some(can_guard), + }, + can_expr, + branch_output.references.union(guard_out.references), + ) } - None => None, - }; - - ( - WhenPattern { - pattern: loc_can_pattern, - guard: loc_can_guard, - }, - can_expr, - branch_output.references, - ) + None => ( + WhenPattern { + pattern: loc_can_pattern, + guard: None, + }, + can_expr, + branch_output.references, + ), + } } pub fn union_pairs<'a, K, V, I>(mut map: ImMap, pairs: I) -> ImMap