diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index eec5754c71..2c0013447d 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -1780,7 +1780,7 @@ fn (mut c Checker) fail_if_immutable(expr ast.Expr) (string, token.Position) { c.error('`$typ_sym.kind` can not be modified', expr.pos) } } - .aggregate { + .aggregate, .placeholder { c.fail_if_immutable(expr.expr) } else { diff --git a/vlib/v/tests/generics_fn_return_generic_interface_test.v b/vlib/v/tests/generics_fn_return_generic_interface_test.v index aededf0ed5..b11bff70f3 100644 --- a/vlib/v/tests/generics_fn_return_generic_interface_test.v +++ b/vlib/v/tests/generics_fn_return_generic_interface_test.v @@ -4,18 +4,22 @@ interface Iter { struct ArrayIter { data []T +mut: + index int } fn (mut i ArrayIter) next() ?T { if i.data.len == 0 { return none } - return i.data[0] + i.index += 1 + return i.data[i.index] } fn iter(arr []T) Iter { return ArrayIter{ data: arr + index: 0 } } @@ -24,5 +28,5 @@ fn test_generics_fn_return_generic_interface() { println(x) y := x.next() or { 0 } println(y) - assert y == 1 + assert y == 2 }