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

checker: avoid get_type_symbol panic inside array_init (#9800)

This commit is contained in:
Ned Palacios 2021-04-19 19:58:30 +08:00 committed by GitHub
parent 9ec91f4d58
commit dde3189e66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3298,12 +3298,16 @@ pub fn (mut c Checker) array_init(mut array_init ast.ArrayInit) ast.Type {
if array_init.has_len { if array_init.has_len {
c.ensure_sumtype_array_has_default_value(array_init) c.ensure_sumtype_array_has_default_value(array_init)
} }
c.ensure_type_exists(array_init.elem_type, array_init.elem_type_pos) or {} if array_init.elem_type != 0 {
c.ensure_type_exists(array_init.elem_type, array_init.elem_type_pos) or {}
}
return array_init.typ return array_init.typ
} }
if array_init.is_fixed { if array_init.is_fixed {
c.ensure_sumtype_array_has_default_value(array_init) c.ensure_sumtype_array_has_default_value(array_init)
c.ensure_type_exists(array_init.elem_type, array_init.elem_type_pos) or {} if array_init.elem_type != 0 {
c.ensure_type_exists(array_init.elem_type, array_init.elem_type_pos) or {}
}
} }
// a = [] // a = []
if array_init.exprs.len == 0 { if array_init.exprs.len == 0 {