From cad4f740126e5cfc171b74c4795de8ccbe6fdeb8 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 11 Dec 2020 23:54:14 +0000 Subject: [PATCH] Unary minus is not implemented for fixed point type --- libsolidity/codegen/ExpressionCompiler.cpp | 4 ++++ libsolidity/codegen/YulUtilFunctions.cpp | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index a93ba02e0..2abf03453 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -453,6 +453,10 @@ bool ExpressionCompiler::visit(UnaryOperation const& _unaryOperation) // unary add, so basically no-op break; case Token::Sub: // - + solUnimplementedAssert( + type.category() != Type::Category::FixedPoint, + "Not yet implemented - FixedPointType." + ); if (m_context.arithmetic() == Arithmetic::Checked) m_context.callYulFunction(m_context.utilFunctions().negateNumberCheckedFunction(type), 1, 1); else diff --git a/libsolidity/codegen/YulUtilFunctions.cpp b/libsolidity/codegen/YulUtilFunctions.cpp index dc7a0c262..383e782ee 100644 --- a/libsolidity/codegen/YulUtilFunctions.cpp +++ b/libsolidity/codegen/YulUtilFunctions.cpp @@ -3484,6 +3484,7 @@ string YulUtilFunctions::forwardingRevertFunction() std::string YulUtilFunctions::decrementCheckedFunction(Type const& _type) { + solAssert(_type.category() == Type::Category::Integer, ""); IntegerType const& type = dynamic_cast(_type); string const functionName = "decrement_" + _type.identifier(); @@ -3506,6 +3507,7 @@ std::string YulUtilFunctions::decrementCheckedFunction(Type const& _type) std::string YulUtilFunctions::decrementWrappingFunction(Type const& _type) { + solAssert(_type.category() == Type::Category::Integer, ""); IntegerType const& type = dynamic_cast(_type); string const functionName = "decrement_wrapping_" + _type.identifier(); @@ -3524,6 +3526,7 @@ std::string YulUtilFunctions::decrementWrappingFunction(Type const& _type) std::string YulUtilFunctions::incrementCheckedFunction(Type const& _type) { + solAssert(_type.category() == Type::Category::Integer, ""); IntegerType const& type = dynamic_cast(_type); string const functionName = "increment_" + _type.identifier(); @@ -3546,6 +3549,7 @@ std::string YulUtilFunctions::incrementCheckedFunction(Type const& _type) std::string YulUtilFunctions::incrementWrappingFunction(Type const& _type) { + solAssert(_type.category() == Type::Category::Integer, ""); IntegerType const& type = dynamic_cast(_type); string const functionName = "increment_wrapping_" + _type.identifier(); @@ -3564,6 +3568,7 @@ std::string YulUtilFunctions::incrementWrappingFunction(Type const& _type) string YulUtilFunctions::negateNumberCheckedFunction(Type const& _type) { + solAssert(_type.category() == Type::Category::Integer, ""); IntegerType const& type = dynamic_cast(_type); solAssert(type.isSigned(), "Expected signed type!"); @@ -3586,6 +3591,7 @@ string YulUtilFunctions::negateNumberCheckedFunction(Type const& _type) string YulUtilFunctions::negateNumberWrappingFunction(Type const& _type) { + solAssert(_type.category() == Type::Category::Integer, ""); IntegerType const& type = dynamic_cast(_type); solAssert(type.isSigned(), "Expected signed type!");