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

parser: fix multi fixed arrays init (#7996)

This commit is contained in:
yuyi 2021-01-10 13:58:31 +08:00 committed by GitHub
parent a8dd13f086
commit 704f38d87f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -1305,3 +1305,8 @@ fn test_array_of_map_insert() {
println(x)
assert '$x' == "[{}, {}, {'123': 123}, {}]"
}
fn test_multi_fixed_array_init() {
a := [3][3]int{}
assert '$a' == '[[0, 0, 0], [0, 0, 0], [0, 0, 0]]'
}

View File

@ -54,7 +54,7 @@ fn (mut p Parser) array_init() ast.ArrayInit {
}
last_pos = p.tok.position()
p.check(.rsbr)
if exprs.len == 1 && p.tok.kind in [.name, .amp] && p.tok.line_nr == line_nr {
if exprs.len == 1 && p.tok.kind in [.name, .amp, .lsbr] && p.tok.line_nr == line_nr {
// [100]byte
elem_type = p.parse_type()
is_fixed = true