Skip to content

Commit 8efa234

Browse files
committed
Add match conditions to rich AST representation
1 parent 8ddce7f commit 8efa234

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

compiler/frontend/src/ast.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,22 @@ impl ToRichIr for Match {
555555
}
556556
impl ToRichIr for MatchCase {
557557
fn build_rich_ir(&self, builder: &mut RichIrBuilder) {
558+
builder.push("case ", None, EnumSet::empty());
558559
self.pattern.build_rich_ir(builder);
560+
if let Some(box condition) = &self.condition {
561+
builder.push(", ", None, EnumSet::empty());
562+
builder.indent();
563+
builder.push_newline();
564+
builder.push("condition ", None, EnumSet::empty());
565+
condition.build_rich_ir(builder);
566+
}
559567
builder.push(" -> ", None, EnumSet::empty());
568+
builder.indent();
560569
builder.push_foldable(|builder| builder.push_children_multiline(&self.body));
570+
if self.condition.is_some() {
571+
builder.dedent();
572+
}
573+
builder.dedent();
561574
}
562575
}
563576
impl ToRichIr for OrPattern {

0 commit comments

Comments
 (0)