Fix exponentiation bug

This commit is contained in:
Harikrishnan Mulackal
2020-05-13 13:53:06 +05:30
parent cccf16ec35
commit 47e9a13e8a
4 changed files with 25 additions and 0 deletions
+7
View File
@@ -613,6 +613,13 @@ TypeResult IntegerType::binaryOperatorResult(Token _operator, Type const* _other
}
else if (dynamic_cast<FixedPointType const*>(_other))
return nullptr;
else if (auto rationalNumberType = dynamic_cast<RationalNumberType const*>(_other))
{
if (rationalNumberType->isFractional())
return TypeResult::err("Exponent is fractional.");
if (!rationalNumberType->integerType())
return TypeResult::err("Exponent too large.");
}
return this;
}