aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDaniel Kirchner <daniel@ekpyron.org>2019-01-17 19:59:11 +0800
committerchriseth <chris@ethereum.org>2019-01-21 17:30:57 +0800
commit610ef9f1999c1dd201a121334394b10f6ac54bc7 (patch)
treecec0b5e39c47e82e66fd3130c9ed99df3a42b762 /test
parentd3270bc31174d6c155314231e07755c4bb055729 (diff)
downloaddexon-solidity-610ef9f1999c1dd201a121334394b10f6ac54bc7.tar
dexon-solidity-610ef9f1999c1dd201a121334394b10f6ac54bc7.tar.gz
dexon-solidity-610ef9f1999c1dd201a121334394b10f6ac54bc7.tar.bz2
dexon-solidity-610ef9f1999c1dd201a121334394b10f6ac54bc7.tar.lz
dexon-solidity-610ef9f1999c1dd201a121334394b10f6ac54bc7.tar.xz
dexon-solidity-610ef9f1999c1dd201a121334394b10f6ac54bc7.tar.zst
dexon-solidity-610ef9f1999c1dd201a121334394b10f6ac54bc7.zip
Disallow calldata structs.
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp14
-rw-r--r--test/libsolidity/syntaxTests/inheritance/override/calldata_memory_struct.sol4
-rw-r--r--test/libsolidity/syntaxTests/structs/array_calldata.sol10
-rw-r--r--test/libsolidity/syntaxTests/structs/calldata.sol8
4 files changed, 32 insertions, 4 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 774f67fe..0470cf4c 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -198,7 +198,7 @@ BOOST_AUTO_TEST_CASE(enum_external_type)
}
}
-BOOST_AUTO_TEST_CASE(external_structs)
+BOOST_AUTO_TEST_CASE(external_struct_signatures)
{
char const* text = R"(
pragma experimental ABIEncoderV2;
@@ -213,7 +213,10 @@ BOOST_AUTO_TEST_CASE(external_structs)
function i(Nested[] calldata) external {}
}
)";
- SourceUnit const* sourceUnit = parseAndAnalyse(text);
+ // Ignore analysis errors. This test only checks that correct signatures
+ // are generated for external structs, but they are not yet supported
+ // in code generation and therefore cause an error in the TypeChecker.
+ SourceUnit const* sourceUnit = parseAnalyseAndReturnError(text, false, true, true).first;
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{
@@ -226,7 +229,7 @@ BOOST_AUTO_TEST_CASE(external_structs)
}
}
-BOOST_AUTO_TEST_CASE(external_structs_in_libraries)
+BOOST_AUTO_TEST_CASE(external_struct_signatures_in_libraries)
{
char const* text = R"(
pragma experimental ABIEncoderV2;
@@ -241,7 +244,10 @@ BOOST_AUTO_TEST_CASE(external_structs_in_libraries)
function i(Nested[] calldata) external {}
}
)";
- SourceUnit const* sourceUnit = parseAndAnalyse(text);
+ // Ignore analysis errors. This test only checks that correct signatures
+ // are generated for external structs, but calldata structs are not yet supported
+ // in code generation and therefore cause an error in the TypeChecker.
+ SourceUnit const* sourceUnit = parseAnalyseAndReturnError(text, false, true, true).first;
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{
diff --git a/test/libsolidity/syntaxTests/inheritance/override/calldata_memory_struct.sol b/test/libsolidity/syntaxTests/inheritance/override/calldata_memory_struct.sol
index 42aebf30..b81e3859 100644
--- a/test/libsolidity/syntaxTests/inheritance/override/calldata_memory_struct.sol
+++ b/test/libsolidity/syntaxTests/inheritance/override/calldata_memory_struct.sol
@@ -15,3 +15,7 @@ contract B is A {
}
// ----
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
+// TypeError: (102-112): Calldata structs are not yet supported.
+// TypeError: (146-156): Calldata structs are not yet supported.
+// TypeError: (198-208): Calldata structs are not yet supported.
+// TypeError: (250-260): Calldata structs are not yet supported.
diff --git a/test/libsolidity/syntaxTests/structs/array_calldata.sol b/test/libsolidity/syntaxTests/structs/array_calldata.sol
new file mode 100644
index 00000000..3aac5606
--- /dev/null
+++ b/test/libsolidity/syntaxTests/structs/array_calldata.sol
@@ -0,0 +1,10 @@
+pragma experimental ABIEncoderV2;
+contract Test {
+ struct S { int a; }
+ function f(S[] calldata) external { }
+ function f(S[][] calldata) external { }
+}
+// ----
+// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
+// TypeError: (89-101): Calldata structs are not yet supported.
+// TypeError: (131-145): Calldata structs are not yet supported.
diff --git a/test/libsolidity/syntaxTests/structs/calldata.sol b/test/libsolidity/syntaxTests/structs/calldata.sol
new file mode 100644
index 00000000..dadf6e4f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/structs/calldata.sol
@@ -0,0 +1,8 @@
+pragma experimental ABIEncoderV2;
+contract Test {
+ struct S { int a; }
+ function f(S calldata) external { }
+}
+// ----
+// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
+// TypeError: (89-99): Calldata structs are not yet supported.