Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unary operator misused, fails to compile with solidity v8.18 #641

Open
stevieraykatz opened this issue May 3, 2023 · 2 comments
Open

Unary operator misused, fails to compile with solidity v8.18 #641

stevieraykatz opened this issue May 3, 2023 · 2 comments

Comments

@stevieraykatz
Copy link

stevieraykatz commented May 3, 2023

uint256 twos = -denominator & denominator;

TypeError: Unary operator - cannot be applied to type uint256
  --> @uniswap/v3-core/contracts/libraries/FullMath.sol:64:24:
   |
64 |         uint256 twos = -denominator & denominator;

This line can be safely replaced by the following which is compatible with the newer solidity compilers:

uint256 twos = denominator & (~denominator + 1);
@ashutosh887
Copy link

I would like to work on this @stevieraykatz @NoahZinsmeister @danrobinson

Swapnapratim added a commit to Swapnapratim/Swapnapratim-v3-core that referenced this issue Jul 15, 2023
@Swapnapratim
Copy link

@stevieraykatz @NoahZinsmeister @danrobinson I have submitted a PR on this issue.

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

No branches or pull requests

3 participants