mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
This commit is contained in:
parent
70f466460f
commit
9887dd1fbf
@ -1826,8 +1826,15 @@ fn (mut g Gen) go_expr(node ast.GoExpr) {
|
||||
g.type_definitions.writeln('EMPTY_STRUCT_DECLARATION;')
|
||||
} else {
|
||||
for i, arg in expr.args {
|
||||
styp := g.typ(arg.typ)
|
||||
g.type_definitions.writeln('\t$styp arg${i + 1};')
|
||||
arg_sym := g.table.sym(arg.typ)
|
||||
if arg_sym.info is ast.FnType {
|
||||
sig := g.fn_var_signature(arg_sym.info.func.return_type, arg_sym.info.func.params,
|
||||
'arg${i + 1}')
|
||||
g.type_definitions.writeln('\t' + sig + ';')
|
||||
} else {
|
||||
styp := g.typ(arg.typ)
|
||||
g.type_definitions.writeln('\t$styp arg${i + 1};')
|
||||
}
|
||||
}
|
||||
}
|
||||
if need_return_ptr {
|
||||
|
14
vlib/v/tests/go_call_fn_with_anon_fn_arg_test.v
Normal file
14
vlib/v/tests/go_call_fn_with_anon_fn_arg_test.v
Normal file
@ -0,0 +1,14 @@
|
||||
fn start(f fn ()) string {
|
||||
f()
|
||||
return 'ok!!'
|
||||
}
|
||||
|
||||
fn on_connect() {
|
||||
println('fn ok!!')
|
||||
}
|
||||
|
||||
fn test_go_call_fn_with_anon_fn_arg() {
|
||||
g := go start(on_connect)
|
||||
ret := g.wait()
|
||||
assert ret == 'ok!!'
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user