diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 831f71e912..abb7425dff 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -3810,7 +3810,7 @@ fn (mut g Gen) match_expr_classic(node ast.MatchExpr, is_expr bool, cond_var str } } g.stmts_with_tmp_var(branch.stmts, tmp_var) - if g.inside_ternary == 0 && node.branches.len > 1 { + if g.inside_ternary == 0 && node.branches.len >= 1 { g.write('}') } } diff --git a/vlib/v/tests/match_expr_with_one_branch_test.v b/vlib/v/tests/match_expr_with_one_branch_test.v new file mode 100644 index 0000000000..e38c13bb4d --- /dev/null +++ b/vlib/v/tests/match_expr_with_one_branch_test.v @@ -0,0 +1,12 @@ +enum Color { + red +} + +fn test_match_one_branch() { + col := Color.red + match col { + .red { + assert true + } + } +}