mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: check if struct field type isn't type (#15359)
This commit is contained in:
parent
8d9af2e4a1
commit
d6b594c4e8
@ -84,6 +84,10 @@ pub fn (mut c Checker) struct_decl(mut node ast.StructDecl) {
|
|||||||
struct_sym.info.is_heap = true
|
struct_sym.info.is_heap = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if sym.kind == .multi_return {
|
||||||
|
c.error('cannot use multi return as field type', field.type_pos)
|
||||||
|
}
|
||||||
|
|
||||||
if field.has_default_expr {
|
if field.has_default_expr {
|
||||||
c.expected_type = field.typ
|
c.expected_type = field.typ
|
||||||
default_expr_type := c.expr(field.default_expr)
|
default_expr_type := c.expr(field.default_expr)
|
||||||
|
6
vlib/v/checker/tests/struct_multi_return_field_err.out
Normal file
6
vlib/v/checker/tests/struct_multi_return_field_err.out
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
vlib/v/checker/tests/struct_multi_return_field_err.vv:2:16: error: cannot use multi return as field type
|
||||||
|
1 | struct Tuple{
|
||||||
|
2 | data (int, int)
|
||||||
|
| ^
|
||||||
|
3 | }
|
||||||
|
4 |
|
8
vlib/v/checker/tests/struct_multi_return_field_err.vv
Normal file
8
vlib/v/checker/tests/struct_multi_return_field_err.vv
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
struct Tuple{
|
||||||
|
data (int, int)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
x := Tuple{}
|
||||||
|
println(x)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user