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

parser: fix initialization for array of Option type - []?Cell{} (#16652)

This commit is contained in:
Felipe Pena 2022-12-12 03:40:05 -03:00 committed by GitHub
parent d7c244e5ec
commit 1e7208d28b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -28,7 +28,7 @@ fn (mut p Parser) array_init() ast.ArrayInit {
line_nr := p.tok.line_nr line_nr := p.tok.line_nr
p.next() p.next()
// []string // []string
if p.tok.kind in [.name, .amp, .lsbr, .key_shared] && p.tok.line_nr == line_nr { if p.tok.kind in [.name, .amp, .lsbr, .question, .key_shared] && p.tok.line_nr == line_nr {
elem_type_pos = p.tok.pos() elem_type_pos = p.tok.pos()
elem_type = p.parse_type() elem_type = p.parse_type()
// this is set here because it's a known type, others could be the // this is set here because it's a known type, others could be the

View File

@ -0,0 +1,6 @@
struct Cell {}
fn test_main() {
mut var := []?Cell{len: 1}
assert var.len == 1
}