From a33ffcedfbbfdd06414cfb4d887e338d71d8b4fc Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Mon, 22 May 2023 14:13:16 +0200 Subject: [PATCH] parser: remove attributes from anonymous structs (fixes #18233) --- vlib/v/fmt/tests/struct_keep.vv | 7 +++++++ vlib/v/parser/struct.v | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/vlib/v/fmt/tests/struct_keep.vv b/vlib/v/fmt/tests/struct_keep.vv index 68ed58bc3b..023afbb4ce 100644 --- a/vlib/v/fmt/tests/struct_keep.vv +++ b/vlib/v/fmt/tests/struct_keep.vv @@ -44,3 +44,10 @@ struct KeepMultiLineDefaultExprsIndent { text: 'M5' }] } + +[typedef] +struct C.some_t { + @type int + data struct {} + +} diff --git a/vlib/v/parser/struct.v b/vlib/v/parser/struct.v index 935451305d..a06765ecbc 100644 --- a/vlib/v/parser/struct.v +++ b/vlib/v/parser/struct.v @@ -387,7 +387,7 @@ fn (mut p Parser) struct_decl(is_anon bool) ast.StructDecl { module_pos: module_pos language: language is_union: is_union - attrs: attrs + attrs: if is_anon { []ast.Attr{} } else { attrs } // anon structs can't have attributes end_comments: end_comments generic_types: generic_types embeds: embeds