argotorg / argotorg/solidity

Add support for shift operators for UDVT

Open
#14,006 3 comments 0 reactions 0 assignees View on GitHub
feature language design :rage4: low effort medium impact must have eventually
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
21

Description

## Abstract

Solidity 0.8.19 introduced operator overloading for UDVT. However the shift operator cannot currently be overriden.

```
error[4403]: ParserError: Not a user-definable operator: >>. Only the following operators can be user-defined: |, &, ^, ~, +, -, *, /, %, ==, !=, <, >, <=, >=
```

## Specification

Allow syntax such as

```solidity
using { lshift as <<, rshift as >> } for X global;
```

with requirement that these function have type
```solidity
function lshift(X, uint256) pure returns (X); // use uint8 instead of uint256?
function rshift(X, uint256) pure returns (X); // use uint8 instead of uint256?
```

## Backwards Compatibility

No issue

Contributor guide

Open the contributing guide

Research direction

The issue names no implementation files or tests. Start by tracing parser diagnostic 4403 and the existing user-defined value type operator-overloading path; done means accepting << and >> in the shown using declaration, validating their function signatures, and covering the behavior with tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, solidity
Domain
blockchain, compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.