mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #12417 from nishant-sachdeva/invalid_ir_generated_during_copy_of_dynamically_sized_storage_arrays_of_function_type
Added sameType check for fromType and toType in YulUtilFunctions.cpp and relevant tests in semanticTests
This commit is contained in:
commit
1594518cfc
@ -4,12 +4,27 @@ contract C {
|
|||||||
function testFunction3() public {}
|
function testFunction3() public {}
|
||||||
|
|
||||||
|
|
||||||
function() external [3] externalArray0;
|
function() external [] externalArray0;
|
||||||
function() external [3] externalArray1 = [
|
function() external [] externalArray1;
|
||||||
this.testFunction1,
|
|
||||||
this.testFunction2,
|
function() internal [] internalArray0;
|
||||||
this.testFunction3
|
function() internal [] internalArray1;
|
||||||
];
|
|
||||||
|
constructor() {
|
||||||
|
externalArray0 = new function() external[] (3);
|
||||||
|
externalArray1 = [
|
||||||
|
this.testFunction1,
|
||||||
|
this.testFunction2,
|
||||||
|
this.testFunction3
|
||||||
|
];
|
||||||
|
|
||||||
|
internalArray0 = new function() internal[] (3);
|
||||||
|
internalArray1 = [
|
||||||
|
testFunction1,
|
||||||
|
testFunction2,
|
||||||
|
testFunction3
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
function copyExternalStorageArrayOfFunctionType() external returns (bool) {
|
function copyExternalStorageArrayOfFunctionType() external returns (bool) {
|
||||||
assert(keccak256(abi.encode(externalArray0)) != keccak256(abi.encode(externalArray1)));
|
assert(keccak256(abi.encode(externalArray0)) != keccak256(abi.encode(externalArray1)));
|
||||||
@ -17,27 +32,22 @@ contract C {
|
|||||||
return keccak256(abi.encode(externalArray0)) == keccak256(abi.encode(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) {
|
function copyInternalArrayOfFunctionType() external returns (bool) {
|
||||||
internalArray0 = internalArray1;
|
internalArray0 = internalArray1;
|
||||||
assert(internalArray0.length == 3);
|
assert(internalArray0.length == 3);
|
||||||
|
|
||||||
return
|
return
|
||||||
internalArray0.length == internalArray1.length &&
|
internalArray0.length == internalArray1.length &&
|
||||||
internalArray0[0] == internalArray1[0] &&
|
internalArray0[0] == internalArray1[0] &&
|
||||||
internalArray0[1] == internalArray1[1] &&
|
internalArray0[1] == internalArray1[1] &&
|
||||||
internalArray0[2] == internalArray1[2];
|
internalArray0[2] == internalArray1[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ====
|
// ====
|
||||||
// compileViaYul: also
|
// compileViaYul: also
|
||||||
// ----
|
// ----
|
||||||
// copyExternalStorageArrayOfFunctionType() -> true
|
// copyExternalStorageArrayOfFunctionType() -> true
|
||||||
// gas legacy: 103412
|
// gas irOptimized: 104701
|
||||||
|
// gas legacy: 108725
|
||||||
|
// gas legacyOptimized: 102441
|
||||||
// copyInternalArrayOfFunctionType() -> true
|
// copyInternalArrayOfFunctionType() -> true
|
||||||
|
@ -3,12 +3,29 @@ contract C {
|
|||||||
function testFunction2() public view {}
|
function testFunction2() public view {}
|
||||||
function testFunction3() public pure {}
|
function testFunction3() public pure {}
|
||||||
|
|
||||||
function() external [3] externalArray0;
|
|
||||||
function() external [3] externalArray1 = [
|
function() external [] externalArray0;
|
||||||
this.testFunction1,
|
function() external [] externalArray1;
|
||||||
this.testFunction2,
|
|
||||||
this.testFunction3
|
function() internal [] internalArray0;
|
||||||
];
|
function() internal [] internalArray1;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
externalArray0 = new function() external[] (3);
|
||||||
|
externalArray1 = [
|
||||||
|
this.testFunction1,
|
||||||
|
this.testFunction2,
|
||||||
|
this.testFunction3
|
||||||
|
];
|
||||||
|
|
||||||
|
internalArray0 = new function() internal[] (3);
|
||||||
|
internalArray1 = [
|
||||||
|
testFunction1,
|
||||||
|
testFunction2,
|
||||||
|
testFunction3
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function copyExternalStorageArraysOfFunctionType() external returns (bool)
|
function copyExternalStorageArraysOfFunctionType() external returns (bool)
|
||||||
{
|
{
|
||||||
@ -17,29 +34,24 @@ contract C {
|
|||||||
return keccak256(abi.encodePacked(externalArray0)) == keccak256(abi.encodePacked(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)
|
function copyInternalArrayOfFunctionType() external returns (bool)
|
||||||
{
|
{
|
||||||
internalArray0 = internalArray1;
|
internalArray0 = internalArray1;
|
||||||
assert(internalArray0.length == 3);
|
assert(internalArray0.length == 3);
|
||||||
|
|
||||||
return
|
return
|
||||||
internalArray0.length == internalArray1.length &&
|
internalArray0.length == internalArray1.length &&
|
||||||
internalArray0[0] == internalArray1[0] &&
|
internalArray0[0] == internalArray1[0] &&
|
||||||
internalArray0[1] == internalArray1[1] &&
|
internalArray0[1] == internalArray1[1] &&
|
||||||
internalArray0[2] == internalArray1[2];
|
internalArray0[2] == internalArray1[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ====
|
// ====
|
||||||
// compileViaYul: also
|
// compileViaYul: also
|
||||||
// ----
|
// ----
|
||||||
// copyExternalStorageArraysOfFunctionType() -> true
|
// copyExternalStorageArraysOfFunctionType() -> true
|
||||||
// gas legacy: 103398
|
// gas irOptimized: 104372
|
||||||
|
// gas legacy: 108462
|
||||||
|
// gas legacyOptimized: 102174
|
||||||
// copyInternalArrayOfFunctionType() -> true
|
// copyInternalArrayOfFunctionType() -> true
|
||||||
// gas legacy: 104178
|
// gas legacy: 104178
|
||||||
|
Loading…
Reference in New Issue
Block a user