Skip to content

Commit 8314639

Browse files
committed
fmt
1 parent 1fd17db commit 8314639

11 files changed

Lines changed: 80 additions & 76 deletions

File tree

‎vlib/v2/builder/builder.v‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,8 @@ fn sanitize_staged_c_source(c_source string) string {
9696
// The if-guard on the result also needs restructuring for correct C semantics.
9797
source = source.replace('(void (*)(mbedtls__SSLListener*, string))get_cert_callback',
9898
'((_result_mbedtls__SSLCertsptr (*)(mbedtls__SSLListener*, string))get_cert_callback)')
99-
source = source.replace(
100-
'if ((((_result_mbedtls__SSLCertsptr (*)(mbedtls__SSLListener*, string))get_cert_callback))(l, host)) {\n\t\t_result_mbedtls__SSLCertsptr certs = (((_result_mbedtls__SSLCertsptr (*)(mbedtls__SSLListener*, string))get_cert_callback))(l, host);\n\t\treturn mbedtls_ssl_set_hs_own_cert(ssl, &certs.client_cert, &certs.client_key);',
101-
'{ _result_mbedtls__SSLCertsptr _cert_res = (((_result_mbedtls__SSLCertsptr (*)(mbedtls__SSLListener*, string))get_cert_callback))(l, host);\n\tif (!_cert_res.is_error) {\n\t\tmbedtls__SSLCerts* certs = *(mbedtls__SSLCerts**)(((u8*)(&_cert_res.err)) + sizeof(IError));\n\t\treturn mbedtls_ssl_set_hs_own_cert(ssl, &certs->client_cert, &certs->client_key);'
102-
)
99+
source = source.replace('if ((((_result_mbedtls__SSLCertsptr (*)(mbedtls__SSLListener*, string))get_cert_callback))(l, host)) {\n\t\t_result_mbedtls__SSLCertsptr certs = (((_result_mbedtls__SSLCertsptr (*)(mbedtls__SSLListener*, string))get_cert_callback))(l, host);\n\t\treturn mbedtls_ssl_set_hs_own_cert(ssl, &certs.client_cert, &certs.client_key);',
100+
'{ _result_mbedtls__SSLCertsptr _cert_res = (((_result_mbedtls__SSLCertsptr (*)(mbedtls__SSLListener*, string))get_cert_callback))(l, host);\n\tif (!_cert_res.is_error) {\n\t\tmbedtls__SSLCerts* certs = *(mbedtls__SSLCerts**)(((u8*)(&_cert_res.err)) + sizeof(IError));\n\t\treturn mbedtls_ssl_set_hs_own_cert(ssl, &certs->client_cert, &certs->client_key);')
103101
// UdpSocket result pointer auto-deref: .sock field is UdpSocket (value), result contains &UdpSocket.
104102
source = source.replace('.sock = (*(net__UdpSocket**)(((u8*)(&_or_t54.err)) + sizeof(IError)))',
105103
'.sock = *(*(net__UdpSocket**)(((u8*)(&_or_t54.err)) + sizeof(IError)))')
@@ -109,7 +107,8 @@ fn sanitize_staged_c_source(c_source string) string {
109107
// ObjC .m file references g_vui_webview_cookie_val as a global variable.
110108
// The cleanc backend uses DarwinWebViewState singleton instead.
111109
// Add the global so the .m file can link against it.
112-
if !source.contains('g_vui_webview_cookie_val') && source.contains('webview__darwin_webview_state') {
110+
if !source.contains('g_vui_webview_cookie_val')
111+
&& source.contains('webview__darwin_webview_state') {
113112
source = source + '\nstring g_vui_webview_cookie_val;\n'
114113
}
115114
return source
@@ -1370,9 +1369,9 @@ fn normalize_flag_value_for_file(flag_value string, file_path string) string {
13701369
i++
13711370
continue
13721371
}
1373-
if tok.contains('@VMODROOT') || tok.contains('@VEXEROOT')
1374-
|| tok.starts_with('./') || tok.starts_with('../')
1375-
|| tok.ends_with('.c') || tok.ends_with('.m') || tok.ends_with('.o') {
1372+
if tok.contains('@VMODROOT') || tok.contains('@VEXEROOT') || tok.starts_with('./')
1373+
|| tok.starts_with('../') || tok.ends_with('.c') || tok.ends_with('.m')
1374+
|| tok.ends_with('.o') {
13761375
out << resolve_flag_path(tok, file_dir, vmod_root)
13771376
i++
13781377
continue
@@ -1506,7 +1505,8 @@ fn (b &Builder) collect_cflags_from_sources() string {
15061505
continue
15071506
}
15081507
// Replace @VEXEROOT before parsing so path normalization sees absolute paths
1509-
resolved_line := line.replace('@VEXEROOT', b.pref.vroot).replace('VEXEROOT', b.pref.vroot)
1508+
resolved_line := line.replace('@VEXEROOT', b.pref.vroot).replace('VEXEROOT',
1509+
b.pref.vroot)
15101510
mut flag := parse_flag_directive_line(resolved_line, scan_path) or { continue }
15111511
// Build include flags from already-collected flags for compiling missing .o files
15121512
mut inc_flags := []string{}

‎vlib/v2/gen/cleanc/array.v‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,7 @@ fn (mut g Gen) infer_array_elem_type_from_expr(arr_expr ast.Expr) string {
409409
}
410410
// __new_array_with_default_noscan(len, cap, sizeof(T), default)
411411
// arg[2] is sizeof(T) — extract T from the KeywordOperator
412-
if fn_name in ['__new_array_with_default_noscan', '__new_array_with_default',
413-
'builtin____new_array_with_default_noscan', 'builtin____new_array_with_default']
412+
if fn_name in ['__new_array_with_default_noscan', '__new_array_with_default', 'builtin____new_array_with_default_noscan', 'builtin____new_array_with_default']
414413
&& arr_expr.args.len >= 3 {
415414
sizeof_arg := arr_expr.args[2]
416415
if sizeof_arg is ast.KeywordOperator && sizeof_arg.op == .key_sizeof

‎vlib/v2/gen/cleanc/cleanc.v‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,23 @@ mut:
8585
called_fn_names map[string]bool
8686
generic_spec_index map[string][]string // fn_name → matching keys in env.generic_types
8787
anon_fn_defs []string // lifted anonymous function definitions
88-
pass5_start_pos int // position in sb where pass 5 starts
89-
deferred_m_includes []string // Objective-C .m file #include lines deferred until after type definitions
90-
spawned_fns map[string]bool // spawn wrapper names already emitted
91-
spawn_wrapper_defs []string // spawn wrapper struct + function definitions
92-
emitted_trampolines map[string]bool // bound method trampoline names already emitted
93-
trampoline_defs []string // bound method trampoline definitions
88+
pass5_start_pos int // position in sb where pass 5 starts
89+
deferred_m_includes []string // Objective-C .m file #include lines deferred until after type definitions
90+
spawned_fns map[string]bool // spawn wrapper names already emitted
91+
spawn_wrapper_defs []string // spawn wrapper struct + function definitions
92+
emitted_trampolines map[string]bool // bound method trampoline names already emitted
93+
trampoline_defs []string // bound method trampoline definitions
9494
// @[live] hot code reloading
95-
live_fns []LiveFnInfo // @[live] functions detected during code generation
96-
live_source_file string // source file containing @[live] functions
97-
test_fn_names []string // test function names collected in Pass 4
98-
has_main bool // whether a main() function was found in Pass 4
99-
fn_owner_file map[string]int // fn_key -> first file index (for parallel dedup)
95+
live_fns []LiveFnInfo // @[live] functions detected during code generation
96+
live_source_file string // source file containing @[live] functions
97+
test_fn_names []string // test function names collected in Pass 4
98+
has_main bool // whether a main() function was found in Pass 4
99+
fn_owner_file map[string]int // fn_key -> first file index (for parallel dedup)
100100
generic_struct_bindings map[string]map[string]types.Type // struct_name -> {T: concrete_type}
101-
c_file_fn_keys map[string]bool // fn_key -> emitted from a .c.v file, so plain .v fallback should be skipped
102-
typedef_c_types map[string]bool // C struct names with @[typedef] attribute (emit without 'struct' prefix)
103-
blocked_fn_keys map[string]bool // worker-only fn keys reserved to other pass5 chunks
104-
cached_vhash string // cached git short hash for @VHASH/@VCURRENTHASH
101+
c_file_fn_keys map[string]bool // fn_key -> emitted from a .c.v file, so plain .v fallback should be skipped
102+
typedef_c_types map[string]bool // C struct names with @[typedef] attribute (emit without 'struct' prefix)
103+
blocked_fn_keys map[string]bool // worker-only fn keys reserved to other pass5 chunks
104+
cached_vhash string // cached git short hash for @VHASH/@VCURRENTHASH
105105
}
106106

107107
struct LiveFnInfo {

‎vlib/v2/gen/cleanc/consts_and_globals.v‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -688,11 +688,9 @@ fn (mut g Gen) gen_const_decl(node ast.ConstDecl) {
688688
// their address (&) or mutating them in-place has no effect.
689689
if typ != '' && typ != 'void' && typ != 'int' && is_c_struct_init(field.value) {
690690
g.sb.writeln('${typ} ${name} = {0};')
691-
} else if typ != '' && typ != 'void' && typ != 'int'
692-
&& !typ.starts_with('Array_') && !typ.starts_with('Map_')
693-
&& !typ.contains('*') && !typ.contains('(')
694-
&& field.value is ast.InitExpr
695-
&& (field.value as ast.InitExpr).fields.len == 0 {
691+
} else if typ != '' && typ != 'void' && typ != 'int' && !typ.starts_with('Array_')
692+
&& !typ.starts_with('Map_') && !typ.contains('*') && !typ.contains('(')
693+
&& field.value is ast.InitExpr && (field.value as ast.InitExpr).fields.len == 0 {
696694
// Zero-initialized struct const — emit as global variable.
697695
g.sb.writeln('${typ} ${name} = {0};')
698696
} else {

‎vlib/v2/gen/cleanc/fn.v‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,8 +1237,7 @@ fn (mut g Gen) gen_fn_decl_ptr(node &ast.FnDecl) {
12371237
// eventbus module: all generic struct methods use T = string.
12381238
// For subscribe_method/unsubscribe_method, the specialized name (_string suffix) is used.
12391239
// For other methods (publish, has_subscriber, etc.), keep the base name but resolve T = string.
1240-
if g.cur_module == 'eventbus' && node.is_method
1241-
&& receiver_generic_param_names(*node).len > 0 {
1240+
if g.cur_module == 'eventbus' && node.is_method && receiver_generic_param_names(*node).len > 0 {
12421241
prev_generic_types := g.active_generic_types.clone()
12431242
string_types := {
12441243
'T': types.Type(types.string_)
@@ -2000,7 +1999,8 @@ fn (mut g Gen) expr_is_pointer(arg ast.Expr) bool {
20001999
if arg.name in g.cur_fn_mut_params {
20012000
return true
20022001
}
2003-
return local_type.ends_with('*') || local_type in ['voidptr', 'charptr', 'byteptr', 'chan']
2002+
return local_type.ends_with('*')
2003+
|| local_type in ['voidptr', 'charptr', 'byteptr', 'chan']
20042004
}
20052005
if arg.name in g.cur_fn_mut_params {
20062006
return true
@@ -3029,8 +3029,8 @@ fn (mut g Gen) gen_interface_call_arg(expected_type string, arg ast.Expr) {
30293029
arg_base := arg_type.trim_right('*')
30303030
if g.is_interface_type(expected_base) && arg_base != '' && arg_base != 'int'
30313031
&& arg_base != expected_base && !g.is_interface_type(arg_base)
3032-
&& !arg_base.starts_with('Array_') && arg_base != 'array'
3033-
&& !arg_base.starts_with('Map_') && arg_base != 'map' {
3032+
&& !arg_base.starts_with('Array_') && arg_base != 'array' && !arg_base.starts_with('Map_')
3033+
&& arg_base != 'map' {
30343034
if expected_type.ends_with('*') {
30353035
if g.gen_heap_interface_cast(expected_base, base_arg) {
30363036
return
@@ -3390,7 +3390,8 @@ fn (mut g Gen) call_expr(lhs ast.Expr, args []ast.Expr) {
33903390
param_idx := i - param_offset
33913391
if method := g.interface_method_by_name(base_receiver, method_name) {
33923392
if param_idx >= 0 && param_idx < method.param_types.len {
3393-
g.gen_interface_call_arg(method.param_types[param_idx], arg)
3393+
g.gen_interface_call_arg(method.param_types[param_idx],
3394+
arg)
33943395
} else {
33953396
g.expr(arg)
33963397
}
@@ -3526,9 +3527,7 @@ fn (mut g Gen) call_expr(lhs ast.Expr, args []ast.Expr) {
35263527
g.sb.write_string(')')
35273528
return
35283529
}
3529-
if emb := g.resolve_method_on_embedded_receiver(base_receiver,
3530-
method_name)
3531-
{
3530+
if emb := g.resolve_method_on_embedded_receiver(base_receiver, method_name) {
35323531
ptr_params := g.fn_param_is_ptr[emb.method_c_name] or { []bool{} }
35333532
receiver_as_ptr := ptr_params.len > 0 && ptr_params[0]
35343533
g.sb.write_string('${emb.method_c_name}(')
@@ -4070,8 +4069,7 @@ fn (mut g Gen) call_expr(lhs ast.Expr, args []ast.Expr) {
40704069
continue
40714070
}
40724071
// For fn-pointer calls, auto-deref mut params when the fn type expects by-value
4073-
if fnptr_param_is_ptr.len > 0 && i < fnptr_param_is_ptr.len
4074-
&& !fnptr_param_is_ptr[i] {
4072+
if fnptr_param_is_ptr.len > 0 && i < fnptr_param_is_ptr.len && !fnptr_param_is_ptr[i] {
40754073
arg := call_args[i]
40764074
mut arg_ident_name := ''
40774075
if arg is ast.ModifierExpr {

‎vlib/v2/gen/cleanc/interface.v‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,8 @@ fn (mut g Gen) find_concrete_types_for_interface(iface_name string) []string {
610610
emb_key := '${cand}.${df.name}'
611611
short_cand := if cand.contains('__') { cand.all_after_last('__') } else { cand }
612612
emb_short_key := '${short_cand}.${df.name}'
613-
if emb_key !in g.embedded_field_owner && emb_short_key !in g.embedded_field_owner {
613+
if emb_key !in g.embedded_field_owner
614+
&& emb_short_key !in g.embedded_field_owner {
614615
has_all = false
615616
break
616617
}

‎vlib/v2/gen/cleanc/types.v‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2586,7 +2586,7 @@ fn (mut g Gen) record_generic_struct_bindings(struct_base_name string, struct_c_
25862586
for i, param_name in generic_param_names {
25872587
concrete_expr := concrete_params[i]
25882588
if is_generic_placeholder_type_name(concrete_expr.name()) {
2589-
return // Still a placeholder (e.g. T), not a concrete type
2589+
return
25902590
}
25912591
// Look up the concrete type from the Environment.
25922592
concrete_c_name := g.expr_type_to_c(concrete_expr)
@@ -2620,7 +2620,7 @@ fn (mut g Gen) record_generic_struct_bindings_with_parent(struct_base_name strin
26202620
bindings[param_name] = parent_type
26212621
continue
26222622
}
2623-
return // Unresolvable placeholder
2623+
return
26242624
}
26252625
concrete_c_name := g.expr_type_to_c(concrete_expr)
26262626
if concrete_type := g.lookup_type_by_c_name(concrete_c_name) {

‎vlib/v2/transformer/expr.v‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,8 @@ fn (mut t Transformer) transform_selector_expr(expr ast.SelectorExpr) ast.Expr {
698698
if expr.lhs is ast.Ident {
699699
lhs_name := expr.lhs.name
700700
// Check if LHS is an enum type in the current module
701-
qualified := if t.cur_module != '' && t.cur_module != 'main'
702-
&& t.cur_module != 'builtin' && !lhs_name.contains('__') {
701+
qualified := if t.cur_module != '' && t.cur_module != 'main' && t.cur_module != 'builtin'
702+
&& !lhs_name.contains('__') {
703703
'${t.cur_module}__${lhs_name}'
704704
} else {
705705
lhs_name
@@ -1301,9 +1301,11 @@ fn (mut t Transformer) transform_if_expr(expr ast.IfExpr) ast.Expr {
13011301
// Keep original is-check condition (let cleanc handle it)
13021302
return ast.IfExpr{
13031303
cond: t.transform_expr(ast.Expr(lhs_infix))
1304-
stmts: [ast.Stmt(ast.ExprStmt{
1305-
expr: inner_if
1306-
})]
1304+
stmts: [
1305+
ast.Stmt(ast.ExprStmt{
1306+
expr: inner_if
1307+
}),
1308+
]
13071309
else_expr: transformed_else_fallback
13081310
pos: expr.pos
13091311
}

‎vlib/v2/transformer/fn.v‎

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,8 +1307,8 @@ fn (mut t Transformer) transform_call_expr(expr ast.CallExpr) ast.Expr {
13071307
}
13081308
}
13091309
}
1310-
is_module_call := sel.lhs is ast.Ident
1311-
&& (t.is_module_ident(sel.lhs.name) || (t.get_module_scope(sel.lhs.name) != none
1310+
is_module_call := sel.lhs is ast.Ident && (t.is_module_ident(sel.lhs.name)
1311+
|| (t.get_module_scope(sel.lhs.name) != none
13121312
&& t.lookup_var_type(sel.lhs.name) == none))
13131313
if !is_module_call {
13141314
if resolved := t.resolve_method_call_name(sel.lhs, sel.rhs.name) {
@@ -1445,24 +1445,24 @@ fn (mut t Transformer) transform_call_expr(expr ast.CallExpr) ast.Expr {
14451445
gai := expr.lhs as ast.GenericArgOrIndexExpr
14461446
if gai.lhs is ast.SelectorExpr {
14471447
sel := gai.lhs as ast.SelectorExpr
1448-
is_module_call := sel.lhs is ast.Ident
1449-
&& (t.is_module_ident(sel.lhs.name) || (t.get_module_scope(sel.lhs.name) != none
1448+
is_module_call := sel.lhs is ast.Ident && (t.is_module_ident(sel.lhs.name)
1449+
|| (t.get_module_scope(sel.lhs.name) != none
14501450
&& t.lookup_var_type(sel.lhs.name) == none))
14511451
if !is_module_call {
14521452
// Compute generic specialization suffix from the type arg
14531453
suffix := '_' + t.generic_specialization_token(gai.expr)
14541454
// When receiver matches the current method's receiver parameter
14551455
// and get_expr_type would fail (generic body), use the known prefix
14561456
recv_is_self := t.cur_fn_recv_param != '' && sel.lhs is ast.Ident
1457-
&& (sel.lhs as ast.Ident).name == t.cur_fn_recv_param
1458-
&& t.get_expr_type(sel.lhs) == none
1457+
&& (sel.lhs as ast.Ident).name == t.cur_fn_recv_param && t.get_expr_type(sel.lhs) == none
14591458
if recv_is_self && t.cur_fn_recv_prefix != '' {
14601459
call_args2 := t.lower_missing_call_args(expr.lhs, expr.args)
14611460
fn_info2 := t.lookup_call_fn_info(expr.lhs)
14621461
mut args2 := []ast.Expr{cap: call_args2.len + 1}
14631462
args2 << t.transform_expr(sel.lhs)
14641463
for i, arg in call_args2 {
1465-
args2 << t.transform_call_arg_with_sumtype_check(arg, fn_info2, i)
1464+
args2 << t.transform_call_arg_with_sumtype_check(arg, fn_info2,
1465+
i)
14661466
}
14671467
return ast.CallExpr{
14681468
lhs: ast.Ident{
@@ -1479,7 +1479,8 @@ fn (mut t Transformer) transform_call_expr(expr ast.CallExpr) ast.Expr {
14791479
mut args2 := []ast.Expr{cap: call_args2.len + 1}
14801480
args2 << t.transform_expr(sel.lhs)
14811481
for i, arg in call_args2 {
1482-
args2 << t.transform_call_arg_with_sumtype_check(arg, fn_info2, i)
1482+
args2 << t.transform_call_arg_with_sumtype_check(arg, fn_info2,
1483+
i)
14831484
}
14841485
return ast.CallExpr{
14851486
lhs: ast.Ident{
@@ -1496,7 +1497,8 @@ fn (mut t Transformer) transform_call_expr(expr ast.CallExpr) ast.Expr {
14961497
mut args2 := []ast.Expr{cap: call_args2.len + 1}
14971498
args2 << t.transform_expr(sel.lhs)
14981499
for i, arg in call_args2 {
1499-
args2 << t.transform_call_arg_with_sumtype_check(arg, fn_info2, i)
1500+
args2 << t.transform_call_arg_with_sumtype_check(arg, fn_info2,
1501+
i)
15001502
}
15011503
return ast.CallExpr{
15021504
lhs: ast.Ident{
@@ -1901,9 +1903,7 @@ fn (t &Transformer) resolve_method_call_name(receiver ast.Expr, method_name stri
19011903
}
19021904

19031905
fn (mut t Transformer) lower_missing_call_args(lhs ast.Expr, args []ast.Expr) []ast.Expr {
1904-
info := t.lookup_call_fn_info(lhs) or {
1905-
return args
1906-
}
1906+
info := t.lookup_call_fn_info(lhs) or { return args }
19071907
param_types := info.param_types
19081908
if param_types.len == 0 {
19091909
return args
@@ -2638,8 +2638,8 @@ fn (mut t Transformer) transform_call_or_cast_expr(expr ast.CallOrCastExpr) ast.
26382638
// Method call resolution: rewrite receiver.method(arg) -> Type__method(receiver, arg)
26392639
if expr.lhs is ast.SelectorExpr {
26402640
sel := expr.lhs as ast.SelectorExpr
2641-
is_module_call := sel.lhs is ast.Ident
2642-
&& (t.is_module_ident(sel.lhs.name) || (t.get_module_scope(sel.lhs.name) != none
2641+
is_module_call := sel.lhs is ast.Ident && (t.is_module_ident(sel.lhs.name)
2642+
|| (t.get_module_scope(sel.lhs.name) != none
26432643
&& t.lookup_var_type(sel.lhs.name) == none))
26442644
if !is_module_call {
26452645
if resolved := t.resolve_method_call_name(sel.lhs, sel.rhs.name) {
@@ -2733,17 +2733,16 @@ fn (mut t Transformer) transform_call_or_cast_expr(expr ast.CallOrCastExpr) ast.
27332733
gai := expr.lhs as ast.GenericArgOrIndexExpr
27342734
if gai.lhs is ast.SelectorExpr {
27352735
sel := gai.lhs as ast.SelectorExpr
2736-
is_module_call := sel.lhs is ast.Ident
2737-
&& (t.is_module_ident(sel.lhs.name) || (t.get_module_scope(sel.lhs.name) != none
2736+
is_module_call := sel.lhs is ast.Ident && (t.is_module_ident(sel.lhs.name)
2737+
|| (t.get_module_scope(sel.lhs.name) != none
27382738
&& t.lookup_var_type(sel.lhs.name) == none))
27392739
if !is_module_call {
27402740
suffix := '_' + t.generic_specialization_token(gai.expr)
27412741
// When the receiver matches the current method's receiver parameter
27422742
// and get_expr_type would fail (generic body), use the known prefix
27432743
// directly to avoid wrong fallback to 'array__' prefix.
27442744
recv_is_self := t.cur_fn_recv_param != '' && sel.lhs is ast.Ident
2745-
&& (sel.lhs as ast.Ident).name == t.cur_fn_recv_param
2746-
&& t.get_expr_type(sel.lhs) == none
2745+
&& (sel.lhs as ast.Ident).name == t.cur_fn_recv_param && t.get_expr_type(sel.lhs) == none
27472746
if recv_is_self && t.cur_fn_recv_prefix != '' {
27482747
mut args2 := []ast.Expr{cap: 2}
27492748
args2 << t.transform_expr(sel.lhs)

‎vlib/v2/transformer/if.v‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,9 @@ fn (mut t Transformer) build_tuple_branch_assigns(stmts []ast.Stmt, tuple_lhs []
839839
// Single expression returning a tuple (e.g. function call)
840840
t.temp_counter++
841841
tmp_name := '_tuple_t${t.temp_counter}'
842-
tmp_ident := ast.Ident{ name: tmp_name }
842+
tmp_ident := ast.Ident{
843+
name: tmp_name
844+
}
843845
mut result := []ast.Stmt{cap: n + 1}
844846
// Include any preceding statements from the branch
845847
for i in 0 .. last_idx {
@@ -859,10 +861,14 @@ fn (mut t Transformer) build_tuple_branch_assigns(stmts []ast.Stmt, tuple_lhs []
859861
result << ast.Stmt(ast.AssignStmt{
860862
op: .assign
861863
lhs: [tuple_lhs[i]]
862-
rhs: [ast.Expr(ast.SelectorExpr{
863-
lhs: tmp_ident
864-
rhs: ast.Ident{ name: 'arg${i}' }
865-
})]
864+
rhs: [
865+
ast.Expr(ast.SelectorExpr{
866+
lhs: tmp_ident
867+
rhs: ast.Ident{
868+
name: 'arg${i}'
869+
}
870+
}),
871+
]
866872
pos: pos
867873
})
868874
}

0 commit comments

Comments
 (0)