diff --git a/vlib/v/checker/infix.v b/vlib/v/checker/infix.v index a0460377ed..24e4f97b33 100644 --- a/vlib/v/checker/infix.v +++ b/vlib/v/checker/infix.v @@ -306,15 +306,13 @@ 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] @@ -322,7 +320,7 @@ fn (mut c Checker) infix_expr(mut node ast.InfixExpr) ast.Type { && 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 @@ -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 @@ -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