checker: fix global fn calls

pull/10573/head
Alexander Medvednikov 2021-06-25 20:26:24 +03:00
parent 72c12b6735
commit 7458927593
2 changed files with 11 additions and 0 deletions

View File

@ -28,12 +28,14 @@ pub fn (s &Scope) free() {
}
}
/*
pub fn new_scope(parent &Scope, start_pos int) &Scope {
return &Scope{
parent: parent
start_pos: start_pos
}
}
*/
fn (s &Scope) dont_lookup_parent() bool {
return isnil(s.parent) || s.detached_from_parent

View File

@ -2407,6 +2407,15 @@ pub fn (mut c Checker) fn_call(mut call_expr ast.CallExpr) ast.Type {
}
}
}
// global fn?
if !found {
if obj := c.file.global_scope.find(fn_name) {
sym := c.table.get_type_symbol(obj.typ)
if sym.kind == .function {
found = true
}
}
}
if !found {
c.error('unknown function: $fn_name', call_expr.pos)
return ast.void_type