ci: fix mut_args_warning.vv error

pull/6298/head
Delyan Angelov 2020-10-06 09:38:07 +03:00
parent f943bf2aaf
commit 70826914a7
1 changed files with 3 additions and 1 deletions

View File

@ -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) {}`.')