parser: verify async functions

pull/3081/head
Alexander Medvednikov 2019-12-14 02:33:19 +03:00
parent ef562413cd
commit 962109e855
1 changed files with 8 additions and 2 deletions

View File

@ -645,6 +645,7 @@ fn (p mut Parser) check_unused_and_mut_vars() {
// receiver_var - "user" (needed for pthreads)
// receiver_type - "User"
fn (p mut Parser) async_fn_call(f Fn, method_ph int, receiver_var, receiver_type string) {
p.verify_fn_before_call(f)
// println('\nfn_call $f.name is_method=$f.is_method receiver_type=$f.receiver_type')
// p.print_tok()
mut thread_name := ''
@ -721,10 +722,10 @@ fn (p mut Parser) async_fn_call(f Fn, method_ph int, receiver_var, receiver_type
p.genln('int $tmp2 = pthread_create(& $thread_name, NULL, (void *)$wrapper_name, $parg);')
}
p.check(.rpar)
}
// p.tok == fn_name
fn (p mut Parser) fn_call(f mut Fn, method_ph int, receiver_var, receiver_type string) {
fn (p mut Parser) verify_fn_before_call(f &Fn) {
if f.is_unsafe && !p.builtin_mod && !p.inside_unsafe {
p.warn('you are calling an unsafe function outside of an unsafe block')
}
@ -737,6 +738,11 @@ fn (p mut Parser) fn_call(f mut Fn, method_ph int, receiver_var, receiver_type s
}
p.error('function `$f.name` is private')
}
}
// p.tok == fn_name
fn (p mut Parser) fn_call(f mut Fn, method_ph int, receiver_var, receiver_type string) {
p.verify_fn_before_call(f)
is_comptime_define := f.comptime_define != '' && f.comptime_define != p.pref.comptime_define
if is_comptime_define {
p.cgen.nogen = true