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:
parent
d7c244e5ec
commit
1e7208d28b
@ -28,7 +28,7 @@ fn (mut p Parser) array_init() ast.ArrayInit {
|
||||
line_nr := p.tok.line_nr
|
||||
p.next()
|
||||
// []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 = p.parse_type()
|
||||
// this is set here because it's a known type, others could be the
|
||||
|
6
vlib/v/tests/option_init_test.v
Normal file
6
vlib/v/tests/option_init_test.v
Normal file
@ -0,0 +1,6 @@
|
||||
struct Cell {}
|
||||
|
||||
fn test_main() {
|
||||
mut var := []?Cell{len: 1}
|
||||
assert var.len == 1
|
||||
}
|
Loading…
Reference in New Issue
Block a user