mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Added sameType check for fromType and toType in YulUtilFunctions.cpp and relevant tests in semanticTests
This commit is contained in:
+43
@@ -0,0 +1,43 @@
|
||||
contract C {
|
||||
function testFunction1() public {}
|
||||
function testFunction2() public {}
|
||||
function testFunction3() public {}
|
||||
|
||||
|
||||
function() external [3] externalArray0;
|
||||
function() external [3] externalArray1 = [
|
||||
this.testFunction1,
|
||||
this.testFunction2,
|
||||
this.testFunction3
|
||||
];
|
||||
|
||||
function copyExternalStorageArrayOfFunctionType() external returns (bool) {
|
||||
assert(keccak256(abi.encode(externalArray0)) != keccak256(abi.encode(externalArray1)));
|
||||
externalArray0 = externalArray1;
|
||||
return keccak256(abi.encode(externalArray0)) == keccak256(abi.encode(externalArray1));
|
||||
}
|
||||
|
||||
function() internal [3] internalArray0;
|
||||
function() internal [3] internalArray1 = [
|
||||
testFunction1,
|
||||
testFunction2,
|
||||
testFunction3
|
||||
];
|
||||
|
||||
function copyInternalArrayOfFunctionType() external returns (bool) {
|
||||
internalArray0 = internalArray1;
|
||||
assert(internalArray0.length == 3);
|
||||
|
||||
return
|
||||
internalArray0.length == internalArray1.length &&
|
||||
internalArray0[0] == internalArray1[0] &&
|
||||
internalArray0[1] == internalArray1[1] &&
|
||||
internalArray0[2] == internalArray1[2];
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// copyExternalStorageArrayOfFunctionType() -> true
|
||||
// gas legacy: 103412
|
||||
// copyInternalArrayOfFunctionType() -> true
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
contract C {
|
||||
function testFunction1() public {}
|
||||
function testFunction2() public view {}
|
||||
function testFunction3() public pure {}
|
||||
|
||||
function() external [3] externalArray0;
|
||||
function() external [3] externalArray1 = [
|
||||
this.testFunction1,
|
||||
this.testFunction2,
|
||||
this.testFunction3
|
||||
];
|
||||
|
||||
function copyExternalStorageArraysOfFunctionType() external returns (bool)
|
||||
{
|
||||
assert(keccak256(abi.encodePacked(externalArray0)) != keccak256(abi.encodePacked(externalArray1)));
|
||||
externalArray0 = externalArray1;
|
||||
return keccak256(abi.encodePacked(externalArray0)) == keccak256(abi.encodePacked(externalArray1));
|
||||
}
|
||||
|
||||
function() internal [3] internalArray0;
|
||||
function() internal [3] internalArray1 = [
|
||||
testFunction1,
|
||||
testFunction2,
|
||||
testFunction3
|
||||
];
|
||||
|
||||
function copyInternalArrayOfFunctionType() external returns (bool)
|
||||
{
|
||||
internalArray0 = internalArray1;
|
||||
assert(internalArray0.length == 3);
|
||||
|
||||
return
|
||||
internalArray0.length == internalArray1.length &&
|
||||
internalArray0[0] == internalArray1[0] &&
|
||||
internalArray0[1] == internalArray1[1] &&
|
||||
internalArray0[2] == internalArray1[2];
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// copyExternalStorageArraysOfFunctionType() -> true
|
||||
// gas legacy: 103398
|
||||
// copyInternalArrayOfFunctionType() -> true
|
||||
// gas legacy: 104178
|
||||
+1
-1
@@ -18,6 +18,6 @@ contract C {
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// test() -> 7
|
||||
// gas irOptimized: 126552
|
||||
// gas irOptimized: 124080
|
||||
// gas legacy: 205196
|
||||
// gas legacyOptimized: 204987
|
||||
Reference in New Issue
Block a user