diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index eab989a0ab..da663b5fd9 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -4352,6 +4352,10 @@ fn (mut g Gen) go_stmt(node ast.GoStmt) { if expr.is_method { receiver_sym := g.table.get_type_symbol(expr.receiver_type) name = receiver_sym.name + '_' + name + } else if expr.left is ast.AnonFn as anon_fn { + g.gen_anon_fn_decl(anon_fn) + fsym := g.table.get_type_symbol(anon_fn.typ) + name = fsym.name } name = util.no_dots(name) g.writeln('// go') diff --git a/vlib/v/tests/anon_fn_test.v b/vlib/v/tests/anon_fn_test.v new file mode 100644 index 0000000000..0773e4cccf --- /dev/null +++ b/vlib/v/tests/anon_fn_test.v @@ -0,0 +1,9 @@ +import sync + +fn test_go_anon_fn() { + mut wg := sync.new_waitgroup() + go fn (mut wg sync.WaitGroup) { + wg.done() + }(mut wg) + wg.wait() +}