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

parser: mut x Type syntax for args

This commit is contained in:
Alexander Medvednikov 2020-05-06 12:13:19 +02:00
parent 61e00e6796
commit 99cf520bd4
2 changed files with 16 additions and 4 deletions

View File

@ -358,16 +358,20 @@ fn (mut p Parser) fn_args() ([]table.Arg, bool) {
}
} else {
for p.tok.kind != .rpar {
mut is_mut := p.tok.kind == .key_mut
if is_mut {
p.next()
}
mut arg_names := [p.check_name()]
// `a, b, c int`
for p.tok.kind == .comma {
p.check(.comma)
arg_names << p.check_name()
}
is_mut := p.tok.kind == .key_mut
// if is_mut {
// p.check(.key_mut)
// }
if p.tok.kind == .key_mut {
// TODO remove old syntax
is_mut = true
}
if p.tok.kind == .ellipsis {
p.check(.ellipsis)
is_variadic = true

View File

@ -65,6 +65,14 @@ fn modify_array(a mut []int) {
// a << 888
}
fn modify_array2(mut a []int) {
a[0] = 10
for i in 0 .. a.len {
a[i] = a[i] * 2
}
// a << 888
}
fn test_mut_array() {
mut nums := [1, 2, 3]
modify_array(mut nums)