Skip to content

Commit 66b75c2

Browse files
authored
markused: fix const as fn mark as used (fix #25888) (#25895)
1 parent b01273e commit 66b75c2

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

vlib/v/markused/walker.v

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,9 @@ fn (mut w Walker) expr(node_ ast.Expr) {
454454
}
455455
ast.CallExpr {
456456
w.call_expr(mut node)
457-
if node.name == 'json.decode' {
457+
if node.is_fn_a_const {
458+
w.mark_const_as_used(node.name)
459+
} else if node.name == 'json.decode' {
458460
w.mark_by_type((node.args[0].expr as ast.TypeNode).typ)
459461
} else if node.name == 'json.encode' && node.args[0].typ != 0 {
460462
sym := w.table.final_sym(node.args[0].typ)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import my_utils
2+
3+
fn test_main() {
4+
v := f64(1.0 / 8)
5+
assert my_utils.my_round(v, 2) == '0.13'
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module my_utils
2+
3+
import strconv
4+
5+
pub const my_round = strconv.f64_to_str_lnd1

0 commit comments

Comments
 (0)