argotorg / argotorg/solidity

Remove `uint` as alias for `uint256`

Open
#14,026 17 comments 15 reactions 0 assignees View on GitHub
breaking change :warning: feature language design :rage4: low effort medium impact nice to have
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
2d 19h
Merged PRs (30d)
29

Description

## Abstract

I would like to propose removing `uint` as an alias for `uint256` for the upcoming breaking `>=0.9.0` versions. The reason is that global aliases in the area of user-defined types and operators decrease readability.

## Motivation

Consider the following example:

```solidity
// SPDX-License-Identifier: WTFPL
pragma solidity 0.8.19;

type Uint is uint8; /// @dev Use `Uint` for `uint8` type.
using {safeAddUint256 as +} for Uint global;

/// @dev The function name is chosen on purpose like that to increase the confusion.
function unsafeAddUint256(Uint a, Uint b) pure returns (Uint) {
unchecked {
return Uint.wrap(Uint.unwrap(a) + Uint.unwrap(b));
}
}

contract evil {
function add(Uint a, Uint b) external pure returns (Uint) {
return a + b;
}
}
```

The example is on purpose like that to indicate that `uint` and `Uint` can mean completely different things and I feel that for the reason of auditability and readability, we should discourage the use of `uint` as an alias for `uint256`. Explicitness of the type range is a good language feature to have.

[EDIT]: This example was on purpose rather provocative and please take a look at the examples of @Amxx [here](https://github.com/ethereum/solidity/issues/14026#issuecomment-1454691844) for more spot-on examples.

## Specification

I would like to propose the following specification:
- For the remaining `>=0.8.20` versions, the compiler issues a deprecation warning for the alias `uint`.
- Starting with version `0.9.0` disallow the usage of the `uint` alias.

## Backwards Compatibility

This change is not backward-compatible with `<0.9.0` versions.

Contributor guide

Open the contributing guide

Research direction

Start with the proposed specification and the Solidity user-defined type examples in this issue, then trace how the compiler handles the `uint` alias across the stated version boundaries. Done means deprecation warnings for the remaining >=0.8.20 versions and rejection of the alias starting in 0.9.0, while preserving the stated pre-0.9.0 compatibility boundary.

Written by the indexing model from the issue text.

Assessment

Tech stack
solidity
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.