diff --git a/vlib/v/checker/fn.v b/vlib/v/checker/fn.v index ff67297f1a4de0..090e7cd3e9d713 100644 --- a/vlib/v/checker/fn.v +++ b/vlib/v/checker/fn.v @@ -759,7 +759,7 @@ fn (mut c Checker) call_expr(mut node ast.CallExpr) ast.Type { c.markused_option_or_result(!c.is_builtin_mod && c.mod != 'strings') } c.expected_or_type = old_expected_or_type - c.markused_call_expr(mut node) + c.markused_call_expr(left_type, mut node) if !c.inside_const && c.table.cur_fn != unsafe { nil } && !c.table.cur_fn.is_main && !c.table.cur_fn.is_test { // TODO: use just `if node.or_block.kind == .propagate_result && !c.table.cur_fn.return_type.has_flag(.result) {` after the deprecation for ?!Type diff --git a/vlib/v/checker/used_features.v b/vlib/v/checker/used_features.v index 4a73831c1f1d03..99704135b3e463 100644 --- a/vlib/v/checker/used_features.v +++ b/vlib/v/checker/used_features.v @@ -111,7 +111,7 @@ fn (mut c Checker) markused_comptimefor(mut node ast.ComptimeFor, unwrapped_expr } } -fn (mut c Checker) markused_call_expr(mut node ast.CallExpr) { +fn (mut c Checker) markused_call_expr(left_type ast.Type, mut node ast.CallExpr) { if !c.is_builtin_mod && c.mod == 'main' && !c.table.used_features.external_types { if node.is_method { if c.table.sym(node.left_type).is_builtin() { @@ -121,6 +121,10 @@ fn (mut c Checker) markused_call_expr(mut node ast.CallExpr) { c.table.used_features.external_types = true } } + if left_type != 0 && left_type.is_ptr() && !c.table.used_features.auto_str_ptr + && node.name == 'str' { + c.table.used_features.auto_str_ptr = true + } } fn (mut c Checker) markused_fn_call(mut node ast.CallExpr) { diff --git a/vlib/v/tests/skip_unused/option_ptr_print.run.out b/vlib/v/tests/skip_unused/option_ptr_print.run.out new file mode 100644 index 00000000000000..0d24c399178729 --- /dev/null +++ b/vlib/v/tests/skip_unused/option_ptr_print.run.out @@ -0,0 +1 @@ +[vlib/v/tests/skip_unused/option_ptr_print.vv:7] hrefs.str(): &