Replaced "assert" with "if" (incorrect contract code is not supposed to trigger asserts).

This commit is contained in:
a3d4
2020-03-12 14:03:27 +01:00
parent bdd8045db5
commit a86c511713
7 changed files with 40 additions and 8 deletions
+3 -2
View File
@@ -21,7 +21,7 @@
namespace solidity::frontend
{
VariableDeclaration const* rootVariableDeclaration(VariableDeclaration const& _varDecl)
VariableDeclaration const* rootConstVariableDeclaration(VariableDeclaration const& _varDecl)
{
solAssert(_varDecl.isConstant(), "Constant variable expected");
@@ -30,7 +30,8 @@ VariableDeclaration const* rootVariableDeclaration(VariableDeclaration const& _v
while ((identifier = dynamic_cast<Identifier const*>(rootDecl->value().get())))
{
auto referencedVarDecl = dynamic_cast<VariableDeclaration const*>(identifier->annotation().referencedDeclaration);
solAssert(referencedVarDecl && referencedVarDecl->isConstant(), "Identifier is not referencing a variable declaration");
if (!referencedVarDecl || !referencedVarDecl->isConstant())
return nullptr;
rootDecl = referencedVarDecl;
}
return rootDecl;