argotorg / argotorg/solidity

Remove the disabled `>>>` (SHR) operator

Open
#15,839 2 comments 0 reactions 0 assignees View on GitHub
low effort low impact should have
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
2d 19h
Merged PRs (30d)
29

Description

Solidity parser accepts `>>>` and `>>>=` as valid operators. They're also present in the grammar. Looks like they have been present ever since the shift operators were introduced (#1487). They are, however, not documented and seem to be deliberately disabled:

https://github.com/ethereum/solidity/blob/9ff6d26833cabd53e8356887614f75a1a68cf867/libsolidity/ast/Types.cpp#L576-L578

The operators seem to have been meant to handle unsigned right shift (`SHR`), as opposed to `>>`, which performs a signed right shift (`SAR`). Note that both were introduced at the same time, in the `constantinople` EVM.

It's been a long time (>9 years) since the shift operators were added and I don't remember anyone actually requesting them or reporting them as broken so we should probably just remove this bit of legacy. But enabling and properly documenting them would not hurt either.

For the time being it would also be clearer to reject them with a proper error message (disabled? unimplemented? dangerous?) rather than make them incompatible with all types, which must be very confusing to anyone who encounters them (it was for me).

Contributor guide

Open the contributing guide

Research direction

Start with the grammar entries for >>> and >>>= and inspect libsolidity/ast/Types.cpp around the linked operator handling. Confirm how the parser currently accepts these operators and determine whether the intended outcome is removal or explicit support. Done means the chosen behavior is consistent and the operators no longer produce a confusing type incompatibility.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, solidity
Domain
blockchain, compilers
Issue type
Bug
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.