diff --git a/vlib/v/parser/assign.v b/vlib/v/parser/assign.v index a5debeab50..97d2d57c06 100644 --- a/vlib/v/parser/assign.v +++ b/vlib/v/parser/assign.v @@ -90,41 +90,21 @@ fn (mut p Parser) partial_assign_stmt(left []ast.Expr, left_comments []ast.Comme op := p.tok.kind pos := p.tok.position() p.next() + mut comments := []ast.Comment{cap: 2 * left_comments.len + 1} + comments << left_comments + comments << p.eat_comments() mut right_comments := []ast.Comment{} mut right := []ast.Expr{cap: left.len} if p.tok.kind == .key_go { - spos := p.tok.position() - p.next() - right_comments = p.eat_comments() - mut mod := '' - mut language := table.Language.v - if p.peek_tok.kind == .dot { - if p.tok.lit == 'C' { - language = table.Language.c - p.check_for_impure_v(language, p.tok.position()) - } else if p.tok.lit == 'JS' { - language = table.Language.js - p.check_for_impure_v(language, p.tok.position()) - } else { - mod = p.tok.lit - } - p.next() - p.next() - } - call_expr := p.call_expr(language, mod) - allpos := spos.extend(p.tok.position()) + stmt := p.stmt(false) + go_stmt := stmt as ast.GoStmt right << ast.GoExpr{ - go_stmt: ast.GoStmt{ - call_expr: call_expr - pos: allpos - } - pos: allpos + go_stmt: go_stmt + pos: go_stmt.pos } } else { right, right_comments = p.expr_list() } - mut comments := []ast.Comment{cap: left_comments.len + right_comments.len} - comments << left_comments comments << right_comments end_comments := p.eat_line_end_comments() mut has_cross_var := false diff --git a/vlib/v/tests/go_wait_3_test.v b/vlib/v/tests/go_wait_3_test.v new file mode 100644 index 0000000000..b41efb9bb4 --- /dev/null +++ b/vlib/v/tests/go_wait_3_test.v @@ -0,0 +1,22 @@ +struct Test { + sub SubTest +} + +struct SubTest { + test string +} + +fn test_method_go_wait() { + a := Test{ + sub: SubTest{ + test: 'hi' + } + } + thread := go a.sub.get() + r := thread.wait() + assert r == 'hi' +} + +fn (t SubTest) get() string { + return t.test +}