1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

ci: fix mut_args_warning.vv error

This commit is contained in:
Delyan Angelov 2020-10-06 09:38:07 +03:00
parent f943bf2aaf
commit 70826914a7

View File

@ -152,8 +152,10 @@ pub fn (mut p Parser) parse_type() table.Type {
if p.tok.kind == .mul { if p.tok.kind == .mul {
p.error('use `&Type` instead of `*Type` when declaring references') p.error('use `&Type` instead of `*Type` when declaring references')
} }
mut nr_amps := 0
// &Type // &Type
for p.tok.kind == .amp { for p.tok.kind == .amp {
nr_amps++
nr_muls++ nr_muls++
p.next() p.next()
} }
@ -178,7 +180,7 @@ pub fn (mut p Parser) parse_type() table.Type {
} }
if nr_muls > 0 { if nr_muls > 0 {
typ = typ.set_nr_muls(nr_muls) 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, 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`). 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) {}`.') If you need to modify an array in a function, use a mutable argument instead: `fn foo(mut s []string) {}`.')