Solc fails to properly generate IR when enabling experimental features
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 21
Description
Compile: `solc out.sol --bin --via-ir`
Solc Version: `Version: 0.8.29-develop.2025.1.21+commit.d750b9df.Linux.g++`
```solidity
pragma experimental solidity;
type uint256 = __builtin("word");
function f(x:uint256) -> uint256
{
return x;
}
contract C {
fallback() external {
let a: uint256->uint256 = f;
}
}
```
It appears that `solc` is generating faulty IR, which leads to a crash.
```
Internal compiler error:
/solidity/libsolidity/interface/CompilerStack.cpp(821): Throw in function solidity::yul::YulStack solidity::frontend::CompilerStack::loadGeneratedIR(const std::string&) const
Dynamic exception type: boost::wrapexcept
std::exception::what:
object "C_21" {
code {
codecopy(0, dataoffset("C_21_deployed"), datasize("C_21_deployed"))
return(0, datasize("C_21_deployed"))
}
object "C_21_deployed" {
code {
{
fun__20$fun$unit$unit$$()
revert(0,0)
}
function fun__20$fun$unit$unit$$(){
let var_a_16 := expr_17
}
}
}
}
Invalid IR generated:
Error: Identifier "expr_17" not found.
[solidity::util::tag_comment*] =
object "C_21" {
code {
codecopy(0, dataoffset("C_21_deployed"), datasize("C_21_deployed"))
return(0, datasize("C_21_deployed"))
}
object "C_21_deployed" {
code {
{
fun__20$fun$unit$unit$$()
revert(0,0)
}
function fun__20$fun$unit$unit$$(){
let var_a_16 := expr_17
}
}
}
}
Invalid IR generated:
Error: Identifier "expr_17" not found.
```
Additionally, I would like to inquire whether the experimental features are now officially supported or if they are still under development.
Contributor guide
Research direction
Reproduce the crash with the provided solc command and experimental Solidity source, then inspect CompilerStack.cpp around line 821 and the generated IR shown in the report. Trace why expr_17 is emitted without a definition in via-ir output; done means the example no longer produces invalid IR or crashes, with the support status of the experimental features addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, solidity
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100