parser: check function argument mutable syntax
parent
edd56bc080
commit
dd7ebf7fac
|
@ -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]
|
|
@ -0,0 +1,5 @@
|
|||
fn f(x mut []int) { x[0] = 1 }
|
||||
fn main() {
|
||||
mut x := [0]
|
||||
f(mut x)
|
||||
}
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue