pragma solidity ^0.8.0;
library MyLibrary {
function identity(bytes1 self) internal pure returns (bytes1) { return self; }
function identity(bytes2 self) internal pure returns (bytes2) { return self; }
function identity(bytes3 self) internal pure returns (bytes3) { return self; }
}
contract MyContract {
using MyLibrary for *;
function fn1(bytes1 value) external pure returns (bytes1) { return value.identity(); }
function fn3(bytes2 value) external pure returns (bytes2) { return value.identity(); }
function fn3(bytes3 value) external pure returns (bytes3) { return value.identity(); }
}
When trying to compile that, I'm getting errors for fn1 and fn2. My understanding is that the compiler believes that there exist multiple versions of identity that match bytes1 and bytes2. That may be because some bytesXx are implicitely convertible to bigger ones?
Only having a single version of identity forces the result to be a bytes3 ...
A fix availble today if to redefine all values types I'm using as UDVT, but that is making all the code more complex.
Environment
Compiler version: 0.8.26
Target EVM version (as per compiler settings): default
Description
Lets consider the following code
When trying to compile that, I'm getting errors for
fn1
andfn2
. My understanding is that the compiler believes that there exist multiple versions ofidentity
that matchbytes1
andbytes2
. That may be because some bytesXx are implicitely convertible to bigger ones?Only having a single version of identity forces the result to be a bytes3 ...
A fix availble today if to redefine all values types I'm using as UDVT, but that is making all the code more complex.
Environment
Steps to Reproduce
See above.