ICE in `TypeChecker::visit(UnaryOperation)` when duplicate `using for` unary operator bindings include a self-referential call
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 21
Description
The compiler panics with `Solidity assertion failed` in [`libsolidity/analysis/TypeChecker.cpp:1641`](https://github.com/ethereum/solidity/blob/9be66192f9db40e5a43f71fc78e06b2f35e9ccdd/libsolidity/analysis/TypeChecker.cpp#L1641) when two functions are bound to the same unary operator via `using for` and one of them uses that operator in its own body.
The root cause is similar to #16616, but the crash site is different. Maybe they should be fixed in one PR.
MRE:
```solidity
type T is int256;
function neg1(T a) pure returns (T) { return -a; }
function neg2(T a) pure returns (T) { return a; }
using {neg1 as -, neg2 as -} for T global;
```
Reproduce: save as `mre.sol`, run `solc --bin mre.sol`.
Output:
```
Internal compiler error:
/solidity/libsolidity/analysis/TypeChecker.cpp(1641): Throw in function virtual bool solidity::frontend::TypeChecker::visit(const solidity::frontend::UnaryOperation&)
Dynamic exception type: boost::wrapexcept
std::exception::what: Solidity assertion failed
[solidity::util::tag_comment*] = Solidity assertion failed
```
Expected behavior: a type error about duplicate unary operator bindings for `-` before any operator expression is type-checked.
Git commit: 9be66192f
solc 0.8.35-develop.2026.4.18+commit.9be66192.Linux.g++
Contributor guide
Research direction
Start with libsolidity/analysis/TypeChecker.cpp at line 1641 and reproduce the ICE using the provided mre.sol and `solc --bin mre.sol` command. Trace how duplicate `using for` unary bindings are handled before the self-referential operator expression is type-checked; done means the compiler reports a duplicate unary operator binding type error instead of panicking.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, solidity
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100