diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 564aa147c5..07d6c20f22 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -1456,12 +1456,16 @@ pub fn (mut f Fmt) call_expr(node ast.CallExpr) { f.or_expr(node.or_block) } else { f.write_language_prefix(node.language) - mut name := f.short_module(node.name) - f.mark_module_as_used(name) - if node.name in f.mod2alias { - name = f.mod2alias[node.name] + if node.left is ast.AnonFn as anon_fn { + f.fn_decl(anon_fn.decl) + } else { + mut name := f.short_module(node.name) + f.mark_module_as_used(name) + if node.name in f.mod2alias { + name = f.mod2alias[node.name] + } + f.write('$name') } - f.write('$name') if node.generic_type != 0 && node.generic_type != table.void_type { f.write('<') f.write(f.type_to_str(node.generic_type)) diff --git a/vlib/v/fmt/tests/anon_fn_call_keep.vv b/vlib/v/fmt/tests/anon_fn_call_keep.vv new file mode 100644 index 0000000000..e2661ba5a7 --- /dev/null +++ b/vlib/v/fmt/tests/anon_fn_call_keep.vv @@ -0,0 +1,7 @@ +fn main() { + fn () { + for { + println('Hello V!') + } + }() +}