[ICE] via-IR: internal compiler error when emitting an event with an indexed external function parameter that requires a mutability conversion
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 21
Description
## Description
Emitting an event whose indexed parameter has an external function type triggers an internal compiler error under `--via-ir`, when the argument's function type differs from the declared parameter type by state mutability. Here `this.f` has type `function () external payable` while the event parameter is declared `function () external`, so the emit requires the implicit payable to non-payable function conversion. That conversion is legal, and the legacy pipeline compiles the contract without error and produces bytecode. via-IR instead aborts with an assertion.
Removing `indexed`, or removing the conversion (declaring `f` non-payable, or declaring the event parameter payable as well), makes the contract compile under via-IR. Assigning the pointer to a local variable before the emit also avoids it. Optimization settings make no difference.
## Steps to Reproduce
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract C {
event E(function() external indexed);
function f() public payable {
emit E(this.f);
}
}
```
```
solc --via-ir --bin ice.sol
```
The same error occurs through standard-JSON with `"viaIR": true`.
```
Internal compiler error:
/solidity/libsolidity/codegen/ir/IRGeneratorForStatements.cpp(1094): Throw in function virtual void solidity::frontend::IRGeneratorForStatements::endVisit(const solidity::frontend::FunctionCall&)
Dynamic exception type: boost::wrapexcept
std::exception::what: Solidity assertion failed
[solidity::util::tag_comment*] = Solidity assertion failed
```
## Environment
- Compiler version: 0.8.36+commit.8a079791.Linux.g++
- Target EVM version: osaka (default)
Contributor guide
Research direction
Start with the Solidity reproducer and run `solc --via-ir --bin ice.sol`, then inspect `libsolidity/codegen/ir/IRGeneratorForStatements.cpp` around line 1094. Trace the indexed external-function argument and its mutability conversion, and compare with the legacy pipeline. Done means the reproducer compiles under via-IR without the assertion, with regression coverage for this case.
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
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100