parser: cleanup check_cross_variables() (#10754)
parent
b5f1cf80a6
commit
581280e6fc
|
@ -81,12 +81,12 @@ fn (mut p Parser) check_undefined_variables(exprs []ast.Expr, val ast.Expr) ? {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut p Parser) check_cross_variables(exprs []ast.Expr, val ast.Expr) bool {
|
fn (mut p Parser) check_cross_variables(exprs []ast.Expr, val ast.Expr) bool {
|
||||||
val_ := val
|
val_str := val.str()
|
||||||
match val_ {
|
match val {
|
||||||
ast.Ident {
|
ast.Ident {
|
||||||
for expr in exprs {
|
for expr in exprs {
|
||||||
if expr is ast.Ident {
|
if expr is ast.Ident {
|
||||||
if expr.name == val_.name {
|
if expr.name == val.name {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,24 +94,24 @@ fn (mut p Parser) check_cross_variables(exprs []ast.Expr, val ast.Expr) bool {
|
||||||
}
|
}
|
||||||
ast.IndexExpr {
|
ast.IndexExpr {
|
||||||
for expr in exprs {
|
for expr in exprs {
|
||||||
if expr.str() == val.str() {
|
if expr.str() == val_str {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast.InfixExpr {
|
ast.InfixExpr {
|
||||||
return p.check_cross_variables(exprs, val_.left)
|
return p.check_cross_variables(exprs, val.left)
|
||||||
|| p.check_cross_variables(exprs, val_.right)
|
|| p.check_cross_variables(exprs, val.right)
|
||||||
}
|
}
|
||||||
ast.PrefixExpr {
|
ast.PrefixExpr {
|
||||||
return p.check_cross_variables(exprs, val_.right)
|
return p.check_cross_variables(exprs, val.right)
|
||||||
}
|
}
|
||||||
ast.PostfixExpr {
|
ast.PostfixExpr {
|
||||||
return p.check_cross_variables(exprs, val_.expr)
|
return p.check_cross_variables(exprs, val.expr)
|
||||||
}
|
}
|
||||||
ast.SelectorExpr {
|
ast.SelectorExpr {
|
||||||
for expr in exprs {
|
for expr in exprs {
|
||||||
if expr.str() == val.str() {
|
if expr.str() == val_str {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue