aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libsolidity/AST.cpp7
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp1
2 files changed, 5 insertions, 3 deletions
diff --git a/libsolidity/AST.cpp b/libsolidity/AST.cpp
index 5e51d222..674f33b7 100644
--- a/libsolidity/AST.cpp
+++ b/libsolidity/AST.cpp
@@ -85,6 +85,9 @@ void ContractDefinition::checkTypeRequirements()
for (ASTPointer<VariableDeclaration> const& variable: m_stateVariables)
variable->checkTypeRequirements();
+ for (ASTPointer<EventDefinition> const& event: events())
+ event->checkTypeRequirements();
+
for (ASTPointer<ModifierDefinition> const& modifier: functionModifiers())
modifier->checkTypeRequirements();
@@ -717,13 +720,13 @@ void EventDefinition::checkTypeRequirements()
{
if (var->isIndexed())
numIndexed++;
+ if (numIndexed > 3)
+ BOOST_THROW_EXCEPTION(createTypeError("More than 3 indexed arguments for event."));
if (!var->type()->canLiveOutsideStorage())
BOOST_THROW_EXCEPTION(var->createTypeError("Type is required to live outside storage."));
if (!var->type()->externalType())
BOOST_THROW_EXCEPTION(var->createTypeError("Internal type is not allowed as event parameter type."));
}
- if (numIndexed > 3)
- BOOST_THROW_EXCEPTION(createTypeError("More than 3 indexed arguments for event."));
}
void Block::checkTypeRequirements()
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 99497ff3..5d174367 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -1050,7 +1050,6 @@ BOOST_AUTO_TEST_CASE(event_too_many_indexed)
char const* text = R"(
contract c {
event e(uint indexed a, bytes3 indexed b, bool indexed c, uint indexed d);
- function f() { e(2, "abc", true); }
})";
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
}