From b97a04abd9033b973c2396df9cd22a976438e61e Mon Sep 17 00:00:00 2001 From: yuyi Date: Wed, 25 May 2022 20:17:30 +0800 Subject: [PATCH] fmt: fix fmt of Ok<[]Token>{[]} (#14522) --- vlib/v/fmt/fmt.v | 2 +- vlib/v/fmt/tests/generic_struct_init_keep.vv | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 vlib/v/fmt/tests/generic_struct_init_keep.vv diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index f10e93b8f7..fc91352e42 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -249,7 +249,7 @@ pub fn (mut f Fmt) short_module(name string) string { } } if aname == '' { - return symname + return '$tprefix$symname' } return '$tprefix${aname}.$symname' } diff --git a/vlib/v/fmt/tests/generic_struct_init_keep.vv b/vlib/v/fmt/tests/generic_struct_init_keep.vv new file mode 100644 index 0000000000..8dcccf0074 --- /dev/null +++ b/vlib/v/fmt/tests/generic_struct_init_keep.vv @@ -0,0 +1,9 @@ +module x + +struct Ok { + foo []T +} + +fn test_fmt() { + r := Ok<[]Token>{[]} +}