diff --git a/vlib/v/checker/fn.v b/vlib/v/checker/fn.v index 5bdd212ddc..24ff4ad7e6 100644 --- a/vlib/v/checker/fn.v +++ b/vlib/v/checker/fn.v @@ -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 + } } } } diff --git a/vlib/v/checker/tests/unknown_function.out b/vlib/v/checker/tests/unknown_function.out new file mode 100644 index 0000000000..955d354fd1 --- /dev/null +++ b/vlib/v/checker/tests/unknown_function.out @@ -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 | } diff --git a/vlib/v/checker/tests/unknown_function.vv b/vlib/v/checker/tests/unknown_function.vv new file mode 100644 index 0000000000..08021c5e53 --- /dev/null +++ b/vlib/v/checker/tests/unknown_function.vv @@ -0,0 +1,5 @@ +import math + +fn main() { + println(math.max_i64()) +}