diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index ee1f40b95f..3bd626ad6b 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -2359,7 +2359,7 @@ fn (mut c Checker) stmt(mut node ast.Stmt) { } ast.Module { c.mod = node.name - c.is_just_builtin_mod = node.name == 'builtin' + c.is_just_builtin_mod = node.name in ['builtin', 'builtin.closure'] c.is_builtin_mod = c.is_just_builtin_mod || node.name in ['os', 'strconv'] c.check_valid_snake_case(node.name, 'module name', node.pos) } diff --git a/vlib/v/checker/used_features.v b/vlib/v/checker/used_features.v index d873da9d73..311e67ef06 100644 --- a/vlib/v/checker/used_features.v +++ b/vlib/v/checker/used_features.v @@ -171,10 +171,11 @@ fn (mut c Checker) markused_string_inter_lit(mut node ast.StringInterLiteral, ft } fn (mut c Checker) markused_infixexpr(check bool) { - if check { - c.table.used_features.index = true - c.table.used_features.arr_init = true + if !check { + return } + c.table.used_features.index = true + c.table.used_features.arr_init = true } fn (mut c Checker) markused_array_method(check bool, method_name string) { diff --git a/vlib/v/markused/markused.v b/vlib/v/markused/markused.v index 0645beba4c..e696673cc2 100644 --- a/vlib/v/markused/markused.v +++ b/vlib/v/markused/markused.v @@ -166,7 +166,18 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a if !table.used_features.arr_init { table.used_features.arr_init = table.used_features.print_types.keys().any(table.type_to_str(it).contains('[]')) } - if table.used_features.arr_init || table.used_features.comptime_for { + if table.used_features.arr_init { + core_fns << '__new_array' + core_fns << 'new_array_from_c_array' + core_fns << 'new_array_from_c_array_noscan' + core_fns << '__new_array_with_default' + core_fns << '__new_array_with_default_noscan' + core_fns << '__new_array_with_multi_default' + core_fns << '__new_array_with_multi_default_noscan' + core_fns << '__new_array_with_array_default' + core_fns << ref_array_idx_str + '.set' + } + if table.used_features.comptime_for { include_panic_deps = true core_fns << '__new_array' core_fns << 'new_array_from_c_array' diff --git a/vlib/v/markused/walker.v b/vlib/v/markused/walker.v index 935ae29a97..ac6dbac153 100644 --- a/vlib/v/markused/walker.v +++ b/vlib/v/markused/walker.v @@ -748,7 +748,7 @@ pub fn (mut w Walker) fn_decl(mut node ast.FnDecl) { w.mark_fn_ret_and_params(node.return_type, node.params) w.mark_fn_as_used(fkey) last_is_builtin_mod := w.is_builtin_mod - w.is_builtin_mod = node.mod in ['builtin', 'os', 'strconv'] + w.is_builtin_mod = node.mod in ['builtin', 'os', 'strconv', 'builtin.closure'] w.stmts(node.stmts) w.is_builtin_mod = last_is_builtin_mod w.defer_stmts(node.defer_stmts)