mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #9108 from ethereum/issues-9065
Disallow override with non-public state variables
This commit is contained in:
commit
0b595d28c0
@ -23,6 +23,7 @@ Bugfixes:
|
||||
* Type Checker: Fix internal compiler error when trying to decode too large static arrays.
|
||||
* Type Checker: Fix wrong compiler error when referencing an overridden function without calling it.
|
||||
* Type Checker: Fix internal compiler error when forward referencing non-literal constants from inline assembly.
|
||||
* Type Checker: Disallow usage of override with non-public state variables.
|
||||
* NatSpec: DocString block is terminated when encountering an empty line.
|
||||
* Scanner: Fix bug when two empty NatSpec comments lead to scanning past EOL.
|
||||
* Code Generator: Trigger proper unimplemented errors on certain array copy operations.
|
||||
|
@ -481,7 +481,12 @@ void OverrideChecker::checkIllegalOverrides(ContractDefinition const& _contract)
|
||||
for (auto const* stateVar: _contract.stateVariables())
|
||||
{
|
||||
if (!stateVar->isPublic())
|
||||
{
|
||||
if (stateVar->overrides())
|
||||
m_errorReporter.typeError(8022_error, stateVar->location(), "Override can only be used with public state variables.");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (contains_if(inheritedMods, MatchByName{stateVar->name()}))
|
||||
m_errorReporter.typeError(1456_error, stateVar->location(), "Override changes modifier to public state variable.");
|
||||
|
@ -0,0 +1,9 @@
|
||||
contract C1 {
|
||||
function f() external pure returns(int) { return 42; }
|
||||
}
|
||||
|
||||
contract C is C1 {
|
||||
int override f;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (96-110): Override can only be used with public state variables.
|
Loading…
Reference in New Issue
Block a user