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 { function A() public { } }
contract A { constructor() public {} }
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: (135-178): This declaration shadows an existing declaration.
// Warning: (57-100): 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 { }
// ----
// Warning: (13-42): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// Warning: (24-30): Unused function parameter. Remove or comment out the variable name to silence this warning.
// Warning: (25-31): 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 { }
// ----
// Warning: (13-42): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// Warning: (24-30): Unused function parameter. Remove or comment out the variable name to silence this warning.
// Warning: (25-31): Unused function parameter. Remove or comment out the variable name to silence this warning.

View File

@ -1,8 +1,7 @@
contract c {
function c () public {
constructor() public {
a = 115792089237316195423570985008687907853269984665640564039458;
}
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 {
function c () public {
constructor() public {
a = 115792089237316195423570985008687907853269984665640564039458 ether;
}
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.

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test() public {
constructor() public {
a = uint256(ActionChoices.GoStraight);
b = uint64(ActionChoices.Sit);
}
@ -8,4 +8,3 @@ contract test {
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 {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test() public {
constructor() public {
a = 2;
b = ActionChoices(a);
}
@ -8,4 +8,3 @@ contract test {
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 {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test() public {
constructor() public {
a = ActionChoices.GoStraight;
}
uint256 a;
}
// ----
// Warning: (80-148): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
// TypeError: (117-141): Type enum test.ActionChoices is not implicitly convertible to expected type uint256.
// TypeError: (115-139): Type enum test.ActionChoices is not implicitly convertible to expected type uint256.

View File

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

View File

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

View File

@ -1,5 +1,5 @@
contract C {
function C() { }
constructor() { }
}
contract D {
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: (98-111): Member "value" not found or not visible after argument-dependent lookup in function () returns (contract C) - did you forget the "payable" modifier?
// 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?

View File

@ -1,7 +1,6 @@
contract test {
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: (78-79): Integer constant expected.
// TypeError: (76-77): Integer constant expected.

View File

@ -1,10 +1,9 @@
contract C {
struct S { uint a; bool x; }
S public s;
function C() public {
constructor() public {
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: (96-114): Type is not callable
// TypeError: (97-115): Type is not callable

View File

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

View File

@ -1,10 +1,9 @@
contract c {
function c ()
constructor()
{
a = 1 wei * 100 wei + 7 szabo - 3;
}
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".