AST reimport fails for inline assembly with uninitialized variable declarations
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 29
Description
An attempt to import an AST produced by the compiler fails when the original source code contains an inline assembly block with a variable declaration without an initializer:
`test.sol`
```solidity
contract C {
function f() public pure {
assembly {
let x
}
}
}
```
```bash
solc test.sol --combined-json ast | solc --import-ast -
```
```
Failed to import AST: Expected "nodeType" to be of type string!
```
This is reproducible all the way down to 0.6.2, when the `--import-ast` option was introduced, though before 0.8.0 the error message was different and it seems to be failing for a different reason (even examples that work on 0.8.x fail on those versions)
```
Failed to import AST: Top-level node should be a 'SourceUnit'
```
Discovered by @aart in https://github.com/ethereum/solidity/pull/13576#discussion_r1013440891.
Contributor guide
Research direction
Reproduce the failure with the `test.sol` inline assembly example and the `solc --combined-json ast | solc --import-ast -` command. Trace AST import handling for an uninitialized assembly declaration, then verify that the generated AST imports successfully while existing AST import cases continue to work.
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
- 42/100