Merge pull request #7713 from ethereum/no-lib-instance-7625

Disallow variables of library types
This commit is contained in:
chriseth
2019-11-14 13:39:56 +01:00
committed by GitHub
5 changed files with 28 additions and 4 deletions
@@ -1,9 +1,14 @@
contract X {}
library test {
struct StructType { uint a; }
function f(StructType storage b, uint[] storage c, test d) public returns (uint[] memory e, StructType storage f) { f = f; }
function f1(uint[] memory c, test d) public pure returns (uint[] memory e) { }
function f(StructType storage b, uint[] storage c, X d) public returns (uint[] memory e, StructType storage f) { f = f; }
function f1(uint[] memory c, X d) public pure returns (uint[] memory e) { }
}
// ----
// :X
// []
//
//
// :test
// [
// {
@@ -16,9 +21,9 @@ library test {
// "type": "uint256[]"
// },
// {
// "internalType": "library test",
// "internalType": "contract X",
// "name": "d",
// "type": "test"
// "type": "X"
// }
// ],
// "name": "f1",
@@ -6,4 +6,5 @@ contract test {
}
}
// ----
// TypeError: (87-90): The type of a variable cannot be a library.
// TypeError: (100-103): Member "l" not found or not visible after argument-dependent lookup in library L.
@@ -0,0 +1,14 @@
library X { }
contract Y {
X abc;
function foo(X param) private view
{
X ofg;
ofg = abc;
}
}
// ----
// TypeError: (29-34): The type of a variable cannot be a library.
// TypeError: (50-57): The type of a variable cannot be a library.
// TypeError: (77-82): The type of a variable cannot be a library.