From 4e037281acaf74c907f68e6227d6aa1b8847c78d Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Mon, 11 Dec 2017 18:00:15 -0300 Subject: Error on duplicated super constructor calls --- .../syntaxTests/inheritance/duplicated_super_constructor_call.sol | 4 ++++ .../inheritance/duplicated_super_constructor_call_empty.sol | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call.sol create mode 100644 test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_empty.sol (limited to 'test/libsolidity/syntaxTests/inheritance') diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call.sol new file mode 100644 index 00000000..95df1040 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call.sol @@ -0,0 +1,4 @@ +contract A { constructor(uint) public { } } +contract B is A(2) { constructor() A(3) public { } } +// ---- +// DeclarationError: Duplicated super constructor call. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_empty.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_empty.sol new file mode 100644 index 00000000..f8024ad6 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_empty.sol @@ -0,0 +1,4 @@ +contract A { constructor() public { } } +contract B is A { constructor() A() public { } } +// ---- +// DeclarationError: Duplicated super constructor call. -- cgit From b8fdb666e235bb6b19f11dba7740227026111598 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Wed, 4 Apr 2018 12:28:22 +0200 Subject: Allow duplicated constructor calls, if no arguments; support for multiple inheritance; backwards compatibility. # tmp --- .../allow_empty_duplicated_super_constructor_call.sol | 3 +++ .../inheritance/base_arguments_multiple_inheritance.sol | 9 +++++++++ .../inheritance/duplicated_ancestor_constructor_call.sol | 5 +++++ .../inheritance/duplicated_ancestor_constructor_call_V050.sol | 7 +++++++ .../inheritance/duplicated_super_constructor_call.sol | 2 +- .../inheritance/duplicated_super_constructor_call_V050.sol | 6 ++++++ .../inheritance/duplicated_super_constructor_call_empty.sol | 4 ---- .../inheritance/duplicated_super_constructor_call_multi.sol | 7 +++++++ 8 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 test/libsolidity/syntaxTests/inheritance/allow_empty_duplicated_super_constructor_call.sol create mode 100644 test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol create mode 100644 test/libsolidity/syntaxTests/inheritance/duplicated_ancestor_constructor_call.sol create mode 100644 test/libsolidity/syntaxTests/inheritance/duplicated_ancestor_constructor_call_V050.sol create mode 100644 test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_V050.sol delete mode 100644 test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_empty.sol create mode 100644 test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_multi.sol (limited to 'test/libsolidity/syntaxTests/inheritance') diff --git a/test/libsolidity/syntaxTests/inheritance/allow_empty_duplicated_super_constructor_call.sol b/test/libsolidity/syntaxTests/inheritance/allow_empty_duplicated_super_constructor_call.sol new file mode 100644 index 00000000..1f580b1d --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/allow_empty_duplicated_super_constructor_call.sol @@ -0,0 +1,3 @@ +contract A { constructor() public { } } +contract B1 is A { constructor() A() public { } } +contract B2 is A { constructor() A public { } } diff --git a/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol b/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol new file mode 100644 index 00000000..f63d0f02 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol @@ -0,0 +1,9 @@ +contract Base { + constructor(uint) public { } +} +contract Base1 is Base(3) {} +contract Derived is Base, Base1 { + constructor(uint i) Base(i) public {} +} +// ---- +// Warning: Duplicated super constructor calls are deprecated. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_ancestor_constructor_call.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_ancestor_constructor_call.sol new file mode 100644 index 00000000..97f3f8ff --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_ancestor_constructor_call.sol @@ -0,0 +1,5 @@ +contract A { constructor(uint) public { } } +contract B is A(2) { constructor() public { } } +contract C is B { constructor() A(3) public { } } +// ---- +// Warning: Duplicated super constructor calls are deprecated. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_ancestor_constructor_call_V050.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_ancestor_constructor_call_V050.sol new file mode 100644 index 00000000..933c9087 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_ancestor_constructor_call_V050.sol @@ -0,0 +1,7 @@ +pragma experimental "v0.5.0"; + +contract A { constructor(uint) public { } } +contract B is A(2) { constructor() public { } } +contract C is B { constructor() A(3) public { } } +// ---- +// DeclarationError: Duplicated super constructor call. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call.sol index 95df1040..876b07ea 100644 --- a/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call.sol +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call.sol @@ -1,4 +1,4 @@ contract A { constructor(uint) public { } } contract B is A(2) { constructor() A(3) public { } } // ---- -// DeclarationError: Duplicated super constructor call. +// Warning: Duplicated super constructor calls are deprecated. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_V050.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_V050.sol new file mode 100644 index 00000000..31a363fd --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_V050.sol @@ -0,0 +1,6 @@ +pragma experimental "v0.5.0"; + +contract A { constructor(uint) public { } } +contract B is A(2) { constructor() A(3) public { } } +// ---- +// DeclarationError: Duplicated super constructor call. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_empty.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_empty.sol deleted file mode 100644 index f8024ad6..00000000 --- a/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_empty.sol +++ /dev/null @@ -1,4 +0,0 @@ -contract A { constructor() public { } } -contract B is A { constructor() A() public { } } -// ---- -// DeclarationError: Duplicated super constructor call. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_multi.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_multi.sol new file mode 100644 index 00000000..caed18eb --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_multi.sol @@ -0,0 +1,7 @@ +contract C { constructor(uint) public {} } +contract A is C(2) {} +contract B is C(2) {} +contract D is A, B { constructor() C(3) public {} } +// ---- +// Warning: Duplicated super constructor calls are deprecated. +// Warning: Duplicated super constructor calls are deprecated. -- cgit From b918a105a40aa90fe9b89eecbcdfc7ac2937c141 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Thu, 5 Apr 2018 16:25:20 +0200 Subject: Move constructor argument override check to TypeChecker and reuse annotations in ContractCompiler. --- .../inheritance/base_arguments_multiple_inheritance.sol | 2 +- .../inheritance/duplicated_ancestor_constructor_call.sol | 5 ----- .../inheritance/duplicated_ancestor_constructor_call_V050.sol | 7 ------- .../inheritance/duplicated_constructor_call/ancestor.sol | 5 +++++ .../inheritance/duplicated_constructor_call/ancestor_V050.sol | 7 +++++++ .../syntaxTests/inheritance/duplicated_constructor_call/base.sol | 4 ++++ .../inheritance/duplicated_constructor_call/base_V050.sol | 6 ++++++ .../inheritance/duplicated_constructor_call/base_multi.sol | 7 +++++++ .../duplicated_constructor_call/base_multi_no_constructor.sol | 6 ++++++ .../base_multi_no_constructor_modifier_style.sol | 6 ++++++ .../syntaxTests/inheritance/duplicated_super_constructor_call.sol | 4 ---- .../inheritance/duplicated_super_constructor_call_V050.sol | 6 ------ .../inheritance/duplicated_super_constructor_call_multi.sol | 7 ------- 13 files changed, 42 insertions(+), 30 deletions(-) delete mode 100644 test/libsolidity/syntaxTests/inheritance/duplicated_ancestor_constructor_call.sol delete mode 100644 test/libsolidity/syntaxTests/inheritance/duplicated_ancestor_constructor_call_V050.sol create mode 100644 test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol create mode 100644 test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol create mode 100644 test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol create mode 100644 test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_V050.sol create mode 100644 test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol create mode 100644 test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol create mode 100644 test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol delete mode 100644 test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call.sol delete mode 100644 test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_V050.sol delete mode 100644 test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_multi.sol (limited to 'test/libsolidity/syntaxTests/inheritance') diff --git a/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol b/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol index f63d0f02..5483d5d7 100644 --- a/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol +++ b/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol @@ -6,4 +6,4 @@ contract Derived is Base, Base1 { constructor(uint i) Base(i) public {} } // ---- -// Warning: Duplicated super constructor calls are deprecated. +// Warning: Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_ancestor_constructor_call.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_ancestor_constructor_call.sol deleted file mode 100644 index 97f3f8ff..00000000 --- a/test/libsolidity/syntaxTests/inheritance/duplicated_ancestor_constructor_call.sol +++ /dev/null @@ -1,5 +0,0 @@ -contract A { constructor(uint) public { } } -contract B is A(2) { constructor() public { } } -contract C is B { constructor() A(3) public { } } -// ---- -// Warning: Duplicated super constructor calls are deprecated. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_ancestor_constructor_call_V050.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_ancestor_constructor_call_V050.sol deleted file mode 100644 index 933c9087..00000000 --- a/test/libsolidity/syntaxTests/inheritance/duplicated_ancestor_constructor_call_V050.sol +++ /dev/null @@ -1,7 +0,0 @@ -pragma experimental "v0.5.0"; - -contract A { constructor(uint) public { } } -contract B is A(2) { constructor() public { } } -contract C is B { constructor() A(3) public { } } -// ---- -// DeclarationError: Duplicated super constructor call. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol new file mode 100644 index 00000000..8b1af245 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol @@ -0,0 +1,5 @@ +contract A { constructor(uint) public { } } +contract B is A(2) { constructor() public { } } +contract C is B { constructor() A(3) public { } } +// ---- +// Warning: Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol new file mode 100644 index 00000000..6616c9a9 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol @@ -0,0 +1,7 @@ +pragma experimental "v0.5.0"; + +contract A { constructor(uint) public { } } +contract B is A(2) { constructor() public { } } +contract C is B { constructor() A(3) public { } } +// ---- +// DeclarationError: Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol new file mode 100644 index 00000000..1fb504fe --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol @@ -0,0 +1,4 @@ +contract A { constructor(uint) public { } } +contract B is A(2) { constructor() A(3) public { } } +// ---- +// Warning: Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_V050.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_V050.sol new file mode 100644 index 00000000..96eb1bb1 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_V050.sol @@ -0,0 +1,6 @@ +pragma experimental "v0.5.0"; + +contract A { constructor(uint) public { } } +contract B is A(2) { constructor() A(3) public { } } +// ---- +// DeclarationError: Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol new file mode 100644 index 00000000..db9ffc85 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol @@ -0,0 +1,7 @@ +contract C { constructor(uint) public {} } +contract A is C(2) {} +contract B is C(2) {} +contract D is A, B { constructor() C(3) public {} } +// ---- +// Warning: Base constructor arguments given twice. +// Warning: Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol new file mode 100644 index 00000000..fe280ad5 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol @@ -0,0 +1,6 @@ +contract C { constructor(uint) public {} } +contract A is C(2) {} +contract B is C(2) {} +contract D is A, B {} +// ---- +// Warning: Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol new file mode 100644 index 00000000..ea85aae7 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol @@ -0,0 +1,6 @@ +contract C { constructor(uint) public {} } +contract A is C { constructor() C(2) public {} } +contract B is C { constructor() C(2) public {} } +contract D is A, B { } +// ---- +// Warning: Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call.sol deleted file mode 100644 index 876b07ea..00000000 --- a/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call.sol +++ /dev/null @@ -1,4 +0,0 @@ -contract A { constructor(uint) public { } } -contract B is A(2) { constructor() A(3) public { } } -// ---- -// Warning: Duplicated super constructor calls are deprecated. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_V050.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_V050.sol deleted file mode 100644 index 31a363fd..00000000 --- a/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_V050.sol +++ /dev/null @@ -1,6 +0,0 @@ -pragma experimental "v0.5.0"; - -contract A { constructor(uint) public { } } -contract B is A(2) { constructor() A(3) public { } } -// ---- -// DeclarationError: Duplicated super constructor call. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_multi.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_multi.sol deleted file mode 100644 index caed18eb..00000000 --- a/test/libsolidity/syntaxTests/inheritance/duplicated_super_constructor_call_multi.sol +++ /dev/null @@ -1,7 +0,0 @@ -contract C { constructor(uint) public {} } -contract A is C(2) {} -contract B is C(2) {} -contract D is A, B { constructor() C(3) public {} } -// ---- -// Warning: Duplicated super constructor calls are deprecated. -// Warning: Duplicated super constructor calls are deprecated. -- cgit