argotorg / argotorg/solidity

AST reimport fails for inline assembly with uninitialized variable declarations

Open
#13,684 0 comments 1 reaction 0 assignees View on GitHub
bug :bug: low effort low impact must have eventually should compile without error
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.