Skip to content

Commit c54c9b8

Browse files
committed
cgen: c2v infix fix
1 parent 84e375e commit c54c9b8

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

vlib/v/gen/c/cgen.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1825,7 +1825,7 @@ fn (mut g Gen) stmt(node ast.Stmt) {
18251825
g.global_decl(node)
18261826
}
18271827
ast.GotoLabel {
1828-
g.writeln('${c_name(node.name)}: {}')
1828+
g.writeln('${c_name(node.name)}: ')
18291829
}
18301830
ast.GotoStmt {
18311831
g.write_v_source_line_info(node.pos)

vlib/v/gen/c/infix.v

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ fn (mut g Gen) infix_expr_eq_op(node ast.InfixExpr) {
8787
right := g.unwrap(node.right_type)
8888
has_defined_eq_operator := g.table.has_method(left.sym, '==')
8989
has_alias_eq_op_overload := left.sym.info is ast.Alias && left.sym.has_method('==')
90+
if g.pref.translated && !g.is_builtin_mod {
91+
g.gen_plain_infix_expr(node)
92+
return
93+
}
9094
if (left.typ.is_ptr() && right.typ.is_int()) || (right.typ.is_ptr() && left.typ.is_int()) {
9195
g.gen_plain_infix_expr(node)
9296
} else if (left.typ.idx() == ast.string_type_idx || (!has_defined_eq_operator
@@ -291,6 +295,10 @@ fn (mut g Gen) infix_expr_cmp_op(node ast.InfixExpr) {
291295
left := g.unwrap(node.left_type)
292296
right := g.unwrap(node.right_type)
293297
has_operator_overloading := g.table.has_method(left.sym, '<')
298+
if g.pref.translated && !g.is_builtin_mod {
299+
g.gen_plain_infix_expr(node)
300+
return
301+
}
294302
if left.sym.kind == .struct_ && (left.sym.info as ast.Struct).generic_types.len > 0 {
295303
if node.op in [.le, .ge] {
296304
g.write('!')

0 commit comments

Comments
 (0)