mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #10055 from ethereum/userDefinedLibraryTypes
Disallow invalid use of library names as type names.
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
library L {}
|
||||
contract C {
|
||||
function f() public {
|
||||
L[] memory x;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 1130: (51-52): Invalid use of a library name.
|
||||
@@ -0,0 +1,8 @@
|
||||
library L {}
|
||||
contract C {
|
||||
function f() public pure {
|
||||
new L[](2);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 1130: (63-64): Invalid use of a library name.
|
||||
@@ -0,0 +1,11 @@
|
||||
library L {}
|
||||
library M {}
|
||||
contract C {
|
||||
using L for M;
|
||||
using M for L;
|
||||
using L for L;
|
||||
}
|
||||
// ----
|
||||
// TypeError 1130: (55-56): Invalid use of a library name.
|
||||
// TypeError 1130: (74-75): Invalid use of a library name.
|
||||
// TypeError 1130: (93-94): Invalid use of a library name.
|
||||
@@ -0,0 +1,8 @@
|
||||
library L {}
|
||||
contract C {
|
||||
function f() public pure {
|
||||
new L();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 1130: (63-64): Invalid use of a library name.
|
||||
@@ -0,0 +1,6 @@
|
||||
library L {}
|
||||
contract C {
|
||||
function f() public override (L) {}
|
||||
}
|
||||
// ----
|
||||
// TypeError 1130: (57-58): Invalid use of a library name.
|
||||
+1
-2
@@ -6,5 +6,4 @@ contract test {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 1273: (87-90): The type of a variable cannot be a library.
|
||||
// TypeError 9582: (100-103): Member "l" not found or not visible after argument-dependent lookup in library L.
|
||||
// TypeError 1130: (87-88): Invalid use of a library name.
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
library L {}
|
||||
contract C {
|
||||
function f() public {
|
||||
new L();
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -9,6 +9,6 @@ contract Y {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 1273: (29-34): The type of a variable cannot be a library.
|
||||
// TypeError 1273: (50-57): The type of a variable cannot be a library.
|
||||
// TypeError 1273: (77-82): The type of a variable cannot be a library.
|
||||
// TypeError 1130: (29-30): Invalid use of a library name.
|
||||
// TypeError 1130: (50-51): Invalid use of a library name.
|
||||
// TypeError 1130: (77-78): Invalid use of a library name.
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
library L {}
|
||||
contract C { mapping(L => bool) i; }
|
||||
contract C
|
||||
{
|
||||
mapping(bool => L) j;
|
||||
mapping(L => bool) i;
|
||||
}
|
||||
// ----
|
||||
// TypeError 1665: (34-35): Library types cannot be used as mapping keys.
|
||||
// TypeError 1130: (44-45): Invalid use of a library name.
|
||||
// TypeError 1130: (60-61): Invalid use of a library name.
|
||||
|
||||
Reference in New Issue
Block a user