mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: fix returning [] from fn which retuns optional array
This commit is contained in:
parent
0a03856c83
commit
5d36a59dd8
@ -2985,7 +2985,8 @@ pub fn (mut c Checker) array_init(mut array_init ast.ArrayInit) table.Type {
|
|||||||
// }
|
// }
|
||||||
array_info := type_sym.array_info()
|
array_info := type_sym.array_info()
|
||||||
array_init.elem_type = array_info.elem_type
|
array_init.elem_type = array_info.elem_type
|
||||||
return c.expected_type
|
// clear optional flag incase of: `fn opt_arr ?[]int { return [] }`
|
||||||
|
return c.expected_type.clear_flag(.optional)
|
||||||
}
|
}
|
||||||
// [1,2,3]
|
// [1,2,3]
|
||||||
if array_init.exprs.len > 0 && array_init.elem_type == table.void_type {
|
if array_init.exprs.len > 0 && array_init.elem_type == table.void_type {
|
||||||
|
Loading…
Reference in New Issue
Block a user