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

parser: fix struct init and assign using sql variable (#10968)

This commit is contained in:
yuyi
2021-07-27 02:14:31 +08:00
committed by GitHub
parent 79c7aed3c2
commit cb7be87d4e
3 changed files with 29 additions and 4 deletions

View File

@@ -674,7 +674,7 @@ pub fn (mut p Parser) stmt(is_top_level bool) ast.Stmt {
return p.for_stmt()
}
.name {
if p.tok.lit == 'sql' {
if p.tok.lit == 'sql' && p.peek_tok.kind == .name {
return p.sql_stmt()
}
if p.peek_tok.kind == .colon {

View File

@@ -1,6 +1,5 @@
vlib/v/parser/tests/sql_no_db_expr_a.vv:3:6: error: invalid expression: unexpected token `:=`, expecting database
1 | fn x() {
vlib/v/parser/tests/sql_no_db_expr_a.vv:4:1: error: invalid expression: unexpected token `}`
2 | // SqlStmt
3 | sql :=
| ~~
4 | }
| ^