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

parser: fix [] in if expr. closes #9131

This commit is contained in:
Joe Conigliaro 2021-03-06 01:43:34 +11:00
parent 2d73411396
commit 818be80581
No known key found for this signature in database
GPG Key ID: C12F7136C08206F1

View File

@ -105,7 +105,7 @@ fn (mut p Parser) array_init() ast.ArrayInit {
mut has_cap := false
mut len_expr := ast.Expr{}
mut cap_expr := ast.Expr{}
if p.tok.kind == .lcbr && exprs.len == 0 {
if p.tok.kind == .lcbr && exprs.len == 0 && !p.inside_if {
// `[]int{ len: 10, cap: 100}` syntax
p.next()
for p.tok.kind != .rcbr {