mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add proper unipmlemented errors for array copying
This commit is contained in:
parent
7a6ad61583
commit
d45bb2aa07
@ -14,7 +14,7 @@ Bugfixes:
|
||||
* Type Checker: Disallow assignments to storage variables of type ``mapping``.
|
||||
* NatSpec: DocString block is terminated when encountering an empty line.
|
||||
* Scanner: Fix bug when two empty NatSpec comments lead to scanning past EOL.
|
||||
|
||||
* Code Generator: Trigger proper unimplemented errors on certain array copy operations.
|
||||
|
||||
### 0.6.8 (2020-05-14)
|
||||
|
||||
|
@ -185,6 +185,13 @@ void ArrayUtils::copyArrayToStorage(ArrayType const& _targetType, ArrayType cons
|
||||
{
|
||||
solAssert(byteOffsetSize == 0, "Byte offset for array as base type.");
|
||||
auto const& sourceBaseArrayType = dynamic_cast<ArrayType const&>(*sourceBaseType);
|
||||
|
||||
solUnimplementedAssert(
|
||||
_sourceType.location() != DataLocation::CallData ||
|
||||
!_sourceType.isDynamicallyEncoded() ||
|
||||
!sourceBaseArrayType.isDynamicallySized(),
|
||||
"Copying nested calldata dynamic arrays to storage is not implemented in the old code generator."
|
||||
);
|
||||
_context << Instruction::DUP3;
|
||||
if (sourceBaseArrayType.location() == DataLocation::Memory)
|
||||
_context << Instruction::MLOAD;
|
||||
|
@ -974,6 +974,14 @@ void CompilerUtils::convertType(
|
||||
}
|
||||
else
|
||||
{
|
||||
if (auto baseType = dynamic_cast<ArrayType const*>(typeOnStack.baseType()))
|
||||
solUnimplementedAssert(
|
||||
typeOnStack.location() != DataLocation::CallData ||
|
||||
!typeOnStack.isDynamicallyEncoded() ||
|
||||
!baseType->isDynamicallySized(),
|
||||
"Copying nested dynamic calldata arrays to memory is not implemented in the old code generator."
|
||||
);
|
||||
|
||||
m_context << u256(0) << Instruction::SWAP1;
|
||||
// stack: <mem start> <source ref> (variably sized) <length> <counter> <mem data pos>
|
||||
auto repeat = m_context.newTag();
|
||||
|
@ -0,0 +1,13 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract Test {
|
||||
struct shouldBug {
|
||||
bytes[2] deadly;
|
||||
}
|
||||
function killer(bytes[2] calldata weapon) pure external {
|
||||
shouldBug(weapon);
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
// UnimplementedFeatureError: Copying nested dynamic calldata arrays to memory is not implemented in the old code generator.
|
@ -0,0 +1,13 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract Test {
|
||||
struct shouldBug {
|
||||
uint256[][2] deadly;
|
||||
}
|
||||
function killer(uint256[][2] calldata weapon) pure external {
|
||||
shouldBug(weapon);
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
// UnimplementedFeatureError: Copying nested dynamic calldata arrays to memory is not implemented in the old code generator.
|
@ -0,0 +1,13 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract Test {
|
||||
struct shouldBug {
|
||||
uint256[][] deadly;
|
||||
}
|
||||
function killer(uint256[][] calldata weapon) pure external {
|
||||
shouldBug(weapon);
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
// UnimplementedFeatureError: Copying nested dynamic calldata arrays to memory is not implemented in the old code generator.
|
@ -0,0 +1,9 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
uint[][2] tmp_i;
|
||||
function i(uint[][2] calldata s) external { tmp_i = s; }
|
||||
}
|
||||
|
||||
// ----
|
||||
// UnimplementedFeatureError: Copying nested calldata dynamic arrays to storage is not implemented in the old code generator.
|
@ -0,0 +1,9 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
uint[][] tmp_i;
|
||||
function i(uint[][] calldata s) external { tmp_i = s; }
|
||||
}
|
||||
|
||||
// ----
|
||||
// UnimplementedFeatureError: Copying nested calldata dynamic arrays to storage is not implemented in the old code generator.
|
Loading…
Reference in New Issue
Block a user