Skip to content

Fix ICE when emitting event with indexed function type requiring implicit conversion#16524

Open
chfast wants to merge 1 commit intoargotorg:developfrom
chfast:fix/event-indexed-function-type-ice
Open

Fix ICE when emitting event with indexed function type requiring implicit conversion#16524
chfast wants to merge 1 commit intoargotorg:developfrom
chfast:fix/event-indexed-function-type-ice

Conversation

@chfast
Copy link
Contributor

@chfast chfast commented Mar 13, 2026

The IR codegen asserted exact type equality between the argument and event parameter types for indexed function-type parameters (IRVariable(arg).type() == *functionType). This fails when the argument has a different but implicitly convertible state mutability (e.g. function() external pure passed to an event expecting function() external view indexed), since FunctionType::operator== compares mutability.

Replace the strict equality check with individual structural assertions matching the legacy codegen (ExpressionCompiler.cpp:999-1009): verify both types are external function types and the argument has no bound first argument. The underlying combineExternalFunctionIdFunction operates on raw (address, selector) stack values and is unaffected by mutability differences.

The legacy codegen is not affected — it already checks the argument and parameter types separately without requiring equality.

Fixes #16298

…icit conversion

The IR codegen asserted exact type equality between the argument and
event parameter types for indexed function-type parameters. This fails
when the argument has a different but implicitly convertible state
mutability (e.g. pure -> view), since FunctionType::operator== compares
mutability.

Replace the strict equality check with individual structural assertions
matching the legacy codegen: verify both types are external function
types and the argument has no bound first argument. The underlying
combineExternalFunctionIdFunction operates on raw (address, selector)
stack values and is unaffected by mutability differences.

Fixes argotorg#16298
@github-actions
Copy link

Thank you for your contribution to the Solidity compiler! A team member will follow up shortly.

If you haven't read our contributing guidelines and our review checklist before, please do it now, this makes the reviewing process and accepting your contribution smoother.

If you have any questions or need our help, feel free to post them in the PR or talk to us directly on the #solidity-dev channel on Matrix.

@cameel cameel requested review from nikola-matic and rodiazet March 13, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE for emit statement with argument of function type

1 participant