aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/libjulia/Parser.cpp10
-rw-r--r--test/libsolidity/GasMeter.cpp40
-rw-r--r--test/libsolidity/InlineAssembly.cpp26
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp76
-rw-r--r--test/libsolidity/SolidityParser.cpp2
-rw-r--r--test/libsolidity/StandardCompiler.cpp4
-rw-r--r--test/libsolidity/syntaxTests/functionTypes/function_type_constructor_local.sol2
-rw-r--r--test/libsolidity/syntaxTests/parsing/constant_is_keyword.sol2
-rw-r--r--test/libsolidity/syntaxTests/parsing/emit_without_event.sol2
-rw-r--r--test/libsolidity/syntaxTests/parsing/event_with_no_argument_list.sol2
-rw-r--r--test/libsolidity/syntaxTests/parsing/external_variable.sol2
-rw-r--r--test/libsolidity/syntaxTests/parsing/fixed_literal_with_double_radix.sol2
-rw-r--r--test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_modifiers.sol2
-rw-r--r--test/libsolidity/syntaxTests/parsing/local_const_variable.sol2
-rw-r--r--test/libsolidity/syntaxTests/parsing/location_specifiers_for_state_variables.sol2
-rw-r--r--test/libsolidity/syntaxTests/parsing/malformed_enum_declaration.sol2
-rw-r--r--test/libsolidity/syntaxTests/parsing/missing_parameter_name_in_named_args.sol2
-rw-r--r--test/libsolidity/syntaxTests/parsing/missing_variable_name_in_declaration.sol2
-rw-r--r--test/libsolidity/syntaxTests/parsing/modifier_without_semicolon.sol2
-rw-r--r--test/libsolidity/syntaxTests/parsing/payable_accessor.sol2
-rw-r--r--test/libsolidity/syntaxTests/parsing/tuples_without_commas.sol2
-rw-r--r--test/libsolidity/syntaxTests/parsing/var_array.sol2
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/error_fill.sol12
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/large_component_count.sol24
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/nowarn_explicit_singleton_token_expression.sol8
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/nowarn_swap_memory.sol8
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/nowarn_swap_storage_pointers.sol10
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/warn_fill_assignment.sol11
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/warn_fill_vardecl.sol11
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies.sol9
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_left.sol10
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_right.sol10
32 files changed, 191 insertions, 112 deletions
diff --git a/test/libjulia/Parser.cpp b/test/libjulia/Parser.cpp
index 9d66658e..96261dec 100644
--- a/test/libjulia/Parser.cpp
+++ b/test/libjulia/Parser.cpp
@@ -212,10 +212,10 @@ BOOST_AUTO_TEST_CASE(tokens_as_identifers)
BOOST_AUTO_TEST_CASE(lacking_types)
{
- CHECK_ERROR("{ let x := 1:u256 }", ParserError, "Expected token Identifier got 'Assign'");
- CHECK_ERROR("{ let x:u256 := 1 }", ParserError, "Expected token Colon got 'RBrace'");
- CHECK_ERROR("{ function f(a) {} }", ParserError, "Expected token Colon got 'RParen'");
- CHECK_ERROR("{ function f(a:u256) -> b {} }", ParserError, "Expected token Colon got 'LBrace'");
+ CHECK_ERROR("{ let x := 1:u256 }", ParserError, "Expected identifier but got '='");
+ CHECK_ERROR("{ let x:u256 := 1 }", ParserError, "Expected ':' but got '}'");
+ CHECK_ERROR("{ function f(a) {} }", ParserError, "Expected ':' but got ')'");
+ CHECK_ERROR("{ function f(a:u256) -> b {} }", ParserError, "Expected ':' but got '{'");
}
BOOST_AUTO_TEST_CASE(invalid_types)
@@ -294,7 +294,7 @@ BOOST_AUTO_TEST_CASE(if_statement)
BOOST_AUTO_TEST_CASE(if_statement_invalid)
{
CHECK_ERROR("{ if let x:u256 {} }", ParserError, "Literal or identifier expected.");
- CHECK_ERROR("{ if true:bool let x:u256 := 3:u256 }", ParserError, "Expected token LBrace");
+ CHECK_ERROR("{ if true:bool let x:u256 := 3:u256 }", ParserError, "Expected '{' but got reserved keyword 'let'");
// TODO change this to an error once we check types.
BOOST_CHECK(successParse("{ if 42:u256 { } }"));
}
diff --git a/test/libsolidity/GasMeter.cpp b/test/libsolidity/GasMeter.cpp
index 0d66456c..f16d9abe 100644
--- a/test/libsolidity/GasMeter.cpp
+++ b/test/libsolidity/GasMeter.cpp
@@ -307,6 +307,46 @@ BOOST_AUTO_TEST_CASE(regular_functions_exclude_fallback)
testCreationTimeGas(sourceCode);
testRunTimeGas("x()", vector<bytes>{encodeArgs()});
}
+
+BOOST_AUTO_TEST_CASE(complex_control_flow)
+{
+ // This crashed the gas estimator previously (or took a very long time).
+ // Now we do not follow branches if they start out with lower gas costs than the ones
+ // we previously considered. This of course reduces accuracy.
+ char const* sourceCode = R"(
+ contract log {
+ function ln(int128 x) constant returns (int128 result) {
+ int128 t = x / 256;
+ int128 y = 5545177;
+ x = t;
+ t = x * 16; if (t <= 1000000) { x = t; y = y - 2772588; }
+ t = x * 4; if (t <= 1000000) { x = t; y = y - 1386294; }
+ t = x * 2; if (t <= 1000000) { x = t; y = y - 693147; }
+ t = x + x / 2; if (t <= 1000000) { x = t; y = y - 405465; }
+ t = x + x / 4; if (t <= 1000000) { x = t; y = y - 223144; }
+ t = x + x / 8; if (t <= 1000000) { x = t; y = y - 117783; }
+ t = x + x / 16; if (t <= 1000000) { x = t; y = y - 60624; }
+ t = x + x / 32; if (t <= 1000000) { x = t; y = y - 30771; }
+ t = x + x / 64; if (t <= 1000000) { x = t; y = y - 15504; }
+ t = x + x / 128; if (t <= 1000000) { x = t; y = y - 7782; }
+ t = x + x / 256; if (t <= 1000000) { x = t; y = y - 3898; }
+ t = x + x / 512; if (t <= 1000000) { x = t; y = y - 1951; }
+ t = x + x / 1024; if (t <= 1000000) { x = t; y = y - 976; }
+ t = x + x / 2048; if (t <= 1000000) { x = t; y = y - 488; }
+ t = x + x / 4096; if (t <= 1000000) { x = t; y = y - 244; }
+ t = x + x / 8192; if (t <= 1000000) { x = t; y = y - 122; }
+ t = x + x / 16384; if (t <= 1000000) { x = t; y = y - 61; }
+ t = x + x / 32768; if (t <= 1000000) { x = t; y = y - 31; }
+ t = x + x / 65536; if (t <= 1000000) { y = y - 15; }
+ return y;
+ }
+ }
+ )";
+ testCreationTimeGas(sourceCode);
+ // max gas is used for small x
+ testRunTimeGas("ln(int128)", vector<bytes>{encodeArgs(0), encodeArgs(10), encodeArgs(105), encodeArgs(30000)});
+}
+
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/test/libsolidity/InlineAssembly.cpp b/test/libsolidity/InlineAssembly.cpp
index 0ced1792..181ca959 100644
--- a/test/libsolidity/InlineAssembly.cpp
+++ b/test/libsolidity/InlineAssembly.cpp
@@ -170,7 +170,7 @@ BOOST_AUTO_TEST_CASE(smoke_test)
BOOST_AUTO_TEST_CASE(surplus_input)
{
- CHECK_PARSE_ERROR("{ } { }", ParserError, "Expected token EOS");
+ CHECK_PARSE_ERROR("{ } { }", ParserError, "Expected end of source but got '{'");
}
BOOST_AUTO_TEST_CASE(simple_instructions)
@@ -246,7 +246,7 @@ BOOST_AUTO_TEST_CASE(functional)
BOOST_AUTO_TEST_CASE(functional_partial)
{
- CHECK_PARSE_ERROR("{ let x := byte }", ParserError, "Expected token \"(\"");
+ CHECK_PARSE_ERROR("{ let x := byte }", ParserError, "Expected '(' (instruction \"byte\" expects 2 arguments)");
}
BOOST_AUTO_TEST_CASE(functional_partial_success)
@@ -290,10 +290,10 @@ BOOST_AUTO_TEST_CASE(if_statement_scope)
BOOST_AUTO_TEST_CASE(if_statement_invalid)
{
- CHECK_PARSE_ERROR("{ if mload {} }", ParserError, "Expected token \"(\"");
+ CHECK_PARSE_ERROR("{ if mload {} }", ParserError, "Expected '(' (instruction \"mload\" expects 1 arguments)");
BOOST_CHECK("{ if calldatasize() {}");
CHECK_PARSE_ERROR("{ if mstore(1, 1) {} }", ParserError, "Instruction \"mstore\" not allowed in this context");
- CHECK_PARSE_ERROR("{ if 32 let x := 3 }", ParserError, "Expected token LBrace");
+ CHECK_PARSE_ERROR("{ if 32 let x := 3 }", ParserError, "Expected '{' but got reserved keyword 'let'");
}
BOOST_AUTO_TEST_CASE(switch_statement)
@@ -320,7 +320,7 @@ BOOST_AUTO_TEST_CASE(switch_duplicate_case)
BOOST_AUTO_TEST_CASE(switch_invalid_expression)
{
CHECK_PARSE_ERROR("{ switch {} default {} }", ParserError, "Literal, identifier or instruction expected.");
- CHECK_PARSE_ERROR("{ switch mload default {} }", ParserError, "Expected token \"(\"");
+ CHECK_PARSE_ERROR("{ switch mload default {} }", ParserError, "Expected '(' (instruction \"mload\" expects 1 arguments)");
CHECK_PARSE_ERROR("{ switch mstore(1, 1) default {} }", ParserError, "Instruction \"mstore\" not allowed in this context");
}
@@ -341,7 +341,7 @@ BOOST_AUTO_TEST_CASE(switch_invalid_case)
BOOST_AUTO_TEST_CASE(switch_invalid_body)
{
- CHECK_PARSE_ERROR("{ switch 42 case 1 mul case 2 {} default {} }", ParserError, "Expected token LBrace got 'Identifier'");
+ CHECK_PARSE_ERROR("{ switch 42 case 1 mul case 2 {} default {} }", ParserError, "Expected '{' but got identifier");
}
BOOST_AUTO_TEST_CASE(for_statement)
@@ -353,10 +353,10 @@ BOOST_AUTO_TEST_CASE(for_statement)
BOOST_AUTO_TEST_CASE(for_invalid_expression)
{
CHECK_PARSE_ERROR("{ for {} {} {} {} }", ParserError, "Literal, identifier or instruction expected.");
- CHECK_PARSE_ERROR("{ for 1 1 {} {} }", ParserError, "Expected token LBrace got 'Number'");
- CHECK_PARSE_ERROR("{ for {} 1 1 {} }", ParserError, "Expected token LBrace got 'Number'");
- CHECK_PARSE_ERROR("{ for {} 1 {} 1 }", ParserError, "Expected token LBrace got 'Number'");
- CHECK_PARSE_ERROR("{ for {} mload {} {} }", ParserError, "Expected token \"(\"");
+ CHECK_PARSE_ERROR("{ for 1 1 {} {} }", ParserError, "Expected '{' but got 'Number'");
+ CHECK_PARSE_ERROR("{ for {} 1 1 {} }", ParserError, "Expected '{' but got 'Number'");
+ CHECK_PARSE_ERROR("{ for {} 1 {} 1 }", ParserError, "Expected '{' but got 'Number'");
+ CHECK_PARSE_ERROR("{ for {} mload {} {} }", ParserError, "Expected '(' (instruction \"mload\" expects 1 arguments)");
CHECK_PARSE_ERROR("{ for {} mstore(1, 1) {} {} }", ParserError, "Instruction \"mstore\" not allowed in this context");
}
@@ -437,13 +437,13 @@ BOOST_AUTO_TEST_CASE(invalid_tuple_assignment)
BOOST_AUTO_TEST_CASE(instruction_too_few_arguments)
{
- CHECK_PARSE_ERROR("{ mul() }", ParserError, "Expected expression (\"mul\" expects 2 arguments)");
- CHECK_PARSE_ERROR("{ mul(1) }", ParserError, "Expected comma (\"mul\" expects 2 arguments)");
+ CHECK_PARSE_ERROR("{ mul() }", ParserError, "Expected expression (instruction \"mul\" expects 2 arguments)");
+ CHECK_PARSE_ERROR("{ mul(1) }", ParserError, "Expected ',' (instruction \"mul\" expects 2 arguments)");
}
BOOST_AUTO_TEST_CASE(instruction_too_many_arguments)
{
- CHECK_PARSE_ERROR("{ mul(1, 2, 3) }", ParserError, "Expected ')' (\"mul\" expects 2 arguments)");
+ CHECK_PARSE_ERROR("{ mul(1, 2, 3) }", ParserError, "Expected ')' (instruction \"mul\" expects 2 arguments)");
}
BOOST_AUTO_TEST_CASE(recursion_depth)
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index a2540302..91fd1fff 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -2894,7 +2894,7 @@ BOOST_AUTO_TEST_CASE(dynamic_return_types_not_possible)
contract C {
function f(uint) public returns (string);
function g() public {
- var (x,) = this.f(2);
+ var x = this.f(2);
// we can assign to x but it is not usable.
bytes(x).length;
}
@@ -5833,80 +5833,6 @@ BOOST_AUTO_TEST_CASE(pure_statement_check_for_regular_for_loop)
CHECK_SUCCESS(text);
}
-BOOST_AUTO_TEST_CASE(warn_multiple_storage_storage_copies)
-{
- char const* text = R"(
- contract C {
- struct S { uint a; uint b; }
- S x; S y;
- function f() public {
- (x, y) = (y, x);
- }
- }
- )";
- CHECK_WARNING(text, "This assignment performs two copies to storage.");
-}
-
-BOOST_AUTO_TEST_CASE(warn_multiple_storage_storage_copies_fill_right)
-{
- char const* text = R"(
- contract C {
- struct S { uint a; uint b; }
- S x; S y;
- function f() public {
- (x, y, ) = (y, x, 1, 2);
- }
- }
- )";
- CHECK_WARNING(text, "This assignment performs two copies to storage.");
-}
-
-BOOST_AUTO_TEST_CASE(warn_multiple_storage_storage_copies_fill_left)
-{
- char const* text = R"(
- contract C {
- struct S { uint a; uint b; }
- S x; S y;
- function f() public {
- (,x, y) = (1, 2, y, x);
- }
- }
- )";
- CHECK_WARNING(text, "This assignment performs two copies to storage.");
-}
-
-BOOST_AUTO_TEST_CASE(nowarn_swap_memory)
-{
- char const* text = R"(
- contract C {
- struct S { uint a; uint b; }
- function f() pure public {
- S memory x;
- S memory y;
- (x, y) = (y, x);
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(nowarn_swap_storage_pointers)
-{
- char const* text = R"(
- contract C {
- struct S { uint a; uint b; }
- S x; S y;
- function f() public {
- S storage x_local = x;
- S storage y_local = y;
- S storage z_local = x;
- (x, y_local, x_local, z_local) = (y, x_local, y_local, y);
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
BOOST_AUTO_TEST_CASE(warn_unused_local)
{
char const* text = R"(
diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp
index f428f892..77686b03 100644
--- a/test/libsolidity/SolidityParser.cpp
+++ b/test/libsolidity/SolidityParser.cpp
@@ -992,7 +992,7 @@ BOOST_AUTO_TEST_CASE(keyword_is_reserved)
for (const auto& keyword: keywords)
{
auto text = std::string("contract ") + keyword + " {}";
- CHECK_PARSE_ERROR(text.c_str(), "Expected token Identifier got reserved keyword");
+ CHECK_PARSE_ERROR(text.c_str(), "Expected identifier but got reserved keyword");
}
}
diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp
index f816905c..560c9013 100644
--- a/test/libsolidity/StandardCompiler.cpp
+++ b/test/libsolidity/StandardCompiler.cpp
@@ -326,8 +326,8 @@ BOOST_AUTO_TEST_CASE(compilation_error)
{
BOOST_CHECK_EQUAL(
dev::jsonCompactPrint(error),
- "{\"component\":\"general\",\"formattedMessage\":\"fileA:1:23: ParserError: Expected token Identifier got 'RBrace'\\n"
- "contract A { function }\\n ^\\n\",\"message\":\"Expected token Identifier got 'RBrace'\","
+ "{\"component\":\"general\",\"formattedMessage\":\"fileA:1:23: ParserError: Expected identifier but got '}'\\n"
+ "contract A { function }\\n ^\\n\",\"message\":\"Expected identifier but got '}'\","
"\"severity\":\"error\",\"sourceLocation\":{\"end\":22,\"file\":\"fileA\",\"start\":22},\"type\":\"ParserError\"}"
);
}
diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_constructor_local.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_constructor_local.sol
index b7763d28..766b98b3 100644
--- a/test/libsolidity/syntaxTests/functionTypes/function_type_constructor_local.sol
+++ b/test/libsolidity/syntaxTests/functionTypes/function_type_constructor_local.sol
@@ -5,4 +5,4 @@ contract C {
}
}
// ----
-// ParserError: (118-118): Expected token Semicolon got 'Identifier'
+// ParserError: (118-118): Expected ';' but got identifier
diff --git a/test/libsolidity/syntaxTests/parsing/constant_is_keyword.sol b/test/libsolidity/syntaxTests/parsing/constant_is_keyword.sol
index 59fe8518..da3fa1c6 100644
--- a/test/libsolidity/syntaxTests/parsing/constant_is_keyword.sol
+++ b/test/libsolidity/syntaxTests/parsing/constant_is_keyword.sol
@@ -2,4 +2,4 @@ contract Foo {
uint constant = 4;
}
// ----
-// ParserError: (30-30): Expected token Identifier got 'Assign'
+// ParserError: (30-30): Expected identifier but got '='
diff --git a/test/libsolidity/syntaxTests/parsing/emit_without_event.sol b/test/libsolidity/syntaxTests/parsing/emit_without_event.sol
index 5916fc2b..1af1d4ab 100644
--- a/test/libsolidity/syntaxTests/parsing/emit_without_event.sol
+++ b/test/libsolidity/syntaxTests/parsing/emit_without_event.sol
@@ -5,4 +5,4 @@ contract C {
}
}
// ----
-// ParserError: (49-49): Expected token LParen got 'Semicolon'
+// ParserError: (49-49): Expected '(' but got ';'
diff --git a/test/libsolidity/syntaxTests/parsing/event_with_no_argument_list.sol b/test/libsolidity/syntaxTests/parsing/event_with_no_argument_list.sol
index ae2591db..850c3627 100644
--- a/test/libsolidity/syntaxTests/parsing/event_with_no_argument_list.sol
+++ b/test/libsolidity/syntaxTests/parsing/event_with_no_argument_list.sol
@@ -2,4 +2,4 @@ contract c {
event e;
}
// ----
-// ParserError: (21-21): Expected token LParen got 'Semicolon'
+// ParserError: (21-21): Expected '(' but got ';'
diff --git a/test/libsolidity/syntaxTests/parsing/external_variable.sol b/test/libsolidity/syntaxTests/parsing/external_variable.sol
index 1d2e65e6..2de70e23 100644
--- a/test/libsolidity/syntaxTests/parsing/external_variable.sol
+++ b/test/libsolidity/syntaxTests/parsing/external_variable.sol
@@ -2,4 +2,4 @@ contract c {
uint external x;
}
// ----
-// ParserError: (19-19): Expected token Identifier got 'External'
+// ParserError: (19-19): Expected identifier but got 'external'
diff --git a/test/libsolidity/syntaxTests/parsing/fixed_literal_with_double_radix.sol b/test/libsolidity/syntaxTests/parsing/fixed_literal_with_double_radix.sol
index 43bb61fa..b3adc03d 100644
--- a/test/libsolidity/syntaxTests/parsing/fixed_literal_with_double_radix.sol
+++ b/test/libsolidity/syntaxTests/parsing/fixed_literal_with_double_radix.sol
@@ -2,4 +2,4 @@ contract A {
fixed40x40 pi = 3.14.15;
}
// ----
-// ParserError: (34-34): Expected token Semicolon got 'Number'
+// ParserError: (34-34): Expected ';' but got 'Number'
diff --git a/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_modifiers.sol b/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_modifiers.sol
index 12480459..198d250b 100644
--- a/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_modifiers.sol
+++ b/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_modifiers.sol
@@ -2,4 +2,4 @@ contract test {
function (uint, uint) modifier1() returns (uint) f1;
}
// ----
-// ParserError: (66-66): Expected token LBrace got 'Identifier'
+// ParserError: (66-66): Expected '{' but got identifier
diff --git a/test/libsolidity/syntaxTests/parsing/local_const_variable.sol b/test/libsolidity/syntaxTests/parsing/local_const_variable.sol
index 55673160..f06e2501 100644
--- a/test/libsolidity/syntaxTests/parsing/local_const_variable.sol
+++ b/test/libsolidity/syntaxTests/parsing/local_const_variable.sol
@@ -6,4 +6,4 @@ contract Foo {
}
}
// ----
-// ParserError: (67-67): Expected token Semicolon got 'Constant'
+// ParserError: (67-67): Expected ';' but got 'constant'
diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_state_variables.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_state_variables.sol
index 0fc85177..9cc7a4fa 100644
--- a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_state_variables.sol
+++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_state_variables.sol
@@ -2,4 +2,4 @@ contract Foo {
uint[] memory x;
}
// ----
-// ParserError: (23-23): Expected token Identifier got 'Memory'
+// ParserError: (23-23): Expected identifier but got 'memory'
diff --git a/test/libsolidity/syntaxTests/parsing/malformed_enum_declaration.sol b/test/libsolidity/syntaxTests/parsing/malformed_enum_declaration.sol
index 5a6eb270..9fc7efff 100644
--- a/test/libsolidity/syntaxTests/parsing/malformed_enum_declaration.sol
+++ b/test/libsolidity/syntaxTests/parsing/malformed_enum_declaration.sol
@@ -2,4 +2,4 @@ contract c {
enum foo { WARNING,}
}
// ----
-// ParserError: (33-33): Expected Identifier after ','
+// ParserError: (33-33): Expected identifier after ','
diff --git a/test/libsolidity/syntaxTests/parsing/missing_parameter_name_in_named_args.sol b/test/libsolidity/syntaxTests/parsing/missing_parameter_name_in_named_args.sol
index 3604f3b2..b950c76a 100644
--- a/test/libsolidity/syntaxTests/parsing/missing_parameter_name_in_named_args.sol
+++ b/test/libsolidity/syntaxTests/parsing/missing_parameter_name_in_named_args.sol
@@ -3,4 +3,4 @@ contract test {
function b() returns (uint r) { r = a({: 1, : 2, : 3}); }
}
// ----
-// ParserError: (143-143): Expected token Identifier got 'Colon'
+// ParserError: (143-143): Expected identifier but got ':'
diff --git a/test/libsolidity/syntaxTests/parsing/missing_variable_name_in_declaration.sol b/test/libsolidity/syntaxTests/parsing/missing_variable_name_in_declaration.sol
index bb1d015b..15927f50 100644
--- a/test/libsolidity/syntaxTests/parsing/missing_variable_name_in_declaration.sol
+++ b/test/libsolidity/syntaxTests/parsing/missing_variable_name_in_declaration.sol
@@ -2,4 +2,4 @@ contract test {
uint256 ;
}
// ----
-// ParserError: (28-28): Expected token Identifier got 'Semicolon'
+// ParserError: (28-28): Expected identifier but got ';'
diff --git a/test/libsolidity/syntaxTests/parsing/modifier_without_semicolon.sol b/test/libsolidity/syntaxTests/parsing/modifier_without_semicolon.sol
index 0d719db4..1b488837 100644
--- a/test/libsolidity/syntaxTests/parsing/modifier_without_semicolon.sol
+++ b/test/libsolidity/syntaxTests/parsing/modifier_without_semicolon.sol
@@ -2,4 +2,4 @@ contract c {
modifier mod { if (msg.sender == 0) _ }
}
// ----
-// ParserError: (52-52): Expected token Semicolon got 'RBrace'
+// ParserError: (52-52): Expected ';' but got '}'
diff --git a/test/libsolidity/syntaxTests/parsing/payable_accessor.sol b/test/libsolidity/syntaxTests/parsing/payable_accessor.sol
index 44b04afd..46bf6e13 100644
--- a/test/libsolidity/syntaxTests/parsing/payable_accessor.sol
+++ b/test/libsolidity/syntaxTests/parsing/payable_accessor.sol
@@ -2,4 +2,4 @@ contract test {
uint payable x;
}
// ----
-// ParserError: (22-22): Expected token Identifier got 'Payable'
+// ParserError: (22-22): Expected identifier but got 'payable'
diff --git a/test/libsolidity/syntaxTests/parsing/tuples_without_commas.sol b/test/libsolidity/syntaxTests/parsing/tuples_without_commas.sol
index d0e376b0..e283e0bb 100644
--- a/test/libsolidity/syntaxTests/parsing/tuples_without_commas.sol
+++ b/test/libsolidity/syntaxTests/parsing/tuples_without_commas.sol
@@ -4,4 +4,4 @@ contract C {
}
}
// ----
-// ParserError: (42-42): Expected token Comma got 'Number'
+// ParserError: (42-42): Expected ',' but got 'Number'
diff --git a/test/libsolidity/syntaxTests/parsing/var_array.sol b/test/libsolidity/syntaxTests/parsing/var_array.sol
index 86fc4fcb..d635a04b 100644
--- a/test/libsolidity/syntaxTests/parsing/var_array.sol
+++ b/test/libsolidity/syntaxTests/parsing/var_array.sol
@@ -2,4 +2,4 @@ contract Foo {
function f() { var[] a; }
}
// ----
-// ParserError: (34-34): Expected token Identifier got 'LBrack'
+// ParserError: (34-34): Expected identifier but got '['
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/error_fill.sol b/test/libsolidity/syntaxTests/tupleAssignments/error_fill.sol
new file mode 100644
index 00000000..5b7f870b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/tupleAssignments/error_fill.sol
@@ -0,0 +1,12 @@
+pragma experimental "v0.5.0";
+contract C {
+ function f() public pure returns (uint, uint, bytes32) {
+ uint a;
+ bytes32 b;
+ (a,) = f();
+ (,b) = f();
+ }
+}
+// ----
+// TypeError: (126-136): Different number of components on the left hand side (2) than on the right hand side (3).
+// TypeError: (140-150): Different number of components on the left hand side (2) than on the right hand side (3).
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/large_component_count.sol b/test/libsolidity/syntaxTests/tupleAssignments/large_component_count.sol
new file mode 100644
index 00000000..bbf21d7e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/tupleAssignments/large_component_count.sol
@@ -0,0 +1,24 @@
+pragma experimental "v0.5.0";
+contract C {
+ function g() public pure returns (
+ uint,
+ uint,
+ uint,
+ uint,
+ uint,
+ uint,
+ uint,
+ uint,
+ uint,
+ uint,
+ uint,
+ uint,
+ uint
+ ) { }
+ function f() public pure returns (uint, uint, bytes32) {
+ uint a;
+ uint b;
+ (,,,,a,,,,b,,,,) = g();
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/nowarn_explicit_singleton_token_expression.sol b/test/libsolidity/syntaxTests/tupleAssignments/nowarn_explicit_singleton_token_expression.sol
new file mode 100644
index 00000000..3262781b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/tupleAssignments/nowarn_explicit_singleton_token_expression.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() public pure {
+ uint a;
+ (a,) = (uint(1),);
+ }
+}
+// ----
+// Warning: (53-70): Different number of components on the left hand side (2) than on the right hand side (1).
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/nowarn_swap_memory.sol b/test/libsolidity/syntaxTests/tupleAssignments/nowarn_swap_memory.sol
new file mode 100644
index 00000000..b20bbf90
--- /dev/null
+++ b/test/libsolidity/syntaxTests/tupleAssignments/nowarn_swap_memory.sol
@@ -0,0 +1,8 @@
+contract C {
+ struct S { uint a; uint b; }
+ function f() pure public {
+ S memory x;
+ S memory y;
+ (x, y) = (y, x);
+ }
+}
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/nowarn_swap_storage_pointers.sol b/test/libsolidity/syntaxTests/tupleAssignments/nowarn_swap_storage_pointers.sol
new file mode 100644
index 00000000..5f7a18f7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/tupleAssignments/nowarn_swap_storage_pointers.sol
@@ -0,0 +1,10 @@
+ contract C {
+ struct S { uint a; uint b; }
+ S x; S y;
+ function f() public {
+ S storage x_local = x;
+ S storage y_local = y;
+ S storage z_local = x;
+ (x, y_local, x_local, z_local) = (y, x_local, y_local, y);
+ }
+ }
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/warn_fill_assignment.sol b/test/libsolidity/syntaxTests/tupleAssignments/warn_fill_assignment.sol
new file mode 100644
index 00000000..a079a509
--- /dev/null
+++ b/test/libsolidity/syntaxTests/tupleAssignments/warn_fill_assignment.sol
@@ -0,0 +1,11 @@
+contract C {
+ function f() public pure returns (uint, uint, bytes32) {
+ uint a;
+ bytes32 b;
+ (a,) = f();
+ (,b) = f();
+ }
+}
+// ----
+// Warning: (96-106): Different number of components on the left hand side (2) than on the right hand side (3).
+// Warning: (110-120): Different number of components on the left hand side (2) than on the right hand side (3).
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/warn_fill_vardecl.sol b/test/libsolidity/syntaxTests/tupleAssignments/warn_fill_vardecl.sol
new file mode 100644
index 00000000..1d243c7c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/tupleAssignments/warn_fill_vardecl.sol
@@ -0,0 +1,11 @@
+contract C {
+ function f() public pure returns (uint, uint, uint, uint) {
+ // Can later be replaced by (uint a, uint b,) = f();
+ var (a,b,) = f();
+ a; b;
+ }
+}
+// ----
+// Warning: (136-137): Use of the "var" keyword is deprecated.
+// Warning: (138-139): Use of the "var" keyword is deprecated.
+// Warning: (131-147): Different number of components on the left hand side (3) than on the right hand side (4).
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies.sol b/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies.sol
new file mode 100644
index 00000000..e4c3e694
--- /dev/null
+++ b/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies.sol
@@ -0,0 +1,9 @@
+contract C {
+ struct S { uint a; uint b; }
+ S x; S y;
+ function f() public {
+ (x, y) = (y, x);
+ }
+}
+// ----
+// Warning: (79-94): This assignment performs two copies to storage. Since storage copies do not first copy to a temporary location, one of them might be overwritten before the second is executed and thus may have unexpected effects. It is safer to perform the copies separately or assign to storage pointers first.
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_left.sol b/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_left.sol
new file mode 100644
index 00000000..b2979804
--- /dev/null
+++ b/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_left.sol
@@ -0,0 +1,10 @@
+contract C {
+ struct S { uint a; uint b; }
+ S x; S y;
+ function f() public {
+ (,x, y) = (1, 2, y, x);
+ }
+}
+// ----
+// Warning: (79-101): This assignment performs two copies to storage. Since storage copies do not first copy to a temporary location, one of them might be overwritten before the second is executed and thus may have unexpected effects. It is safer to perform the copies separately or assign to storage pointers first.
+// Warning: (79-101): Different number of components on the left hand side (3) than on the right hand side (4).
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_right.sol b/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_right.sol
new file mode 100644
index 00000000..aa35d7d4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_right.sol
@@ -0,0 +1,10 @@
+contract C {
+ struct S { uint a; uint b; }
+ S x; S y;
+ function f() public {
+ (x, y, ) = (y, x, 1, 2);
+ }
+}
+// ----
+// Warning: (79-102): This assignment performs two copies to storage. Since storage copies do not first copy to a temporary location, one of them might be overwritten before the second is executed and thus may have unexpected effects. It is safer to perform the copies separately or assign to storage pointers first.
+// Warning: (79-102): Different number of components on the left hand side (3) than on the right hand side (4).