mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #4063 from ethereum/emit-non-event
Show proper error when trying to emit a non-event
This commit is contained in:
commit
150d226603
@ -8,6 +8,7 @@ Features:
|
||||
* Type Checker: Make literals (without explicit type casting) an error for tight packing as experimental 0.5.0 feature.
|
||||
|
||||
Bugfixes:
|
||||
* Type Checker: Show proper error when trying to ``emit`` a non-event.
|
||||
* Type Checker: Warn about empty tuple components (this will turn into an error with version 0.5.0).
|
||||
|
||||
|
||||
|
@ -1067,6 +1067,7 @@ void TypeChecker::endVisit(EmitStatement const& _emit)
|
||||
{
|
||||
if (
|
||||
_emit.eventCall().annotation().kind != FunctionCallKind::FunctionCall ||
|
||||
type(_emit.eventCall().expression())->category() != Type::Category::Function ||
|
||||
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 invocation.");
|
||||
|
10
test/libsolidity/syntaxTests/emit_non_event.sol
Normal file
10
test/libsolidity/syntaxTests/emit_non_event.sol
Normal file
@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
uint256 Test;
|
||||
|
||||
function f() {
|
||||
emit Test();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (56-62): Type is not callable
|
||||
// TypeError: (56-60): Expression has to be an event invocation.
|
Loading…
Reference in New Issue
Block a user