mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: improve error message of method_call_arg_no_mut_err.vv (#15281)
This commit is contained in:
parent
c9a5896468
commit
014f44eab3
@ -1609,7 +1609,7 @@ pub fn (mut c Checker) method_call(mut node ast.CallExpr) ast.Type {
|
||||
to_lock, pos := c.fail_if_immutable(arg.expr)
|
||||
if !param.is_mut {
|
||||
tok := arg.share.str()
|
||||
c.error('`$node.name` parameter `$param.name` is not `$tok`, `$tok` is not needed`',
|
||||
c.error('`$node.name` parameter ${i + 1} is not `$tok`, `$tok` is not needed`',
|
||||
arg.expr.pos())
|
||||
} else {
|
||||
if param_share != arg.share {
|
||||
@ -1624,7 +1624,7 @@ pub fn (mut c Checker) method_call(mut node ast.CallExpr) ast.Type {
|
||||
} else {
|
||||
if param.is_mut {
|
||||
tok := arg.share.str()
|
||||
c.error('method `$node.name` parameter `$param.name` is `$tok`, so use `$tok $arg.expr` instead',
|
||||
c.error('method `$node.name` parameter ${i + 1} is `$tok`, so use `$tok $arg.expr` instead',
|
||||
arg.expr.pos())
|
||||
} else {
|
||||
c.fail_if_unreadable(arg.expr, targ, 'argument')
|
||||
|
@ -1,4 +1,4 @@
|
||||
vlib/v/checker/tests/method_call_arg_no_mut_err.vv:25:14: error: method `alarm_fkt` parameter `a` is `mut`, so use `mut last` instead
|
||||
vlib/v/checker/tests/method_call_arg_no_mut_err.vv:25:14: error: method `alarm_fkt` parameter 1 is `mut`, so use `mut last` instead
|
||||
23 | c.arr << Alarm{}
|
||||
24 | mut last := c.arr.last()
|
||||
25 | c.alarm_fkt(last)
|
||||
|
@ -1,6 +1,6 @@
|
||||
module main
|
||||
|
||||
type Fkt = fn (mut a Alarm)
|
||||
type Fkt = fn (mut Alarm)
|
||||
|
||||
struct Alarm {
|
||||
x int
|
||||
|
Loading…
Reference in New Issue
Block a user