`@src` debug annotations cannot be disabled without disabling other debug annotations
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 21
Description
## Description
`--debug-info` allows selecting any subset of `location`, `snippet`, `ast-id`, `ethdebug`. The `@src` annotations are supposed to appear in Yul output only when the first one is present, but it seems that any subset other than an empty one triggers them.
## Environment
- Compiler version: 0.8.33
- Compilation pipeline (legacy, IR, EOF): IR
## Steps to Reproduce
### `--debug-info location`
```bash
echo 'contract C {}' | solc - --ir --debug-info location | grep @src
```
```
/// @src 0:0:13
/// @src 0:0:13
/// @src 0:0:13
/// @src 0:0:13
/// @src 0:0:13
```
Works as expected. `@src` present.
### `--debug-info none`
```bash
echo 'contract C {}' | solc - --ir --debug-info none | grep @src
```
```
```
Works as expected. No `@src` annotations
### `--debug-info ast-id`
```bash
echo 'contract C {}' | solc - --ir --debug-info ast-id | grep @src
```
```
/// @src 0:0:13
/// @src 0:0:13
/// @src 0:0:13
/// @src 0:0:13
/// @src 0:0:13
```
Has `@src` annotations even though they were not requested.
## Implementation notes
The problem likely lies between [`dispenseLocationComment()`](https://github.com/argotorg/solidity/blob/v0.8.33/libsolidity/codegen/ir/Common.cpp#L141-L154) and [`AsmPrinter::formatDebugData()`](https://github.com/argotorg/solidity/blob/v0.8.33/libyul/AsmPrinter.cpp#L308-L341). One of them should check this and apparently neither does.
Contributor guide
Research direction
Start with dispenseLocationComment() in libsolidity/codegen/ir/Common.cpp and AsmPrinter::formatDebugData() in libyul/AsmPrinter.cpp, then run the issue's solc IR reproduction commands for location, none, and ast-id. Done means @src annotations appear for location, but not for none or ast-id.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, solidity
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100