We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0a03856 commit 5d36a59Copy full SHA for 5d36a59
vlib/v/checker/checker.v
@@ -2985,7 +2985,8 @@ pub fn (mut c Checker) array_init(mut array_init ast.ArrayInit) table.Type {
2985
// }
2986
array_info := type_sym.array_info()
2987
array_init.elem_type = array_info.elem_type
2988
- return c.expected_type
+ // clear optional flag incase of: `fn opt_arr ?[]int { return [] }`
2989
+ return c.expected_type.clear_flag(.optional)
2990
}
2991
// [1,2,3]
2992
if array_init.exprs.len > 0 && array_init.elem_type == table.void_type {
0 commit comments