Skip to content

Commit 6aede65

Browse files
authored
markused,checker: fix hello world size after the introduction of builtin.closure in 2d87ac4 (#24989)
1 parent ace5df7 commit 6aede65

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

vlib/v/checker/checker.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2359,7 +2359,7 @@ fn (mut c Checker) stmt(mut node ast.Stmt) {
23592359
}
23602360
ast.Module {
23612361
c.mod = node.name
2362-
c.is_just_builtin_mod = node.name == 'builtin'
2362+
c.is_just_builtin_mod = node.name in ['builtin', 'builtin.closure']
23632363
c.is_builtin_mod = c.is_just_builtin_mod || node.name in ['os', 'strconv']
23642364
c.check_valid_snake_case(node.name, 'module name', node.pos)
23652365
}

vlib/v/checker/used_features.v

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,11 @@ fn (mut c Checker) markused_string_inter_lit(mut node ast.StringInterLiteral, ft
171171
}
172172

173173
fn (mut c Checker) markused_infixexpr(check bool) {
174-
if check {
175-
c.table.used_features.index = true
176-
c.table.used_features.arr_init = true
174+
if !check {
175+
return
177176
}
177+
c.table.used_features.index = true
178+
c.table.used_features.arr_init = true
178179
}
179180

180181
fn (mut c Checker) markused_array_method(check bool, method_name string) {

vlib/v/markused/markused.v

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,18 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a
166166
if !table.used_features.arr_init {
167167
table.used_features.arr_init = table.used_features.print_types.keys().any(table.type_to_str(it).contains('[]'))
168168
}
169-
if table.used_features.arr_init || table.used_features.comptime_for {
169+
if table.used_features.arr_init {
170+
core_fns << '__new_array'
171+
core_fns << 'new_array_from_c_array'
172+
core_fns << 'new_array_from_c_array_noscan'
173+
core_fns << '__new_array_with_default'
174+
core_fns << '__new_array_with_default_noscan'
175+
core_fns << '__new_array_with_multi_default'
176+
core_fns << '__new_array_with_multi_default_noscan'
177+
core_fns << '__new_array_with_array_default'
178+
core_fns << ref_array_idx_str + '.set'
179+
}
180+
if table.used_features.comptime_for {
170181
include_panic_deps = true
171182
core_fns << '__new_array'
172183
core_fns << 'new_array_from_c_array'

vlib/v/markused/walker.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ pub fn (mut w Walker) fn_decl(mut node ast.FnDecl) {
748748
w.mark_fn_ret_and_params(node.return_type, node.params)
749749
w.mark_fn_as_used(fkey)
750750
last_is_builtin_mod := w.is_builtin_mod
751-
w.is_builtin_mod = node.mod in ['builtin', 'os', 'strconv']
751+
w.is_builtin_mod = node.mod in ['builtin', 'os', 'strconv', 'builtin.closure']
752752
w.stmts(node.stmts)
753753
w.is_builtin_mod = last_is_builtin_mod
754754
w.defer_stmts(node.defer_stmts)

0 commit comments

Comments
 (0)