Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgen: fix gen wrong for thread wrappers, when spawn with anon-fn array args(fix #19425) #20241

Merged
merged 2 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions vlib/v/gen/c/spawn_and_go.v
Original file line number Diff line number Diff line change
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
}
}
}
spytheman marked this conversation as resolved.
Show resolved Hide resolved
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
Original file line number Diff line number Diff line change
@@ -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
}
Loading