Skip to content

Commit

Permalink
builtin,checker: remove @[markused] from fn isnil(), set `c.table…
Browse files Browse the repository at this point in the history
….used_features.auto_str_ptr = true` instead (#23464)
  • Loading branch information
kbkpbot authored Jan 15, 2025
1 parent b1d2593 commit 6284c27
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion vlib/builtin/builtin.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module builtin

// isnil returns true if an object is nil (only for C objects).
@[inline; markused]
@[inline]
pub fn isnil(v voidptr) bool {
return v == 0
}
Expand Down
6 changes: 3 additions & 3 deletions vlib/v/checker/str.v
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ fn (mut c Checker) string_inter_lit(mut node ast.StringInterLiteral) ast.Type {
if c.pref.skip_unused && !c.is_builtin_mod {
if !c.table.sym(ftyp).has_method('str') {
c.table.used_features.auto_str = true
if ftyp.is_ptr() {
c.table.used_features.auto_str_ptr = true
}
} else {
c.table.used_features.print_types[ftyp.idx()] = true
}
if ftyp.is_ptr() {
c.table.used_features.auto_str_ptr = true
}
c.table.used_features.interpolation = true
}
c.fail_if_unreadable(expr, ftyp, 'interpolation object')
Expand Down
3 changes: 3 additions & 0 deletions vlib/v/tests/skip_unused/auto_string.run.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Hello Tom
C->&Tom
&1.24
3 changes: 3 additions & 0 deletions vlib/v/tests/skip_unused/auto_string.skip_unused.run.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Hello Tom
C->&Tom
&1.24
9 changes: 9 additions & 0 deletions vlib/v/tests/skip_unused/auto_string.vv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
a := 'Tom'
b := 'Hello ${a}'
c := &a
println(b)
println('C->${c}')

f := 1.24
f_p := &f
println('${f_p}')

0 comments on commit 6284c27

Please sign in to comment.