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

pull/13010/head
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,6 +637,7 @@ 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) {
if obj.typ != 0 {
sym := c.table.sym(obj.typ)
if sym.kind == .function {
found = true
@ -644,6 +645,7 @@ pub fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool)
}
}
}
}
if !found {
continue_check = false
c.error('unknown function: $fn_name', node.pos)

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())
}