mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: check struct field with default expression (#15151)
This commit is contained in:
parent
49228e1acd
commit
7029e39088
@ -320,7 +320,7 @@ pub fn (mut c Checker) struct_init(mut node ast.StructInit) ast.Type {
|
||||
}
|
||||
if type_sym.name.len == 1 && !isnil(c.table.cur_fn) && c.table.cur_fn.generic_names.len == 0 {
|
||||
c.error('unknown struct `$type_sym.name`', node.pos)
|
||||
return 0
|
||||
return ast.void_type
|
||||
}
|
||||
match type_sym.kind {
|
||||
.placeholder {
|
||||
|
6
vlib/v/checker/tests/struct_field_with_default_err.out
Normal file
6
vlib/v/checker/tests/struct_field_with_default_err.out
Normal file
@ -0,0 +1,6 @@
|
||||
vlib/v/checker/tests/struct_field_with_default_err.vv:2:22: error: unknown struct `T`
|
||||
1 | struct Dummy<T> {
|
||||
2 | arbitrary_field T = T{}
|
||||
| ~~~
|
||||
3 | }
|
||||
4 |
|
5
vlib/v/checker/tests/struct_field_with_default_err.vv
Normal file
5
vlib/v/checker/tests/struct_field_with_default_err.vv
Normal file
@ -0,0 +1,5 @@
|
||||
struct Dummy<T> {
|
||||
arbitrary_field T = T{}
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user