Skip to content

Commit

Permalink
cgen: minor cleanup in stmt() (#8659)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 committed Feb 9, 2021
1 parent f3c5f24 commit 95c3ef3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion vlib/v/gen/c/cgen.v
Expand Up @@ -1042,7 +1042,7 @@ fn (mut g Gen) stmt(node ast.Stmt) {
// if af {
// g.autofree_call_postgen()
// }
if g.inside_ternary == 0 && !node.is_expr && !(node.expr is ast.IfExpr) {
if g.inside_ternary == 0 && !node.is_expr && node.expr !is ast.IfExpr {
g.writeln(';')
}
}
Expand Down
6 changes: 3 additions & 3 deletions vlib/v/gen/js/js.v
Expand Up @@ -1039,7 +1039,7 @@ fn (mut g JsGen) gen_struct_decl(node ast.StructDecl) {
}
// gen toString method
fn_names := fns.map(it.name)
if !('toString' in fn_names) {
if 'toString' !in fn_names {
g.writeln('toString() {')
g.inc_indent()
g.write('return `$js_name {')
Expand Down Expand Up @@ -1569,13 +1569,13 @@ fn (mut g JsGen) gen_type_cast_expr(it ast.CastExpr) {
|| (it.expr is ast.FloatLiteral && it.typ in table.float_type_idxs))
typ := g.typ(it.typ)
if !is_literal {
if !(typ in js.v_types) || g.ns.name == 'builtin' {
if typ !in js.v_types || g.ns.name == 'builtin' {
g.write('new ')
}
g.write('${typ}(')
}
g.expr(it.expr)
if typ == 'string' && !(it.expr is ast.StringLiteral) {
if typ == 'string' && it.expr !is ast.StringLiteral {
g.write('.toString()')
}
if !is_literal {
Expand Down

0 comments on commit 95c3ef3

Please sign in to comment.