v3-core icon indicating copy to clipboard operation
v3-core copied to clipboard

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

Open stevieraykatz opened this issue 2 years ago • 2 comments

https://github.com/Uniswap/v3-core/blob/d8b1c635c275d2a9450bd6a78f3fa2484fef73eb/contracts/libraries/FullMath.sol#L64

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

stevieraykatz avatar May 03 '23 23:05 stevieraykatz

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

ashutosh887 avatar Jun 12 '23 12:06 ashutosh887

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

Swapnapratim avatar Jul 15 '23 06:07 Swapnapratim