mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: ensure array init matches the array's type (#7118)
This commit is contained in:
parent
215a76a715
commit
6a47deb3f8
@ -2317,7 +2317,10 @@ pub fn (mut c Checker) array_init(mut array_init ast.ArrayInit) table.Type {
|
||||
}
|
||||
sym := c.table.get_type_symbol(array_init.elem_type)
|
||||
if array_init.has_default {
|
||||
c.expr(array_init.default_expr)
|
||||
default_typ := c.expr(array_init.default_expr)
|
||||
c.check_expected(default_typ, array_init.elem_type) or {
|
||||
c.error(err, array_init.default_expr.position())
|
||||
}
|
||||
}
|
||||
if sym.kind == .sum_type {
|
||||
if array_init.has_len && !array_init.has_default {
|
||||
|
Loading…
Reference in New Issue
Block a user