checker: avoid get_type_symbol panic inside array_init (#9800)

pull/9814/head
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
1 changed files with 6 additions and 2 deletions

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 {
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
}
if array_init.is_fixed {
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 = []
if array_init.exprs.len == 0 {