Skip to content

Commit a4afcba

Browse files
authored
fmt: don't break it variable name in match expression function calls (#21600)
1 parent ea20c1f commit a4afcba

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

vlib/v/fmt/fmt.v

+2-9
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ pub mut:
3939
mod2alias map[string]string // for `import time as t`, will contain: 'time'=>'t'
4040
mod2syms map[string]string // import time { now } 'time.now'=>'now'
4141
use_short_fn_args bool
42-
single_line_fields bool // should struct fields be on a single line
43-
it_name string // the name to replace `it` with
42+
single_line_fields bool // should struct fields be on a single line
4443
in_lambda_depth int
4544
inside_const bool
4645
inside_unsafe bool
@@ -2258,9 +2257,7 @@ pub fn (mut f Fmt) ident(node ast.Ident) {
22582257
}
22592258
}
22602259
f.write_language_prefix(node.language)
2261-
if node.name == 'it' && f.it_name != '' && f.in_lambda_depth == 0 { // allow `it` in lambdas
2262-
f.write(f.it_name)
2263-
} else if node.kind == .blank_ident {
2260+
if node.kind == .blank_ident {
22642261
f.write('_')
22652262
} else {
22662263
mut is_local := false
@@ -2773,9 +2770,6 @@ fn (mut f Fmt) match_branch(branch ast.MatchBranch, single_line bool) {
27732770
pub fn (mut f Fmt) match_expr(node ast.MatchExpr) {
27742771
f.write('match ')
27752772
f.expr(node.cond)
2776-
if node.cond is ast.Ident {
2777-
f.it_name = node.cond.name
2778-
}
27792773
f.writeln(' {')
27802774
f.indent++
27812775
f.comments(node.comments)
@@ -2806,7 +2800,6 @@ pub fn (mut f Fmt) match_expr(node ast.MatchExpr) {
28062800
}
28072801
f.indent--
28082802
f.write('}')
2809-
f.it_name = ''
28102803
}
28112804

28122805
pub fn (mut f Fmt) offset_of(node ast.OffsetOf) {

0 commit comments

Comments
 (0)