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

ast: use const empty_expr instead of fn empty_expr (thanks to Joe Conigliaro for the idea) (#15175)

This commit is contained in:
Delyan Angelov
2022-07-22 12:14:46 +03:00
committed by GitHub
parent c6aea659e3
commit e9809572b1
20 changed files with 64 additions and 71 deletions

View File

@@ -374,7 +374,7 @@ pub fn (mut t Transformer) expr_stmt_if_expr(mut node ast.IfExpr) ast.Expr {
/*
FIXME: optimization causes cgen error `g.expr(): unhandled EmptyExpr`
if original.branches.len == 0 { // no remain branches to walk through
return ast.EmptyExpr{}
return ast.empty_expr
}*/
if node.branches.len == 1 && node.branches[0].cond.type_name() == 'unknown v.ast.Expr' {
node.branches[0].cond = ast.BoolLiteral{
@@ -484,7 +484,7 @@ pub fn (mut t Transformer) for_stmt(mut node ast.ForStmt) ast.Stmt {
match node.cond {
ast.BoolLiteral {
if !(node.cond as ast.BoolLiteral).val { // for false { ... } should be eleminated
return ast.EmptyStmt{}
return ast.empty_stmt
}
}
else {