From 320174bd5b4d438805b221fa89e6449646c4b52a Mon Sep 17 00:00:00 2001 From: BigBlack <840206@qq.com> Date: Fri, 27 Dec 2019 11:09:09 +0800 Subject: [PATCH] fix #3202 --- vlib/builtin/array_test.v | 14 ++++++++++++++ vlib/compiler/parser.v | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/vlib/builtin/array_test.v b/vlib/builtin/array_test.v index 8cc0da76cd..7f94c36a75 100644 --- a/vlib/builtin/array_test.v +++ b/vlib/builtin/array_test.v @@ -542,3 +542,17 @@ fn test_for_last() { assert s == '[1, 2, 3, 4]' } */ + +struct Foo { + mut: + bar []int +} + +fn test_in_struct() { + mut baz := Foo{ + bar: [0, 0, 0] + } + baz.bar[0] += 2 + baz.bar[0]++ + assert baz.bar[0] == 3 +} diff --git a/vlib/compiler/parser.v b/vlib/compiler/parser.v index 7afd30acf4..6c54279682 100644 --- a/vlib/compiler/parser.v +++ b/vlib/compiler/parser.v @@ -1964,7 +1964,7 @@ fn (p mut Parser) var_expr(v Var) string { // p.print_tok() // dc++ if p.tok == .lsbr { - // typ = p.index_expr(typ, fn_ph, v) + typ = p.index_expr(typ, fn_ph) } } // `a++` and `a--`