Skip to content

Commit

Permalink
cgen: fix cgen for thread wrappers, when spawning fns with with anon-…
Browse files Browse the repository at this point in the history
…fn array args and mut interfaces (fix #19425) (#20241)
  • Loading branch information
shove70 committed Dec 22, 2023
1 parent ada9efd commit 869bac1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions vlib/v/gen/c/spawn_and_go.v
Expand Up @@ -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')
}
}
Expand Down
12 changes: 12 additions & 0 deletions 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
}

0 comments on commit 869bac1

Please sign in to comment.