Skip to content

Commit 88dab8f

Browse files
authored
all: clean up multiple 'is' infix expr (#17005)
1 parent 2fb9bdc commit 88dab8f

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

vlib/v/gen/c/comptime.v

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,7 @@ fn (mut g Gen) comptime_if_cond(cond ast.Expr, pkg_exist bool) (bool, bool) {
526526
}
527527
}
528528
.key_in, .not_in {
529-
if (cond.left is ast.TypeNode || cond.left is ast.SelectorExpr)
530-
&& cond.right is ast.ArrayInit {
529+
if cond.left in [ast.TypeNode, ast.SelectorExpr] && cond.right is ast.ArrayInit {
531530
checked_type := g.get_expr_type(cond.left)
532531

533532
for expr in cond.right.exprs {

vlib/v/gen/c/fn.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2262,7 +2262,7 @@ fn (mut g Gen) ref_or_deref_arg(arg ast.CallArg, expected_type ast.Type, lang as
22622262
}
22632263
return
22642264
} else if arg_sym.kind == .sum_type && exp_sym.kind == .sum_type
2265-
&& (arg.expr is ast.Ident || arg.expr is ast.SelectorExpr) {
2265+
&& arg.expr in [ast.Ident, ast.SelectorExpr] {
22662266
g.write('&/*sum*/')
22672267
g.expr(arg.expr)
22682268
return

vlib/v/gen/c/for.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ fn (mut g Gen) for_in_stmt(node_ ast.ForInStmt) {
343343
}
344344
g.indent--
345345
} else if node.kind == .string {
346-
cond := if node.cond is ast.StringLiteral || node.cond is ast.StringInterLiteral {
346+
cond := if node.cond in [ast.StringLiteral, ast.StringInterLiteral] {
347347
ast.Expr(g.new_ctemp_var_then_gen(node.cond, ast.string_type))
348348
} else {
349349
node.cond

vlib/v/gen/js/js.v

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,9 +1544,8 @@ fn (mut g JsGen) gen_const_decl(it ast.ConstDecl) {
15441544
g.push_pub_var(field.name)
15451545
}
15461546

1547-
if field.expr is ast.StringInterLiteral || field.expr is ast.StringLiteral
1548-
|| field.expr is ast.IntegerLiteral || field.expr is ast.FloatLiteral
1549-
|| field.expr is ast.BoolLiteral {
1547+
if field.expr in [ast.StringInterLiteral, ast.StringLiteral, ast.IntegerLiteral, ast.FloatLiteral,
1548+
ast.BoolLiteral] {
15501549
g.write('const ${g.js_name(field.name)} = ')
15511550
g.expr(field.expr)
15521551
} else {

0 commit comments

Comments
 (0)