Skip to content

Commit a3180e5

Browse files
authored
cgen: fix x in [...]! operator with fixed arrays (fix #24082) (#24083)
1 parent 01a719a commit a3180e5

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎vlib/v/gen/c/infix.v‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,9 @@ fn (mut g Gen) infix_expr_in_optimization(left ast.Expr, left_type ast.Type, rig
823823
g.expr(left)
824824
}
825825
g.write(' == ')
826+
if elem_sym.kind == .array_fixed {
827+
g.write('(${g.styp(right.elem_type)})')
828+
}
826829
g.expr(array_expr)
827830
}
828831
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
fn test_main() {
2+
arr := [u8(1), 2, 3, 4]!
3+
if arr != [4]u8{} || arr != [4]u8{init: 255} {
4+
println('success')
5+
}
6+
if arr !in [[4]u8{}, [4]u8{init: 255}] {
7+
println('success')
8+
}
9+
}

0 commit comments

Comments
 (0)