Warn about using events without emit.

This commit is contained in:
chriseth committed 2018-02-22 15:17:42 +01:00
1 parent f58024b974
commit 8c1a8ecc2e
2 files changed
+13 -1

No files matched your search

+9 -1
View File
@@ -961,7 +961,8 @@ void TypeChecker::endVisit(EmitStatement const& _emit)
_emit.eventCall().annotation().kind != FunctionCallKind::FunctionCall ||
dynamic_cast<FunctionType const&>(*type(_emit.eventCall().expression())).kind() != FunctionType::Kind::Event
)
m_errorReporter.typeError(_emit.eventCall().expression().location(), "Expression has to be an event.");
m_errorReporter.typeError(_emit.eventCall().expression().location(), "Expression has to be an event invocation.");
m_insideEmitStatement = false;
}
bool TypeChecker::visit(VariableDeclarationStatement const& _statement)
@@ -1540,6 +1541,13 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
else if (functionName->name() == "suicide" && functionType->kind() == FunctionType::Kind::Selfdestruct)
m_errorReporter.warning(_functionCall.location(), "\"suicide\" has been deprecated in favour of \"selfdestruct\"");
}
if (!m_insideEmitStatement && functionType->kind() == FunctionType::Kind::Event)
{
if (m_scope->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050))
m_errorReporter.typeError(_functionCall.location(), "Event invocations have to be prefixed by \"emit\".");
else
m_errorReporter.warning(_functionCall.location(), "Invoking events without \"emit\" prefix is deprecated.");
}
TypePointers parameterTypes = functionType->parameterTypes();