1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser: make spawn behave like go

This commit is contained in:
Alexander Medvednikov 2022-11-05 10:41:30 +03:00
parent 141c404d45
commit a082328e40
4 changed files with 6 additions and 2 deletions

View File

@ -114,7 +114,7 @@ pub fn (mut p Parser) check_expr(precedence int) !ast.Expr {
node = p.prefix_expr()
}
}
.key_go {
.key_go, .key_spawn {
mut go_expr := p.go_expr()
go_expr.is_expr = true
node = go_expr

View File

@ -1051,7 +1051,7 @@ pub fn (mut p Parser) stmt(is_top_level bool) ast.Stmt {
}
}
}
.key_go {
.key_go, .key_spawn {
go_expr := p.go_expr()
return ast.ExprStmt{
expr: go_expr

View File

@ -1 +1,2 @@
[1, 2, 3]
[4,5, 6]

View File

@ -1,4 +1,7 @@
fn main(){
g := go print([1, 2, 3])
g.wait()
println('')
g2 := spawn print([4, 5, 6])
g2.wait()
}