From 0522f2f416f020ba0152794b6128e0337d6ccbe2 Mon Sep 17 00:00:00 2001 From: yuyi Date: Tue, 9 Jul 2024 17:51:16 +0800 Subject: [PATCH] fix fmt of optional reference --- vlib/v/ast/str.v | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vlib/v/ast/str.v b/vlib/v/ast/str.v index 439b8b72d309a6..e47f81fbe24c81 100644 --- a/vlib/v/ast/str.v +++ b/vlib/v/ast/str.v @@ -203,9 +203,12 @@ fn (t &Table) stringify_fn_after_name(node &FnDecl, mut f strings.Builder, cur_m } else { mut s := t.type_to_str(param.typ.clear_flag(.shared_f)) if param.is_mut { - if (!param_sym.is_number() && param_sym.kind != .bool) + if s.starts_with('&') && ((!param_sym.is_number() && param_sym.kind != .bool) || node.language != .v - || (param.typ.is_ptr() && t.sym(param.typ).kind == .struct_) { + || (param.typ.is_ptr() && t.sym(param.typ).kind == .struct_)) { + s = s[1..] + } else if param.typ.is_ptr() && t.sym(param.typ).kind == .struct_ + && !s.contains('[') { s = t.type_to_str(param.typ.clear_flag(.shared_f).deref()) } }