From 70826914a7b52bfe634abbb5f41b85e396668096 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Tue, 6 Oct 2020 09:38:07 +0300 Subject: [PATCH] ci: fix mut_args_warning.vv error --- vlib/v/parser/parse_type.v | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vlib/v/parser/parse_type.v b/vlib/v/parser/parse_type.v index 13eb3c6e20..76a72b6201 100644 --- a/vlib/v/parser/parse_type.v +++ b/vlib/v/parser/parse_type.v @@ -152,8 +152,10 @@ pub fn (mut p Parser) parse_type() table.Type { if p.tok.kind == .mul { p.error('use `&Type` instead of `*Type` when declaring references') } + mut nr_amps := 0 // &Type for p.tok.kind == .amp { + nr_amps++ nr_muls++ p.next() } @@ -178,7 +180,7 @@ pub fn (mut p Parser) parse_type() table.Type { } if nr_muls > 0 { typ = typ.set_nr_muls(nr_muls) - if is_array { + if is_array && nr_amps > 0 { p.error('V arrays are already references behind the scenes, there is no need to use a reference to an array (e.g. use `[]string` instead of `&[]string`). If you need to modify an array in a function, use a mutable argument instead: `fn foo(mut s []string) {}`.')