mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Disallow private functions from being overridden
This commit is contained in:
parent
9c3226ce75
commit
e2db9d7ef3
@ -1,3 +1,8 @@
|
||||
### 0.5.17 (2020-03-17)
|
||||
|
||||
Bugfixes:
|
||||
* Type Checker: Disallow overriding of private functions.
|
||||
|
||||
### 0.5.16 (2020-01-02)
|
||||
|
||||
Bugfixes:
|
||||
|
@ -782,6 +782,10 @@
|
||||
"bugs": [],
|
||||
"released": "2020-01-02"
|
||||
},
|
||||
"0.5.17": {
|
||||
"bugs": [],
|
||||
"released": "2020-03-17"
|
||||
},
|
||||
"0.5.2": {
|
||||
"bugs": [
|
||||
"SignedArrayStorageCopy",
|
||||
|
@ -203,6 +203,9 @@ void ContractLevelChecker::checkFunctionOverride(FunctionDefinition const& _func
|
||||
stateMutabilityToString(_function.stateMutability()) +
|
||||
"\"."
|
||||
);
|
||||
if (_super.visibility() == Declaration::Visibility::Private)
|
||||
overrideError(_function, _super, "Private functions cannot be overridden.");
|
||||
|
||||
}
|
||||
|
||||
void ContractLevelChecker::overrideError(FunctionDefinition const& function, FunctionDefinition const& super, string message)
|
||||
|
@ -31,7 +31,7 @@ function test_fn { npm run test; }
|
||||
function zeppelin_test
|
||||
{
|
||||
OPTIMIZER_LEVEL=1
|
||||
setup https://github.com/OpenZeppelin/openzeppelin-solidity.git master
|
||||
setup https://github.com/OpenZeppelin/openzeppelin-solidity.git v2.5.0
|
||||
run_install install_fn
|
||||
|
||||
CONFIG="truffle-config.js"
|
||||
|
@ -0,0 +1,8 @@
|
||||
contract A {
|
||||
function test() private returns (uint256) {}
|
||||
}
|
||||
contract X is A {
|
||||
function test() private returns (uint256) {}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (80-124): Private functions cannot be overridden.
|
@ -0,0 +1,8 @@
|
||||
contract A {
|
||||
function test() public returns (uint256) {}
|
||||
}
|
||||
contract X is A {
|
||||
function test() private returns (uint256) {}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (79-123): Overriding function visibility differs.
|
@ -0,0 +1,9 @@
|
||||
contract A {
|
||||
function test() private returns (uint256) {}
|
||||
}
|
||||
contract X is A {
|
||||
function test() public returns (uint256) {}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (80-123): Overriding function visibility differs.
|
||||
// TypeError: (80-123): Private functions cannot be overridden.
|
@ -0,0 +1,11 @@
|
||||
contract A {
|
||||
function test() private returns (uint256) {}
|
||||
}
|
||||
contract B {
|
||||
function test() private returns (uint256) {}
|
||||
}
|
||||
|
||||
contract X is A, B {
|
||||
}
|
||||
// ----
|
||||
// TypeError: (75-119): Private functions cannot be overridden.
|
@ -0,0 +1,11 @@
|
||||
contract A {
|
||||
function test() public returns (uint256) {}
|
||||
}
|
||||
contract B {
|
||||
function test() private returns (uint256) {}
|
||||
}
|
||||
|
||||
contract X is A, B {
|
||||
}
|
||||
// ----
|
||||
// TypeError: (74-118): Overriding function visibility differs.
|
@ -0,0 +1,12 @@
|
||||
contract A {
|
||||
function test() private returns (uint256) {}
|
||||
}
|
||||
contract B {
|
||||
function test() public returns (uint256) {}
|
||||
}
|
||||
|
||||
contract X is A, B {
|
||||
}
|
||||
// ----
|
||||
// TypeError: (75-118): Overriding function visibility differs.
|
||||
// TypeError: (75-118): Private functions cannot be overridden.
|
@ -58,6 +58,7 @@ DIR=$(mktemp -d)
|
||||
npm version --allow-same-version --no-git-tag-version $VERSION
|
||||
|
||||
echo "Running solc-js tests..."
|
||||
sed -i -e 's/latest/v0.5.0+commit.1d4f565a/' test/package.js
|
||||
npm run test
|
||||
)
|
||||
rm -rf "$DIR"
|
||||
|
Loading…
Reference in New Issue
Block a user