Fixed some bugs

This commit is contained in:
2026-05-21 14:04:12 +02:00
parent 8703ac4254
commit f2257a4e81
3 changed files with 18 additions and 6 deletions
+15
View File
@@ -68,6 +68,14 @@ impl GenRust for Literal {
impl GenRust for Expression {
fn gen_rust(&self, ctx: &mut Context, cg: &mut RustCodegen) {
let ensure_semicolon = if ctx.expr_ensure_semicolon {
ctx.expr_ensure_semicolon = false;
true
} else {
false
};
match self {
Expression::Path(path) => cg.add(&path.get_rust()),
Expression::Literal(literal) => literal.gen_rust(ctx, cg),
@@ -90,6 +98,11 @@ impl GenRust for Expression {
rhs.gen_rust(ctx, cg);
}
}
if ensure_semicolon {
ctx.expr_ensure_semicolon = true;
cg.add(";");
}
}
}
@@ -175,6 +188,8 @@ impl GenRust for Postfix {
expr.gen_rust(ctx, cg);
cg.add(",");
}
cg.add("}");
}
Postfix::Index(idx) => {