mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Disallow array slicing for arrays with dyanmically encoded base types.
This commit is contained in:
@@ -990,7 +990,8 @@ void CompilerUtils::convertType(
|
||||
solAssert(_targetType == typeOnStack.arrayType(), "");
|
||||
solUnimplementedAssert(
|
||||
typeOnStack.arrayType().location() == DataLocation::CallData &&
|
||||
typeOnStack.arrayType().isDynamicallySized(),
|
||||
typeOnStack.arrayType().isDynamicallySized() &&
|
||||
!typeOnStack.arrayType().baseType()->isDynamicallyEncoded(),
|
||||
""
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -1769,7 +1769,12 @@ bool ExpressionCompiler::visit(IndexAccess const& _indexAccess)
|
||||
case Type::Category::ArraySlice:
|
||||
{
|
||||
auto const& arrayType = dynamic_cast<ArraySliceType const&>(baseType).arrayType();
|
||||
solAssert(arrayType.location() == DataLocation::CallData && arrayType.isDynamicallySized(), "");
|
||||
solAssert(
|
||||
arrayType.location() == DataLocation::CallData &&
|
||||
arrayType.isDynamicallySized() &&
|
||||
!arrayType.baseType()->isDynamicallyEncoded(),
|
||||
""
|
||||
);
|
||||
solAssert(_indexAccess.indexExpression(), "Index expression expected.");
|
||||
|
||||
acceptAndConvert(*_indexAccess.indexExpression(), *TypeProvider::uint256(), true);
|
||||
@@ -1852,7 +1857,12 @@ bool ExpressionCompiler::visit(IndexRangeAccess const& _indexAccess)
|
||||
arrayType = &sliceType->arrayType();
|
||||
|
||||
solAssert(arrayType, "");
|
||||
solUnimplementedAssert(arrayType->location() == DataLocation::CallData && arrayType->isDynamicallySized(), "");
|
||||
solUnimplementedAssert(
|
||||
arrayType->location() == DataLocation::CallData &&
|
||||
arrayType->isDynamicallySized() &&
|
||||
!arrayType->baseType()->isDynamicallyEncoded(),
|
||||
""
|
||||
);
|
||||
|
||||
if (_indexAccess.startExpression())
|
||||
acceptAndConvert(*_indexAccess.startExpression(), *TypeProvider::uint256());
|
||||
|
||||
@@ -1599,6 +1599,7 @@ string YulUtilFunctions::conversionFunction(Type const& _from, Type const& _to)
|
||||
ArraySliceType const& fromType = dynamic_cast<ArraySliceType const&>(_from);
|
||||
ArrayType const& targetType = dynamic_cast<ArrayType const&>(_to);
|
||||
|
||||
solAssert(!fromType.arrayType().baseType()->isDynamicallyEncoded(), "");
|
||||
solAssert(
|
||||
*fromType.arrayType().baseType() == *targetType.baseType(),
|
||||
"Converting arrays of different type is not possible"
|
||||
|
||||
Reference in New Issue
Block a user