Skip to content

Commit e015200

Browse files
medvednikovclaude
andcommitted
Fix TCC Windows: avoid ternary dispatch, reduce stack pressure in checker
Replace the if-expression ternary for method_call/fn_call dispatch with an imperative if/else statement to avoid potential TCC codegen issues with ternaries involving large function calls. Also pass CallExpr by pointer in call_can_fill_optional_args and simplify final_left_kind computation to reduce stack frame size and avoid nested as_cast ternary. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4117fd9 commit e015200

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

vlib/v/checker/fn.v

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,10 +1053,11 @@ fn (mut c Checker) call_expr(mut node ast.CallExpr) ast.Type {
10531053
mut continue_check := true
10541054
node.left_type = left_type
10551055
// Now call `method_call` or `fn_call` for specific checks.
1056-
typ := if node.is_method {
1057-
c.method_call(mut node, mut continue_check)
1056+
mut typ := ast.void_type
1057+
if node.is_method {
1058+
typ = c.method_call(mut node, mut continue_check)
10581059
} else {
1059-
c.fn_call(mut node, mut continue_check)
1060+
typ = c.fn_call(mut node, mut continue_check)
10601061
}
10611062
if c.pref.is_vls {
10621063
c.autocomplete_for_fn_call_expr(node)
@@ -2565,10 +2566,9 @@ fn (mut c Checker) method_call(mut node ast.CallExpr, mut continue_check &bool)
25652566
unwrapped_left_type := c.unwrap_generic(left_type)
25662567
left_sym := c.table.sym(unwrapped_left_type)
25672568
final_left_sym := c.table.final_sym(unwrapped_left_type)
2568-
final_left_kind := if final_left_sym.kind == .generic_inst {
2569-
c.table.sym(ast.new_type((final_left_sym.info as ast.GenericInst).parent_idx)).kind
2570-
} else {
2571-
final_left_sym.kind
2569+
mut final_left_kind := final_left_sym.kind
2570+
if final_left_sym.kind == .generic_inst && final_left_sym.info is ast.GenericInst {
2571+
final_left_kind = c.table.sym(ast.new_type(final_left_sym.info.parent_idx)).kind
25722572
}
25732573

25742574
method_name := node.name
@@ -3492,7 +3492,7 @@ fn min_required_call_params(f &ast.Fn, is_method_call bool) int {
34923492
return required
34933493
}
34943494

3495-
fn call_can_fill_optional_args(node ast.CallExpr) bool {
3495+
fn call_can_fill_optional_args(node &ast.CallExpr) bool {
34963496
if node.args.any(it.expr is ast.ArrayDecompose) {
34973497
return false
34983498
}

0 commit comments

Comments
 (0)