Merge pull request #3799 from meowingtwurtle/fixLiteralComparisons

Fix bug in typechecking when comparing rational literals
This commit is contained in:
chriseth
2018-04-11 14:39:13 +02:00
committed by GitHub
3 changed files with 11 additions and 3 deletions
+1
View File
@@ -27,6 +27,7 @@ Bugfixes:
* DocString Parser: Fix error message for empty descriptions.
* Standard JSON: Support ``constantinople`` as ``evmVersion`` properly.
* Type Checker: Fix detection of recursive structs.
* Type Checker: Fix asymmetry bug when comparing with literal numbers.
* Type System: Improve error message when attempting to shift by a fractional amount.
* Type System: Make external library functions accessible.
* Type System: Prevent encoding of weird types.
+3 -3
View File
@@ -839,10 +839,10 @@ TypePointer RationalNumberType::binaryOperatorResult(Token::Value _operator, Typ
{
if (_other->category() == Category::Integer || _other->category() == Category::FixedPoint)
{
auto mobile = mobileType();
if (!mobile)
auto commonType = Type::commonType(shared_from_this(), _other);
if (!commonType)
return TypePointer();
return mobile->binaryOperatorResult(_operator, _other);
return commonType->binaryOperatorResult(_operator, _other);
}
else if (_other->category() != category())
return TypePointer();
@@ -0,0 +1,7 @@
contract test {
function f(int8 x) public pure {
if (x == 1) {}
if (1 == x) {}
}
}
// ----