1
0
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:
yuyi 2022-10-13 03:43:59 +08:00 committed by GitHub
parent 211cb2af7b
commit 6bdd11e53b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 5 deletions

View File

@ -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 { if !found && mut node.left is ast.CallExpr {
c.expr(node.left) c.expr(node.left)
sym := c.table.sym(node.left.return_type) if node.left.return_type != 0 {
if sym.info is ast.FnType { sym := c.table.sym(node.left.return_type)
node.return_type = sym.info.func.return_type if sym.info is ast.FnType {
found = true node.return_type = sym.info.func.return_type
func = sym.info.func found = true
func = sym.info.func
}
} }
} }
// already prefixed (mod.fn) or C/builtin/main // already prefixed (mod.fn) or C/builtin/main

View 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 | }

View File

@ -0,0 +1,6 @@
fn doit(i int) {
}
fn main() {
main.doit()(1)
}