argotorg / argotorg/solidity

The `--asm-json` output suppresses `--asm`

Open
#14,628 3 comments 0 reactions 0 assignees View on GitHub
bug :bug: low effort low impact
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
21

Description

If you request the JSON assembly output on the CLI with `--asm-json` the normal assembly output (`--asm`) no longer appears.

This is not how other outputs work on the CLI. Standard JSON also does not behave this way - it is possible to request both `evm.assembly` and `evm.legacyAssembly` at the same time.

## Environment

- Compiler version: 0.8.21

## How to reproduce

### Only `--asm`
```bash
echo 'contract C {}' | solc - --asm
```

Output

```
======= :C =======
EVM assembly:
/* "":0:13 contract C {} */
mstore(0x40, 0x80)
callvalue
dup1
iszero
tag_1
jumpi
0x00
dup1
revert
tag_1:
pop
dataSize(sub_0)
dup1
dataOffset(sub_0)
0x00
codecopy
0x00
return
stop

sub_0: assembly {
/* "":0:13 contract C {} */
mstore(0x40, 0x80)
0x00
dup1
revert

auxdata: 0xa26469706673582212203de2612385ddacb7fd5cc0b2a4bd9f59a2c09a735e08d1d1461c0e3e3f66778264736f6c63430008150033
}
```

### Only `--asm-json`
```bash
echo 'contract C {}' | solc - --asm-json
```

Output

```
======= :C =======
EVM assembly:
{".code":[{"begin":0,"end":13,"name":"PUSH","source":0,"value":"80"},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"40"},{"begin":0,"end":13,"name":"MSTORE","source":0},{"begin":0,"end":13,"name":"CALLVALUE","source":0},{"begin":0,"end":13,"name":"DUP1","source":0},{"begin":0,"end":13,"name":"ISZERO","source":0},{"begin":0,"end":13,"name":"PUSH [tag]","source":0,"value":"1"},{"begin":0,"end":13,"name":"JUMPI","source":0},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"0"},{"begin":0,"end":13,"name":"DUP1","source":0},{"begin":0,"end":13,"name":"REVERT","source":0},{"begin":0,"end":13,"name":"tag","source":0,"value":"1"},{"begin":0,"end":13,"name":"JUMPDEST","source":0},{"begin":0,"end":13,"name":"POP","source":0},{"begin":0,"end":13,"name":"PUSH #[$]","source":0,"value":"0000000000000000000000000000000000000000000000000000000000000000"},{"begin":0,"end":13,"name":"DUP1","source":0},{"begin":0,"end":13,"name":"PUSH [$]","source":0,"value":"0000000000000000000000000000000000000000000000000000000000000000"},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"0"},{"begin":0,"end":13,"name":"CODECOPY","source":0},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"0"},{"begin":0,"end":13,"name":"RETURN","source":0}],".data":{"0":{".auxdata":"a26469706673582212203de2612385ddacb7fd5cc0b2a4bd9f59a2c09a735e08d1d1461c0e3e3f66778264736f6c63430008150033",".code":[{"begin":0,"end":13,"name":"PUSH","source":0,"value":"80"},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"40"},{"begin":0,"end":13,"name":"MSTORE","source":0},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"0"},{"begin":0,"end":13,"name":"DUP1","source":0},{"begin":0,"end":13,"name":"REVERT","source":0}]}},"sourceList":["","#utility.yul"]}
```

### `--asm` and `--asm-json`
```bash
echo 'contract C {}' | solc - --asm --asm-json
```

Note that the output is identical to the case with only `--asm-json`.

Output

```
======= :C =======
EVM assembly:
{".code":[{"begin":0,"end":13,"name":"PUSH","source":0,"value":"80"},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"40"},{"begin":0,"end":13,"name":"MSTORE","source":0},{"begin":0,"end":13,"name":"CALLVALUE","source":0},{"begin":0,"end":13,"name":"DUP1","source":0},{"begin":0,"end":13,"name":"ISZERO","source":0},{"begin":0,"end":13,"name":"PUSH [tag]","source":0,"value":"1"},{"begin":0,"end":13,"name":"JUMPI","source":0},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"0"},{"begin":0,"end":13,"name":"DUP1","source":0},{"begin":0,"end":13,"name":"REVERT","source":0},{"begin":0,"end":13,"name":"tag","source":0,"value":"1"},{"begin":0,"end":13,"name":"JUMPDEST","source":0},{"begin":0,"end":13,"name":"POP","source":0},{"begin":0,"end":13,"name":"PUSH #[$]","source":0,"value":"0000000000000000000000000000000000000000000000000000000000000000"},{"begin":0,"end":13,"name":"DUP1","source":0},{"begin":0,"end":13,"name":"PUSH [$]","source":0,"value":"0000000000000000000000000000000000000000000000000000000000000000"},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"0"},{"begin":0,"end":13,"name":"CODECOPY","source":0},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"0"},{"begin":0,"end":13,"name":"RETURN","source":0}],".data":{"0":{".auxdata":"a26469706673582212203de2612385ddacb7fd5cc0b2a4bd9f59a2c09a735e08d1d1461c0e3e3f66778264736f6c63430008150033",".code":[{"begin":0,"end":13,"name":"PUSH","source":0,"value":"80"},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"40"},{"begin":0,"end":13,"name":"MSTORE","source":0},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"0"},{"begin":0,"end":13,"name":"DUP1","source":0},{"begin":0,"end":13,"name":"REVERT","source":0}]}},"sourceList":["","#utility.yul"]}
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the three solc commands using --asm and --asm-json, then trace the CLI handling of these options and how assembly output is emitted. Add regression coverage for requesting both outputs and verify that the human-readable assembly and JSON assembly are both present.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli, compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.