diff --git a/vlib/v/gen/c/spawn_and_go.v b/vlib/v/gen/c/spawn_and_go.v index b6c1fced1d7b78..a2654ec0d3872a 100644 --- a/vlib/v/gen/c/spawn_and_go.v +++ b/vlib/v/gen/c/spawn_and_go.v @@ -252,6 +252,19 @@ fn (mut g Gen) spawn_and_go_expr(node ast.SpawnExpr, mode SpawnGoMode) { mut arg_types := f.params.map(it.typ) arg_types = arg_types.map(muttable.resolve_generic_to_concrete(it, f.generic_names, node.call_expr.concrete_types) or { it }) + for i, typ in arg_types { + mut typ_sym := g.table.sym(typ) + for { + if mut typ_sym.info is ast.Array { + typ_sym = g.table.sym(typ_sym.info.elem_type) + } else { + if typ_sym.info is ast.FnType { + arg_types[i] = expr.args[i].typ + } + break + } + } + } fn_var = g.fn_var_signature(return_type, arg_types, 'fn') } } diff --git a/vlib/v/tests/go_call_fn_with_anon_fn_array_arg_test.v b/vlib/v/tests/go_call_fn_with_anon_fn_array_arg_test.v new file mode 100644 index 00000000000000..78291d18a8c763 --- /dev/null +++ b/vlib/v/tests/go_call_fn_with_anon_fn_array_arg_test.v @@ -0,0 +1,12 @@ +// for issue 19425 +interface MyInterface {} + +type Func = fn () int + +fn handle_fns(fns []Func, mut w MyInterface) {} + +fn test_main() { + mut w := &MyInterface(123) + spawn handle_fns([], mut w) + assert true +}