Inconsistent behavior of `*` and empty string in `outputSelection`
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 21
Description
Discovered in #15447.
## Description
`outputSelection` in Standard JSON has two selectors that are handled specially: `"*"` and `""`.
The asterisk consistently works a wildcard selecting all sources/contracts. The empty string, on the other hand, is sometimes treated as a wildcard and sometimes as a literal empty string:
- When selecting outputs, it's a literal empty string. Will never match an output.
- When selecting contracts, it's a literal empty string. Will never match a contract.
- When selecting sources, it depends on what's at the contract level. Combined with `"*"` acts as a wildcard matching all sources, while with a specific name (or empty string) will only match a source with an empty name.
Another quirk is that, even though `*` is a valid source name, it cannot be matched literally. It can still be matched with a wildcard, but cannot be selected on its own. This should be documented because tools must be aware of this and handle it in some way (e.g. by disallowing `*` as a name). Perhaps we should consider disallowing `*` as well.
## Environment
- Compiler version: 0.8.28
## Steps to Reproduce
See [`standard_output_selection_multiple_matching_source_and_contract_selectors/input.json`](https://github.com/ethereum/solidity/blob/v0.8.28/test/cmdlineTests/standard_output_selection_multiple_matching_source_and_contract_selectors/input.json).
Contributor guide
Research direction
Start with test/cmdlineTests/standard_output_selection_multiple_matching_source_and_contract_selectors/input.json and reproduce the Standard JSON outputSelection behavior using compiler version 0.8.28. Compare how "*" and "" are handled for outputs, contracts, and sources, then determine the agreed behavior and document or implement it, including the special case where "*" is a source name.
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
- 30/100