File tree Expand file tree Collapse file tree 3 files changed +50
-0
lines changed Expand file tree Collapse file tree 3 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -2584,6 +2584,10 @@ fn (mut c Checker) spawn_expr(mut node ast.SpawnExpr) ast.Type {
2584
2584
// Make sure there are no mutable arguments
2585
2585
for arg in node.call_expr.args {
2586
2586
if arg.is_mut && ! arg.typ.is_ptr () {
2587
+ if arg.typ == 0 {
2588
+ c.error ('invalid expr' , node.pos)
2589
+ return 0
2590
+ }
2587
2591
if c.table.final_sym (arg.typ).kind == .array {
2588
2592
// allow mutable []array to be passed as mut
2589
2593
continue
Original file line number Diff line number Diff line change
1
+ vlib/v/checker/tests/spawn_wrong_fn_err.vv:29:5: error: unknown function: vlang_ip
2
+ 27 | wg.add(2)
3
+ 28 | go vlang_time(mut wg)
4
+ 29 | go vlang_ip(mut wg)
5
+ | ~~~~~~~~~~~~~~~~
6
+ 30 | wg.wait()
7
+ 31 | }
8
+ vlib/v/checker/tests/spawn_wrong_fn_err.vv:29:5: error: invalid expr
9
+ 27 | wg.add(2)
10
+ 28 | go vlang_time(mut wg)
11
+ 29 | go vlang_ip(mut wg)
12
+ | ~~~~~~~~~~~~~~~~
13
+ 30 | wg.wait()
14
+ 31 | }
Original file line number Diff line number Diff line change
1
+ import net.http
2
+ import sync
3
+ import time
4
+
5
+ fn vlang_time(mut wg sync.WaitGroup) !string {
6
+ start := time.ticks()
7
+ data := http.get('https://vlang.io/utc_now')!
8
+ finish := time.ticks()
9
+ println('Finish getting time ${finish - start} ms')
10
+ println(data.body)
11
+ wg.done()
12
+ return data.body
13
+ }
14
+
15
+ fn remote_ip(mut wg sync.WaitGroup) !string {
16
+ start := time.ticks()
17
+ data := http.get('https://api.ipify.org')!
18
+ finish := time.ticks()
19
+ println('Finish getting ip ${finish - start} ms')
20
+ println(data.body)
21
+ wg.done()
22
+ return data.body
23
+ }
24
+
25
+ fn main() {
26
+ mut wg := sync.new_waitgroup()
27
+ wg.add(2)
28
+ go vlang_time(mut wg)
29
+ go vlang_ip(mut wg)
30
+ wg.wait()
31
+ }
32
+
You can’t perform that action at this time.
0 commit comments