1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

all: clean up multiple 'is' infix expr (#17005)

This commit is contained in:
yuyi 2023-01-18 02:27:09 +08:00 committed by GitHub
parent 2fb9bdce9a
commit 88dab8fc2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 7 deletions

View File

@ -526,8 +526,7 @@ fn (mut g Gen) comptime_if_cond(cond ast.Expr, pkg_exist bool) (bool, bool) {
}
}
.key_in, .not_in {
if (cond.left is ast.TypeNode || cond.left is ast.SelectorExpr)
&& cond.right is ast.ArrayInit {
if cond.left in [ast.TypeNode, ast.SelectorExpr] && cond.right is ast.ArrayInit {
checked_type := g.get_expr_type(cond.left)
for expr in cond.right.exprs {

View File

@ -2262,7 +2262,7 @@ fn (mut g Gen) ref_or_deref_arg(arg ast.CallArg, expected_type ast.Type, lang as
}
return
} else if arg_sym.kind == .sum_type && exp_sym.kind == .sum_type
&& (arg.expr is ast.Ident || arg.expr is ast.SelectorExpr) {
&& arg.expr in [ast.Ident, ast.SelectorExpr] {
g.write('&/*sum*/')
g.expr(arg.expr)
return

View File

@ -343,7 +343,7 @@ fn (mut g Gen) for_in_stmt(node_ ast.ForInStmt) {
}
g.indent--
} else if node.kind == .string {
cond := if node.cond is ast.StringLiteral || node.cond is ast.StringInterLiteral {
cond := if node.cond in [ast.StringLiteral, ast.StringInterLiteral] {
ast.Expr(g.new_ctemp_var_then_gen(node.cond, ast.string_type))
} else {
node.cond

View File

@ -1544,9 +1544,8 @@ fn (mut g JsGen) gen_const_decl(it ast.ConstDecl) {
g.push_pub_var(field.name)
}
if field.expr is ast.StringInterLiteral || field.expr is ast.StringLiteral
|| field.expr is ast.IntegerLiteral || field.expr is ast.FloatLiteral
|| field.expr is ast.BoolLiteral {
if field.expr in [ast.StringInterLiteral, ast.StringLiteral, ast.IntegerLiteral, ast.FloatLiteral,
ast.BoolLiteral] {
g.write('const ${g.js_name(field.name)} = ')
g.expr(field.expr)
} else {