checker: check array init with a void type value (#13106)
parent
86ba4517b1
commit
0ac450927c
|
@ -85,6 +85,9 @@ pub fn (mut c Checker) array_init(mut node ast.ArrayInit) ast.Type {
|
|||
// }
|
||||
for i, mut expr in node.exprs {
|
||||
typ := c.check_expr_opt_call(expr, c.expr(expr))
|
||||
if typ == ast.void_type {
|
||||
c.error('invalid void array element type', expr.position())
|
||||
}
|
||||
node.expr_types << typ
|
||||
// The first element's type
|
||||
if expecting_interface_array {
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
vlib/v/checker/tests/array_init_with_void_value_err.vv:4:8: error: invalid void array element type
|
||||
2 |
|
||||
3 | fn main() {
|
||||
4 | a := [yo()]
|
||||
| ~~~~
|
||||
5 | println(a)
|
||||
6 | }
|
|
@ -0,0 +1,8 @@
|
|||
module main
|
||||
|
||||
fn main() {
|
||||
a := [yo()]
|
||||
println(a)
|
||||
}
|
||||
|
||||
fn yo() {}
|
Loading…
Reference in New Issue