[Bug-Candidate]: Ternary operators involving function types fail to be generated.
- Dominant language
- Python
- Stars
- 6.4k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the issue:
The ternary operator `r = true ? g : f;`, which involves function types, fails to generate IR, causing Slither to crash.
### Code example to reproduce the issue:
```solidity
contract C {
function f() public {
}
function g() public {
}
function() r = true ? g : f;
}
```
### Version:
0.11.0
### Relevant log output:
```shell
ERROR:SlitherSolcParsing:
Failed to generate IR for C.slitherConstructorVariables. Please open an issue https://github.com/crytic/slither/issues.
C.slitherConstructorVariables (a.sol#1-10):
r = if true then g else f
Traceback (most recent call last):
...
slither.slithir.exceptions.SlithIRError: Ternary operator are not convertible to SlithIR if true then g else f
ERROR:root:Error:
ERROR:root:Ternary operator are not convertible to SlithIR if true then g else f
ERROR:root:Please report an issue to https://github.com/crytic/slither/issues
```
Contributor guide
Research direction
Start by reproducing the failure with the Solidity contract and the reported ternary expression, then trace the SlithIR conversion that rejects `if true then g else f`. Done means the example generates IR successfully without the reported SlithIRError or Slither crash.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, solidity
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100