Skip to content

Commit fc640f7

Browse files
authored
cgen: fix codegen for thread.call() on var auto heap (fix #24326) (#24327)
1 parent 8f25285 commit fc640f7

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

‎vlib/v/gen/c/array.v‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,9 @@ fn (mut g Gen) gen_array_wait(node ast.CallExpr) {
14411441
eltyp := g.table.sym(thread_ret_type).cname
14421442
fn_name := g.register_thread_array_wait_call(eltyp)
14431443
g.write('${fn_name}(')
1444+
if node.left_type.is_ptr() {
1445+
g.write('*')
1446+
}
14441447
g.expr(node.left)
14451448
g.write(')')
14461449
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import math { sqrt }
2+
import time
3+
4+
fn get_hypot(a f64, b f64) f64 {
5+
time.sleep(100 * time.millisecond)
6+
c := sqrt(a * a + b * b)
7+
return c
8+
}
9+
10+
fn test_main() {
11+
mut arr := &[]thread f64{}
12+
for num in 1 .. 1000 {
13+
g := go get_hypot(num, num)
14+
arr << g
15+
}
16+
result := arr.wait()
17+
assert result[0] == 1.4142135623730951
18+
}

0 commit comments

Comments
 (0)