Skip to content

Inconsistent behavior of * and empty string in outputSelection #15747

Open
@cameel

Description

@cameel

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛low effortThere is not much implementation work to be done. The task is very easy or tiny.low impactChanges are not very noticeable or potential benefits are limited.must have eventuallySomething we consider essential but not enough to prevent us from releasing Solidity 1.0 without it.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions