1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: check using const var as function (#13006)

This commit is contained in:
yuyi 2022-01-01 15:15:43 +08:00 committed by GitHub
parent 6438512529
commit 7622ff3f54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 4 deletions

View File

@ -637,10 +637,12 @@ pub fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool)
// global fn?
if !found {
if obj := c.file.global_scope.find(fn_name) {
sym := c.table.sym(obj.typ)
if sym.kind == .function {
found = true
func = (sym.info as ast.FnType).func
if obj.typ != 0 {
sym := c.table.sym(obj.typ)
if sym.kind == .function {
found = true
func = (sym.info as ast.FnType).func
}
}
}
}

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/unknown_function.vv:4:15: error: unknown function: math.max_i64
2 |
3 | fn main() {
4 | println(math.max_i64())
| ~~~~~~~~~
5 | }

View File

@ -0,0 +1,5 @@
import math
fn main() {
println(math.max_i64())
}