mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Disallow override with non-public state variables
This commit is contained in:
parent
ecc9f84f2f
commit
6f8b5fe53b
@ -23,6 +23,7 @@ Bugfixes:
|
|||||||
* Type Checker: Fix internal compiler error when trying to decode too large static arrays.
|
* 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 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: 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.
|
* NatSpec: DocString block is terminated when encountering an empty line.
|
||||||
* Scanner: Fix bug when two empty NatSpec comments lead to scanning past EOL.
|
* Scanner: Fix bug when two empty NatSpec comments lead to scanning past EOL.
|
||||||
* Code Generator: Trigger proper unimplemented errors on certain array copy operations.
|
* 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())
|
for (auto const* stateVar: _contract.stateVariables())
|
||||||
{
|
{
|
||||||
if (!stateVar->isPublic())
|
if (!stateVar->isPublic())
|
||||||
|
{
|
||||||
|
if (stateVar->overrides())
|
||||||
|
m_errorReporter.typeError(8022_error, stateVar->location(), "Override can only be used with public state variables.");
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (contains_if(inheritedMods, MatchByName{stateVar->name()}))
|
if (contains_if(inheritedMods, MatchByName{stateVar->name()}))
|
||||||
m_errorReporter.typeError(1456_error, stateVar->location(), "Override changes modifier to public state variable.");
|
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