mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: fix fn returning ![]string
called in main (#16023)
This commit is contained in:
parent
0f229874a2
commit
89eb8358cf
@ -121,7 +121,7 @@ pub fn (mut c Checker) array_init(mut node ast.ArrayInit) ast.Type {
|
||||
c.expected_type.clear_flag(.shared_f).deref()
|
||||
} else {
|
||||
c.expected_type
|
||||
}.clear_flag(.optional)
|
||||
}.clear_flag(.optional).clear_flag(.result)
|
||||
}
|
||||
// [1,2,3]
|
||||
if node.exprs.len > 0 && node.elem_type == ast.void_type {
|
||||
|
13
vlib/v/tests/fn_return_opt_or_res_of_array_test.v
Normal file
13
vlib/v/tests/fn_return_opt_or_res_of_array_test.v
Normal file
@ -0,0 +1,13 @@
|
||||
fn foo_res() ![]string {
|
||||
return []
|
||||
}
|
||||
|
||||
fn foo_opt() ?[]string {
|
||||
return []
|
||||
}
|
||||
|
||||
fn test_fn_return_opt_or_res_of_array() {
|
||||
foo_res() or { panic(err) }
|
||||
foo_opt() or { panic(err) }
|
||||
assert true
|
||||
}
|
Loading…
Reference in New Issue
Block a user