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

checker: fix global fn calls

This commit is contained in:
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 { pub fn new_scope(parent &Scope, start_pos int) &Scope {
return &Scope{ return &Scope{
parent: parent parent: parent
start_pos: start_pos start_pos: start_pos
} }
} }
*/
fn (s &Scope) dont_lookup_parent() bool { fn (s &Scope) dont_lookup_parent() bool {
return isnil(s.parent) || s.detached_from_parent 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 { if !found {
c.error('unknown function: $fn_name', call_expr.pos) c.error('unknown function: $fn_name', call_expr.pos)
return ast.void_type return ast.void_type