diff options
author | Christian <c@ethdev.com> | 2014-12-17 06:45:24 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-12-17 06:49:02 +0800 |
commit | 147e77b61fd202cbfd593270cc2639477ea7c61e (patch) | |
tree | e45799327589cddf7af99b92cb906da9b7c497ce /NameAndTypeResolver.cpp | |
parent | 5b802b685e794832bf8834183bf6c9604e513bbf (diff) | |
download | dexon-solidity-147e77b61fd202cbfd593270cc2639477ea7c61e.tar.gz dexon-solidity-147e77b61fd202cbfd593270cc2639477ea7c61e.tar.zst dexon-solidity-147e77b61fd202cbfd593270cc2639477ea7c61e.zip |
Fix: Resolve function types of all contracts before checking types inside functions.
Diffstat (limited to 'NameAndTypeResolver.cpp')
-rw-r--r-- | NameAndTypeResolver.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/NameAndTypeResolver.cpp b/NameAndTypeResolver.cpp index 2ad27680..80732615 100644 --- a/NameAndTypeResolver.cpp +++ b/NameAndTypeResolver.cpp @@ -49,8 +49,6 @@ void NameAndTypeResolver::resolveNamesAndTypes(ContractDefinition& _contract) m_currentScope = &m_scopes[&_contract]; for (ASTPointer<StructDefinition> const& structDef: _contract.getDefinedStructs()) ReferencesResolver resolver(*structDef, *this, nullptr); - for (ASTPointer<StructDefinition> const& structDef: _contract.getDefinedStructs()) - structDef->checkValidityOfMembers(); for (ASTPointer<VariableDeclaration> const& variable: _contract.getStateVariables()) ReferencesResolver resolver(*variable, *this, nullptr); for (ASTPointer<FunctionDefinition> const& function: _contract.getDefinedFunctions()) @@ -59,13 +57,16 @@ void NameAndTypeResolver::resolveNamesAndTypes(ContractDefinition& _contract) ReferencesResolver referencesResolver(*function, *this, function->getReturnParameterList().get()); } - // First, the parameter types of all functions need to be resolved before we can check - // the types, since it is possible to call functions that are only defined later - // in the source. - _contract.checkTypeRequirements(); m_currentScope = &m_scopes[nullptr]; } +void NameAndTypeResolver::checkTypeRequirements(ContractDefinition& _contract) +{ + for (ASTPointer<StructDefinition> const& structDef: _contract.getDefinedStructs()) + structDef->checkValidityOfMembers(); + _contract.checkTypeRequirements(); +} + void NameAndTypeResolver::updateDeclaration(Declaration const& _declaration) { m_scopes[nullptr].registerDeclaration(_declaration, true); |