codegen minor fix

This commit is contained in:
2026-05-05 15:17:36 +02:00
parent cd81ef1bc4
commit f604b52384
2 changed files with 7 additions and 9 deletions
+3 -9
View File
@@ -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("}");
}
}
+4
View File
@@ -9,5 +9,9 @@ public struct ApiCall {
void main() {
ApiCall call = ApiCall { x: 10, y: 12 };
if (call.x == 20) {
println("= 20");
}
println!("{call:?}");
}