diff --git a/vlib/v/checker/struct.v b/vlib/v/checker/struct.v index 40f298be5d..49eaa9705c 100644 --- a/vlib/v/checker/struct.v +++ b/vlib/v/checker/struct.v @@ -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 { diff --git a/vlib/v/checker/tests/struct_field_with_default_err.out b/vlib/v/checker/tests/struct_field_with_default_err.out new file mode 100644 index 0000000000..572f0eac3c --- /dev/null +++ b/vlib/v/checker/tests/struct_field_with_default_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/struct_field_with_default_err.vv:2:22: error: unknown struct `T` + 1 | struct Dummy { + 2 | arbitrary_field T = T{} + | ~~~ + 3 | } + 4 | diff --git a/vlib/v/checker/tests/struct_field_with_default_err.vv b/vlib/v/checker/tests/struct_field_with_default_err.vv new file mode 100644 index 0000000000..5bd78a829d --- /dev/null +++ b/vlib/v/checker/tests/struct_field_with_default_err.vv @@ -0,0 +1,5 @@ +struct Dummy { + arbitrary_field T = T{} +} + +fn main() {}