mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Detect different vars in condition and increment
This commit is contained in:
parent
0acab9d07e
commit
2528ff31ee
@ -481,6 +481,12 @@ struct SimpleCounterForLoopChecker: public PostTypeChecker::Checker
|
||||
if (!lhsIdentifier || !lhsIntegerType || !commonIntegerType || *lhsIntegerType != *commonIntegerType)
|
||||
return false;
|
||||
|
||||
if (
|
||||
auto const* incExpressionIdentifier = dynamic_cast<Identifier const*>(&simplePostExpression->subExpression());
|
||||
incExpressionIdentifier->annotation().referencedDeclaration != lhsIdentifier->annotation().referencedDeclaration
|
||||
)
|
||||
return false;
|
||||
|
||||
LValueChecker lhsLValueChecker{*lhsIdentifier};
|
||||
_forStatement.body().accept(lhsLValueChecker);
|
||||
return !lhsLValueChecker.willBeWrittenTo();
|
||||
|
Loading…
Reference in New Issue
Block a user