From 3a05f524c56e3ff6b94024ef3ca847ba9d43ddf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Pottb=C3=A4cker?= <1104693+fpottbaecker@users.noreply.github.com> Date: Sat, 6 Jan 2024 23:47:49 +0100 Subject: [PATCH] Add match conditions to rich AST representation --- compiler/frontend/src/ast.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/compiler/frontend/src/ast.rs b/compiler/frontend/src/ast.rs index 2fe9e3179..5f0c53845 100644 --- a/compiler/frontend/src/ast.rs +++ b/compiler/frontend/src/ast.rs @@ -555,9 +555,22 @@ impl ToRichIr for Match { } impl ToRichIr for MatchCase { fn build_rich_ir(&self, builder: &mut RichIrBuilder) { + builder.push("case ", None, EnumSet::empty()); self.pattern.build_rich_ir(builder); + if let Some(box condition) = &self.condition { + builder.push(", ", None, EnumSet::empty()); + builder.indent(); + builder.push_newline(); + builder.push("condition ", None, EnumSet::empty()); + condition.build_rich_ir(builder); + } builder.push(" -> ", None, EnumSet::empty()); + builder.indent(); builder.push_foldable(|builder| builder.push_children_multiline(&self.body)); + if self.condition.is_some() { + builder.dedent(); + } + builder.dedent(); } } impl ToRichIr for OrPattern {