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

Explicit type conversion not allowed from "int24" to "uint8".

Open shubhamanandspeqto opened this issue 2 years ago • 4 comments

i am getting same error , how to fix this. KIndly help me

shubhamanandspeqto avatar Jan 10 '23 10:01 shubhamanandspeqto

This error is in TickBitmap.sol file

my pragma solidity >=0.5.0; my hardhat.config.ts solidity version: '0.8.17', image: https://user-images.githubusercontent.com/91736262/211527874-8e0aa79b-b25d-4d89-b89e-3b456e448ee8.png

shubhamanandspeqto avatar Jan 10 '23 10:01 shubhamanandspeqto

I'm getting the same issue. Using two solidity compilers, 0.7.6 and 0.8.17

Lockwu6749 avatar Jan 16 '23 11:01 Lockwu6749

Solidity v0.8 disallowed conversions in which there are multiple changes. int24 to uint8 requires change in width and sign. Hence using uint8(uint24(tick % 256)) , would solve the problem.

jksgfsdfd avatar Apr 02 '23 10:04 jksgfsdfd

I got same error in TickBitmap.sol. -Original Code library TickBitmap { function position(int24 tick) private pure returns (int16 wordPos, uint8 bitPos) { wordPos = int16(tick >> 8); bitPos = uint8(tick % 0xFF); }

-Fixed Code library TickBitmap { function position(int24 tick) private pure returns (int16 wordPos, uint8 bitPos) { wordPos = int16(tick >> 8); bitPos = uint8(uint24(tick % 256)); }

Solidity Version: pragma solidity >=0.5.0; Remix Version: pragma solidity >=0.7.6;

This code is currently working fine.

etherpan avatar Apr 12 '24 17:04 etherpan