checker: don't panic on non-array decomposition (#7836)
parent
91a1a2877b
commit
529f46d808
|
@ -3049,7 +3049,8 @@ pub fn (mut c Checker) expr(node ast.Expr) table.Type {
|
||||||
typ := c.expr(node.expr)
|
typ := c.expr(node.expr)
|
||||||
type_sym := c.table.get_type_symbol(typ)
|
type_sym := c.table.get_type_symbol(typ)
|
||||||
if type_sym.kind != .array {
|
if type_sym.kind != .array {
|
||||||
c.error('expected array', node.pos)
|
c.error('decomposition can only be used on arrays', node.expr.position())
|
||||||
|
return table.void_type
|
||||||
}
|
}
|
||||||
array_info := type_sym.info as table.Array
|
array_info := type_sym.info as table.Array
|
||||||
elem_type := array_info.elem_type.set_flag(.variadic)
|
elem_type := array_info.elem_type.set_flag(.variadic)
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
vlib/v/checker/tests/decompose_type_err.vv:4:10: error: decomposition can only be used on arrays
|
||||||
|
2 |
|
||||||
|
3 | fn main() {
|
||||||
|
4 | varargs(123...)
|
||||||
|
| ~~~
|
||||||
|
5 | }
|
|
@ -0,0 +1,5 @@
|
||||||
|
fn varargs(a ...int) { println(a) }
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
varargs(123...)
|
||||||
|
}
|
Loading…
Reference in New Issue