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

parser: check function argument mutable syntax

This commit is contained in:
yuyi 2020-06-04 21:20:43 +08:00 committed by GitHub
parent edd56bc080
commit dd7ebf7fac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions

View File

@ -0,0 +1,5 @@
vlib/v/checker/tests/mut_args_warning.v:1:8: warning: use `mut f Foo` instead of `f mut Foo`
1 | fn f(x mut []int) { x[0] = 1 }
| ~~~
2 | fn main() {
3 | mut x := [0]

View File

@ -0,0 +1,5 @@
fn f(x mut []int) { x[0] = 1 }
fn main() {
mut x := [0]
f(mut x)
}

View File

@ -415,6 +415,7 @@ fn (mut p Parser) fn_args() ([]table.Arg, bool) {
}
if p.tok.kind == .key_mut {
// TODO remove old syntax
p.warn_with_pos('use `mut f Foo` instead of `f mut Foo`', p.tok.position())
is_mut = true
}
if p.tok.kind == .ellipsis {