Fix bug in typechecking when comparing rational literals

This commit is contained in:
Jason Cobb 2018-04-10 17:35:15 -04:00 committed by chriseth
parent 41d81a7432
commit 3b7b962b66
3 changed files with 11 additions and 3 deletions

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.

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();

View File

@ -0,0 +1,7 @@
contract test {
function f(int8 x) public pure {
if (x == 1) {}
if (1 == x) {}
}
}
// ----