Fix else if statements #49

This commit is contained in:
2026-06-04 17:57:27 +02:00
parent e571d98cd0
commit d3b54b4114
3 changed files with 4 additions and 4 deletions
+2
View File
@@ -90,12 +90,14 @@ impl GenRust for Statement {
else_branch, else_branch,
} => { } => {
cg.add("if "); cg.add("if ");
ctx.expr_ensure_semicolon = false;
initial.condition.gen_rust(ctx, cg); initial.condition.gen_rust(ctx, cg);
cg.add(" "); cg.add(" ");
cg.ensure_brackets_body(ctx, &initial.body); cg.ensure_brackets_body(ctx, &initial.body);
for else_if_branch in else_if { for else_if_branch in else_if {
cg.add(" else if "); cg.add(" else if ");
ctx.expr_ensure_semicolon = false;
else_if_branch.condition.gen_rust(ctx, cg); else_if_branch.condition.gen_rust(ctx, cg);
cg.add(" "); cg.add(" ");
cg.ensure_brackets_body(ctx, &else_if_branch.body); cg.ensure_brackets_body(ctx, &else_if_branch.body);
+1 -1
View File
@@ -399,7 +399,7 @@ control_flow = {
statement_branch = { "(" ~ expr ~ ")" ~ statement_body } statement_branch = { "(" ~ expr ~ ")" ~ statement_body }
else_if = { else_if = _{
"else" ~ "if" ~ statement_branch "else" ~ "if" ~ statement_branch
} }
-2
View File
@@ -1,5 +1,3 @@
void main() { void main() {
test_package::hello(); test_package::hello();
let idk = Bro::new();
} }