parser: verify async functions
parent
ef562413cd
commit
962109e855
|
@ -645,6 +645,7 @@ fn (p mut Parser) check_unused_and_mut_vars() {
|
||||||
// receiver_var - "user" (needed for pthreads)
|
// receiver_var - "user" (needed for pthreads)
|
||||||
// receiver_type - "User"
|
// receiver_type - "User"
|
||||||
fn (p mut Parser) async_fn_call(f Fn, method_ph int, receiver_var, receiver_type string) {
|
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')
|
// println('\nfn_call $f.name is_method=$f.is_method receiver_type=$f.receiver_type')
|
||||||
// p.print_tok()
|
// p.print_tok()
|
||||||
mut thread_name := ''
|
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.genln('int $tmp2 = pthread_create(& $thread_name, NULL, (void *)$wrapper_name, $parg);')
|
||||||
}
|
}
|
||||||
p.check(.rpar)
|
p.check(.rpar)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// p.tok == fn_name
|
fn (p mut Parser) verify_fn_before_call(f &Fn) {
|
||||||
fn (p mut Parser) fn_call(f mut Fn, method_ph int, receiver_var, receiver_type string) {
|
|
||||||
if f.is_unsafe && !p.builtin_mod && !p.inside_unsafe {
|
if f.is_unsafe && !p.builtin_mod && !p.inside_unsafe {
|
||||||
p.warn('you are calling an unsafe function outside of an unsafe block')
|
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.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
|
is_comptime_define := f.comptime_define != '' && f.comptime_define != p.pref.comptime_define
|
||||||
if is_comptime_define {
|
if is_comptime_define {
|
||||||
p.cgen.nogen = true
|
p.cgen.nogen = true
|
||||||
|
|
Loading…
Reference in New Issue