diff --git a/test/libsolidity/semanticTests/array/bytes_to_fixed_bytes_simple.sol b/test/libsolidity/semanticTests/array/bytes_to_fixed_bytes_simple.sol new file mode 100644 index 000000000000..720cadb3e965 --- /dev/null +++ b/test/libsolidity/semanticTests/array/bytes_to_fixed_bytes_simple.sol @@ -0,0 +1,28 @@ +contract C { + bytes s = "abcdefghabcdefgh"; + bytes sLong = "abcdefghabcdefghabcdefghabcdefgh"; + + function fromMemory(bytes memory m) public returns (bytes16) { + return bytes16(m); + } + function fromCalldata(bytes calldata c) external returns (bytes16) { + return bytes16(c); + } + function fromStorage() external returns (bytes16) { + return bytes16(s); + } + function fromStorageLong() external returns (bytes32) { + return bytes32(sLong); + } + function fromSlice(bytes calldata c) external returns (bytes8) { + return bytes8(c[8:]); + } +} +// ==== +// compileViaYul: also +// ---- +// fromMemory(bytes): 0x20, 16, "abcdefghabcdefgh" -> "abcdefghabcdefgh" +// fromCalldata(bytes): 0x20, 16, "abcdefghabcdefgh" -> "abcdefghabcdefgh" +// fromStorage() -> "abcdefghabcdefgh" +// fromStorageLong() -> "abcdefghabcdefghabcdefghabcdefgh" +// fromSlice(bytes): 0x20, 16, "abcdefghabcdefgh" -> "abcdefgh"