mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #9326 from ethereum/eventOverwriting
[BREAKING] Disallow multiple events with same name and types.
This commit is contained in:
commit
12f390a60a
@ -11,6 +11,7 @@ Breaking changes:
|
||||
* Type Checker: Exponentiation and shifts of literals by non-literals will always use ``uint256`` or ``int256`` as a type.
|
||||
* Type Checker: Disallow structs and arrays in memory or calldata if they contain nested mappings.
|
||||
* Type Checker: Disallow assignments to state variables that contain nested mappings.
|
||||
* Type checker: Disallow events with same name and parameter types in inheritance hierarchy.
|
||||
* ``using A for B`` only affects the contract it is mentioned in and not all derived contracts
|
||||
* Inline Assembly: Disallow `.` in user-defined function and variable names.
|
||||
|
||||
|
@ -120,8 +120,9 @@ void ContractLevelChecker::checkDuplicateEvents(ContractDefinition const& _contr
|
||||
/// Checks that two events with the same name defined in this contract have different
|
||||
/// argument types
|
||||
map<string, vector<EventDefinition const*>> events;
|
||||
for (EventDefinition const* event: _contract.events())
|
||||
events[event->name()].push_back(event);
|
||||
for (auto const* contract: _contract.annotation().linearizedBaseContracts)
|
||||
for (EventDefinition const* event: contract->events())
|
||||
events[event->name()].push_back(event);
|
||||
|
||||
findDuplicateDefinitions(events);
|
||||
}
|
||||
|
@ -0,0 +1,8 @@
|
||||
contract A {
|
||||
event X();
|
||||
}
|
||||
contract B is A {
|
||||
event X() anonymous;
|
||||
}
|
||||
// ----
|
||||
// DeclarationError 5883: (52-72): Event with same name and parameter types defined twice.
|
@ -0,0 +1,8 @@
|
||||
contract A {
|
||||
event X(uint);
|
||||
}
|
||||
contract B is A {
|
||||
event X(uint indexed);
|
||||
}
|
||||
// ----
|
||||
// DeclarationError 5883: (56-78): Event with same name and parameter types defined twice.
|
@ -0,0 +1,6 @@
|
||||
contract A {
|
||||
event X();
|
||||
}
|
||||
contract B is A {
|
||||
event X(uint);
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
contract A {
|
||||
event X(uint);
|
||||
}
|
||||
contract B is A {
|
||||
event X(uint);
|
||||
}
|
||||
// ----
|
||||
// DeclarationError 5883: (56-70): Event with same name and parameter types defined twice.
|
@ -0,0 +1,10 @@
|
||||
contract A {
|
||||
event X(uint, uint indexed);
|
||||
}
|
||||
contract B {
|
||||
event X(uint, uint);
|
||||
}
|
||||
contract C is A, B {
|
||||
}
|
||||
// ----
|
||||
// DeclarationError 5883: (65-85): Event with same name and parameter types defined twice.
|
@ -0,0 +1,8 @@
|
||||
contract A {
|
||||
event X(uint, uint indexed);
|
||||
}
|
||||
contract B is A {
|
||||
event X(uint, uint);
|
||||
}
|
||||
// ----
|
||||
// DeclarationError 5883: (70-90): Event with same name and parameter types defined twice.
|
@ -0,0 +1,4 @@
|
||||
contract A { event X(uint); }
|
||||
contract B is A {}
|
||||
contract C is A {}
|
||||
contract D is B, C {}
|
@ -0,0 +1,5 @@
|
||||
contract A {
|
||||
event X();
|
||||
event X(uint);
|
||||
}
|
||||
// ----
|
Loading…
Reference in New Issue
Block a user