Merge pull request #8301 from ethereum/fixPostTypeChecker

PostTypeChecker: ConstStateVarCircularReferenceChecker on function type state variables.
This commit is contained in:
chriseth 2020-02-12 18:40:19 +01:00 committed by GitHub
commit 1ea66fd1f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View File

@ -133,9 +133,9 @@ struct ConstStateVarCircularReferenceChecker: public PostTypeChecker::Checker
bool visit(VariableDeclaration const& _variable) override
{
solAssert(!m_currentConstVariable, "");
if (_variable.isConstant())
{
solAssert(!m_currentConstVariable, "");
m_currentConstVariable = &_variable;
m_constVariables.push_back(&_variable);
}

View File

@ -0,0 +1,6 @@
// Used to cause ICE.
contract C {
function ( ) internal returns ( bytes [ ] storage , mapping ( bytes => mapping ( bytes => mapping ( uint => mapping ( bytes => mapping ( string => mapping ( uint => mapping ( uint => mapping ( uint => mapping ( uint => mapping ( string => mapping ( string => mapping ( uint => mapping ( bytes => mapping ( uint => mapping ( uint => mapping ( uint => mapping ( uint => mapping ( uint => mapping ( bytes => mapping ( uint => mapping ( uint => mapping ( uint => mapping ( uint => mapping ( string => mapping ( uint => string ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) [ ] storage ) constant c = c ;
}
// ----
// TypeError: (43-643): The value of the constant c has a cyclic dependency via c.

View File

@ -0,0 +1,7 @@
contract C {
// Used to cause internal compiler error.
function() returns (x) constant x = x;
}
// ----
// TypeError: (77-78): Name has to refer to a struct, enum or contract.