Fix infinite recursion in function call graph generator due to recursive constant references.

This commit is contained in:
chriseth 2021-06-08 12:43:43 +02:00
parent 7d8a4e63d8
commit 3eaa37030a
3 changed files with 16 additions and 7 deletions

View File

@ -20,6 +20,7 @@ Bugfixes:
* Code Generator: Fix internal error when super would have to skip an unimplemented function in the virtual resolution order.
* Control Flow Graph: Take internal calls to functions that always revert into account for reporting unused or unassigned variables.
* Control Flow Graph: Assume unimplemented modifiers use a placeholder.
* Function Call Graph: Fix internal error connected with circular constant references.
* Natspec: Allow multiple ``@return`` tags on public state variable documentation.
* SMTChecker: Fix internal error on struct constructor with fixed bytes member initialized with string literal.
* SMTChecker: Fix internal error on external calls from the constructor.

View File

@ -480,13 +480,6 @@ bool CompilerStack::analyze()
if (source->ast && !typeChecker.checkTypeRequirements(*source->ast))
noErrors = false;
// Create & assign callgraphs and check for contract dependency cycles
if (noErrors)
{
createAndAssignCallGraphs();
findAndReportCyclicContractDependencies();
}
if (noErrors)
{
// Checks that can only be done when all types of all AST nodes are known.
@ -498,6 +491,13 @@ bool CompilerStack::analyze()
noErrors = false;
}
// Create & assign callgraphs and check for contract dependency cycles
if (noErrors)
{
createAndAssignCallGraphs();
findAndReportCyclicContractDependencies();
}
if (noErrors)
for (Source const* source: m_sourceOrder)
if (source->ast && !PostTypeContractLevelChecker{m_errorReporter}.check(*source->ast))

View File

@ -0,0 +1,8 @@
contract C {
uint constant a = uint(keccak256(abi.encode(d)));
uint c = uint(keccak256(abi.encode(d)));
uint constant d = a;
}
// ----
// TypeError 6161: (15-63): The value of the constant a has a cyclic dependency via d.
// TypeError 6161: (110-129): The value of the constant d has a cyclic dependency via a.