cgen: fix 'for in mut val' with 'if val in' (#13263)
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(', ')
|
||||
if right.is_auto_deref_var() {
|
||||
g.write('*')
|
||||
}
|
||||
g.expr(right)
|
||||
g.write(')')
|
||||
}
|
||||
|
|
|
@ -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