mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix 'for in mut val' with 'if val in' (#13263)
This commit is contained in:
parent
7199528a27
commit
509a8fcaf1
@ -710,6 +710,9 @@ fn (mut g Gen) gen_array_contains(typ ast.Type, left ast.Expr, right ast.Expr) {
|
|||||||
g.write('->val')
|
g.write('->val')
|
||||||
}
|
}
|
||||||
g.write(', ')
|
g.write(', ')
|
||||||
|
if right.is_auto_deref_var() {
|
||||||
|
g.write('*')
|
||||||
|
}
|
||||||
g.expr(right)
|
g.expr(right)
|
||||||
g.write(')')
|
g.write(')')
|
||||||
}
|
}
|
||||||
|
13
vlib/v/tests/for_in_mut_val_with_if_val_in_test.v
Normal file
13
vlib/v/tests/for_in_mut_val_with_if_val_in_test.v
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
fn test_for_in_mut_val_with_if_val_in() {
|
||||||
|
array := ['e']
|
||||||
|
mut splited := ['h', 'f', 's', 'e']
|
||||||
|
mut has_e := false
|
||||||
|
|
||||||
|
for mut s in splited {
|
||||||
|
if s in array {
|
||||||
|
println('Hello')
|
||||||
|
has_e = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert has_e
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user