mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: check error for fn call with extra parenthesis (#16052)
This commit is contained in:
parent
211cb2af7b
commit
6bdd11e53b
@ -715,11 +715,13 @@ pub fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool)
|
||||
}
|
||||
if !found && mut node.left is ast.CallExpr {
|
||||
c.expr(node.left)
|
||||
sym := c.table.sym(node.left.return_type)
|
||||
if sym.info is ast.FnType {
|
||||
node.return_type = sym.info.func.return_type
|
||||
found = true
|
||||
func = sym.info.func
|
||||
if node.left.return_type != 0 {
|
||||
sym := c.table.sym(node.left.return_type)
|
||||
if sym.info is ast.FnType {
|
||||
node.return_type = sym.info.func.return_type
|
||||
found = true
|
||||
func = sym.info.func
|
||||
}
|
||||
}
|
||||
}
|
||||
// already prefixed (mod.fn) or C/builtin/main
|
||||
|
6
vlib/v/checker/tests/fn_call_with_extra_parenthesis.out
Normal file
6
vlib/v/checker/tests/fn_call_with_extra_parenthesis.out
Normal file
@ -0,0 +1,6 @@
|
||||
vlib/v/checker/tests/fn_call_with_extra_parenthesis.vv:5:7: error: expected 1 arguments, but got 0
|
||||
3 |
|
||||
4 | fn main() {
|
||||
5 | main.doit()(1)
|
||||
| ~~~~~~
|
||||
6 | }
|
6
vlib/v/checker/tests/fn_call_with_extra_parenthesis.vv
Normal file
6
vlib/v/checker/tests/fn_call_with_extra_parenthesis.vv
Normal file
@ -0,0 +1,6 @@
|
||||
fn doit(i int) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
main.doit()(1)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user