1
0
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:
Felipe Pena 2023-05-30 09:22:47 -03:00 committed by GitHub
parent 4174048f96
commit f430c0b67a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View File

@ -474,6 +474,7 @@ fn (mut p Parser) select_expr() ast.SelectExpr {
} }
branch_last_pos := p.tok.pos() branch_last_pos := p.tok.pos()
p.inside_match_body = true p.inside_match_body = true
p.inside_for = false
stmts := p.parse_block_no_scope(false) stmts := p.parse_block_no_scope(false)
p.close_scope() p.close_scope()
p.inside_match_body = false p.inside_match_body = false

View 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)
}