mirror of
https://github.com/vlang/v.git
synced 2025-09-21 03:07:36 -04:00
cgen: fix match with mut cond variable (#22207)
This commit is contained in:
parent
6eae77b61e
commit
4572c64759
@ -491,7 +491,8 @@ fn (mut g Gen) match_expr_classic(node ast.MatchExpr, is_expr bool, cond_var str
|
||||
g.write(')')
|
||||
}
|
||||
.string {
|
||||
g.write('string__eq(${cond_var}, ')
|
||||
ptr_str := if node.cond_type.is_ptr() { '*' } else { '' }
|
||||
g.write('string__eq(${ptr_str}${cond_var}, ')
|
||||
g.expr(expr)
|
||||
g.write(')')
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
fn test_match_with_mut_cond_var() {
|
||||
mut aaa := []string{}
|
||||
for mut ccc in aaa {
|
||||
match ccc {
|
||||
'/' {}
|
||||
else {}
|
||||
}
|
||||
}
|
||||
assert true
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user