mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
User-defined literal suffixes: Tests
This commit is contained in:
parent
b84f1b586e
commit
d0701ccc44
220
test/libsolidity/ASTJSON/literalSuffix.json
Normal file
220
test/libsolidity/ASTJSON/literalSuffix.json
Normal file
@ -0,0 +1,220 @@
|
|||||||
|
{
|
||||||
|
"absolutePath": "a",
|
||||||
|
"exportedSymbols":
|
||||||
|
{
|
||||||
|
"C":
|
||||||
|
[
|
||||||
|
15
|
||||||
|
],
|
||||||
|
"str":
|
||||||
|
[
|
||||||
|
10
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"id": 16,
|
||||||
|
"nodeType": "SourceUnit",
|
||||||
|
"nodes":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"body":
|
||||||
|
{
|
||||||
|
"id": 9,
|
||||||
|
"nodeType": "Block",
|
||||||
|
"src": "63:2:1",
|
||||||
|
"statements": []
|
||||||
|
},
|
||||||
|
"id": 10,
|
||||||
|
"implemented": true,
|
||||||
|
"kind": "freeFunction",
|
||||||
|
"modifiers": [],
|
||||||
|
"name": "str",
|
||||||
|
"nameLocation": "9:3:1",
|
||||||
|
"nodeType": "FunctionDefinition",
|
||||||
|
"parameters":
|
||||||
|
{
|
||||||
|
"id": 5,
|
||||||
|
"nodeType": "ParameterList",
|
||||||
|
"parameters":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"id": 2,
|
||||||
|
"mutability": "mutable",
|
||||||
|
"name": "",
|
||||||
|
"nameLocation": "-1:-1:-1",
|
||||||
|
"nodeType": "VariableDeclaration",
|
||||||
|
"scope": 10,
|
||||||
|
"src": "13:6:1",
|
||||||
|
"stateVariable": false,
|
||||||
|
"storageLocation": "default",
|
||||||
|
"typeDescriptions":
|
||||||
|
{
|
||||||
|
"typeIdentifier": "t_uint32",
|
||||||
|
"typeString": "uint32"
|
||||||
|
},
|
||||||
|
"typeName":
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"name": "uint32",
|
||||||
|
"nodeType": "ElementaryTypeName",
|
||||||
|
"src": "13:6:1",
|
||||||
|
"typeDescriptions":
|
||||||
|
{
|
||||||
|
"typeIdentifier": "t_uint32",
|
||||||
|
"typeString": "uint32"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"visibility": "internal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"id": 4,
|
||||||
|
"mutability": "mutable",
|
||||||
|
"name": "",
|
||||||
|
"nameLocation": "-1:-1:-1",
|
||||||
|
"nodeType": "VariableDeclaration",
|
||||||
|
"scope": 10,
|
||||||
|
"src": "21:4:1",
|
||||||
|
"stateVariable": false,
|
||||||
|
"storageLocation": "default",
|
||||||
|
"typeDescriptions":
|
||||||
|
{
|
||||||
|
"typeIdentifier": "t_uint256",
|
||||||
|
"typeString": "uint256"
|
||||||
|
},
|
||||||
|
"typeName":
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"name": "uint",
|
||||||
|
"nodeType": "ElementaryTypeName",
|
||||||
|
"src": "21:4:1",
|
||||||
|
"typeDescriptions":
|
||||||
|
{
|
||||||
|
"typeIdentifier": "t_uint256",
|
||||||
|
"typeString": "uint256"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"visibility": "internal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"src": "12:14:1"
|
||||||
|
},
|
||||||
|
"returnParameters":
|
||||||
|
{
|
||||||
|
"id": 8,
|
||||||
|
"nodeType": "ParameterList",
|
||||||
|
"parameters":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"id": 7,
|
||||||
|
"mutability": "mutable",
|
||||||
|
"name": "",
|
||||||
|
"nameLocation": "-1:-1:-1",
|
||||||
|
"nodeType": "VariableDeclaration",
|
||||||
|
"scope": 10,
|
||||||
|
"src": "48:13:1",
|
||||||
|
"stateVariable": false,
|
||||||
|
"storageLocation": "memory",
|
||||||
|
"typeDescriptions":
|
||||||
|
{
|
||||||
|
"typeIdentifier": "t_string_memory_ptr",
|
||||||
|
"typeString": "string"
|
||||||
|
},
|
||||||
|
"typeName":
|
||||||
|
{
|
||||||
|
"id": 6,
|
||||||
|
"name": "string",
|
||||||
|
"nodeType": "ElementaryTypeName",
|
||||||
|
"src": "48:6:1",
|
||||||
|
"typeDescriptions":
|
||||||
|
{
|
||||||
|
"typeIdentifier": "t_string_storage_ptr",
|
||||||
|
"typeString": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"visibility": "internal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"src": "47:15:1"
|
||||||
|
},
|
||||||
|
"scope": 16,
|
||||||
|
"src": "0:65:1",
|
||||||
|
"stateMutability": "pure",
|
||||||
|
"suffix": true,
|
||||||
|
"virtual": false,
|
||||||
|
"visibility": "internal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"abstract": false,
|
||||||
|
"baseContracts": [],
|
||||||
|
"canonicalName": "C",
|
||||||
|
"contractDependencies": [],
|
||||||
|
"contractKind": "contract",
|
||||||
|
"fullyImplemented": true,
|
||||||
|
"id": 15,
|
||||||
|
"linearizedBaseContracts":
|
||||||
|
[
|
||||||
|
15
|
||||||
|
],
|
||||||
|
"name": "C",
|
||||||
|
"nameLocation": "75:1:1",
|
||||||
|
"nodeType": "ContractDefinition",
|
||||||
|
"nodes":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"id": 14,
|
||||||
|
"mutability": "mutable",
|
||||||
|
"name": "s",
|
||||||
|
"nameLocation": "90:1:1",
|
||||||
|
"nodeType": "VariableDeclaration",
|
||||||
|
"scope": 15,
|
||||||
|
"src": "83:26:1",
|
||||||
|
"stateVariable": true,
|
||||||
|
"storageLocation": "default",
|
||||||
|
"typeDescriptions":
|
||||||
|
{
|
||||||
|
"typeIdentifier": "t_string_storage",
|
||||||
|
"typeString": "string"
|
||||||
|
},
|
||||||
|
"typeName":
|
||||||
|
{
|
||||||
|
"id": 11,
|
||||||
|
"name": "string",
|
||||||
|
"nodeType": "ElementaryTypeName",
|
||||||
|
"src": "83:6:1",
|
||||||
|
"typeDescriptions":
|
||||||
|
{
|
||||||
|
"typeIdentifier": "t_string_storage_ptr",
|
||||||
|
"typeString": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"value":
|
||||||
|
{
|
||||||
|
"hexValue": "3132332e3334355f373839",
|
||||||
|
"id": 13,
|
||||||
|
"isConstant": false,
|
||||||
|
"isLValue": false,
|
||||||
|
"isPure": false,
|
||||||
|
"kind": "number",
|
||||||
|
"lValueRequested": false,
|
||||||
|
"nodeType": "Literal",
|
||||||
|
"src": "94:15:1",
|
||||||
|
"typeDescriptions":
|
||||||
|
{
|
||||||
|
"typeIdentifier": "t_string_memory_ptr",
|
||||||
|
"typeString": "string memory"
|
||||||
|
},
|
||||||
|
"value": "123.345_789"
|
||||||
|
},
|
||||||
|
"visibility": "internal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"scope": 16,
|
||||||
|
"src": "66:46:1",
|
||||||
|
"usedErrors": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"src": "0:113:1"
|
||||||
|
}
|
6
test/libsolidity/ASTJSON/literalSuffix.sol
Normal file
6
test/libsolidity/ASTJSON/literalSuffix.sol
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
function str(uint32, uint) pure suffix returns (string memory) {}
|
||||||
|
contract C {
|
||||||
|
string s = 123.345_789 str;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----
|
157
test/libsolidity/ASTJSON/literalSuffix_parseOnly.json
Normal file
157
test/libsolidity/ASTJSON/literalSuffix_parseOnly.json
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
{
|
||||||
|
"absolutePath": "a",
|
||||||
|
"id": 16,
|
||||||
|
"nodeType": "SourceUnit",
|
||||||
|
"nodes":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"body":
|
||||||
|
{
|
||||||
|
"id": 9,
|
||||||
|
"nodeType": "Block",
|
||||||
|
"src": "63:2:1",
|
||||||
|
"statements": []
|
||||||
|
},
|
||||||
|
"id": 10,
|
||||||
|
"implemented": true,
|
||||||
|
"kind": "freeFunction",
|
||||||
|
"modifiers": [],
|
||||||
|
"name": "str",
|
||||||
|
"nameLocation": "9:3:1",
|
||||||
|
"nodeType": "FunctionDefinition",
|
||||||
|
"parameters":
|
||||||
|
{
|
||||||
|
"id": 5,
|
||||||
|
"nodeType": "ParameterList",
|
||||||
|
"parameters":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"id": 2,
|
||||||
|
"mutability": "mutable",
|
||||||
|
"name": "",
|
||||||
|
"nameLocation": "-1:-1:-1",
|
||||||
|
"nodeType": "VariableDeclaration",
|
||||||
|
"src": "13:6:1",
|
||||||
|
"stateVariable": false,
|
||||||
|
"storageLocation": "default",
|
||||||
|
"typeDescriptions": {},
|
||||||
|
"typeName":
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"name": "uint32",
|
||||||
|
"nodeType": "ElementaryTypeName",
|
||||||
|
"src": "13:6:1",
|
||||||
|
"typeDescriptions": {}
|
||||||
|
},
|
||||||
|
"visibility": "internal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"id": 4,
|
||||||
|
"mutability": "mutable",
|
||||||
|
"name": "",
|
||||||
|
"nameLocation": "-1:-1:-1",
|
||||||
|
"nodeType": "VariableDeclaration",
|
||||||
|
"src": "21:4:1",
|
||||||
|
"stateVariable": false,
|
||||||
|
"storageLocation": "default",
|
||||||
|
"typeDescriptions": {},
|
||||||
|
"typeName":
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"name": "uint",
|
||||||
|
"nodeType": "ElementaryTypeName",
|
||||||
|
"src": "21:4:1",
|
||||||
|
"typeDescriptions": {}
|
||||||
|
},
|
||||||
|
"visibility": "internal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"src": "12:14:1"
|
||||||
|
},
|
||||||
|
"returnParameters":
|
||||||
|
{
|
||||||
|
"id": 8,
|
||||||
|
"nodeType": "ParameterList",
|
||||||
|
"parameters":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"id": 7,
|
||||||
|
"mutability": "mutable",
|
||||||
|
"name": "",
|
||||||
|
"nameLocation": "-1:-1:-1",
|
||||||
|
"nodeType": "VariableDeclaration",
|
||||||
|
"src": "48:13:1",
|
||||||
|
"stateVariable": false,
|
||||||
|
"storageLocation": "memory",
|
||||||
|
"typeDescriptions": {},
|
||||||
|
"typeName":
|
||||||
|
{
|
||||||
|
"id": 6,
|
||||||
|
"name": "string",
|
||||||
|
"nodeType": "ElementaryTypeName",
|
||||||
|
"src": "48:6:1",
|
||||||
|
"typeDescriptions": {}
|
||||||
|
},
|
||||||
|
"visibility": "internal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"src": "47:15:1"
|
||||||
|
},
|
||||||
|
"src": "0:65:1",
|
||||||
|
"stateMutability": "pure",
|
||||||
|
"suffix": true,
|
||||||
|
"virtual": false,
|
||||||
|
"visibility": "internal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"abstract": false,
|
||||||
|
"baseContracts": [],
|
||||||
|
"contractDependencies": [],
|
||||||
|
"contractKind": "contract",
|
||||||
|
"id": 15,
|
||||||
|
"name": "C",
|
||||||
|
"nameLocation": "75:1:1",
|
||||||
|
"nodeType": "ContractDefinition",
|
||||||
|
"nodes":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"id": 14,
|
||||||
|
"mutability": "mutable",
|
||||||
|
"name": "s",
|
||||||
|
"nameLocation": "90:1:1",
|
||||||
|
"nodeType": "VariableDeclaration",
|
||||||
|
"src": "83:26:1",
|
||||||
|
"stateVariable": false,
|
||||||
|
"storageLocation": "default",
|
||||||
|
"typeDescriptions": {},
|
||||||
|
"typeName":
|
||||||
|
{
|
||||||
|
"id": 11,
|
||||||
|
"name": "string",
|
||||||
|
"nodeType": "ElementaryTypeName",
|
||||||
|
"src": "83:6:1",
|
||||||
|
"typeDescriptions": {}
|
||||||
|
},
|
||||||
|
"value":
|
||||||
|
{
|
||||||
|
"hexValue": "3132332e3334355f373839",
|
||||||
|
"id": 13,
|
||||||
|
"kind": "number",
|
||||||
|
"nodeType": "Literal",
|
||||||
|
"src": "94:15:1",
|
||||||
|
"typeDescriptions": {},
|
||||||
|
"value": "123.345_789"
|
||||||
|
},
|
||||||
|
"visibility": "internal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"src": "66:46:1",
|
||||||
|
"usedErrors": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"src": "0:113:1"
|
||||||
|
}
|
@ -967,6 +967,49 @@ BOOST_AUTO_TEST_CASE(modifiers)
|
|||||||
checkCallGraphExpectations(get<1>(graphs), expectedDeployedEdges, expectedCreatedContractsAfterDeployment);
|
checkCallGraphExpectations(get<1>(graphs), expectedDeployedEdges, expectedCreatedContractsAfterDeployment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(literal_suffixes)
|
||||||
|
{
|
||||||
|
unique_ptr<CompilerStack> compilerStack = parseAndAnalyzeContracts(R"(
|
||||||
|
function free() pure {}
|
||||||
|
function intSuffix(uint) pure suffix returns (uint) { free(); return 1; }
|
||||||
|
function strSuffix(string memory) pure suffix returns (uint) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
modifier m(uint) virtual { _; }
|
||||||
|
|
||||||
|
constructor() m(1 intSuffix) { "a" strSuffix; }
|
||||||
|
function ext() external pure m("a" strSuffix) { 1 intSuffix; inr(); }
|
||||||
|
function inr() internal pure { 1 intSuffix; }
|
||||||
|
}
|
||||||
|
)"s);
|
||||||
|
tuple<CallGraphMap, CallGraphMap> graphs = collectGraphs(*compilerStack);
|
||||||
|
|
||||||
|
map<string, EdgeNames> expectedCreationEdges = {
|
||||||
|
{"C", {
|
||||||
|
{"Entry", "constructor of C"},
|
||||||
|
{"constructor of C", "modifier C.m"},
|
||||||
|
{"constructor of C", "function intSuffix(uint256)"},
|
||||||
|
{"constructor of C", "function strSuffix(string)"},
|
||||||
|
{"function intSuffix(uint256)", "function free()"},
|
||||||
|
}},
|
||||||
|
};
|
||||||
|
|
||||||
|
map<string, EdgeNames> expectedDeployedEdges = {
|
||||||
|
{"C", {
|
||||||
|
{"Entry", "function C.ext()"},
|
||||||
|
{"function C.ext()", "modifier C.m"},
|
||||||
|
{"function C.ext()", "function C.inr()"},
|
||||||
|
{"function C.ext()", "function strSuffix(string)"},
|
||||||
|
{"function C.ext()", "function intSuffix(uint256)"},
|
||||||
|
{"function C.inr()", "function intSuffix(uint256)"},
|
||||||
|
{"function intSuffix(uint256)", "function free()"},
|
||||||
|
}},
|
||||||
|
};
|
||||||
|
|
||||||
|
checkCallGraphExpectations(get<0>(graphs), expectedCreationEdges);
|
||||||
|
checkCallGraphExpectations(get<1>(graphs), expectedDeployedEdges);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(events)
|
BOOST_AUTO_TEST_CASE(events)
|
||||||
{
|
{
|
||||||
unique_ptr<CompilerStack> compilerStack = parseAndAnalyzeContracts(R"(
|
unique_ptr<CompilerStack> compilerStack = parseAndAnalyzeContracts(R"(
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
pragma abicoder v2;
|
||||||
|
|
||||||
|
struct Decimal {
|
||||||
|
uint mantissa;
|
||||||
|
uint exponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
function asDecimal(uint mantissa, uint exponent) pure suffix returns (Decimal memory) {
|
||||||
|
return Decimal(mantissa, exponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function zero() public pure returns (Decimal memory) {
|
||||||
|
return 0.0 asDecimal;
|
||||||
|
}
|
||||||
|
|
||||||
|
function simple() public pure returns (Decimal memory, Decimal memory, Decimal memory, Decimal memory, Decimal memory) {
|
||||||
|
return (
|
||||||
|
1234567800.0 asDecimal,
|
||||||
|
12345678.0 asDecimal,
|
||||||
|
1234.5678 asDecimal,
|
||||||
|
12.345678 asDecimal,
|
||||||
|
0.12345678 asDecimal
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function maxMantissa() public pure returns (Decimal memory) {
|
||||||
|
return 0.00115792089237316195423570985008687907853269984665640564039457584007913129639935e10 asDecimal; // (2**256 - 1) * 10**-(80 - 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
function maxUint8Exponent() public pure returns (Decimal memory) {
|
||||||
|
return 1e-256 asDecimal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----
|
||||||
|
// zero() -> 0, 0
|
||||||
|
// simple() -> 1234567800, 0, 12345678, 0, 12345678, 4, 12345678, 6, 12345678, 8
|
||||||
|
// maxMantissa() -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 70
|
||||||
|
// maxUint8Exponent() -> 1, 256
|
@ -0,0 +1,33 @@
|
|||||||
|
pragma abicoder v2;
|
||||||
|
|
||||||
|
struct Decimal {
|
||||||
|
uint mantissa;
|
||||||
|
uint exponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
function asDecimal(uint mantissa, uint exponent) pure suffix returns (Decimal memory) {
|
||||||
|
return Decimal(mantissa, exponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function zero() public pure returns (Decimal memory) {
|
||||||
|
return 0 asDecimal;
|
||||||
|
}
|
||||||
|
|
||||||
|
function simple() public pure returns (Decimal memory, Decimal memory, Decimal memory) {
|
||||||
|
return (
|
||||||
|
1234567800 asDecimal,
|
||||||
|
12345678 asDecimal,
|
||||||
|
1 asDecimal
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function maxMantissa() public pure returns (Decimal memory) {
|
||||||
|
return 115792089237316195423570985008687907853269984665640564039457584007913129639935 asDecimal; // 2**256 - 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----
|
||||||
|
// zero() -> 0, 0
|
||||||
|
// simple() -> 1234567800, 0, 12345678, 0, 1, 0
|
||||||
|
// maxMantissa() -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0
|
@ -0,0 +1,22 @@
|
|||||||
|
type Length is uint;
|
||||||
|
|
||||||
|
function km(uint meters) pure suffix returns (Length) {
|
||||||
|
return Length.wrap(meters * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Float {
|
||||||
|
uint mantissa;
|
||||||
|
uint exponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f(uint mantissa, uint exponent) pure suffix returns (Float memory) {
|
||||||
|
return Float(mantissa, exponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
Length public length = 5000 km;
|
||||||
|
Float public factor = 1.23 f;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// length() -> 5000000
|
||||||
|
// factor() -> 0x7b, 2
|
@ -0,0 +1,16 @@
|
|||||||
|
function not(address a) pure suffix returns (bytes20) {
|
||||||
|
return ~bytes20(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function notMin() public pure returns (bytes20) {
|
||||||
|
return 0x0000000000000000000000000000000000000000 not;
|
||||||
|
}
|
||||||
|
|
||||||
|
function notMax() public pure returns (bytes20) {
|
||||||
|
return 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF not;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// notMin() -> 0xffffffffffffffffffffffffffffffffffffffff000000000000000000000000
|
||||||
|
// notMax() -> 0x0000000000000000000000000000000000000000
|
@ -0,0 +1,16 @@
|
|||||||
|
function not(bool a) pure suffix returns (bool) {
|
||||||
|
return !a;
|
||||||
|
}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function notTrue() public pure returns (bool) {
|
||||||
|
return true not;
|
||||||
|
}
|
||||||
|
|
||||||
|
function notFalse() public pure returns (bool) {
|
||||||
|
return false not;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// notTrue() -> false
|
||||||
|
// notFalse() -> true
|
@ -0,0 +1,31 @@
|
|||||||
|
function length(bytes memory value) pure suffix returns (uint) {
|
||||||
|
return value.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function empty() public pure returns (uint) {
|
||||||
|
return "" length;
|
||||||
|
}
|
||||||
|
|
||||||
|
function short() public pure returns (uint) {
|
||||||
|
return 'abcd' length;
|
||||||
|
}
|
||||||
|
|
||||||
|
function long() public pure returns (uint) {
|
||||||
|
return 'abcdefghijklmnop abcdefghijklmnop' length;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hex_() public pure returns (uint) {
|
||||||
|
return hex'0123456789abcdef' length;
|
||||||
|
}
|
||||||
|
|
||||||
|
function unicode_() public pure returns (uint) {
|
||||||
|
return unicode"😃" length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// empty() -> 0
|
||||||
|
// short() -> 4
|
||||||
|
// long() -> 33
|
||||||
|
// hex_() -> 8
|
||||||
|
// unicode_() -> 4
|
@ -0,0 +1,32 @@
|
|||||||
|
function half(int value) pure suffix returns (int) { return value / 2; }
|
||||||
|
function half128(uint128 value) pure suffix returns (uint128) { return value / 2; }
|
||||||
|
function half64s(int64 value) pure suffix returns (int64) { return value / 2; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function zero() public pure returns (int) {
|
||||||
|
return 0 half + int128(0 half128) + 0 half64s;
|
||||||
|
}
|
||||||
|
|
||||||
|
function two() public pure returns (int) {
|
||||||
|
return 2 half + int128(2 half128) + 2 half64s;
|
||||||
|
}
|
||||||
|
|
||||||
|
function max() public pure returns (int) {
|
||||||
|
return
|
||||||
|
0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff half +
|
||||||
|
int128(0xffffffffffffffffffffffffffffffff half128) +
|
||||||
|
0x7fffffffffffffff half64s;
|
||||||
|
}
|
||||||
|
|
||||||
|
function withDecimals() public pure returns (int) {
|
||||||
|
return
|
||||||
|
2.0 half +
|
||||||
|
int128(0.0004e5 half128) +
|
||||||
|
80000e-2 half64s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// zero() -> 0
|
||||||
|
// two() -> 3
|
||||||
|
// max() -> 0x4000000000000000000000000000000080000000000000003ffffffffffffffd
|
||||||
|
// withDecimals() -> 421
|
@ -0,0 +1,26 @@
|
|||||||
|
function length(string memory value) pure suffix returns (uint) {
|
||||||
|
return bytes(value).length;
|
||||||
|
}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function empty() public pure returns (uint) {
|
||||||
|
return "" length;
|
||||||
|
}
|
||||||
|
|
||||||
|
function short() public pure returns (uint) {
|
||||||
|
return 'abcd' length;
|
||||||
|
}
|
||||||
|
|
||||||
|
function long() public pure returns (uint) {
|
||||||
|
return 'abcdefghijklmnop abcdefghijklmnop' length;
|
||||||
|
}
|
||||||
|
|
||||||
|
function unicode_() public pure returns (uint) {
|
||||||
|
return unicode"😃" length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// empty() -> 0
|
||||||
|
// short() -> 4
|
||||||
|
// long() -> 33
|
||||||
|
// unicode_() -> 4
|
@ -0,0 +1,25 @@
|
|||||||
|
contract C {
|
||||||
|
uint[2 wei] a;
|
||||||
|
uint[2 gwei] b;
|
||||||
|
uint[2 ether] c;
|
||||||
|
uint[2 seconds] d;
|
||||||
|
uint[2 minutes] e;
|
||||||
|
uint[2 hours] f;
|
||||||
|
uint[2 days] g;
|
||||||
|
uint[2 weeks] h;
|
||||||
|
|
||||||
|
function lengths() public returns (uint, uint, uint, uint, uint, uint, uint, uint) {
|
||||||
|
return (
|
||||||
|
a.length,
|
||||||
|
b.length,
|
||||||
|
c.length,
|
||||||
|
d.length,
|
||||||
|
e.length,
|
||||||
|
f.length,
|
||||||
|
g.length,
|
||||||
|
h.length
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// lengths() -> 2, 2000000000, 2000000000000000000, 2, 120, 7200, 172800, 1209600
|
@ -0,0 +1,11 @@
|
|||||||
|
function suffix(uint) pure suffix returns (uint) {
|
||||||
|
revert();
|
||||||
|
}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure {
|
||||||
|
1 suffix;
|
||||||
|
uint a = 0; // TODO: Should warn about unreachable code here
|
||||||
|
a;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
contract C {
|
||||||
|
uint[42 wei] a;
|
||||||
|
uint[42 gwei] b;
|
||||||
|
uint[42 ether] c;
|
||||||
|
uint[42 seconds] d;
|
||||||
|
uint[42 minutes] e;
|
||||||
|
uint[42 hours] f;
|
||||||
|
uint[42 days] g;
|
||||||
|
uint[42 weeks] h;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// Warning 7325: (58-72): Type uint256[42000000000000000000] covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction.
|
@ -0,0 +1,7 @@
|
|||||||
|
function suffix(uint value) pure suffix returns (uint) { return value; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint x = 1000 suffix 1000 suffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 2314: (112-116): Expected ';' but got 'Number'
|
@ -0,0 +1,7 @@
|
|||||||
|
function suffix(string memory s) pure suffix returns (string memory) { return s; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint x = "abcd" suffix "abcd";
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 2314: (124-130): Expected ';' but got 'StringLiteral'
|
@ -0,0 +1,7 @@
|
|||||||
|
function suffix(uint value) pure suffix returns (uint) { return value; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint x = suffix 1000;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 2314: (107-111): Expected ';' but got 'Number'
|
@ -0,0 +1,7 @@
|
|||||||
|
function suffix(uint x) pure suffix returns (uint) { return x; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint x = 1000suffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 8936: (92-96): Identifier-start is not allowed at end of a number.
|
@ -0,0 +1,7 @@
|
|||||||
|
function suffix(uint value) pure suffix returns (uint) { return value; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint x = 1000 suffix{gas: 1};
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 2622: (100-119): Expected callable expression before call options.
|
@ -0,0 +1,7 @@
|
|||||||
|
function suffix(uint value) pure suffix returns (uint) { return value; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint x = 1000 suffix();
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 5704: (100-113): Type is not callable
|
@ -0,0 +1,11 @@
|
|||||||
|
function suffix(uint x) pure suffix returns (uint) { return x; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() pure public {
|
||||||
|
assembly ("memory-safe" suffix) {
|
||||||
|
pop(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 2314: (142-148): Expected ')' but got identifier
|
@ -0,0 +1,7 @@
|
|||||||
|
function suffix(uint value) pure suffix returns (uint) { return value; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
int x = int(1000) suffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 2314: (109-115): Expected ';' but got identifier
|
@ -0,0 +1,7 @@
|
|||||||
|
function suffix(uint a, uint b) pure suffix returns (uint) { return a + b; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint x = 1000 1 suffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 2314: (109-110): Expected ';' but got 'Number'
|
@ -0,0 +1,9 @@
|
|||||||
|
enum E {A, B, C}
|
||||||
|
|
||||||
|
function suffix(E) pure suffix returns (E) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
E e = E.A suffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 2314: (92-98): Expected ';' but got identifier
|
@ -0,0 +1,11 @@
|
|||||||
|
function suffix(uint x) pure returns (uint) { return x; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
error E();
|
||||||
|
|
||||||
|
function f() public {
|
||||||
|
revert E suffix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 2314: (131-137): Expected '(' but got identifier
|
@ -0,0 +1,11 @@
|
|||||||
|
function suffix(uint x) pure suffix returns (uint) { return x; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
event E();
|
||||||
|
|
||||||
|
function f() public {
|
||||||
|
emit E suffix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 2314: (136-142): Expected '(' but got identifier
|
@ -0,0 +1,37 @@
|
|||||||
|
function uintSuffix(uint x) pure suffix returns (uint) {}
|
||||||
|
function int8Suffix(uint x) pure suffix returns (int8) {}
|
||||||
|
function addressSuffix(uint x) pure suffix returns (address) {}
|
||||||
|
function decimalSuffix(uint m, uint e) pure suffix returns (uint) {}
|
||||||
|
function stringSuffix(uint x) pure suffix returns (string memory) {}
|
||||||
|
function bytesSuffix(uint x) pure suffix returns (bytes memory) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint[42 uintSuffix] a;
|
||||||
|
uint[42 int8Suffix] b;
|
||||||
|
uint[42 addressSuffix] c;
|
||||||
|
uint[42 decimalSuffix] d;
|
||||||
|
uint[42 stringSuffix] e;
|
||||||
|
uint[42 bytesSuffix] f;
|
||||||
|
}
|
||||||
|
|
||||||
|
contract D {
|
||||||
|
uint[uintSuffix(42)] a;
|
||||||
|
uint[int8Suffix(42)] b;
|
||||||
|
uint[addressSuffix(42)] c;
|
||||||
|
uint[decimalSuffix(42)] d;
|
||||||
|
uint[stringSuffix(42)] e;
|
||||||
|
uint[bytesSuffix(42)] f;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 5462: (408-421): Invalid array length, expected integer literal or constant expression. A suffixed literal is not a constant expression unless the suffix is a denomination.
|
||||||
|
// TypeError 5462: (435-448): Invalid array length, expected integer literal or constant expression. A suffixed literal is not a constant expression unless the suffix is a denomination.
|
||||||
|
// TypeError 5462: (462-478): Invalid array length, expected integer literal or constant expression. A suffixed literal is not a constant expression unless the suffix is a denomination.
|
||||||
|
// TypeError 5462: (492-508): Invalid array length, expected integer literal or constant expression. A suffixed literal is not a constant expression unless the suffix is a denomination.
|
||||||
|
// TypeError 5462: (522-537): Invalid array length, expected integer literal or constant expression. A suffixed literal is not a constant expression unless the suffix is a denomination.
|
||||||
|
// TypeError 5462: (551-565): Invalid array length, expected integer literal or constant expression. A suffixed literal is not a constant expression unless the suffix is a denomination.
|
||||||
|
// TypeError 5462: (595-609): Invalid array length, expected integer literal or constant expression.
|
||||||
|
// TypeError 5462: (623-637): Invalid array length, expected integer literal or constant expression.
|
||||||
|
// TypeError 5462: (651-668): Invalid array length, expected integer literal or constant expression.
|
||||||
|
// TypeError 5462: (682-699): Invalid array length, expected integer literal or constant expression.
|
||||||
|
// TypeError 5462: (713-729): Invalid array length, expected integer literal or constant expression.
|
||||||
|
// TypeError 5462: (743-758): Invalid array length, expected integer literal or constant expression.
|
@ -0,0 +1,22 @@
|
|||||||
|
function uintSuffix(uint x) pure suffix returns (uint) { return x; }
|
||||||
|
function int8Suffix(int8 x) pure suffix returns (int8) { return x; }
|
||||||
|
function addressSuffix(address x) pure suffix returns (address) { return x; }
|
||||||
|
function decimalSuffix(uint m, uint e) pure suffix returns (uint) { return m + e; }
|
||||||
|
function stringSuffix(string memory x) pure suffix returns (string memory) { return x; }
|
||||||
|
function bytesSuffix(bytes memory x) pure suffix returns (bytes memory) { return x; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint constant a = 1 uintSuffix;
|
||||||
|
int8 constant b = 1 int8Suffix;
|
||||||
|
address constant c = 0x1234567890123456789012345678901234567890 addressSuffix;
|
||||||
|
uint constant d = 1.1 decimalSuffix;
|
||||||
|
string constant e = "a" stringSuffix;
|
||||||
|
bytes constant f = hex"abcd" bytesSuffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 8349: (511-523): Initial value for constant variable has to be compile-time constant.
|
||||||
|
// TypeError 8349: (547-559): Initial value for constant variable has to be compile-time constant.
|
||||||
|
// TypeError 8349: (586-642): Initial value for constant variable has to be compile-time constant.
|
||||||
|
// TypeError 8349: (666-683): Initial value for constant variable has to be compile-time constant.
|
||||||
|
// TypeError 8349: (709-725): Initial value for constant variable has to be compile-time constant.
|
||||||
|
// TypeError 8349: (750-771): Initial value for constant variable has to be compile-time constant.
|
@ -0,0 +1,5 @@
|
|||||||
|
function suffix(uint x) pure suffix returns (uint) { return x; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint immutable a = 1 suffix;
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
function suffix(string memory s) pure suffix returns (string memory) { return s; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
// TODO: This should be an error
|
||||||
|
string s = "abcd" "" suffix;
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
function suffix(string memory s, string memory) pure suffix returns (string memory) { return s; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
string s = "abcd" "" suffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 2505: (127-143): Functions that take 2 arguments can only be used as literal suffixes for rational numbers.
|
@ -0,0 +1,11 @@
|
|||||||
|
struct S {
|
||||||
|
uint x;
|
||||||
|
}
|
||||||
|
|
||||||
|
function suffix(S memory) pure suffix returns (S memory) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint x = (S suffix);
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 2314: (116-122): Expected ',' but got identifier
|
@ -0,0 +1,8 @@
|
|||||||
|
function suffix(uint value) pure suffix returns (uint) { return value; }
|
||||||
|
function metasuffix(function (uint) pure returns (uint) value) pure suffix returns (uint) { return value; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint x = suffix metasuffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 2314: (215-225): Expected ';' but got identifier
|
@ -0,0 +1,7 @@
|
|||||||
|
function suffix(uint value) pure suffix returns (uint) { return value; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint x = 1000 suffix suffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 2314: (112-118): Expected ';' but got identifier
|
@ -0,0 +1,8 @@
|
|||||||
|
function suffix(uint x) pure suffix returns (uint) { return x; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint v = 42;
|
||||||
|
uint x = v suffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 2314: (111-117): Expected ';' but got identifier
|
@ -0,0 +1,9 @@
|
|||||||
|
function selectorSuffix(uint) pure suffix returns (bytes4) { return 0x12345678; }
|
||||||
|
function signatureSuffix(string memory) pure suffix returns (string memory) { return "f()"; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure {
|
||||||
|
abi.encodeWithSelector(1234 selectorSuffix);
|
||||||
|
abi.encodeWithSignature("abcd" signatureSuffix);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
function twice(uint x) pure suffix returns (uint) { return x * 2; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure returns (uint[] memory) {
|
||||||
|
return new uint[](5 twice);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
function suffix(uint x) pure suffix returns (uint) { return x; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure {
|
||||||
|
suffix;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
function suffix(uint) pure suffix returns (bool) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
bool x = 1 suffix ? 2 suffix : 3 suffix ? 4 suffix : 5 suffix;
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
struct S { uint x; }
|
||||||
|
enum E {A, B, C}
|
||||||
|
type T is uint72;
|
||||||
|
interface I {}
|
||||||
|
|
||||||
|
function uintSuffix(uint) pure suffix returns (uint) { return 1234; }
|
||||||
|
function bytes4Suffix(uint) pure suffix returns (bytes4) { return 0x12345678; }
|
||||||
|
function addressSuffix(uint) pure suffix returns (address) { return 0x1111111111222222222233333333334444444444; }
|
||||||
|
function stringSuffix(uint) pure suffix returns (string memory) { return "abcd"; }
|
||||||
|
function bytesSuffix(uint) pure suffix returns (bytes memory) { return "abcd"; }
|
||||||
|
function arraySuffix(uint) pure suffix returns (bytes3[3] memory) { return [bytes3(0x123456), 0x123456, 0x123456]; }
|
||||||
|
function structSuffix(uint) pure suffix returns (S memory) { return S(42); }
|
||||||
|
function enumSuffix(uint) pure suffix returns (E) { return E.A; }
|
||||||
|
function udvtSuffix(uint) pure suffix returns (T) { return T.wrap(1); }
|
||||||
|
function interfaceSuffix(uint) pure suffix returns (I) { return I(address(0)); }
|
||||||
|
function functionSuffix(uint) pure suffix returns (function (uint) pure returns (T)) { return udvtSuffix; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint a = 1 uintSuffix;
|
||||||
|
bytes4 b = 1 bytes4Suffix;
|
||||||
|
address c = 1 addressSuffix;
|
||||||
|
string d = 1 stringSuffix;
|
||||||
|
bytes e = 1 bytesSuffix;
|
||||||
|
bytes3[3] f = 1 arraySuffix;
|
||||||
|
S g = 1 structSuffix;
|
||||||
|
E h = 1 enumSuffix;
|
||||||
|
T i = 1 udvtSuffix;
|
||||||
|
I j = 1 interfaceSuffix;
|
||||||
|
function (uint) pure returns (T) k = 1 functionSuffix;
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
function u8(uint m, uint8 e) pure suffix returns (uint) {}
|
||||||
|
function u16(uint m, uint16 e) pure suffix returns (uint) {}
|
||||||
|
function u256(uint m, uint e) pure suffix returns (uint) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function min() public pure {
|
||||||
|
// We never use positive exponents so here it's just 0 and the whole number goes into mantissa
|
||||||
|
1.0e77 u8;
|
||||||
|
1.0e77 u16;
|
||||||
|
1.0e77 u256;
|
||||||
|
|
||||||
|
115792089237316195423570985008687907853269984665640564039457584007913129639935.0 u8; // 2**256 - 1
|
||||||
|
115792089237316195423570985008687907853269984665640564039457584007913129639935.0 u16; // 2**256 - 1
|
||||||
|
115792089237316195423570985008687907853269984665640564039457584007913129639935.0 u256; // 2**256 - 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function max() public pure {
|
||||||
|
1e-255 u8;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
function u8(uint m, uint8 e) pure suffix returns (uint) {}
|
||||||
|
function u16(uint m, uint16 e) pure suffix returns (uint) {}
|
||||||
|
function u256(uint m, uint e) pure suffix returns (uint) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function min() public pure {
|
||||||
|
// We never use positive exponents so here it's just 0 and the whole number goes into mantissa
|
||||||
|
1.0e78 u8;
|
||||||
|
1.0e78 u16;
|
||||||
|
1.0e78 u256;
|
||||||
|
|
||||||
|
115792089237316195423570985008687907853269984665640564039457584007913129639936 u8; // 2**256
|
||||||
|
115792089237316195423570985008687907853269984665640564039457584007913129639936 u16; // 2**256
|
||||||
|
115792089237316195423570985008687907853269984665640564039457584007913129639936 u256; // 2**256
|
||||||
|
}
|
||||||
|
|
||||||
|
function max() public pure {
|
||||||
|
1e-256 u8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 5503: (338-347): This fractional number cannot be decomposed into a mantissa and decimal exponent that fit the range of parameters of any possible suffix function.
|
||||||
|
// TypeError 5503: (357-367): This fractional number cannot be decomposed into a mantissa and decimal exponent that fit the range of parameters of any possible suffix function.
|
||||||
|
// TypeError 5503: (377-388): This fractional number cannot be decomposed into a mantissa and decimal exponent that fit the range of parameters of any possible suffix function.
|
||||||
|
// TypeError 5503: (399-480): This fractional number cannot be decomposed into a mantissa and decimal exponent that fit the range of parameters of any possible suffix function.
|
||||||
|
// TypeError 5503: (502-584): This fractional number cannot be decomposed into a mantissa and decimal exponent that fit the range of parameters of any possible suffix function.
|
||||||
|
// TypeError 5503: (605-688): This fractional number cannot be decomposed into a mantissa and decimal exponent that fit the range of parameters of any possible suffix function.
|
||||||
|
// TypeError 8838: (748-757): The type of the literal cannot be converted to the parameters of the suffix function.
|
@ -0,0 +1,26 @@
|
|||||||
|
function s8(int8 x) pure suffix returns (uint) {}
|
||||||
|
function u8(uint8 x) pure suffix returns (uint) {}
|
||||||
|
function s16(int16 x) pure suffix returns (uint) {}
|
||||||
|
function u16(uint16 x) pure suffix returns (uint) {}
|
||||||
|
function s256(int x) pure suffix returns (uint) {}
|
||||||
|
function u256(uint x) pure suffix returns (uint) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function min() public pure {
|
||||||
|
0 s8;
|
||||||
|
0 u8;
|
||||||
|
0 s16;
|
||||||
|
0 u16;
|
||||||
|
0 s256;
|
||||||
|
0 u256;
|
||||||
|
}
|
||||||
|
|
||||||
|
function max() public pure {
|
||||||
|
127 s8;
|
||||||
|
255 u8;
|
||||||
|
32767 s16;
|
||||||
|
65535 u16;
|
||||||
|
57896044618658097711785492504343953926634992332820282019728792003956564819967 s256; // 2**255 - 1
|
||||||
|
115792089237316195423570985008687907853269984665640564039457584007913129639935 u256; // 2**256 - 1
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
function s8(int8 x) pure suffix returns (uint) {}
|
||||||
|
function u8(uint8 x) pure suffix returns (uint) {}
|
||||||
|
function s16(int16 x) pure suffix returns (uint) {}
|
||||||
|
function u16(uint16 x) pure suffix returns (uint) {}
|
||||||
|
function s256(int x) pure suffix returns (uint) {}
|
||||||
|
function u256(uint x) pure suffix returns (uint) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function max() public pure {
|
||||||
|
128 s8;
|
||||||
|
256 u8;
|
||||||
|
32768 s16;
|
||||||
|
65536 u16;
|
||||||
|
57896044618658097711785492504343953926634992332820282019728792003956564819968 s256; // 2**255
|
||||||
|
115792089237316195423570985008687907853269984665640564039457584007913129639936 u256; // 2**256
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 8838: (364-370): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (380-386): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (396-405): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (415-424): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (434-516): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 5503: (536-619): This fractional number cannot be decomposed into a mantissa and decimal exponent that fit the range of parameters of any possible suffix function.
|
||||||
|
// TypeError 8838: (536-619): The type of the literal cannot be converted to the parameter of the suffix function.
|
@ -0,0 +1,40 @@
|
|||||||
|
function s8(int8 m, uint e) pure suffix returns (uint) {}
|
||||||
|
function u8(uint8 m, uint e) pure suffix returns (uint) {}
|
||||||
|
function s16(int16 m, uint e) pure suffix returns (uint) {}
|
||||||
|
function u16(uint16 m, uint e) pure suffix returns (uint) {}
|
||||||
|
function s256(int m, uint e) pure suffix returns (uint) {}
|
||||||
|
function u256(uint m, uint e) pure suffix returns (uint) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function min() public pure {
|
||||||
|
0 s8;
|
||||||
|
0 u8;
|
||||||
|
0 s16;
|
||||||
|
0 u16;
|
||||||
|
0 s256;
|
||||||
|
0 u256;
|
||||||
|
|
||||||
|
0.0 s8;
|
||||||
|
0.0 u8;
|
||||||
|
0.0 s16;
|
||||||
|
0.0 u16;
|
||||||
|
0.0 s256;
|
||||||
|
0.0 u256;
|
||||||
|
}
|
||||||
|
|
||||||
|
function max() public pure {
|
||||||
|
127 s8;
|
||||||
|
255 u8;
|
||||||
|
32767 s16;
|
||||||
|
65535 u16;
|
||||||
|
57896044618658097711785492504343953926634992332820282019728792003956564819967 s256; // 2**255 - 1
|
||||||
|
115792089237316195423570985008687907853269984665640564039457584007913129639935 u256; // 2**256 - 1
|
||||||
|
|
||||||
|
1.27 s8;
|
||||||
|
2.55 u8;
|
||||||
|
3.2767 s16;
|
||||||
|
6.5535 u16;
|
||||||
|
5.7896044618658097711785492504343953926634992332820282019728792003956564819967 s256; // (2**255 - 1) * 10**-76
|
||||||
|
1.15792089237316195423570985008687907853269984665640564039457584007913129639935 u256; // (2**256 - 1) * 10**-77
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
function s8(int8 m, uint e) pure suffix returns (uint) {}
|
||||||
|
function u8(uint8 m, uint e) pure suffix returns (uint) {}
|
||||||
|
function s16(int16 m, uint e) pure suffix returns (uint) {}
|
||||||
|
function u16(uint16 m, uint e) pure suffix returns (uint) {}
|
||||||
|
function s256(int m, uint e) pure suffix returns (uint) {}
|
||||||
|
function u256(uint m, uint e) pure suffix returns (uint) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function max() public pure {
|
||||||
|
// TODO: For all of these the error should be that the mantissa or exponent is out of range.
|
||||||
|
// Best if we can tell which of them.
|
||||||
|
128 s8;
|
||||||
|
256 u8;
|
||||||
|
32768 s16;
|
||||||
|
65536 u16;
|
||||||
|
57896044618658097711785492504343953926634992332820282019728792003956564819968 s256; // 2**255
|
||||||
|
115792089237316195423570985008687907853269984665640564039457584007913129639936 u256; // 2**256
|
||||||
|
|
||||||
|
1.28 s8;
|
||||||
|
2.56 u8;
|
||||||
|
3.2768 s16;
|
||||||
|
6.5536 u16;
|
||||||
|
5.7896044618658097711785492504343953926634992332820282019728792003956564819968 s256; // 2**255 * 10**-76
|
||||||
|
1.15792089237316195423570985008687907853269984665640564039457584007913129639936 u256; // 2**256 * 10**-77
|
||||||
|
|
||||||
|
128_000 s8;
|
||||||
|
256_000 u8;
|
||||||
|
32768_000 s16;
|
||||||
|
65536_000 u16;
|
||||||
|
57896044618658097711785492504343953926634992332820282019728792003956564819968_000 s256; // 2**255 * 10**-76
|
||||||
|
115792089237316195423570985008687907853269984665640564039457584007913129639936_000 u256; // 2**256 * 10**-77
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 8838: (559-565): The type of the literal cannot be converted to the parameters of the suffix function.
|
||||||
|
// TypeError 8838: (575-581): The type of the literal cannot be converted to the parameters of the suffix function.
|
||||||
|
// TypeError 8838: (591-600): The type of the literal cannot be converted to the parameters of the suffix function.
|
||||||
|
// TypeError 8838: (610-619): The type of the literal cannot be converted to the parameters of the suffix function.
|
||||||
|
// TypeError 8838: (629-711): The type of the literal cannot be converted to the parameters of the suffix function.
|
||||||
|
// TypeError 5503: (731-814): This fractional number cannot be decomposed into a mantissa and decimal exponent that fit the range of parameters of any possible suffix function.
|
||||||
|
// TypeError 8838: (835-842): The type of the literal cannot be converted to the parameters of the suffix function.
|
||||||
|
// TypeError 8838: (852-859): The type of the literal cannot be converted to the parameters of the suffix function.
|
||||||
|
// TypeError 8838: (869-879): The type of the literal cannot be converted to the parameters of the suffix function.
|
||||||
|
// TypeError 8838: (889-899): The type of the literal cannot be converted to the parameters of the suffix function.
|
||||||
|
// TypeError 8838: (909-992): The type of the literal cannot be converted to the parameters of the suffix function.
|
||||||
|
// TypeError 5503: (1022-1106): This fractional number cannot be decomposed into a mantissa and decimal exponent that fit the range of parameters of any possible suffix function.
|
||||||
|
// TypeError 8838: (1137-1147): The type of the literal cannot be converted to the parameters of the suffix function.
|
||||||
|
// TypeError 8838: (1157-1167): The type of the literal cannot be converted to the parameters of the suffix function.
|
||||||
|
// TypeError 8838: (1177-1190): The type of the literal cannot be converted to the parameters of the suffix function.
|
||||||
|
// TypeError 8838: (1200-1213): The type of the literal cannot be converted to the parameters of the suffix function.
|
||||||
|
// TypeError 5503: (1223-1309): This fractional number cannot be decomposed into a mantissa and decimal exponent that fit the range of parameters of any possible suffix function.
|
||||||
|
// TypeError 5503: (1339-1426): This fractional number cannot be decomposed into a mantissa and decimal exponent that fit the range of parameters of any possible suffix function.
|
@ -0,0 +1,22 @@
|
|||||||
|
struct S { uint x; }
|
||||||
|
|
||||||
|
function uintUintSuffix(uint) pure suffix returns (uint, uint) {
|
||||||
|
return (1, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
function bytesStructContractSuffix(string memory s) pure suffix returns (bytes memory, S memory, C) {
|
||||||
|
return (bytes(s), S(42), C(address(0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure returns (uint, uint) {
|
||||||
|
return 1 uintUintSuffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
function g() public pure returns (bytes memory, S memory, C) {
|
||||||
|
return "abcd" bytesStructContractSuffix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 7848: (72-84): Literal suffix functions must return exactly one value.
|
||||||
|
// TypeError 7848: (181-208): Literal suffix functions must return exactly one value.
|
@ -0,0 +1,9 @@
|
|||||||
|
function nullSuffix(uint) pure suffix {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure {
|
||||||
|
return 1 nullSuffix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 7848: (38-38): Literal suffix functions must return exactly one value.
|
@ -0,0 +1,11 @@
|
|||||||
|
function suffix(uint) pure suffix returns (int) {}
|
||||||
|
function suffix(bool) pure suffix returns (bool) {}
|
||||||
|
function suffix(address) pure suffix returns (address) {}
|
||||||
|
function suffix(string memory) pure suffix returns (string memory) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
int a = 1 suffix;
|
||||||
|
bool b = true suffix;
|
||||||
|
address c = 0x1234567890123456789012345678901234567890 suffix;
|
||||||
|
string d = "a" suffix;
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
function uSuffix(uint8, uint) pure suffix returns (int8) {}
|
||||||
|
function uSuffix(uint16, uint) pure suffix returns (int16) {}
|
||||||
|
|
||||||
|
function iSuffix(int8, uint) pure suffix returns (int24) {}
|
||||||
|
function iSuffix(int16, uint) pure suffix returns (int32) {}
|
||||||
|
|
||||||
|
function iuSuffix(uint8, uint) pure suffix returns (int40) {}
|
||||||
|
function iuSuffix(int8, uint) pure suffix returns (int48) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
int16 a = 1.024 uSuffix;
|
||||||
|
int32 b = 1.024 iSuffix;
|
||||||
|
|
||||||
|
int16 c = -1.024 uSuffix;
|
||||||
|
int32 d = -1.024 iSuffix;
|
||||||
|
|
||||||
|
int40 e = 2.55 iuSuffix;
|
||||||
|
int40 f = -2.55 iuSuffix;
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
function iuSuffix(uint8, uint) pure suffix returns (uint) {}
|
||||||
|
function iuSuffix(int8, uint) pure suffix returns (uint) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint a = 1.27 iuSuffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 4487: (148-161): No unique declaration found after argument-dependent lookup.
|
@ -0,0 +1,8 @@
|
|||||||
|
function uSuffix(uint8, uint) pure suffix returns (uint) {}
|
||||||
|
function uSuffix(uint16, uint) pure suffix returns (uint) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint a = 1.27 uSuffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 4487: (148-160): No unique declaration found after argument-dependent lookup.
|
@ -0,0 +1,10 @@
|
|||||||
|
function suffix256(uint) pure suffix returns (uint) {}
|
||||||
|
function suffix256(uint, uint) pure suffix returns (int) {}
|
||||||
|
|
||||||
|
function suffix8(uint) pure suffix returns (uint8) {}
|
||||||
|
function suffix8(uint8, uint) pure suffix returns (int8) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
int a = 1.1 suffix256;
|
||||||
|
uint8 b = 1024 suffix8;
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
function suffix(uint) pure suffix returns (int) {}
|
||||||
|
function suffix(uint, uint) pure suffix returns (int) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure {
|
||||||
|
int a = 1 suffix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 4487: (169-177): No unique declaration found after argument-dependent lookup.
|
@ -0,0 +1,19 @@
|
|||||||
|
function uSuffix(uint8) pure suffix returns (int8) {}
|
||||||
|
function uSuffix(uint16) pure suffix returns (int16) {}
|
||||||
|
|
||||||
|
function iSuffix(int8) pure suffix returns (int24) {}
|
||||||
|
function iSuffix(int16) pure suffix returns (int32) {}
|
||||||
|
|
||||||
|
function iuSuffix(uint8) pure suffix returns (int40) {}
|
||||||
|
function iuSuffix(int8) pure suffix returns (int48) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
int16 a = 1024 uSuffix;
|
||||||
|
int32 b = 1024 iSuffix;
|
||||||
|
|
||||||
|
int16 c = -1024 uSuffix;
|
||||||
|
int32 d = -1024 iSuffix;
|
||||||
|
|
||||||
|
int40 e = 255 iuSuffix;
|
||||||
|
int40 f = -255 iuSuffix;
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
function iuSuffix(uint8) pure suffix returns (int) {}
|
||||||
|
function iuSuffix(int8) pure suffix returns (int) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
int a = 127 iuSuffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 4487: (133-145): No unique declaration found after argument-dependent lookup.
|
@ -0,0 +1,8 @@
|
|||||||
|
function uSuffix(uint8) pure suffix returns (int) {}
|
||||||
|
function uSuffix(uint16) pure suffix returns (int) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
int a = 127 uSuffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 4487: (133-144): No unique declaration found after argument-dependent lookup.
|
@ -0,0 +1,6 @@
|
|||||||
|
function suffix(string memory) pure suffix returns (string memory) {}
|
||||||
|
function suffix(bytes memory) pure suffix returns (bytes memory) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
bytes a = hex"abcd" suffix;
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
function suffix(string memory) pure suffix returns (uint) {}
|
||||||
|
function suffix(bytes memory) pure suffix returns (uint) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint a = "abcd" suffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 4487: (148-161): No unique declaration found after argument-dependent lookup.
|
@ -0,0 +1,14 @@
|
|||||||
|
function calldataSuffix(string memory s) pure suffix returns (string memory) {}
|
||||||
|
function memorySuffix(string calldata s) pure suffix returns (string memory) {}
|
||||||
|
function storageSuffix(string storage s) pure suffix returns (string memory) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure {
|
||||||
|
"a" calldataSuffix;
|
||||||
|
"a" memorySuffix;
|
||||||
|
"a" storageSuffix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 8838: (321-337): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (347-364): The type of the literal cannot be converted to the parameter of the suffix function.
|
@ -0,0 +1,25 @@
|
|||||||
|
struct S {
|
||||||
|
uint x;
|
||||||
|
}
|
||||||
|
|
||||||
|
function structSuffix(uint x) pure suffix returns (S calldata s) {
|
||||||
|
assembly {
|
||||||
|
s := x
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function arraySuffix(uint x) pure suffix returns (uint[5] calldata a) {
|
||||||
|
assembly {
|
||||||
|
a := x
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure {
|
||||||
|
1 structSuffix;
|
||||||
|
1 arraySuffix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 7251: (77-89): Literal suffix functions can only return value types and reference types stored in memory.
|
||||||
|
// TypeError 7251: (182-200): Literal suffix functions can only return value types and reference types stored in memory.
|
@ -0,0 +1,13 @@
|
|||||||
|
struct S {
|
||||||
|
uint x;
|
||||||
|
}
|
||||||
|
|
||||||
|
function structSuffix(uint x) pure suffix returns (S memory s) {}
|
||||||
|
function arraySuffix(uint x) pure suffix returns (uint[5] memory a) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure {
|
||||||
|
1 structSuffix;
|
||||||
|
1 arraySuffix;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
struct S {
|
||||||
|
uint x;
|
||||||
|
}
|
||||||
|
|
||||||
|
function structSuffix(uint x) pure suffix returns (S storage s) {
|
||||||
|
assembly ("memory-safe") {
|
||||||
|
s.slot := x
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function arraySuffix(uint x) pure suffix returns (uint[5] storage a) {
|
||||||
|
assembly ("memory-safe") {
|
||||||
|
a.slot := x
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function mappingSuffix(uint x) pure suffix returns (mapping(uint => uint) storage m) {
|
||||||
|
assembly ("memory-safe") {
|
||||||
|
m.slot := x
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure {
|
||||||
|
1 structSuffix;
|
||||||
|
1 arraySuffix;
|
||||||
|
1 mappingSuffix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 7251: (77-88): Literal suffix functions can only return value types and reference types stored in memory.
|
||||||
|
// TypeError 7251: (202-219): Literal suffix functions can only return value types and reference types stored in memory.
|
||||||
|
// TypeError 7251: (335-366): Literal suffix functions can only return value types and reference types stored in memory.
|
@ -0,0 +1,38 @@
|
|||||||
|
function s8(uint mantissa, int8 exponent) pure suffix returns (uint) { }
|
||||||
|
function s64(uint mantissa, int64 exponent) pure suffix returns (uint) { }
|
||||||
|
function s160(uint mantissa, int160 exponent) pure suffix returns (uint) { }
|
||||||
|
function s256(uint mantissa, int256 exponent) pure suffix returns (uint) { }
|
||||||
|
function ms64(int64 mantissa, int8 exponent) pure suffix returns (uint) { }
|
||||||
|
function ms160(int160 mantissa, int160 exponent) pure suffix returns (uint) { }
|
||||||
|
function ms256(int256 mantissa, int256 exponent) pure suffix returns (uint) { }
|
||||||
|
function mu64(uint64 mantissa, int8 exponent) pure suffix returns (uint) { }
|
||||||
|
function mu160(uint160 mantissa, int160 exponent) pure suffix returns (uint) { }
|
||||||
|
function mu256(uint256 mantissa, int256 exponent) pure suffix returns (uint) { }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure {
|
||||||
|
3.1415 s8;
|
||||||
|
3.1415 s64;
|
||||||
|
3.1415 s160;
|
||||||
|
3.1415 s256;
|
||||||
|
|
||||||
|
1.6180 ms64;
|
||||||
|
1.6180 ms160;
|
||||||
|
1.6180 ms256;
|
||||||
|
|
||||||
|
2.7182 mu64;
|
||||||
|
2.7182 mu160;
|
||||||
|
2.7182 mu256;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 3123: (27-31): The exponent parameter of a literal suffix function must be unsigned. Exponent is always either zero or a negative power of 10 but the parameter represents its absolute value.
|
||||||
|
// TypeError 3123: (101-106): The exponent parameter of a literal suffix function must be unsigned. Exponent is always either zero or a negative power of 10 but the parameter represents its absolute value.
|
||||||
|
// TypeError 3123: (177-183): The exponent parameter of a literal suffix function must be unsigned. Exponent is always either zero or a negative power of 10 but the parameter represents its absolute value.
|
||||||
|
// TypeError 3123: (254-260): The exponent parameter of a literal suffix function must be unsigned. Exponent is always either zero or a negative power of 10 but the parameter represents its absolute value.
|
||||||
|
// TypeError 3123: (332-336): The exponent parameter of a literal suffix function must be unsigned. Exponent is always either zero or a negative power of 10 but the parameter represents its absolute value.
|
||||||
|
// TypeError 3123: (410-416): The exponent parameter of a literal suffix function must be unsigned. Exponent is always either zero or a negative power of 10 but the parameter represents its absolute value.
|
||||||
|
// TypeError 3123: (490-496): The exponent parameter of a literal suffix function must be unsigned. Exponent is always either zero or a negative power of 10 but the parameter represents its absolute value.
|
||||||
|
// TypeError 3123: (569-573): The exponent parameter of a literal suffix function must be unsigned. Exponent is always either zero or a negative power of 10 but the parameter represents its absolute value.
|
||||||
|
// TypeError 3123: (648-654): The exponent parameter of a literal suffix function must be unsigned. Exponent is always either zero or a negative power of 10 but the parameter represents its absolute value.
|
||||||
|
// TypeError 3123: (729-735): The exponent parameter of a literal suffix function must be unsigned. Exponent is always either zero or a negative power of 10 but the parameter represents its absolute value.
|
@ -0,0 +1,11 @@
|
|||||||
|
function zero() pure suffix returns (uint) { return 1; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure {
|
||||||
|
1 zero;
|
||||||
|
1.1 zero;
|
||||||
|
"a" zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 9128: (13-15): Functions that take no arguments cannot be used as literal suffixes.
|
@ -0,0 +1,32 @@
|
|||||||
|
function uintUintUintSuffix(uint, uint, uint) pure suffix returns (uint) { return 1; }
|
||||||
|
function stringStringStringSuffix(string memory, string memory, string memory) pure suffix returns (uint) { return 1; }
|
||||||
|
function uintStringSuffix(uint, string memory) pure suffix returns (uint) { return 1; }
|
||||||
|
function stringUintSuffix(string memory, uint) pure suffix returns (uint) { return 1; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure {
|
||||||
|
1 uintUintUintSuffix;
|
||||||
|
1 stringStringStringSuffix;
|
||||||
|
1 uintStringSuffix;
|
||||||
|
1 stringUintSuffix;
|
||||||
|
|
||||||
|
1.1 uintUintUintSuffix;
|
||||||
|
1.1 stringStringStringSuffix;
|
||||||
|
1.1 uintStringSuffix;
|
||||||
|
1.1 stringUintSuffix;
|
||||||
|
|
||||||
|
"a" uintUintUintSuffix;
|
||||||
|
"a" stringStringStringSuffix;
|
||||||
|
"a" uintStringSuffix;
|
||||||
|
"a" stringUintSuffix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 9128: (27-45): Functions that take 3 or more arguments cannot be used as literal suffixes.
|
||||||
|
// TypeError 9128: (120-165): Functions that take 3 or more arguments cannot be used as literal suffixes.
|
||||||
|
// TypeError 8838: (502-520): The type of the literal cannot be converted to the parameters of the suffix function.
|
||||||
|
// TypeError 8838: (530-548): The type of the literal cannot be converted to the parameters of the suffix function.
|
||||||
|
// TypeError 8838: (629-649): The type of the literal cannot be converted to the parameters of the suffix function.
|
||||||
|
// TypeError 8838: (659-679): The type of the literal cannot be converted to the parameters of the suffix function.
|
||||||
|
// TypeError 2505: (760-780): Functions that take 2 arguments can only be used as literal suffixes for rational numbers.
|
||||||
|
// TypeError 2505: (790-810): Functions that take 2 arguments can only be used as literal suffixes for rational numbers.
|
@ -0,0 +1,106 @@
|
|||||||
|
function uintSuffix(uint) pure suffix returns (uint) { return 1; }
|
||||||
|
function int8Suffix(int8) pure suffix returns (uint) { return 1; }
|
||||||
|
function boolSuffix(bool) pure suffix returns (uint) { return 1; }
|
||||||
|
function addressSuffix(address) pure suffix returns (uint) { return 1; }
|
||||||
|
function decimalSuffix(uint, uint) pure suffix returns (uint) { return 1; }
|
||||||
|
function stringSuffix(string memory) pure suffix returns (uint) { return 1; }
|
||||||
|
function bytesSuffix(bytes memory) pure suffix returns (uint) { return 1; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure {
|
||||||
|
1 uintSuffix; // allowed
|
||||||
|
1 int8Suffix; // allowed
|
||||||
|
1 boolSuffix;
|
||||||
|
1 addressSuffix;
|
||||||
|
1 decimalSuffix; // allowed
|
||||||
|
1 stringSuffix;
|
||||||
|
1 bytesSuffix;
|
||||||
|
|
||||||
|
1024 uintSuffix; // allowed
|
||||||
|
1024 int8Suffix;
|
||||||
|
1024 boolSuffix;
|
||||||
|
1024 addressSuffix;
|
||||||
|
1024 decimalSuffix; // allowed
|
||||||
|
1024 stringSuffix;
|
||||||
|
1024 bytesSuffix;
|
||||||
|
|
||||||
|
true uintSuffix;
|
||||||
|
true int8Suffix;
|
||||||
|
true boolSuffix; // allowed
|
||||||
|
true addressSuffix;
|
||||||
|
true decimalSuffix;
|
||||||
|
true stringSuffix;
|
||||||
|
true bytesSuffix;
|
||||||
|
|
||||||
|
0x1234567890123456789012345678901234567890 uintSuffix;
|
||||||
|
0x1234567890123456789012345678901234567890 int8Suffix;
|
||||||
|
0x1234567890123456789012345678901234567890 boolSuffix;
|
||||||
|
0x1234567890123456789012345678901234567890 addressSuffix; // allowed
|
||||||
|
0x1234567890123456789012345678901234567890 decimalSuffix;
|
||||||
|
0x1234567890123456789012345678901234567890 stringSuffix;
|
||||||
|
0x1234567890123456789012345678901234567890 bytesSuffix;
|
||||||
|
|
||||||
|
1.1 uintSuffix;
|
||||||
|
1.1 int8Suffix;
|
||||||
|
1.1 boolSuffix;
|
||||||
|
1.1 addressSuffix;
|
||||||
|
1.1 decimalSuffix; // allowed
|
||||||
|
1.1 stringSuffix;
|
||||||
|
1.1 bytesSuffix;
|
||||||
|
|
||||||
|
"a" uintSuffix;
|
||||||
|
"a" int8Suffix;
|
||||||
|
"a" boolSuffix;
|
||||||
|
"a" addressSuffix;
|
||||||
|
"a" decimalSuffix;
|
||||||
|
"a" stringSuffix; // allowed
|
||||||
|
"a" bytesSuffix; // allowed
|
||||||
|
|
||||||
|
hex"abcd" uintSuffix;
|
||||||
|
hex"abcd" int8Suffix;
|
||||||
|
hex"abcd" boolSuffix;
|
||||||
|
hex"abcd" addressSuffix;
|
||||||
|
hex"abcd" decimalSuffix;
|
||||||
|
hex"abcd" stringSuffix;
|
||||||
|
hex"abcd" bytesSuffix; // allowed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 8838: (635-647): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (657-672): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (721-735): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (745-758): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (808-823): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (833-848): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (858-876): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (925-942): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (952-968): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (979-994): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (1004-1019): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (1068-1086): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 2505: (1096-1114): Functions that take 2 arguments can only be used as literal suffixes for rational numbers.
|
||||||
|
// TypeError 8838: (1124-1141): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (1151-1167): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (1178-1231): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (1241-1294): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (1304-1357): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 2505: (1444-1500): Functions that take 2 arguments can only be used as literal suffixes for rational numbers.
|
||||||
|
// TypeError 8838: (1510-1565): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (1575-1629): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (1640-1654): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (1664-1678): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (1688-1702): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (1712-1729): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (1777-1793): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (1803-1818): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (1829-1843): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (1853-1867): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (1877-1891): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (1901-1918): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 2505: (1928-1945): Functions that take 2 arguments can only be used as literal suffixes for rational numbers.
|
||||||
|
// TypeError 8838: (2032-2052): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (2062-2082): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (2092-2112): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 8838: (2122-2145): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 2505: (2155-2178): Functions that take 2 arguments can only be used as literal suffixes for rational numbers.
|
||||||
|
// TypeError 8838: (2188-2210): The type of the literal cannot be converted to the parameter of the suffix function.
|
@ -0,0 +1,15 @@
|
|||||||
|
function uintSuffix(uint x) pure suffix returns (uint) { return x; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function g(uint) public {}
|
||||||
|
|
||||||
|
function f() public {
|
||||||
|
abi.encode(1 uintSuffix);
|
||||||
|
abi.encodePacked(2 uintSuffix);
|
||||||
|
abi.encodeWithSelector(0x12345678, 3 uintSuffix);
|
||||||
|
abi.encodeWithSignature("f()", 4 uintSuffix);
|
||||||
|
abi.encodeCall(this.g, 5 uintSuffix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// Warning 2018: (119-378): Function state mutability can be restricted to view
|
@ -0,0 +1,20 @@
|
|||||||
|
function uintUintSuffix(uint x) pure suffix returns (uint, uint) { return (x, x); }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function g(uint, uint) public {}
|
||||||
|
|
||||||
|
function f() public {
|
||||||
|
abi.encode(1 uintUintSuffix);
|
||||||
|
abi.encodePacked(2 uintUintSuffix);
|
||||||
|
abi.encodeWithSelector(0x12345678, 3 uintUintSuffix);
|
||||||
|
abi.encodeWithSignature("f()", 4 uintUintSuffix);
|
||||||
|
abi.encodeCall(this.g, 5 uintUintSuffix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 7848: (52-64): Literal suffix functions must return exactly one value.
|
||||||
|
// TypeError 2056: (181-197): This type cannot be encoded.
|
||||||
|
// TypeError 2056: (225-241): This type cannot be encoded.
|
||||||
|
// TypeError 2056: (287-303): This type cannot be encoded.
|
||||||
|
// TypeError 2056: (345-361): This type cannot be encoded.
|
||||||
|
// TypeError 9062: (395-411): Expected an inline tuple, not an expression of a tuple type.
|
@ -0,0 +1,23 @@
|
|||||||
|
function nullSuffix(uint) pure suffix {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function g() public {}
|
||||||
|
|
||||||
|
function h() public returns (uint, uint) {}
|
||||||
|
|
||||||
|
event E();
|
||||||
|
function f() public {
|
||||||
|
abi.encode(1 nullSuffix);
|
||||||
|
abi.encodePacked(2 nullSuffix);
|
||||||
|
abi.encodeWithSelector(0x12345678, 3 nullSuffix);
|
||||||
|
abi.encodeWithSignature("f()", 4 nullSuffix);
|
||||||
|
abi.encodeCall(this.g, 5 nullSuffix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 7848: (38-38): Literal suffix functions must return exactly one value.
|
||||||
|
// TypeError 2056: (192-204): This type cannot be encoded.
|
||||||
|
// TypeError 2056: (232-244): This type cannot be encoded.
|
||||||
|
// TypeError 2056: (290-302): This type cannot be encoded.
|
||||||
|
// TypeError 2056: (344-356): This type cannot be encoded.
|
||||||
|
// TypeError 9062: (390-402): Expected an inline tuple, not an expression of a tuple type.
|
@ -0,0 +1,3 @@
|
|||||||
|
error E1(uint) suffix;
|
||||||
|
// ----
|
||||||
|
// ParserError 2314: (15-21): Expected ';' but got identifier
|
@ -0,0 +1,5 @@
|
|||||||
|
contract C {
|
||||||
|
event E(uint) suffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 2314: (31-37): Expected ';' but got identifier
|
@ -0,0 +1,5 @@
|
|||||||
|
contract C {
|
||||||
|
function f(uint) internal pure suffix returns (uint) {}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// DeclarationError 7920: (48-54): Identifier not found or not unique.
|
@ -0,0 +1,6 @@
|
|||||||
|
interface I {
|
||||||
|
function f(uint) external pure suffix returns (uint) {}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// SyntaxError 5842: (18-73): Functions in interfaces cannot have modifiers.
|
||||||
|
// DeclarationError 7920: (49-55): Identifier not found or not unique.
|
@ -0,0 +1,5 @@
|
|||||||
|
library L {
|
||||||
|
function f(uint) internal pure suffix returns (uint) {}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// DeclarationError 7920: (47-53): Identifier not found or not unique.
|
@ -0,0 +1,5 @@
|
|||||||
|
contract C {
|
||||||
|
function (uint) pure suffix returns (uint) ptr;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 2314: (45-52): Expected ';' but got 'returns'
|
@ -0,0 +1,9 @@
|
|||||||
|
function suffix1(uint) pure suffix suffix returns (uint) {}
|
||||||
|
function suffix2(uint) suffix pure suffix returns (uint) {}
|
||||||
|
function suffix3(uint) suffix pure suffix suffix suffix returns (uint) {}
|
||||||
|
// ----
|
||||||
|
// ParserError 2878: (35-41): Suffix already specified.
|
||||||
|
// ParserError 2878: (95-101): Suffix already specified.
|
||||||
|
// ParserError 2878: (155-161): Suffix already specified.
|
||||||
|
// ParserError 2878: (162-168): Suffix already specified.
|
||||||
|
// ParserError 2878: (169-175): Suffix already specified.
|
@ -0,0 +1,5 @@
|
|||||||
|
contract C {
|
||||||
|
modifier m(uint) suffix {}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 2314: (34-40): Expected '{' but got identifier
|
@ -0,0 +1,5 @@
|
|||||||
|
contract C {
|
||||||
|
uint suffix a;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 2314: (29-30): Expected ';' but got identifier
|
@ -0,0 +1,2 @@
|
|||||||
|
function suffix1(uint) pure suffix returns (uint) {}
|
||||||
|
function suffix2(uint) suffix pure returns (uint) {}
|
@ -0,0 +1,24 @@
|
|||||||
|
function s(uint value) pure suffix returns (uint) { return value; }
|
||||||
|
function z(uint value) pure suffix returns (uint) { return value; }
|
||||||
|
function q(uint value) pure suffix returns (uint) { return value; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
address z;
|
||||||
|
|
||||||
|
function q() internal {}
|
||||||
|
|
||||||
|
function f() public {
|
||||||
|
uint s;
|
||||||
|
|
||||||
|
1 s;
|
||||||
|
2 z;
|
||||||
|
3 q;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// Warning 2519: (298-304): This declaration shadows an existing declaration.
|
||||||
|
// Warning 2519: (222-231): This declaration shadows an existing declaration.
|
||||||
|
// Warning 2519: (238-262): This declaration shadows an existing declaration.
|
||||||
|
// TypeError 4438: (315-318): The literal suffix must be either a subdenomination or a file-level suffix function.
|
||||||
|
// TypeError 4438: (328-331): The literal suffix must be either a subdenomination or a file-level suffix function.
|
||||||
|
// TypeError 4438: (341-344): The literal suffix must be either a subdenomination or a file-level suffix function.
|
@ -0,0 +1,27 @@
|
|||||||
|
function s(uint x) pure suffix returns (uint) { return x; }
|
||||||
|
function S(uint x) pure suffix returns (uint) { return x; }
|
||||||
|
function suffix(uint x) pure suffix returns (uint) { return x; }
|
||||||
|
function SUFFIX(uint x) pure suffix returns (uint) { return x; }
|
||||||
|
function suffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffix(uint x) pure suffix returns (uint) { return x; }
|
||||||
|
function __(uint x) pure suffix returns (uint) { return x; }
|
||||||
|
function _____________________________________(uint x) pure suffix returns (uint) { return x; }
|
||||||
|
function _s_(uint x) pure suffix returns (uint) { return x; }
|
||||||
|
function $(uint x) pure suffix returns (uint) { return x; }
|
||||||
|
function _$(uint x) pure suffix returns (uint) { return x; }
|
||||||
|
function abcdef(uint x) pure suffix returns (uint) { return x; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure {
|
||||||
|
1000 s;
|
||||||
|
1000 S;
|
||||||
|
1000 suffix;
|
||||||
|
1000 SUFFIX;
|
||||||
|
1000 suffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffix;
|
||||||
|
1000 __;
|
||||||
|
1000 _____________________________________;
|
||||||
|
1000 _s_;
|
||||||
|
1000 $;
|
||||||
|
1000 _$;
|
||||||
|
0x1000_abcdef abcdef;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
function suffix(address payable a) pure suffix returns (address payable) { return a; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure {
|
||||||
|
0x1234567890123456789012345678901234567890 suffix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 8838: (140-189): The type of the literal cannot be converted to the parameter of the suffix function.
|
@ -0,0 +1,7 @@
|
|||||||
|
function suffix(uint value) pure suffix returns (uint) { return value; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint x = 0x1234567890123456789012345678901234567890 suffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 8838: (100-149): The type of the literal cannot be converted to the parameter of the suffix function.
|
@ -0,0 +1,7 @@
|
|||||||
|
function suffix(address value) pure suffix returns (address) { return value; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
address x = 0x123456789012345678901234567890123456789 suffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// SyntaxError 9429: (109-157): This looks like an address but is not exactly 40 hex digits. It is 39 hex digits. If this is not used as an address, please prepend '00'. For more information please see https://docs.soliditylang.org/en/develop/types.html#address-literals
|
@ -0,0 +1,7 @@
|
|||||||
|
function suffix(address value) pure suffix returns (address) { return value; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
address x = 0x12345678901234567890123456789012345678901 suffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// SyntaxError 9429: (109-159): This looks like an address but is not exactly 40 hex digits. It is 41 hex digits. If this is not used as an address, please prepend '00'. For more information please see https://docs.soliditylang.org/en/develop/types.html#address-literals
|
@ -0,0 +1,7 @@
|
|||||||
|
function suffix(address value) pure suffix returns (address) { return value; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
address x = 0xffffffffffffffffffffffffffffffffffffffff suffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// SyntaxError 9429: (109-158): This looks like an address but has an invalid checksum. Correct checksummed address: "0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF". If this is not used as an address, please prepend '00'. For more information please see https://docs.soliditylang.org/en/develop/types.html#address-literals
|
@ -0,0 +1,7 @@
|
|||||||
|
function suffix(uint[1] memory) pure suffix returns (uint[1] memory) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint[1] x = [42] suffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 2314: (107-113): Expected ';' but got identifier
|
@ -0,0 +1,12 @@
|
|||||||
|
struct Decimal {
|
||||||
|
uint mantissa;
|
||||||
|
uint exponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
function suffix(uint mantissa, uint exponent) pure suffix returns (Decimal memory) { return Decimal(mantissa, exponent); }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
Decimal x = 0.115792089237316195423570985008687907853269984665640564039457584007913129639936 suffix; // 2**256 * 10**-78
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 5503: (211-298): This fractional number cannot be decomposed into a mantissa and decimal exponent that fit the range of parameters of any possible suffix function.
|
@ -0,0 +1,7 @@
|
|||||||
|
function suffix(uint value) pure suffix returns (uint) { return value; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint x = 000.10 suffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 8936: (100-101): Octal numbers not allowed.
|
@ -0,0 +1,7 @@
|
|||||||
|
function suffix(uint value) pure suffix returns (uint) { return value; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint x = 01_23_45 suffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 8936: (100-101): Octal numbers not allowed.
|
@ -0,0 +1,7 @@
|
|||||||
|
function suffix(uint value) pure suffix returns (uint) { return value; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint x = 00 suffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 8936: (100-101): Octal numbers not allowed.
|
@ -0,0 +1,11 @@
|
|||||||
|
function suffix(uint x) pure suffix returns (uint) { return x; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint x = 10e1000 suffix;
|
||||||
|
uint y = 999999999999999999999999999999999999999999999999999999999999999999999999999999 suffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 5503: (92-106): This fractional number cannot be decomposed into a mantissa and decimal exponent that fit the range of parameters of any possible suffix function.
|
||||||
|
// TypeError 8838: (92-106): The type of the literal cannot be converted to the parameter of the suffix function.
|
||||||
|
// TypeError 5503: (121-206): This fractional number cannot be decomposed into a mantissa and decimal exponent that fit the range of parameters of any possible suffix function.
|
||||||
|
// TypeError 8838: (121-206): The type of the literal cannot be converted to the parameter of the suffix function.
|
@ -0,0 +1,31 @@
|
|||||||
|
function asUint(uint x) pure suffix returns (uint) {}
|
||||||
|
function asSint(int x) pure suffix returns (uint) {}
|
||||||
|
function asUdec(uint m, uint e) pure suffix returns (uint) {}
|
||||||
|
function asSdec(int m, uint e) pure suffix returns (uint) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure {
|
||||||
|
1 asUint;
|
||||||
|
1 asSint;
|
||||||
|
1 asUdec;
|
||||||
|
1 asSdec;
|
||||||
|
|
||||||
|
-1 asUint;
|
||||||
|
-1 asSint;
|
||||||
|
-1 asUdec;
|
||||||
|
-1 asSdec;
|
||||||
|
|
||||||
|
1.1 asUdec;
|
||||||
|
1.1 asSdec;
|
||||||
|
|
||||||
|
-1.1 asUdec;
|
||||||
|
-1.1 asSdec;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 4907: (356-365): Built-in unary operator - cannot be applied to type uint256. Unary negation is only allowed for signed integers.
|
||||||
|
// TypeError 4907: (375-384): Built-in unary operator - cannot be applied to type uint256. Unary negation is only allowed for signed integers.
|
||||||
|
// TypeError 4907: (394-403): Built-in unary operator - cannot be applied to type uint256. Unary negation is only allowed for signed integers.
|
||||||
|
// TypeError 4907: (413-422): Built-in unary operator - cannot be applied to type uint256. Unary negation is only allowed for signed integers.
|
||||||
|
// TypeError 4907: (474-485): Built-in unary operator - cannot be applied to type uint256. Unary negation is only allowed for signed integers.
|
||||||
|
// TypeError 4907: (495-506): Built-in unary operator - cannot be applied to type uint256. Unary negation is only allowed for signed integers.
|
@ -0,0 +1,7 @@
|
|||||||
|
function suffix(string memory value) pure suffix returns (string memory) { return value; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
string x = hex"abcd" suffix;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 8838: (120-136): The type of the literal cannot be converted to the parameter of the suffix function.
|
@ -0,0 +1,9 @@
|
|||||||
|
function suffix(uint, uint) pure suffix returns (uint) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public {
|
||||||
|
(1, 2) suffix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 2314: (113-119): Expected ';' but got identifier
|
@ -0,0 +1,11 @@
|
|||||||
|
function suffix(address a) pure suffix returns (address) { return a; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure {
|
||||||
|
0x0000000000000000000000000000000000000000 suffix;
|
||||||
|
0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF suffix;
|
||||||
|
0x1234567890123456789012345678901234567890 suffix;
|
||||||
|
|
||||||
|
0x1234567890_1234567890_1234567890_1234567890 suffix;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
function suffix(bool x) pure suffix returns (bool) {}
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure {
|
||||||
|
true suffix;
|
||||||
|
false suffix;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
function suffix(bytes memory value) pure suffix returns (bytes memory) { return value; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure {
|
||||||
|
"" suffix;
|
||||||
|
'' suffix;
|
||||||
|
"abcd" suffix;
|
||||||
|
'abcd' suffix;
|
||||||
|
hex"abcd" suffix;
|
||||||
|
unicode"😃" suffix;
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user