1
0
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:
yuyi 2022-07-30 23:11:10 +08:00 committed by GitHub
parent c9a5896468
commit 014f44eab3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -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')

View File

@ -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)

View File

@ -1,6 +1,6 @@
module main
type Fkt = fn (mut a Alarm)
type Fkt = fn (mut Alarm)
struct Alarm {
x int