Skip to content

Commit 38bfc48

Browse files
authored
markused: fix option array element (fix #23089) (#25179)
1 parent 1ba4512 commit 38bfc48

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

vlib/v/markused/walker.v

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,9 @@ fn (mut w Walker) expr(node_ ast.Expr) {
432432
if !w.uses_array && !w.is_direct_array_access {
433433
w.uses_array = true
434434
}
435+
if node.elem_type.has_flag(.option) {
436+
w.used_option++
437+
}
435438
}
436439
ast.Assoc {
437440
w.exprs(node.exprs)

vlib/v/tests/skip_unused/option_array_init.run.out

Whitespace-only changes.

vlib/v/tests/skip_unused/option_array_init.skip_unused.run.out

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fn main() {
2+
mut a := []?u32{len: 0xFF}
3+
if c := a[0] {
4+
println('c: ${c} not none!')
5+
}
6+
}

0 commit comments

Comments
 (0)