From f9bb425f6c5c0ea4f5fa742dcf036e888f05c32f Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Sat, 7 Dec 2024 23:06:59 -0300 Subject: [PATCH] markused: fix `-skip-unused` for array.insert() (fix #23092) (#23097) --- vlib/v/markused/markused.v | 5 +---- vlib/v/tests/skip_unused/array_insert.run.out | 1 + vlib/v/tests/skip_unused/array_insert.skip_unused.run.out | 1 + vlib/v/tests/skip_unused/array_insert.vv | 3 +++ 4 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 vlib/v/tests/skip_unused/array_insert.run.out create mode 100644 vlib/v/tests/skip_unused/array_insert.skip_unused.run.out create mode 100644 vlib/v/tests/skip_unused/array_insert.vv diff --git a/vlib/v/markused/markused.v b/vlib/v/markused/markused.v index bfa6943a3..b7e417703 100644 --- a/vlib/v/markused/markused.v +++ b/vlib/v/markused/markused.v @@ -27,7 +27,6 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a ref_map_idx_str := '${int(ast.map_type.ref())}' ref_densearray_idx_str := '${int(table.find_type('DenseArray').ref())}' ref_array_idx_str := '${int(ast.array_type.ref())}' - is_gc_none := pref_.gc_mode == .no_gc mut include_panic_deps := false mut core_fns := [ @@ -138,9 +137,7 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a include_panic_deps = true } if table.used_features.arr_insert { - if is_gc_none { - core_fns << ref_array_idx_str + '.insert_many' - } + core_fns << ref_array_idx_str + '.insert_many' } if pref_.ccompiler_type != .tinyc && 'no_backtrace' !in pref_.compile_defines { // with backtrace on gcc/clang more code needs be generated diff --git a/vlib/v/tests/skip_unused/array_insert.run.out b/vlib/v/tests/skip_unused/array_insert.run.out new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/vlib/v/tests/skip_unused/array_insert.run.out @@ -0,0 +1 @@ +[] diff --git a/vlib/v/tests/skip_unused/array_insert.skip_unused.run.out b/vlib/v/tests/skip_unused/array_insert.skip_unused.run.out new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/vlib/v/tests/skip_unused/array_insert.skip_unused.run.out @@ -0,0 +1 @@ +[] diff --git a/vlib/v/tests/skip_unused/array_insert.vv b/vlib/v/tests/skip_unused/array_insert.vv new file mode 100644 index 000000000..c3bd5d350 --- /dev/null +++ b/vlib/v/tests/skip_unused/array_insert.vv @@ -0,0 +1,3 @@ +mut array := [][]int{} +array.insert(0, []) +println(array) -- 2.39.5