Change assertions to align to TypeChecker.

This commit is contained in:
Djordje Mijovic
2020-12-15 09:21:50 +01:00
parent d479c98920
commit 64f0120622
3 changed files with 38 additions and 12 deletions
+6 -6
View File
@@ -1050,18 +1050,18 @@ void CompilerUtils::convertType(
}
case Type::Category::ArraySlice:
{
auto& typeOnStack = dynamic_cast<ArraySliceType const&>(_typeOnStack);
solAssert(_targetType.category() == Type::Category::Array, "");
auto& typeOnStack = dynamic_cast<ArraySliceType const&>(_typeOnStack);
auto const& targetArrayType = dynamic_cast<ArrayType const&>(_targetType);
solAssert(targetArrayType == *typeOnStack.arrayType().copyForLocation(targetArrayType.location(), false), "");
if (!_targetType.dataStoredIn(DataLocation::CallData))
return convertType(typeOnStack.arrayType(), _targetType);
solUnimplementedAssert(
typeOnStack.arrayType().location() == DataLocation::CallData &&
solAssert(typeOnStack.arrayType().isImplicitlyConvertibleTo(targetArrayType), "");
solAssert(
typeOnStack.arrayType().dataStoredIn(DataLocation::CallData) &&
typeOnStack.arrayType().isDynamicallySized() &&
!typeOnStack.arrayType().baseType()->isDynamicallyEncoded(),
""
);
if (!_targetType.dataStoredIn(DataLocation::CallData))
return convertType(typeOnStack.arrayType(), _targetType);
break;
}
case Type::Category::Struct:
+5 -6
View File
@@ -2848,17 +2848,16 @@ string YulUtilFunctions::conversionFunction(Type const& _from, Type const& _to)
}
else if (_from.category() == Type::Category::ArraySlice)
{
solAssert(_from.isDynamicallySized(), "");
solAssert(_from.dataStoredIn(DataLocation::CallData), "");
solAssert(_to.category() == Type::Category::Array, "");
auto const& fromType = dynamic_cast<ArraySliceType const&>(_from);
auto const& targetType = dynamic_cast<ArrayType const&>(_to);
solAssert(!fromType.arrayType().baseType()->isDynamicallyEncoded(), "");
solAssert(fromType.arrayType().isImplicitlyConvertibleTo(targetType), "");
solAssert(
*fromType.arrayType().baseType() == *targetType.baseType(),
"Converting arrays of different type is not possible"
fromType.arrayType().dataStoredIn(DataLocation::CallData) &&
fromType.arrayType().isDynamicallySized() &&
!fromType.arrayType().baseType()->isDynamicallyEncoded(),
""
);
if (!targetType.dataStoredIn(DataLocation::CallData))