checker: make the misssing shared/mut modifer in fn and method calls error clearer
parent
55d9464890
commit
cc637e5ee8
|
@ -812,8 +812,8 @@ pub fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool)
|
|||
} else {
|
||||
if param.is_mut {
|
||||
tok := call_arg.share.str()
|
||||
c.error('`$node.name` parameter `$param.name` is `$tok`, you need to provide `$tok` e.g. `$tok arg${
|
||||
i + 1}`', call_arg.expr.pos())
|
||||
c.error('function `$node.name` parameter `$param.name` is `$tok`, so use `$tok $call_arg.expr` instead',
|
||||
call_arg.expr.pos())
|
||||
} else {
|
||||
c.fail_if_unreadable(call_arg.expr, typ, 'argument')
|
||||
}
|
||||
|
@ -1307,8 +1307,8 @@ pub fn (mut c Checker) method_call(mut node ast.CallExpr) ast.Type {
|
|||
} else {
|
||||
if param_is_mut {
|
||||
tok := arg.share.str()
|
||||
c.error('`$node.name` parameter `$param.name` is `$tok`, you need to provide `$tok` e.g. `$tok arg${
|
||||
i + 1}`', arg.expr.pos())
|
||||
c.error('method `$node.name` parameter `$param.name` is `$tok`, so use `$tok $arg.expr` instead',
|
||||
arg.expr.pos())
|
||||
} else {
|
||||
c.fail_if_unreadable(arg.expr, got_arg_typ, 'argument')
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ vlib/v/checker/tests/chan_args.vv:5:19: error: cannot use `float literal` as `&f
|
|||
| ~~~
|
||||
6 | b := 2.5
|
||||
7 | _ := ch.try_pop(b)
|
||||
vlib/v/checker/tests/chan_args.vv:7:18: error: `try_pop` parameter `obj` is `mut`, you need to provide `mut` e.g. `mut arg1`
|
||||
vlib/v/checker/tests/chan_args.vv:7:18: error: method `try_pop` parameter `obj` is `mut`, so use `mut b` instead
|
||||
5 | _ := ch.try_push(2.5)
|
||||
6 | b := 2.5
|
||||
7 | _ := ch.try_pop(b)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
vlib/v/checker/tests/mut_arg.vv:6:3: error: `f` parameter `par` is `mut`, you need to provide `mut` e.g. `mut arg1`
|
||||
vlib/v/checker/tests/mut_arg.vv:6:3: error: function `f` parameter `par` is `mut`, so use `mut [3, 4]` instead
|
||||
4 | }
|
||||
5 |
|
||||
6 | f([3,4])
|
||||
| ~~~~~
|
||||
7 | mut a := [1,2]
|
||||
8 | f(a)
|
||||
vlib/v/checker/tests/mut_arg.vv:8:3: error: `f` parameter `par` is `mut`, you need to provide `mut` e.g. `mut arg1`
|
||||
vlib/v/checker/tests/mut_arg.vv:8:3: error: function `f` parameter `par` is `mut`, so use `mut a` instead
|
||||
6 | f([3,4])
|
||||
7 | mut a := [1,2]
|
||||
8 | f(a)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
vlib/v/checker/tests/mut_interface_param_err.vv:19:10: error: `add` parameter `widget` is `mut`, you need to provide `mut` e.g. `mut arg1`
|
||||
vlib/v/checker/tests/mut_interface_param_err.vv:19:10: error: method `add` parameter `widget` is `mut`, so use `mut btn` instead
|
||||
17 | mut win := Window{}
|
||||
18 | mut btn := Button{}
|
||||
19 | win.add(btn) // should be an error here
|
||||
|
|
Loading…
Reference in New Issue