mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: minor cleanup in stmt() (#8659)
This commit is contained in:
parent
f3c5f24c17
commit
95c3ef3a6a
@ -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(';')
|
||||
}
|
||||
}
|
||||
|
@ -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 {')
|
||||
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user