From aee3c13f910a72d5d53dca452f1d3581eee0d8fe Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Sat, 6 Dec 2025 05:42:11 -0300 Subject: [PATCH] checker: fix used features tracking when printing pointer values (fix #25899) (#25901) --- vlib/v/checker/used_features.v | 6 +++++- vlib/v/tests/printing/print_charptr_test.v | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 vlib/v/tests/printing/print_charptr_test.v diff --git a/vlib/v/checker/used_features.v b/vlib/v/checker/used_features.v index 1b28a712f..615b7ee5d 100644 --- a/vlib/v/checker/used_features.v +++ b/vlib/v/checker/used_features.v @@ -143,11 +143,15 @@ fn (mut c Checker) markused_print_call(mut node ast.CallExpr) { if arg_typ.is_ptr() { c.table.used_features.auto_str_ptr = true } - if !c.table.used_features.auto_str_arr { + if !c.table.used_features.auto_str_arr || !c.table.used_features.auto_str_ptr { sym := c.table.final_sym(arg_typ) if sym.kind == .array { c.table.used_features.auto_str_arr = true } else if sym.info is ast.Struct { + if !c.table.used_features.auto_str_ptr { + c.table.used_features.auto_str_ptr = sym.info.fields.any(it.typ.is_ptr() + || it.typ.is_pointer()) + } c.table.used_features.auto_str_arr = sym.info.fields.any(c.table.final_sym(it.typ).kind == .array) } } diff --git a/vlib/v/tests/printing/print_charptr_test.v b/vlib/v/tests/printing/print_charptr_test.v new file mode 100644 index 000000000..744bfb011 --- /dev/null +++ b/vlib/v/tests/printing/print_charptr_test.v @@ -0,0 +1,9 @@ +struct Foo { + intv int + cptr charptr +} + +fn test_main() { + println(Foo{ intv: 42 }) + assert true +} -- 2.39.5