From 4117a469f4112670b820c893b43c04c82a4d90de Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 14 Apr 2026 21:53:50 +0300 Subject: [PATCH] all: fix auto_string.vv test and restore proper &string interpolation logic Restore the full get_string_inter_default_fmt implementation that checks for Ident/Var/is_ptr/!is_arg before applying pointer format for &string and &bool. The simplified version broke the auto_string.vv skip_unused test by unconditionally formatting all &string as pointer addresses. --- vlib/v/checker/str.v | 17 ++++++++++++++--- vlib/v/tests/skip_unused/auto_string.vv | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/vlib/v/checker/str.v b/vlib/v/checker/str.v index 10d37a9ec..ab46fcea7 100644 --- a/vlib/v/checker/str.v +++ b/vlib/v/checker/str.v @@ -41,9 +41,20 @@ fn (mut c Checker) get_default_fmt(ftyp ast.Type, typ ast.Type) u8 { } } -fn (mut c Checker) get_string_inter_default_fmt(_ ast.Expr, ftyp ast.Type, typ ast.Type) u8 { - if ftyp.nr_muls() > 0 && ftyp.idx() in [ast.string_type_idx, ast.bool_type_idx] { - return `p` +fn (mut c Checker) get_string_inter_default_fmt(expr ast.Expr, ftyp ast.Type, typ ast.Type) u8 { + if expr is ast.Ident { + if expr.obj is ast.Var { + obj := expr.obj + if obj.typ.is_ptr() && !obj.is_arg { + pointee_typ := obj.typ.deref() + if c.table.final_sym(pointee_typ).kind != .enum { + final_pointee_typ := c.table.final_type(pointee_typ) + if final_pointee_typ in [ast.string_type, ast.bool_type] { + return `p` + } + } + } + } } return c.get_default_fmt(ftyp, typ) } diff --git a/vlib/v/tests/skip_unused/auto_string.vv b/vlib/v/tests/skip_unused/auto_string.vv index cf10a93c7..3ff8d38a7 100644 --- a/vlib/v/tests/skip_unused/auto_string.vv +++ b/vlib/v/tests/skip_unused/auto_string.vv @@ -2,7 +2,7 @@ a := 'Tom' b := 'Hello ${a}' c := &a println(b) -println('C->${c}') +println('C->${c:s}') f := 1.24 f_p := &f -- 2.39.5