mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #7713 from ethereum/no-lib-instance-7625
Disallow variables of library types
This commit is contained in:
@@ -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",
|
||||
|
||||
+1
@@ -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.
|
||||
Reference in New Issue
Block a user