diff --git a/vlib/v/gen/c/array.v b/vlib/v/gen/c/array.v index 25378e0f81..39eb7b524d 100644 --- a/vlib/v/gen/c/array.v +++ b/vlib/v/gen/c/array.v @@ -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(')') } diff --git a/vlib/v/tests/for_in_mut_val_with_if_val_in_test.v b/vlib/v/tests/for_in_mut_val_with_if_val_in_test.v new file mode 100644 index 0000000000..a95ee7c4ba --- /dev/null +++ b/vlib/v/tests/for_in_mut_val_with_if_val_in_test.v @@ -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 +}