From 472fb21ee00aeec35dd8726d9d7c3d7e23050c97 Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Thu, 14 May 2020 12:34:37 +0200 Subject: [PATCH] [Sol->Yul] Enabling new bytes(n) --- libsolidity/codegen/YulUtilFunctions.cpp | 2 -- .../abiEncoderV1/abi_encode_calldata_slice.sol | 1 + .../abiEncoderV2/abi_encode_calldata_slice.sol | 1 + .../semanticTests/array/create_memory_byte_array.sol | 12 ++++++++++++ .../inlineAssembly/inline_assembly_memory_access.sol | 2 ++ 5 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 test/libsolidity/semanticTests/array/create_memory_byte_array.sol diff --git a/libsolidity/codegen/YulUtilFunctions.cpp b/libsolidity/codegen/YulUtilFunctions.cpp index 4fd681e1f..34b2e1279 100644 --- a/libsolidity/codegen/YulUtilFunctions.cpp +++ b/libsolidity/codegen/YulUtilFunctions.cpp @@ -1499,8 +1499,6 @@ string YulUtilFunctions::zeroComplexMemoryArrayFunction(ArrayType const& _type) string YulUtilFunctions::allocateAndInitializeMemoryArrayFunction(ArrayType const& _type) { - solUnimplementedAssert(!_type.isByteArray(), ""); - string functionName = "allocate_and_zero_memory_array_" + _type.identifier(); return m_functionCollector.createFunction(functionName, [&]() { return Whiskers(R"( diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol index 917704e53..aaffb5b4b 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol @@ -56,6 +56,7 @@ contract C { } } // ==== +// compileViaYul: also // EVMVersion: >homestead // ---- // test_bytes() -> diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol index 1f1444672..6253039f1 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol @@ -57,6 +57,7 @@ contract C { } } // ==== +// compileViaYul: also // EVMVersion: >homestead // ---- // test_bytes() -> diff --git a/test/libsolidity/semanticTests/array/create_memory_byte_array.sol b/test/libsolidity/semanticTests/array/create_memory_byte_array.sol new file mode 100644 index 000000000..67dcbffc3 --- /dev/null +++ b/test/libsolidity/semanticTests/array/create_memory_byte_array.sol @@ -0,0 +1,12 @@ +contract C { + function f() public returns (bytes1) { + bytes memory x = new bytes(35); + assert(x.length == 35); + x[34] = "A"; + return (x[34]); + } +} +// ==== +// compileViaYul: also +// ---- +// f() -> "A" diff --git a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_memory_access.sol b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_memory_access.sol index b43b5f611..857af4243 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_memory_access.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_memory_access.sol @@ -9,5 +9,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // test() -> 0x20, 0x5, "12345"