Skip to content

Commit

Permalink
Revert "cgen: fix assert for alias to fixed array (fix vlang#23149) (v…
Browse files Browse the repository at this point in the history
…lang#23161)"

This reverts commit 9e71e32 , because of failing CI.
  • Loading branch information
spytheman committed Dec 15, 2024
1 parent 9e71e32 commit 3d5f81b
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 54 deletions.
10 changes: 0 additions & 10 deletions vlib/v/ast/types.v
Original file line number Diff line number Diff line change
Expand Up @@ -1006,16 +1006,6 @@ pub fn (t &Struct) is_unresolved_generic() bool {
return t.generic_types.len > 0 && t.concrete_types.len == 0
}

pub fn (t &TypeSymbol) is_primitive_fixed_array() bool {
if t.info is ArrayFixed {
return global_table.final_sym(t.info.elem_type).is_primitive()
} else if t.info is Alias {
return global_table.final_sym(t.info.parent_type).is_primitive_fixed_array()
} else {
return false
}
}

pub fn (t &TypeSymbol) is_array_fixed() bool {
if t.info is ArrayFixed {
return true
Expand Down
5 changes: 0 additions & 5 deletions vlib/v/gen/c/auto_eq_methods.v
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,6 @@ fn (mut g Gen) gen_fixed_array_equality_fn(left_type ast.Type) string {

mut fn_builder := strings.new_builder(512)
fn_builder.writeln('inline bool ${ptr_styp}_arr_eq(${arg_styp} a, ${arg_styp} b) {')
if left_typ.sym.is_primitive_fixed_array() {
fn_builder.writeln('\tif (!memcmp(${left}, ${right}, sizeof(${arg_styp}))) {')
fn_builder.writeln('\t\treturn true;')
fn_builder.writeln('\t}')
}
fn_builder.writeln('\tfor (int i = 0; i < ${size}; ++i) {')
// compare every pair of elements of the two fixed arrays
if elem.sym.kind == .string {
Expand Down
17 changes: 0 additions & 17 deletions vlib/v/gen/c/infix.v
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,8 @@ fn (mut g Gen) infix_expr_eq_op(node ast.InfixExpr) {
if left.typ.is_ptr() {
g.write('*'.repeat(left.typ.nr_muls()))
}
if node.left is ast.StructInit && left.unaliased_sym.is_primitive_fixed_array() {
s := g.styp(left.unaliased)
g.write('(${s})')
}
g.expr(node.left)
g.write(', ')
if node.right is ast.StructInit
&& right.unaliased_sym.is_primitive_fixed_array() {
s := g.styp(right.unaliased)
g.write('(${s})')
}
if right.typ.is_ptr() {
g.write('*'.repeat(right.typ.nr_muls()))
}
Expand Down Expand Up @@ -275,10 +266,6 @@ fn (mut g Gen) infix_expr_eq_op(node ast.InfixExpr) {
s := g.styp(left.unaliased)
g.write('(${s})')
}
} else if node.left is ast.StructInit
&& left.unaliased_sym.is_primitive_fixed_array() {
s := g.styp(left.unaliased)
g.write('(${s})')
}
g.expr(node.left)
g.write(', ')
Expand All @@ -287,10 +274,6 @@ fn (mut g Gen) infix_expr_eq_op(node ast.InfixExpr) {
s := g.styp(right.unaliased)
g.write('(${s})')
}
} else if node.right is ast.StructInit
&& right.unaliased_sym.is_primitive_fixed_array() {
s := g.styp(right.unaliased)
g.write('(${s})')
}
g.expr(node.right)
g.write(')')
Expand Down
4 changes: 0 additions & 4 deletions vlib/v/gen/c/str.v
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,6 @@ fn (mut g Gen) gen_expr_to_string(expr ast.Expr, etype ast.Type) {
if temp_var_needed {
g.write(tmp_var)
} else {
if expr is ast.StructInit && g.table.final_sym(expr.typ).is_primitive_fixed_array() {
s := g.styp(expr.typ)
g.write('(${s})')
}
g.expr_with_cast(expr, typ, typ)
}
} else if typ.has_flag(.option) {
Expand Down
18 changes: 0 additions & 18 deletions vlib/v/tests/assert_alias_array_test.v

This file was deleted.

0 comments on commit 3d5f81b

Please sign in to comment.