From 637ce20a2691503029a7b2ca570807776dd36e30 Mon Sep 17 00:00:00 2001 From: yuyi Date: Fri, 13 Sep 2024 14:59:41 +0800 Subject: [PATCH] fmt: fix import selective with interface implements (fix formatting part of #22200) (#22209) --- vlib/v/fmt/struct.v | 1 + .../fmt/tests/import_selective_with_implements_keep.vv | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 vlib/v/fmt/tests/import_selective_with_implements_keep.vv diff --git a/vlib/v/fmt/struct.v b/vlib/v/fmt/struct.v index 0c85e63b4..bc4cfb165 100644 --- a/vlib/v/fmt/struct.v +++ b/vlib/v/fmt/struct.v @@ -38,6 +38,7 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl, is_anon bool) { if i < node.implements_types.len - 1 { f.write(', ') } + f.mark_types_import_as_used(t) } } // Calculate the alignments first diff --git a/vlib/v/fmt/tests/import_selective_with_implements_keep.vv b/vlib/v/fmt/tests/import_selective_with_implements_keep.vv new file mode 100644 index 000000000..8a925d27c --- /dev/null +++ b/vlib/v/fmt/tests/import_selective_with_implements_keep.vv @@ -0,0 +1,10 @@ +import v.ast.walker { Visitor } +import v.ast { Node } + +struct Walker implements Visitor { + aaa string +} + +fn (mut n Walker) visit(node &Node) ! { + panic('not implemented') +} -- 2.39.5