mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: fix for select parsing (#18306)
This commit is contained in:
parent
4174048f96
commit
f430c0b67a
@ -474,6 +474,7 @@ fn (mut p Parser) select_expr() ast.SelectExpr {
|
||||
}
|
||||
branch_last_pos := p.tok.pos()
|
||||
p.inside_match_body = true
|
||||
p.inside_for = false
|
||||
stmts := p.parse_block_no_scope(false)
|
||||
p.close_scope()
|
||||
p.inside_match_body = false
|
||||
|
27
vlib/v/tests/for_select_test.v
Normal file
27
vlib/v/tests/for_select_test.v
Normal file
@ -0,0 +1,27 @@
|
||||
import time
|
||||
|
||||
fn test_main() {
|
||||
ch := chan int{}
|
||||
go do_send(ch)
|
||||
mut a := 0
|
||||
for select {
|
||||
x := <-ch {
|
||||
a += x
|
||||
check(x)
|
||||
}
|
||||
} {
|
||||
}
|
||||
assert a == 45
|
||||
time.sleep(500 * time.millisecond)
|
||||
}
|
||||
|
||||
fn do_send(ch chan int) {
|
||||
for i in 0 .. 10 {
|
||||
ch <- i
|
||||
}
|
||||
ch.close()
|
||||
}
|
||||
|
||||
fn check(a int) {
|
||||
println(a)
|
||||
}
|
Loading…
Reference in New Issue
Block a user