argotorg / argotorg/solidity

Member not unique after argument-dependent lookup, really ?

Open
#15,144 0 comments 2 reactions 0 assignees View on GitHub
bug :bug:
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
2d 19h
Merged PRs (30d)
29

Description

## Description

Lets consider the following code

```solidity
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
- Framework/IDE (e.g. Truffle or Remix): Remix
- EVM execution environment / backend / blockchain client: irrelevant
- Operating system: irrelevant

## Steps to Reproduce

See above.

Contributor guide

Open the contributing guide

Research direction

Use the supplied contract as the reproduction and compile it with Solidity 0.8.26 to confirm the diagnostics for the overloaded identity calls. Trace the compiler's argument-dependent lookup and overload-resolution behavior for `using MyLibrary for *`; done means the intended behavior is established and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
solidity
Domain
blockchain, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.