Skip to content

Commit 8123728

Browse files
authored
cgen: fix codegen for operator overload method_name on alias to builtin types (fix #25709) (#25726)
1 parent ae5bf7e commit 8123728

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

vlib/v/gen/c/infix.v

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ fn (mut g Gen) infix_expr_eq_op(node ast.InfixExpr) {
164164
g.styp(left.unaliased.set_nr_muls(0))
165165
}
166166
mut is_builtin_or_alias_to_builtin := left.sym.is_builtin()
167-
if !is_builtin_or_alias_to_builtin && left.sym.info is ast.Alias {
167+
if !has_alias_eq_op_overload && !is_builtin_or_alias_to_builtin
168+
&& left.sym.info is ast.Alias {
168169
alias_info := left.sym.info as ast.Alias
169170
parent_sym := g.table.sym(alias_info.parent_type)
170171
is_builtin_or_alias_to_builtin = parent_sym.is_builtin()
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
type MyInt = int
2+
3+
fn (i1 MyInt) == (i2 MyInt) bool {
4+
return int(i1) == int(i2)
5+
}
6+
7+
fn test_main() {
8+
c := MyInt(3) == MyInt(1)
9+
assert c == false
10+
}

0 commit comments

Comments
 (0)