Skip to content

Commit e77e9e4

Browse files
authored
Merge pull request #11499 from ethereum/callGraphInfiniteConstant
Call graph infinite constant
2 parents 215bbe2 + 3eaa370 commit e77e9e4

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

Changelog.md

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

libsolidity/interface/CompilerStack.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -480,13 +480,6 @@ bool CompilerStack::analyze()
480480
if (source->ast && !typeChecker.checkTypeRequirements(*source->ast))
481481
noErrors = false;
482482

483-
// Create & assign callgraphs and check for contract dependency cycles
484-
if (noErrors)
485-
{
486-
createAndAssignCallGraphs();
487-
findAndReportCyclicContractDependencies();
488-
}
489-
490483
if (noErrors)
491484
{
492485
// Checks that can only be done when all types of all AST nodes are known.
@@ -498,6 +491,13 @@ bool CompilerStack::analyze()
498491
noErrors = false;
499492
}
500493

494+
// Create & assign callgraphs and check for contract dependency cycles
495+
if (noErrors)
496+
{
497+
createAndAssignCallGraphs();
498+
findAndReportCyclicContractDependencies();
499+
}
500+
501501
if (noErrors)
502502
for (Source const* source: m_sourceOrder)
503503
if (source->ast && !PostTypeContractLevelChecker{m_errorReporter}.check(*source->ast))
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
contract C {
2+
uint constant a = uint(keccak256(abi.encode(d)));
3+
uint c = uint(keccak256(abi.encode(d)));
4+
uint constant d = a;
5+
}
6+
// ----
7+
// TypeError 6161: (15-63): The value of the constant a has a cyclic dependency via d.
8+
// TypeError 6161: (110-129): The value of the constant d has a cyclic dependency via a.

0 commit comments

Comments
 (0)