From bf9bb5c0ecd9382c3e0cb2a13e25c5732b739706 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Sat, 14 Dec 2024 08:02:46 -0300 Subject: [PATCH] fmt: fix shared receiver formatting (fix #23151) (#23153) --- vlib/v/fmt/fmt.v | 1 + vlib/v/fmt/tests/receiver_state_keep.vv | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 vlib/v/fmt/tests/receiver_state_keep.vv diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 4d5d59cce..32925545e 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -1721,6 +1721,7 @@ pub fn (mut f Fmt) fn_type_decl(node ast.FnTypeDecl) { if s.starts_with('&') { s = s[1..] } + s = s.trim_left('shared ') } is_last_arg := i == fn_info.params.len - 1 should_add_type := true || is_last_arg diff --git a/vlib/v/fmt/tests/receiver_state_keep.vv b/vlib/v/fmt/tests/receiver_state_keep.vv new file mode 100644 index 000000000..e16f9a5cb --- /dev/null +++ b/vlib/v/fmt/tests/receiver_state_keep.vv @@ -0,0 +1,5 @@ +module main + +struct State {} + +type Func = fn (shared state State) string -- 2.39.5