From f604b52384c64ff5977970230d154684ee8536cc Mon Sep 17 00:00:00 2001 From: Selimaj Dev Date: Tue, 5 May 2026 15:17:36 +0200 Subject: [PATCH] codegen minor fix --- src/codegen.rs | 12 +++--------- test/src/main.mist | 4 ++++ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/codegen.rs b/src/codegen.rs index b4c4a35..a900512 100644 --- a/src/codegen.rs +++ b/src/codegen.rs @@ -202,7 +202,7 @@ impl GetRust for Postfix { BinaryOp::LessThanOrEqual => "<=", BinaryOp::GreaterThanOrEqual => ">=", }; - format!("{} {}", op_str, rhs.get_rust()) + format!(" {} {}", op_str, rhs.get_rust()) } } } @@ -358,18 +358,12 @@ impl ToRust for Statement { then_branch, else_branch, }) => { - cg.add_indentedln(&format!("if {} {{", condition.get_rust())); - cg.indent += 1; + cg.add_indentedln(&format!("if {}", condition.get_rust())); then_branch.to_rust(cg); - cg.indent -= 1; - cg.add_indentedln("}"); if let Some(else_br) = else_branch { - cg.add_indentedln("else {"); - cg.indent += 1; + cg.add_indentedln("else"); else_br.to_rust(cg); - cg.indent -= 1; - cg.add_indentedln("}"); } } diff --git a/test/src/main.mist b/test/src/main.mist index 40ba951..fbc6084 100644 --- a/test/src/main.mist +++ b/test/src/main.mist @@ -9,5 +9,9 @@ public struct ApiCall { void main() { ApiCall call = ApiCall { x: 10, y: 12 }; + if (call.x == 20) { + println("= 20"); + } + println!("{call:?}"); }