Skip to content

Commit

Permalink
cgen: minor cleanup in comptime_if_cond() (#18976)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 committed Jul 26, 2023
1 parent ef59a72 commit 3042857
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions vlib/v/gen/c/comptime.v
Expand Up @@ -560,10 +560,9 @@ fn (mut g Gen) comptime_if_cond(cond ast.Expr, pkg_exist bool) (bool, bool) {
if cond.left is ast.SelectorExpr
&& (g.comptime_for_field_var.len > 0 || g.comptime_for_method.len > 0) {
if cond.right is ast.StringLiteral {
selector := cond.left as ast.SelectorExpr
if selector.expr is ast.Ident && selector.field_name == 'name' {
if cond.left.expr is ast.Ident && cond.left.field_name == 'name' {
if g.comptime_for_method_var.len > 0
&& (selector.expr as ast.Ident).name == g.comptime_for_method_var {
&& cond.left.expr.name == g.comptime_for_method_var {
is_true := if cond.op == .eq {
g.comptime_for_method == cond.right.val
} else {
Expand All @@ -576,7 +575,7 @@ fn (mut g Gen) comptime_if_cond(cond ast.Expr, pkg_exist bool) (bool, bool) {
}
return is_true, true
} else if g.comptime_for_field_var.len > 0
&& (selector.expr as ast.Ident).name == g.comptime_for_field_var {
&& cond.left.expr.name == g.comptime_for_field_var {
is_true := if cond.op == .eq {
g.comptime_for_field_value.name == cond.right.val
} else {
Expand Down

0 comments on commit 3042857

Please sign in to comment.