Make visibility optional, but it has to be consistent.

This commit is contained in:
chriseth
2020-07-07 12:16:18 +02:00
parent 479d7a059f
commit 5959d442cb
13 changed files with 78 additions and 15 deletions
@@ -0,0 +1,6 @@
abstract contract C {
constructor() {}
}
contract D is C {
constructor() { }
}
@@ -1,6 +1,8 @@
abstract contract C {
constructor() {}
constructor() internal {}
}
contract D is C {
constructor() { }
}
// ----
// Warning 2462: (23-48): Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is sufficient.
@@ -2,4 +2,4 @@ contract test {
constructor() external {}
}
// ----
// SyntaxError 2462: (17-42): Visibility specified for constructor. If you want the contract to be non-deployable, make it "abstract".
// TypeError 9239: (17-42): Constructor cannot have visibility.
@@ -0,0 +1,8 @@
abstract contract C {
constructor() {}
}
contract D {
function f() public { C c = new C(); c; }
}
// ----
// TypeError 4614: (84-89): Cannot instantiate an abstract contract.
@@ -0,0 +1,13 @@
// Previously, the type information for A was not yet available at the point of
// "new A".
contract B {
A a;
constructor() {
a = new A(address(this));
}
}
abstract contract A {
constructor(address) {}
}
// ----
// TypeError 4614: (134-139): Cannot instantiate an abstract contract.
@@ -1,8 +1,8 @@
abstract contract C {
constructor() {}
contract C {
constructor() internal {}
}
contract D {
function f() public { C c = new C(); c; }
}
// ----
// TypeError 4614: (84-89): Cannot instantiate an abstract contract.
// DeclarationError 1845: (14-39): Non-abstract contracts cannot have internal constructors. Remove the "internal" keyword and make the contract abstract to fix this.
@@ -6,8 +6,8 @@ contract B {
a = new A(address(this));
}
}
abstract contract A {
constructor(address) {}
contract A {
constructor(address) internal {}
}
// ----
// TypeError 4614: (134-139): Cannot instantiate an abstract contract.
// DeclarationError 1845: (175-207): Non-abstract contracts cannot have internal constructors. Remove the "internal" keyword and make the contract abstract to fix this.
@@ -0,0 +1,5 @@
contract C {
constructor() internal {}
}
// ----
// DeclarationError 1845: (14-39): Non-abstract contracts cannot have internal constructors. Remove the "internal" keyword and make the contract abstract to fix this.
@@ -0,0 +1,5 @@
abstract contract C {
constructor() public {}
}
// ----
// DeclarationError 8295: (23-46): Abstract contracts cannot have public constructors. Remove the "public" keyword to fix this.
@@ -0,0 +1,5 @@
contract C {
constructor() public {}
}
// ----
// Warning 2462: (14-37): Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is sufficient.