mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: check call argument on methods (#12965)
This commit is contained in:
parent
3b5de71e60
commit
04be2465dc
@ -654,7 +654,14 @@ pub fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool)
|
||||
node.expected_arg_types << param.typ
|
||||
}
|
||||
}
|
||||
if !c.pref.backend.is_js() && node.args.len > 0 && func.params.len == 0 {
|
||||
c.error('too many arguments in call to `$func.name` (non-js backend: $c.pref.backend)',
|
||||
node.pos)
|
||||
}
|
||||
for i, mut call_arg in node.args {
|
||||
if func.params.len == 0 {
|
||||
continue
|
||||
}
|
||||
param := if func.is_variadic && i >= func.params.len - 1 {
|
||||
func.params[func.params.len - 1]
|
||||
} else {
|
||||
|
@ -0,0 +1,5 @@
|
||||
vlib/v/checker/tests/js_with_non_js_backend_too_many_arguments.vv:3:4: error: too many arguments in call to `JS.Foo.bar` (non-js backend: c)
|
||||
1 | fn JS.Foo.bar() bool
|
||||
2 |
|
||||
3 | JS.Foo.bar(123)
|
||||
| ~~~~~~~~~~~~
|
@ -0,0 +1,3 @@
|
||||
fn JS.Foo.bar() bool
|
||||
|
||||
JS.Foo.bar(123)
|
Loading…
Reference in New Issue
Block a user