argotorg / argotorg/solidity

Duplicate Yul source name triggers asm-json ICE

Open
#16,822 1 comment 0 reactions 1 assignee Claimed by @r0qs View on GitHub
bug :bug: easy difficulty low effort low impact waiting for more input
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
2d 19h
Merged PRs (30d)
29

Description

## Description

Nested strict-assembly Yul objects may each declare `@use-src` mappings. If a parent object maps source index `0` to `A.sol` and a child object maps source index `1` to the same `A.sol`, the input parses and `--asm` succeeds, printing both locations. However, requesting `--asm-json` on the same source exits with an internal compiler error from `Object::collectSourceIndices()`.

The parser (`libyul/ObjectParser.cpp:159`) stores `@use-src` mappings per object without checking global source-name uniqueness. The assembly JSON path (`libyul/Object.cpp:216-223`) then merges all nested object mappings into a single name-to-index map and asserts that a name cannot be associated with two different indices. The CLI runs this check only for `--asm-json` (`solc/CommandLineInterface.cpp:1323`), so the behavior is output-mode-specific: `--asm` accepts the input while `--asm-json` ICEs.

Expected: either both output modes accept duplicate source names under different indices, or the duplicate is rejected with a normal diagnostic rather than an internal assertion.

## Environment

- Compiler version: 0.8.35-develop.2026.5.5+commit.47b9dedd.Linux.g++
- Operating system: Linux Ubuntu Jammy

## Steps to Reproduce

Save the following as `repro.yul`:

```yul
/// @use-src 0: "A.sol"
object "C" {
code {
/// @src 0:0:1
stop()
}
/// @use-src 1: "A.sol"
object "D" {
code {
/// @src 1:0:1
stop()
}
}
}
```

`--asm` succeeds:

```text
$ solc --strict-assembly --asm repro.yul
Text representation:
/* "A.sol":0:1 */
stop
...
```

`--asm-json` triggers an internal compiler error:

```text
$ solc --strict-assembly --asm-json repro.yul
Internal compiler error:
/solidity/libyul/Object.cpp(221): Throw in function void solidity::yul::Object::collectSourceIndices(...)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.