diff --git a/vlib/v/fmt/struct.v b/vlib/v/fmt/struct.v index 4fe03efde1..9b47038e2f 100644 --- a/vlib/v/fmt/struct.v +++ b/vlib/v/fmt/struct.v @@ -118,7 +118,7 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl) { mut default_expr_aligns := []CommentAndExprAlignInfo{} mut field_types := []string{cap: node.fields.len} for i, field in node.fields { - mut ft := f.no_cur_mod(f.table.type_to_str(field.typ)) + mut ft := f.no_cur_mod(f.table.type_to_str_using_aliases(field.typ, f.mod2alias)) if !ft.contains('C.') && !ft.contains('JS.') && !ft.contains('fn (') && !ft.contains('chan') { ft = f.short_module(ft) } @@ -144,7 +144,7 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl) { } for embed in node.embeds { f.mark_types_import_as_used(embed.typ) - styp := f.table.type_to_str(embed.typ) + styp := f.table.type_to_str_using_aliases(embed.typ, f.mod2alias) f.writeln('\t$styp') } mut field_align_i := 0 diff --git a/vlib/v/fmt/tests/import_selective_expected.vv b/vlib/v/fmt/tests/import_selective_expected.vv index be27e374e2..03e503a4a7 100644 --- a/vlib/v/fmt/tests/import_selective_expected.vv +++ b/vlib/v/fmt/tests/import_selective_expected.vv @@ -7,7 +7,11 @@ import os { } struct App { - command Command + command &Command +} + +struct MyCommand { + Command } fn imaginary(im f64) Complex { diff --git a/vlib/v/fmt/tests/import_selective_input.vv b/vlib/v/fmt/tests/import_selective_input.vv index c2aff5caa6..bd7348db6f 100644 --- a/vlib/v/fmt/tests/import_selective_input.vv +++ b/vlib/v/fmt/tests/import_selective_input.vv @@ -8,7 +8,11 @@ import os { input, user_os, file_ext } struct App { - command Command + command &Command +} + +struct MyCommand { + Command } fn imaginary(im f64) Complex {