From 8ea42a69ca9412184aa59457d0dcbffbed982d68 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Sun, 13 Jul 2025 15:07:42 -0300 Subject: [PATCH] markused: fix mark for array init from sumtype (fix #24887) (#24889) --- vlib/v/checker/struct.v | 2 ++ vlib/v/tests/skip_unused/array_init_from_sumtype.run.out | 0 .../skip_unused/array_init_from_sumtype.skip_unused.run.out | 0 vlib/v/tests/skip_unused/array_init_from_sumtype.vv | 5 +++++ 4 files changed, 7 insertions(+) create mode 100644 vlib/v/tests/skip_unused/array_init_from_sumtype.run.out create mode 100644 vlib/v/tests/skip_unused/array_init_from_sumtype.skip_unused.run.out create mode 100644 vlib/v/tests/skip_unused/array_init_from_sumtype.vv diff --git a/vlib/v/checker/struct.v b/vlib/v/checker/struct.v index 94136501f5..0c298b97be 100644 --- a/vlib/v/checker/struct.v +++ b/vlib/v/checker/struct.v @@ -865,6 +865,8 @@ or use an explicit `unsafe{ a[..] }`, if you do not want a copy of the slice.', mut info := first_sym.info as ast.Struct c.check_uninitialized_struct_fields_and_embeds(node, first_sym, mut info, mut inited_fields) + } else if first_sym.kind == .array { + c.table.used_features.arr_init = true } } .none { diff --git a/vlib/v/tests/skip_unused/array_init_from_sumtype.run.out b/vlib/v/tests/skip_unused/array_init_from_sumtype.run.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/vlib/v/tests/skip_unused/array_init_from_sumtype.skip_unused.run.out b/vlib/v/tests/skip_unused/array_init_from_sumtype.skip_unused.run.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/vlib/v/tests/skip_unused/array_init_from_sumtype.vv b/vlib/v/tests/skip_unused/array_init_from_sumtype.vv new file mode 100644 index 0000000000..0fec86d9b1 --- /dev/null +++ b/vlib/v/tests/skip_unused/array_init_from_sumtype.vv @@ -0,0 +1,5 @@ +type Dict = []string | string + +fn main() { + _ := Dict{} +}