mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Forbid private library functions to be attached outside their declaration scope
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
library L {
|
||||
using {L.privateFunction} for uint;
|
||||
function privateFunction(uint x) private pure returns (uint) { return x + 1; }
|
||||
function f() public pure returns (uint) {
|
||||
uint x = 1;
|
||||
return x.privateFunction();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// f() -> 2
|
||||
@@ -0,0 +1,5 @@
|
||||
library L {
|
||||
using {L.privateFunction} for uint;
|
||||
function privateFunction(uint) private pure {}
|
||||
}
|
||||
// ----
|
||||
@@ -0,0 +1,12 @@
|
||||
library L {
|
||||
function privateFunction(uint) private pure {}
|
||||
}
|
||||
|
||||
using {L.privateFunction} for uint;
|
||||
|
||||
contract C {
|
||||
using {L.privateFunction} for uint;
|
||||
}
|
||||
// ----
|
||||
// TypeError 6772: (73-90): Function "L.privateFunction" is private and therefore cannot be attached to a type outside of the library where it is defined.
|
||||
// TypeError 6772: (127-144): Function "L.privateFunction" is private and therefore cannot be attached to a type outside of the library where it is defined.
|
||||
Reference in New Issue
Block a user