argotorg / argotorg/solidity

Disallow using `super` type notation to declare array type.

Open
#16,489 1 comment 0 reactions 0 assignees View on GitHub
bug :bug: low effort low impact
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
21

Description

## Abstract

Current language semantic allows to an index access expression using `super` keyword i.e. `super[3];`. This is the same as `B[3];` where `B` is a contract one level up in inheritance hierarchy.

## Motivation

The index access expression like this is allowed, but we cannot define a variable, which has this type.
```solidity
contract B {
}

contract C is B {
function f() pure public {
super[1] memory t; // Name has to refer to a user-defined type.
}
}
```
This inconsistency is a result of the fact that this type validation is implemented differently in two places, `DeclarationTypeChecker` and `TypeChecker`

## Specification

Disallow `super` to be base expression for index access expression. Analyse other case like mapping. Should we only allow `super` to be used to refer to members of the contract one level up in inheritance hierarchy?

## Backwards Compatibility

It breaks backward compatibility. An analysis is necessary to check how popular this pattern is in the existing contracts implementations.

Contributor guide

Open the contributing guide

Research direction

Start by comparing the `DeclarationTypeChecker` and `TypeChecker` handling of index access expressions involving `super`, then inspect the analogous mapping case. Determine whether `super` should only refer to members of the immediate base contract and assess the backward-compatibility impact of rejecting this syntax. Done means the semantic rule and compatibility analysis are settled.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.