suffix unary operators (++, --) working as intended

This commit is contained in:
uan
2026-02-07 14:39:15 +01:00
parent 99d63ff769
commit 90ab17da24
4 changed files with 111 additions and 44 deletions

View File

@@ -179,7 +179,15 @@ fn (mut g Generator) gen_expr(expr Expr) {
g.out.write_string(mangle_var(expr.name))
}
UnaryExpr {
g.out.write_string('(${mangle_var(expr.ident)}${expr.op})')
if expr.op_on_left {
g.out.write_string('(${expr.op}')
g.gen_expr(expr.expr)
g.out.write_string(')')
} else {
g.out.write_string('(')
g.gen_expr(expr.expr)
g.out.write_string('${expr.op})')
}
}
BinaryExpr {
g.out.write_string('(')