Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Feb 23, 2025
1 parent 33f4c1a commit 0bd8b3c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 2 additions & 6 deletions vlib/v/gen/c/infix.v
Original file line number Diff line number Diff line change
Expand Up @@ -836,11 +836,7 @@ fn (mut g Gen) infix_expr_in_optimization(left ast.Expr, left_type ast.Type, rig
fn (mut g Gen) infix_expr_is_op(node ast.InfixExpr) {
mut left_sym := g.table.sym(g.unwrap_generic(g.type_resolver.get_type_or_default(node.left,
node.left_type)))
is_aggregate := left_sym.kind == .aggregate
if is_aggregate {
parent_left_type := (left_sym.info as ast.Aggregate).sum_type
left_sym = g.table.sym(parent_left_type)
}
is_aggregate := node.left is ast.Ident && g.comptime.get_ct_type_var(node.left) == .aggregate
right_sym := g.table.sym(node.right_type)
if left_sym.kind == .interface && right_sym.kind == .interface {
g.gen_interface_is_op(node)
Expand Down Expand Up @@ -880,7 +876,7 @@ fn (mut g Gen) infix_expr_is_op(node ast.InfixExpr) {
sub_sym := g.table.sym(sub_type)
g.write('_${left_sym.cname}_${sub_sym.cname}_index')
return
} else if left_sym.kind == .sum_type {
} else if left_sym.kind == .sum_type || is_aggregate {
g.write('_typ ${cmp_op} ')
}
if node.right is ast.None {
Expand Down
4 changes: 2 additions & 2 deletions vlib/v/tests/typeof_aggregate_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ fn test_typeof_aggregate() {

assert rets.len == 3
assert rets[0] == 'The type of `a` is `Foo`'
assert rets[1] == 'The type of `a` is `(Bar | Baz | Bazaar)` and its text says bar'
assert rets[2] == 'The type of `a` is `(Bar | Baz | Bazaar)` and its text says baz'
assert rets[1] == 'The type of `a` is `Bar` and its text says bar'
assert rets[2] == 'The type of `a` is `Baz` and its text says baz'
}

0 comments on commit 0bd8b3c

Please sign in to comment.