Private library functions invisible via library name can still be accessed when attached via `using for`
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 29
Description
## Description
Described in [comment](https://github.com/argotorg/solidity/pull/16625#discussion_r3237079340)
```solidity
library L {
function f(bytes1) private {}
using {f} for bytes1;
function g(bytes2) private {}
using L for bytes2;
function test() public {
bytes1(0).f(); // OK
L.f(0); // Error: Member "f" not found or not visible after argument-dependent lookup in type(library L).
bytes2(0).g(); // Error: Member "g" not found or not visible after argument-dependent lookup in bytes2.
L.g(0); // Error: Member "g" not found or not visible after argument-dependent lookup in type(library L).
}
}
```
This inconsistency should be fix. We should allow private functions in library to be attached to a type inside a library and can be used inside the library only. Attaching with `using L for` inside the library should attached all the functions to the type.
## Environment
- Compiler version: 0.8.35
- Compilation pipeline (legacy, IR, EOF):
- Target EVM version (as per compiler settings):
- Framework/IDE (e.g. Foundry, Hardhat, Remix):
- EVM execution environment / backend / blockchain client:
- Operating system:
Contributor guide
Research direction
Start by compiling the Solidity example from the issue and compare member access through `using {f} for bytes1` with `using L for bytes2`. Trace the compiler's handling of library visibility and using-for attachment, then add regression coverage showing that private functions are usable only inside the library and that `using L for` attaches the intended functions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, solidity
- Domain
- blockchain, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100