argotorg / argotorg/solidity

Disallow visibility modifiers on constructors

Open
#16,167 1 comment 0 reactions 0 assignees View on GitHub
breaking change :warning: 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
Constructors can currently have a visibility modifier (`internal` if abstract, `public` otherwise), which has no real effect. This is redundant and should be disallowed.

## Motivation
In Solidity 0.6.x specifying visibility of a constructor was mandatory. It could be either `internal` or `public`. An internal constructor could not be "invoked" from the outside, making the contract undeployable on its own. Such constructor could only be invoked internally, from within a derived contract.

However, the concept did not map 1:1 to the way visibility works for ordinary functions and there were various opinions on how to adjust it (#4392). On the other hand, it lined up exactly with the notion of an abstract contract and was therefore redundant (#8162). In 0.7.0 (#8992) we decided to allow omitting the visibility and disallow abstract contracts with a public constructor as well as non-abstract ones with an internal constructor.

We left the possibility of using the abstract/internal and non-abstract/public combinations open (with a warning). It was argued that this is important for libraries to keep portability across different compiler versions (#9399). Still, the intention was to disallow those eventually as well and now enough time has passed that this should no longer be controversial.

## Specification

Report an error when any visibility specifier is used on a contract constructor.

## Backwards Compatibility

This is a breaking syntax change.

Contributor guide

Open the contributing guide

Research direction

The issue names no files, tests, or entry points. Start by locating the compiler handling for constructor visibility and its diagnostic tests; done means every visibility specifier on a constructor produces an error while constructors without one remain accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, solidity
Domain
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.