Merge pull request #11459 from ethereum/yulFixedPointTypesAssertions

[Sol->Yul] Adding assertion in order to give better error messages for fixed point types
This commit is contained in:
Alex Beregszaszi 2021-05-31 15:32:14 +01:00 committed by GitHub
commit 7eed8b69e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2718,7 +2718,8 @@ string IRGeneratorForStatements::binaryOperation(
solAssert( solAssert(
_type.category() == Type::Category::Integer || _type.category() == Type::Category::Integer ||
_type.category() == Type::Category::FixedBytes, _type.category() == Type::Category::FixedBytes,
""); ""
);
switch (_operator) switch (_operator)
{ {
case Token::BitOr: fun = "or"; break; case Token::BitOr: fun = "or"; break;
@ -2729,6 +2730,10 @@ string IRGeneratorForStatements::binaryOperation(
} }
else if (TokenTraits::isArithmeticOp(_operator)) else if (TokenTraits::isArithmeticOp(_operator))
{ {
solUnimplementedAssert(
_type.category() != Type::Category::FixedPoint,
"Not yet implemented - FixedPointType."
);
IntegerType const* type = dynamic_cast<IntegerType const*>(&_type); IntegerType const* type = dynamic_cast<IntegerType const*>(&_type);
solAssert(type, ""); solAssert(type, "");
bool checked = m_context.arithmetic() == Arithmetic::Checked; bool checked = m_context.arithmetic() == Arithmetic::Checked;
@ -2765,7 +2770,8 @@ std::string IRGeneratorForStatements::shiftOperation(
) )
{ {
solUnimplementedAssert( solUnimplementedAssert(
_amountToShift.type().category() != Type::Category::FixedPoint, _amountToShift.type().category() != Type::Category::FixedPoint &&
_value.type().category() != Type::Category::FixedPoint,
"Not yet implemented - FixedPointType." "Not yet implemented - FixedPointType."
); );
IntegerType const* amountType = dynamic_cast<IntegerType const*>(&_amountToShift.type()); IntegerType const* amountType = dynamic_cast<IntegerType const*>(&_amountToShift.type());