Updates syntax tests to new constructor syntax.

This commit is contained in:
Erik Kundt 2018-06-27 14:00:13 +02:00
parent 12c4eb7697
commit 1346b4407f
20 changed files with 43 additions and 50 deletions

View File

@ -0,0 +1,2 @@
contract A { constructor() public {} }
// ----

View File

@ -0,0 +1,4 @@
pragma experimental "v0.5.0";
contract A { constructor() {} }
// ----
// SyntaxError: (43-59): No visibility specified.

View File

@ -1,6 +1,10 @@
// It is fine to "override" constructor of a base class since it is invisible contract A { constructor() public {} }
contract A { function A() public { } }
contract B is A { function A() public pure returns (uint8) {} } contract B is A { function A() public pure returns (uint8) {} }
contract C is A { function A() public pure returns (uint8) {} }
contract D is B { function B() public pure returns (uint8) {} }
contract E is D { function B() public pure returns (uint8) {} }
// ---- // ----
// Warning: (91-114): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. // Warning: (57-100): This declaration shadows an existing declaration.
// Warning: (135-178): This declaration shadows an existing declaration. // Warning: (121-164): This declaration shadows an existing declaration.
// Warning: (185-228): This declaration shadows an existing declaration.
// Warning: (249-292): This declaration shadows an existing declaration.

View File

@ -1,5 +1,4 @@
contract A { function A(uint a) public { } } contract A { constructor(uint a) public { } }
contract B is A { } contract B is A { }
// ---- // ----
// Warning: (13-42): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. // Warning: (25-31): Unused function parameter. Remove or comment out the variable name to silence this warning.
// Warning: (24-30): Unused function parameter. Remove or comment out the variable name to silence this warning.

View File

@ -1,5 +1,4 @@
contract A { function A(uint a) public { } } contract A { constructor(uint a) public { } }
contract B is A { } contract B is A { }
// ---- // ----
// Warning: (13-42): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. // Warning: (25-31): Unused function parameter. Remove or comment out the variable name to silence this warning.
// Warning: (24-30): Unused function parameter. Remove or comment out the variable name to silence this warning.

View File

@ -1,8 +1,7 @@
contract c { contract c {
function c () public { constructor() public {
a = 115792089237316195423570985008687907853269984665640564039458; a = 115792089237316195423570985008687907853269984665640564039458;
} }
uint256 a; uint256 a;
} }
// ---- // ----
// Warning: (17-119): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.

View File

@ -1,9 +1,8 @@
contract c { contract c {
function c () public { constructor() public {
a = 115792089237316195423570985008687907853269984665640564039458 ether; a = 115792089237316195423570985008687907853269984665640564039458 ether;
} }
uint256 a; uint256 a;
} }
// ---- // ----
// Warning: (17-125): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// TypeError: (52-118): Type int_const 1157...(70 digits omitted)...0000 is not implicitly convertible to expected type uint256. // TypeError: (52-118): Type int_const 1157...(70 digits omitted)...0000 is not implicitly convertible to expected type uint256.

View File

@ -1,11 +1,10 @@
contract test { contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test() constructor()
{ {
choices = ActionChoices.GoStraight; choices = ActionChoices.GoStraight;
} }
ActionChoices choices; ActionChoices choices;
} }
// ---- // ----
// Warning: (80-151): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. // Warning: (80-149): No visibility specified. Defaulting to "public".
// Warning: (80-151): No visibility specified. Defaulting to "public".

View File

@ -1,10 +1,9 @@
contract test { contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test() public { constructor() public {
choices = ActionChoices.RunAroundWavingYourHands; choices = ActionChoices.RunAroundWavingYourHands;
} }
ActionChoices choices; ActionChoices choices;
} }
// ---- // ----
// Warning: (80-168): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. // TypeError: (121-159): Member "RunAroundWavingYourHands" not found or not visible after argument-dependent lookup in type(enum test.ActionChoices)
// TypeError: (123-161): Member "RunAroundWavingYourHands" not found or not visible after argument-dependent lookup in type(enum test.ActionChoices)

View File

@ -1,10 +1,9 @@
contract test { contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test() public { constructor() public {
choices = Sit; choices = Sit;
} }
ActionChoices choices; ActionChoices choices;
} }
// ---- // ----
// Warning: (80-133): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. // DeclarationError: (121-124): Undeclared identifier.
// DeclarationError: (123-126): Undeclared identifier.

View File

@ -1,6 +1,6 @@
contract test { contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test() public { constructor() public {
a = uint256(ActionChoices.GoStraight); a = uint256(ActionChoices.GoStraight);
b = uint64(ActionChoices.Sit); b = uint64(ActionChoices.Sit);
} }
@ -8,4 +8,3 @@ contract test {
uint64 b; uint64 b;
} }
// ---- // ----
// Warning: (80-196): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.

View File

@ -1,6 +1,6 @@
contract test { contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test() public { constructor() public {
a = 2; a = 2;
b = ActionChoices(a); b = ActionChoices(a);
} }
@ -8,4 +8,3 @@ contract test {
ActionChoices b; ActionChoices b;
} }
// ---- // ----
// Warning: (80-155): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.

View File

@ -1,10 +1,9 @@
contract test { contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test() public { constructor() public {
a = ActionChoices.GoStraight; a = ActionChoices.GoStraight;
} }
uint256 a; uint256 a;
} }
// ---- // ----
// Warning: (80-148): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. // TypeError: (115-139): Type enum test.ActionChoices is not implicitly convertible to expected type uint256.
// TypeError: (117-141): Type enum test.ActionChoices is not implicitly convertible to expected type uint256.

View File

@ -1,10 +1,9 @@
contract test { contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test() public { constructor() public {
b = ActionChoices.Sit; b = ActionChoices.Sit;
} }
uint64 b; uint64 b;
} }
// ---- // ----
// Warning: (80-141): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. // TypeError: (115-132): Type enum test.ActionChoices is not implicitly convertible to expected type uint64.
// TypeError: (117-134): Type enum test.ActionChoices is not implicitly convertible to expected type uint64.

View File

@ -1,10 +1,9 @@
contract test { contract test {
enum Paper { Up, Down, Left, Right } enum Paper { Up, Down, Left, Right }
enum Ground { North, South, West, East } enum Ground { North, South, West, East }
function test() public { constructor() public {
Ground(Paper.Up); Ground(Paper.Up);
} }
} }
// ---- // ----
// Warning: (106-162): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. // TypeError: (137-153): Explicit type conversion not allowed from "enum test.Paper" to "enum test.Ground".
// TypeError: (139-155): Explicit type conversion not allowed from "enum test.Paper" to "enum test.Ground".

View File

@ -1,5 +1,5 @@
contract C { contract C {
function C() { } constructor() { }
} }
contract D { contract D {
function f() public returns (uint) { function f() public returns (uint) {
@ -8,5 +8,4 @@ contract D {
} }
} }
// ---- // ----
// Warning: (17-33): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. // TypeError: (99-112): Member "value" not found or not visible after argument-dependent lookup in function () returns (contract C) - did you forget the "payable" modifier?
// TypeError: (98-111): Member "value" not found or not visible after argument-dependent lookup in function () returns (contract C) - did you forget the "payable" modifier?

View File

@ -1,7 +1,6 @@
contract test { contract test {
struct S { uint x; } struct S { uint x; }
function test(uint k) public { S[k]; } constructor(uint k) public { S[k]; }
} }
// ---- // ----
// Warning: (45-83): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. // TypeError: (76-77): Integer constant expected.
// TypeError: (78-79): Integer constant expected.

View File

@ -1,10 +1,9 @@
contract C { contract C {
struct S { uint a; bool x; } struct S { uint a; bool x; }
S public s; S public s;
function C() public { constructor() public {
3({a: 1, x: true}); 3({a: 1, x: true});
} }
} }
// ---- // ----
// Warning: (66-121): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. // TypeError: (97-115): Type is not callable
// TypeError: (96-114): Type is not callable

View File

@ -1,10 +1,9 @@
contract c { contract c {
enum validEnum { Value1, Value2, Value3, Value4 } enum validEnum { Value1, Value2, Value3, Value4 }
function c() { constructor() {
a = validEnum.Value3; a = validEnum.Value3;
} }
validEnum a; validEnum a;
} }
// ---- // ----
// Warning: (71-121): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. // Warning: (71-122): No visibility specified. Defaulting to "public".
// Warning: (71-121): No visibility specified. Defaulting to "public".

View File

@ -1,10 +1,9 @@
contract c { contract c {
function c () constructor()
{ {
a = 1 wei * 100 wei + 7 szabo - 3; a = 1 wei * 100 wei + 7 szabo - 3;
} }
uint256 a; uint256 a;
} }
// ---- // ----
// Warning: (17-86): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// Warning: (17-86): No visibility specified. Defaulting to "public". // Warning: (17-86): No visibility specified. Defaulting to "public".