argotorg / argotorg/solidity

ICE for emit statement with argument of function type

Open
#16,298 0 comments 1 reaction 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

The following code triggers an ICE when compiling with `--ir`. I think the issue comes from passing a function type that is not identical but implicitly convertible to an indexed event parameter.

## Steps to Reproduce

`testcase.sol`

```solidity
// SPDX-License-Identifier: GPL-3.0

pragma solidity =0.8.30;

contract C {
event W(function () external view indexed p);

function f(function () external pure p) public {
emit W(p);
}
}
```

`
solc --ir testcase.sol
`

```
Internal compiler error:
/solidity/libsolidity/codegen/ir/IRGeneratorForStatements.cpp(1093): 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.30```

Contributor guide

Open the contributing guide

Research direction

Reproduce the ICE with the provided testcase.sol and `solc --ir testcase.sol`. Start at libsolidity/codegen/ir/IRGeneratorForStatements.cpp:1093, then trace the failing function-call handling for the emitted event argument. Done means the example no longer produces an internal compiler error and regression coverage verifies the behavior.

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
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.