diff --git a/libsolidity/codegen/YulUtilFunctions.cpp b/libsolidity/codegen/YulUtilFunctions.cpp index 32d96369c..ad4ad2198 100644 --- a/libsolidity/codegen/YulUtilFunctions.cpp +++ b/libsolidity/codegen/YulUtilFunctions.cpp @@ -1542,7 +1542,7 @@ string YulUtilFunctions::copyArrayToStorageFunction(ArrayType const& _fromType, (elementSlot, elementOffset, ) - srcPtr := add(srcPtr, ) + srcPtr := add(srcPtr, ) elementOffset := add(elementOffset, ) @@ -1552,7 +1552,6 @@ string YulUtilFunctions::copyArrayToStorageFunction(ArrayType const& _fromType, } elementSlot := add(elementSlot, ) - elementOffset := 0 } } @@ -1568,7 +1567,6 @@ string YulUtilFunctions::copyArrayToStorageFunction(ArrayType const& _fromType, templ("fromCalldata", fromCalldata); templ("isToDynamic", _toType.isDynamicallySized()); templ("srcDataLocation", arrayDataAreaFunction(_fromType)); - templ("isFromMemoryDynamic", _fromType.isDynamicallySized() && _fromType.dataStoredIn(DataLocation::Memory)); if (fromCalldata) { templ("dynamicallySizedBase", _fromType.baseType()->isDynamicallySized()); @@ -1589,7 +1587,13 @@ string YulUtilFunctions::copyArrayToStorageFunction(ArrayType const& _fromType, _fromType.baseType()->stackItems().size() )); templ("updateStorageValue", updateStorageValueFunction(*_fromType.baseType(), *_toType.baseType())); - templ("stride", to_string(fromCalldata ? _fromType.calldataStride() : _fromType.memoryStride())); + templ("srcStride", + fromCalldata ? + to_string(_fromType.calldataStride()) : + fromMemory ? + to_string(_fromType.memoryStride()) : + formatNumber(_fromType.baseType()->storageSize()) + ); templ("multipleItemsPerSlot", _toType.storageStride() <= 16); templ("storageStride", to_string(_toType.storageStride())); templ("storageSize", _toType.baseType()->storageSize().str()); diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol b/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol index 9330d3162..bd4b1ea92 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol @@ -11,5 +11,7 @@ contract c { } } +// ==== +// compileViaYul: also // ---- // test(uint256[2][]): 32, 3, 7, 8, 9, 10, 11, 12 -> 10 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol index 5c53eaa77..097c86dfe 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol @@ -15,6 +15,8 @@ contract c { data2 = data1; } } +// ==== +// compileViaYul: also // ---- // test() -> 4, 5 // storage: empty