From 552d3534309e4d9afe7550de86d9198db735077f Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 6 Jul 2020 15:47:40 +0200 Subject: [PATCH] New tests. --- .../constructor/constructer_internal_function_abstract.sol | 3 +++ .../constructor/constructor_internal_function.sol | 5 +++++ .../syntaxTests/constructor/constructor_mapping_memory.sol | 6 ++++++ .../constructor/constructor_mapping_memory_abstract.sol | 5 +++++ .../syntaxTests/constructor/constructor_storage.sol | 5 +++++ .../constructor/constructor_storage_abstract.sol | 3 +++ test/libsolidity/syntaxTests/constructor/nonabiv2_type.sol | 5 +++++ .../syntaxTests/constructor/nonabiv2_type_abstract.sol | 4 ++++ 8 files changed, 36 insertions(+) create mode 100644 test/libsolidity/syntaxTests/constructor/constructer_internal_function_abstract.sol create mode 100644 test/libsolidity/syntaxTests/constructor/constructor_internal_function.sol create mode 100644 test/libsolidity/syntaxTests/constructor/constructor_mapping_memory.sol create mode 100644 test/libsolidity/syntaxTests/constructor/constructor_mapping_memory_abstract.sol create mode 100644 test/libsolidity/syntaxTests/constructor/constructor_storage.sol create mode 100644 test/libsolidity/syntaxTests/constructor/constructor_storage_abstract.sol create mode 100644 test/libsolidity/syntaxTests/constructor/nonabiv2_type.sol create mode 100644 test/libsolidity/syntaxTests/constructor/nonabiv2_type_abstract.sol diff --git a/test/libsolidity/syntaxTests/constructor/constructer_internal_function_abstract.sol b/test/libsolidity/syntaxTests/constructor/constructer_internal_function_abstract.sol new file mode 100644 index 000000000..de9a1d5f0 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/constructer_internal_function_abstract.sol @@ -0,0 +1,3 @@ +abstract contract A { + constructor(function() internal) {} +} diff --git a/test/libsolidity/syntaxTests/constructor/constructor_internal_function.sol b/test/libsolidity/syntaxTests/constructor/constructor_internal_function.sol new file mode 100644 index 000000000..bc57055e8 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/constructor_internal_function.sol @@ -0,0 +1,5 @@ +contract A { + constructor(function() internal) {} +} +// ---- +// TypeError 4103: (29-49): Internal type is not allowed for public or external functions. You can make the contract abstract to avoid this problem. diff --git a/test/libsolidity/syntaxTests/constructor/constructor_mapping_memory.sol b/test/libsolidity/syntaxTests/constructor/constructor_mapping_memory.sol new file mode 100644 index 000000000..266a440d6 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/constructor_mapping_memory.sol @@ -0,0 +1,6 @@ +contract A { + constructor(mapping(uint => uint) memory a) {} +} +// ---- +// TypeError 4103: (29-59): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. You can make the contract abstract to avoid this problem. +// TypeError 4061: (29-59): Type mapping(uint256 => uint256) is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/constructor/constructor_mapping_memory_abstract.sol b/test/libsolidity/syntaxTests/constructor/constructor_mapping_memory_abstract.sol new file mode 100644 index 000000000..416287895 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/constructor_mapping_memory_abstract.sol @@ -0,0 +1,5 @@ +abstract contract A { + constructor(mapping(uint => uint) memory a) {} +} +// ---- +// TypeError 4061: (38-68): Type mapping(uint256 => uint256) is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/constructor/constructor_storage.sol b/test/libsolidity/syntaxTests/constructor/constructor_storage.sol new file mode 100644 index 000000000..9388da132 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/constructor_storage.sol @@ -0,0 +1,5 @@ +contract A { + constructor(uint[] storage a) {} +} +// ---- +// TypeError 3644: (29-45): This parameter has a type that can only be used internally. You can make the contract abstract to avoid this problem. diff --git a/test/libsolidity/syntaxTests/constructor/constructor_storage_abstract.sol b/test/libsolidity/syntaxTests/constructor/constructor_storage_abstract.sol new file mode 100644 index 000000000..d00d4f5e3 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/constructor_storage_abstract.sol @@ -0,0 +1,3 @@ +abstract contract A { + constructor(uint[] storage a) {} +} diff --git a/test/libsolidity/syntaxTests/constructor/nonabiv2_type.sol b/test/libsolidity/syntaxTests/constructor/nonabiv2_type.sol new file mode 100644 index 000000000..13b0d02af --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/nonabiv2_type.sol @@ -0,0 +1,5 @@ +contract C { + constructor(uint[][][] memory t) {} +} +// ---- +// TypeError 4957: (26-45): This type is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. Alternatively, make the contract abstract and supply the constructor arguments from a derived contract. diff --git a/test/libsolidity/syntaxTests/constructor/nonabiv2_type_abstract.sol b/test/libsolidity/syntaxTests/constructor/nonabiv2_type_abstract.sol new file mode 100644 index 000000000..7fc802247 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/nonabiv2_type_abstract.sol @@ -0,0 +1,4 @@ +abstract contract C { + constructor(uint[][][] memory t) {} +} +// ----