Skip to content

Commit

Permalink
cgen: fix codegen for array fixed comparison on MatchExpr (fix #23403) (
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp authored Jan 9, 2025
1 parent f75aa34 commit 6348e58
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions vlib/v/gen/c/match.v
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,9 @@ fn (mut g Gen) match_expr_classic(node ast.MatchExpr, is_expr bool, cond_var str
.array_fixed {
ptr_typ := g.equality_fn(node.cond_type)
g.write('${ptr_typ}_arr_eq(${cond_var}, ')
if expr is ast.ArrayInit {
g.write('(${g.styp(node.cond_type)})')
}
g.expr(expr)
g.write(')')
}
Expand Down
14 changes: 14 additions & 0 deletions vlib/v/tests/match_array_fixed_test.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
fn test_main() {
on_event()
}

fn on_event() {
match [0, 0]! {
[0, 1]! {
assert false
}
else {
assert true
}
}
}

0 comments on commit 6348e58

Please sign in to comment.