Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Oct 10, 2024
1 parent a3f6fd5 commit c0796c3
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions vlib/v/checker/infix.v
Original file line number Diff line number Diff line change
Expand Up @@ -306,23 +306,21 @@ fn (mut c Checker) infix_expr(mut node ast.InfixExpr) ast.Type {
right_sym = c.table.sym(unwrapped_right_type)
if mut right_sym.info is ast.Alias && (right_sym.info.language != .c
&& c.mod == c.table.type_to_str(unwrapped_right_type).split('.')[0]
&& (c.table.sym(right_sym.info.parent_type).is_primitive()
|| c.table.sym(right_sym.info.parent_type).kind == .enum)) {
right_sym = c.table.sym(right_sym.info.parent_type)
&& (right_final_sym.is_primitive() || right_final_sym.kind == .enum)) {
right_sym = right_final_sym
}
if mut left_sym.info is ast.Alias && (left_sym.info.language != .c
&& c.mod == c.table.type_to_str(unwrapped_left_type).split('.')[0]
&& (c.table.sym(left_sym.info.parent_type).is_primitive()
|| c.table.sym(left_sym.info.parent_type).kind == .enum)) {
left_sym = c.table.sym(left_sym.info.parent_type)
&& (left_final_sym.is_primitive() || left_final_sym.kind == .enum)) {
left_sym = left_final_sym
}

if c.pref.translated && node.op in [.plus, .minus, .mul]
&& unwrapped_left_type.is_any_kind_of_pointer()
&& unwrapped_right_type.is_any_kind_of_pointer() {
return_type = left_type
} else if !c.pref.translated && left_sym.info is ast.Alias
&& !(c.table.sym(left_sym.info.parent_type).is_primitive()) {
&& !left_final_sym.is_primitive() {
if left_sym.has_method(node.op.str()) {
if method := left_sym.find_method(node.op.str()) {
return_type = method.return_type
Expand All @@ -347,7 +345,7 @@ fn (mut c Checker) infix_expr(mut node ast.InfixExpr) ast.Type {
}
}
} else if !c.pref.translated && right_sym.info is ast.Alias
&& !(c.table.sym(right_sym.info.parent_type).is_primitive()) {
&& !right_final_sym.is_primitive() {
if right_sym.has_method(node.op.str()) {
if method := right_sym.find_method(node.op.str()) {
return_type = method.return_type
Expand Down Expand Up @@ -477,15 +475,13 @@ fn (mut c Checker) infix_expr(mut node ast.InfixExpr) ast.Type {

left_sym = c.table.sym(unwrapped_left_type)
right_sym = c.table.sym(unwrapped_right_type)
if left_sym.info is ast.Alias
&& c.table.sym(left_sym.info.parent_type).is_primitive() {
if left_sym.info is ast.Alias && left_final_sym.is_primitive() {
if left_sym.has_method(node.op.str()) {
if method := left_sym.find_method(node.op.str()) {
return_type = method.return_type
}
}
} else if right_sym.info is ast.Alias
&& c.table.sym(right_sym.info.parent_type).is_primitive() {
} else if right_sym.info is ast.Alias && right_final_sym.is_primitive() {
if right_sym.has_method(node.op.str()) {
if method := right_sym.find_method(node.op.str()) {
return_type = method.return_type
Expand Down

0 comments on commit c0796c3

Please sign in to comment.