argotorg / argotorg/solidity

Generic way to access the underlying type of an UDVT

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

Description

## Abstract

type().max min should work with user defined types that are mapped to scalar types

type MY_THING is uint32;
MY_THING constant MY_THIN_FLAG=type(uint32).max;

is what's currently required because I can't write type(MY_THING).max.

## Motivation

This is really unfortunate, as it destroys one of the main utilities of such a type alias. Now if I decide I want more bits for MY_THING I have to change the underlying type in multiple places = much larger probability of introducing a bug.

## Specification

Allow type(user_defined_type) when user_defined_type maps to a scalar underlying type.

## Backwards Compatibility

none

Contributor guide

Open the contributing guide

Research direction

Start with the issue's UDVT examples and specification, then locate the compiler handling for type(...) and scalar user-defined value types. Done means type(MY_THING).max and type(MY_THING).min work for a UDVT mapped to a scalar type, with coverage for the uint32 example.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.