mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
make the new mut check work with fn foo(mut bar)
This commit is contained in:
parent
9ccd3bde01
commit
2ad0d0200d
@ -678,6 +678,7 @@ fn (p mut Parser) fn_args(f mut Fn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// foo *(1, 2, 3, mut bar)*
|
||||||
fn (p mut Parser) fn_call_args(f *Fn) *Fn {
|
fn (p mut Parser) fn_call_args(f *Fn) *Fn {
|
||||||
// p.gen('(')
|
// p.gen('(')
|
||||||
// println('fn_call_args() name=$f.name args.len=$f.args.len')
|
// println('fn_call_args() name=$f.name args.len=$f.args.len')
|
||||||
@ -725,6 +726,14 @@ fn (p mut Parser) fn_call_args(f *Fn) *Fn {
|
|||||||
p.error('`$arg.name` is a key_mut argument, you need to provide a variable to modify: `$f.name(... mut a...)`')
|
p.error('`$arg.name` is a key_mut argument, you need to provide a variable to modify: `$f.name(... mut a...)`')
|
||||||
}
|
}
|
||||||
p.check(.key_mut)
|
p.check(.key_mut)
|
||||||
|
var_name := p.lit
|
||||||
|
v := p.cur_fn.find_var(var_name)
|
||||||
|
if v.name == '' {
|
||||||
|
p.error('`$arg.name` is a key_mut argument, you need to provide a variable to modify: `$f.name(... mut a...)`')
|
||||||
|
}
|
||||||
|
if !v.is_changed {
|
||||||
|
p.cur_fn.mark_var_changed(v)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
p.expected_type = arg.typ
|
p.expected_type = arg.typ
|
||||||
typ := p.bool_expression()
|
typ := p.bool_expression()
|
||||||
|
Loading…
Reference in New Issue
Block a user