diff --git a/cmd/tools/vtest-cleancode.v b/cmd/tools/vtest-cleancode.v index 70bc667797..4e1225e330 100644 --- a/cmd/tools/vtest-cleancode.v +++ b/cmd/tools/vtest-cleancode.v @@ -35,7 +35,6 @@ const ( 'vlib/v/tests/interop_test.v', /* bad comment formatting */ 'vlib/v/tests/string_interpolation_test.v' /* TODO byteptr: &byte.str() behaves differently than byteptr.str() */, 'vlib/v/gen/js/tests/js.v', /* local `hello` fn, gets replaced with module `hello` aliased as `hl` */ - 'vlib/v/tests/map_enum_keys_test.v' /* temporary here, till PR#10235 is merged */, 'examples/c_interop_wkhtmltopdf.v' /* &charptr --> &&char */, ] vfmt_verify_list = [ diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 028621c2e5..4a02131103 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -2078,7 +2078,9 @@ pub fn (mut f Fmt) lock_expr(node ast.LockExpr) { pub fn (mut f Fmt) map_init(node ast.MapInit) { if node.keys.len == 0 { if node.typ > ast.void_type { - f.mark_types_import_as_used(node.typ) + sym := f.table.get_type_symbol(node.typ) + info := sym.info as ast.Map + f.mark_types_import_as_used(info.key_type) f.write(f.table.type_to_str_using_aliases(node.typ, f.mod2alias)) } else { // m = map{} diff --git a/vlib/v/fmt/tests/import_selective_keep.vv b/vlib/v/fmt/tests/import_selective_keep.vv index 032e4bca5f..ac1ba9643e 100644 --- a/vlib/v/fmt/tests/import_selective_keep.vv +++ b/vlib/v/fmt/tests/import_selective_keep.vv @@ -1,4 +1,9 @@ import math.complex { Complex } +import gg { MouseButton } + +fn keep_imported_enum_map_key() { + bm := map[MouseButton]string{} +} fn main() { assert *(&f64(&byte(&num) + __offsetof(Complex, re))) == 1.0