diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 549e006a7d..c4c7b30e73 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -1502,12 +1502,12 @@ pub fn (mut f Fmt) alias_type_decl(node ast.AliasTypeDecl) { if node.is_pub { f.write('pub ') } - // aliases of anon struct: `type foo = struct {}` + // aliases of anon struct: `type Foo = struct {}` sym := f.table.sym(node.parent_type) if sym.info is ast.Struct { if sym.info.is_anon { f.write('type ${node.name} = ') - f.write_anon_struct_field_decl(node.parent_type, ast.StructDecl{ fields: sym.info.fields }) + f.struct_decl(ast.StructDecl{ fields: sym.info.fields }, true) f.comments(node.comments, has_nl: false) f.mark_types_import_as_used(node.parent_type) return diff --git a/vlib/v/fmt/tests/type_decl_with_anon_struct_keep.vv b/vlib/v/fmt/tests/type_decl_with_anon_struct_keep.vv index f77285bb16..14dc06c5f1 100644 --- a/vlib/v/fmt/tests/type_decl_with_anon_struct_keep.vv +++ b/vlib/v/fmt/tests/type_decl_with_anon_struct_keep.vv @@ -1,9 +1,9 @@ pub type Unit1 = struct {} pub type Unit2 = struct { - name string - age int - } + name string + age int +} pub const unit1 = Unit1{}