cgen: fixe calling anon fn asynchronously (closes #6088) (#6121)

pull/6129/head
Daniel Däschle 2020-08-13 20:06:56 +02:00 committed by GitHub
parent 34b28cb68a
commit 64e8125807
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -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')

View File

@ -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()
}