From ee745113bdbc6586eb848635a4cd155cb6e63c12 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Tue, 9 Jan 2024 10:24:34 -0300 Subject: [PATCH] vfmt: fix fmt for map value type using select import symbol (fix #20449) (#20451) --- vlib/v/fmt/fmt.v | 1 + vlib/v/fmt/tests/import_selective_map_keep.vv | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 vlib/v/fmt/tests/import_selective_map_keep.vv diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 022f530ee9..e37baad309 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -2629,6 +2629,7 @@ pub fn (mut f Fmt) map_init(node ast.MapInit) { sym := f.table.sym(node.typ) info := sym.info as ast.Map f.mark_types_import_as_used(info.key_type) + f.mark_types_import_as_used(info.value_type) f.write(f.table.type_to_str_using_aliases(node.typ, f.mod2alias)) } if node.pos.line_nr == node.pos.last_line { diff --git a/vlib/v/fmt/tests/import_selective_map_keep.vv b/vlib/v/fmt/tests/import_selective_map_keep.vv new file mode 100644 index 0000000000..f5ee64e21e --- /dev/null +++ b/vlib/v/fmt/tests/import_selective_map_keep.vv @@ -0,0 +1,5 @@ +import time { Duration } + +fn main() { + println(map[string]Duration{}) +}