Skip to content

RationalNumberType::isImplicitlyConvertibleTo Refactor.#4304

Closed
khanrn wants to merge 9 commits intoargotorg:developfrom
khanrn:libsolidity/ast/Types
Closed

RationalNumberType::isImplicitlyConvertibleTo Refactor.#4304
khanrn wants to merge 9 commits intoargotorg:developfrom
khanrn:libsolidity/ast/Types

Conversation

@khanrn
Copy link
Copy Markdown
Contributor

@khanrn khanrn commented Jun 15, 2018

No description provided.

@khanrn
Copy link
Copy Markdown
Contributor Author

khanrn commented Jun 16, 2018

I think there is an issue with auto assignment. I'm working on it.

Copy link
Copy Markdown
Collaborator

@erak erak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rnaby Please also check the syntax tests (can be found in test/libsolidity/syntaxTests) and the external tests. Some of them are currently failing because of your changes.

@khanrn
Copy link
Copy Markdown
Contributor Author

khanrn commented Jun 18, 2018

@bit-shift I think now it passes all the tests. 👍 Actually I saw early that it wasn't passing all the tests, but couldn't figured out where is the issue. Now did figure out the issue and fixed. 🙂

@khanrn
Copy link
Copy Markdown
Contributor Author

khanrn commented Jun 19, 2018

Now I think this pull request is ready to review again. 🙂

@erak
Copy link
Copy Markdown
Collaborator

erak commented Jun 20, 2018

@rnaby Can you please squash the commits?

@khanrn khanrn force-pushed the libsolidity/ast/Types branch from 430bf34 to 30a2d48 Compare June 20, 2018 17:11
@khanrn
Copy link
Copy Markdown
Contributor Author

khanrn commented Jun 20, 2018

@bit-shift Commits has been squashed to a single commit. 🙂

else if (targetType.isSigned() && -m_value.numerator() <= (u256(1) << (targetType.numBits() - forSignBit)))
return true;
return false;
return m_value.numerator() <= (u256(-1) >> (256 - targetType.numBits() + forSignBit)) ? true : false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the ? true : false, I think it complicates it and makes it harder to read (same below).

return m_value.numerator() <= (u256(-1) >> (256 - targetType.numBits() + forSignBit)) ? true : false;
if (targetType.isSigned())
return -m_value.numerator() <= (u256(1) << (targetType.numBits() - forSignBit)) ? true : false;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please either keep the else if or add a return false here (preferrably add return false in any case because the function is rather long.

return -m_value.numerator() <= (u256(1) << (targetType.numBits() - forSignBit)) ? true : false;
}
else if (_convertTo.category() == Category::FixedPoint)
if (_convertTo.category() == Category::FixedPoint)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also be changed to a switch (_convertTo.category()) { ... }

}
else
return false;
return !isFractional() && integerType() ? fixedBytes.numBytes() * 8 >= integerType()->numBits() : false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually find the previous version much better to read. It could be improved by removing the !, i.e.

if (isFractional())
  return false;
else if (integerType())
  return fixedBytes.numBytes() * 8 >= integerType()->numBits();
else
  return false;

axic and others added 9 commits June 24, 2018 07:38
This patch enfoces an error when it encounters an empty struct,
effectively eliminating the deprecation warning.

Also adjust 419_interface_structs to explicitely test for (non-empty) structs,
as this behaviour "may" change in the future.
@khanrn khanrn force-pushed the libsolidity/ast/Types branch from 6b8d387 to 098f4da Compare June 24, 2018 02:03
@khanrn
Copy link
Copy Markdown
Contributor Author

khanrn commented Jun 24, 2018

Some merging issue happened, so will submit a different PR.

@khanrn khanrn closed this Jun 24, 2018
@khanrn khanrn deleted the libsolidity/ast/Types branch June 24, 2018 02:09
@khanrn
Copy link
Copy Markdown
Contributor Author

khanrn commented Jun 24, 2018

@chriseth and @bit-shift A cleaned version of this PR is now at #4342 PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants