diff --git a/vlib/v/parser/struct.v b/vlib/v/parser/struct.v index 2c06928406b7c3..ed2f1fb8694080 100644 --- a/vlib/v/parser/struct.v +++ b/vlib/v/parser/struct.v @@ -241,6 +241,7 @@ fn (mut p Parser) struct_decl(is_anon bool) ast.StructDecl { start_type_pos := p.tok.pos() if field_name == p.tok.lit && p.tok.lit[0].is_capital() { p.error('field-name `${p.tok.lit}` cannot be same as the type-name') + return ast.StructDecl{} } typ = p.parse_type() type_pos = start_type_pos.extend(p.prev_tok.pos())