argotorg / argotorg/solidity

`.selector` on functions and error definitions in assembly

Open
#16,583 1 comment 1 reaction 1 assignee Claimed by @rodiazet View on GitHub
feature
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
21

Description

## Motivation

`.selector` exists on both functions and error definitions. It even exists in one case for functions in assembly: assigning to function types (example [here](https://docs.soliditylang.org/en/v0.8.35-pre.1/assembly.html#access-to-external-variables-functions-and-libraries)). Tried everything on 0.8.34.

It would be nice to have reading the selector for both functions and errors available to assembly. Some libraries (like solady) make use of this for quick error paths (example [here](https://github.com/Vectorized/solady/blob/main/src/accounts/ERC7821.sol#L162)):
```
mstore(0x00, 0x3995943b) // `BatchOfBatchesDecodingError()`.
revert(0x1c, 0x04)
```

## Specification

Support `.selector` in assembly, i.e. the above would be:
```
mstore(0x00, BatchOfBatchesDecodingError.selector)
revert(0x1c, 0x04)
```

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.