summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mir/from_hir.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mir/from_hir.cpp b/src/mir/from_hir.cpp
index 3aedd680..5a0efc29 100644
--- a/src/mir/from_hir.cpp
+++ b/src/mir/from_hir.cpp
@@ -675,6 +675,18 @@ namespace {
}
}
+ if( auto* cond_lit = dynamic_cast<::HIR::ExprNode_Literal*>(cond_p->get()) )
+ {
+ DEBUG("- constant condition");
+ if( cond_lit->m_data.as_Boolean() ) {
+ m_builder.end_block( ::MIR::Terminator::make_Goto({ true_branch }) );
+ }
+ else {
+ m_builder.end_block( ::MIR::Terminator::make_Goto({ false_branch }) );
+ }
+ return ;
+ }
+
// If short-circuiting didn't apply, emit condition
::MIR::LValue decision_val;
{