aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/boostTest.cpp7
-rwxr-xr-xtest/cmdlineTests.sh52
-rw-r--r--test/compilationTests/milestonetracker/RLP.sol9
-rw-r--r--test/libdevcore/StringUtils.cpp18
-rw-r--r--test/libjulia/Simplifier.cpp10
-rw-r--r--test/libsolidity/ASTJSON.cpp145
-rw-r--r--test/libsolidity/ASTJSON/array_type_name.json76
-rw-r--r--test/libsolidity/ASTJSON/array_type_name.sol1
-rw-r--r--test/libsolidity/ASTJSON/array_type_name_legacy.json89
-rw-r--r--test/libsolidity/ASTJSON/documentation.json180
-rw-r--r--test/libsolidity/ASTJSON/documentation.sol17
-rw-r--r--test/libsolidity/ASTJSON/documentation_legacy.json176
-rw-r--r--test/libsolidity/ASTJSON/enum_value.json57
-rw-r--r--test/libsolidity/ASTJSON/enum_value.sol1
-rw-r--r--test/libsolidity/ASTJSON/enum_value_legacy.json78
-rw-r--r--test/libsolidity/ASTJSON/event_definition.json50
-rw-r--r--test/libsolidity/ASTJSON/event_definition.sol1
-rw-r--r--test/libsolidity/ASTJSON/event_definition_legacy.json74
-rw-r--r--test/libsolidity/ASTJSON/function_type.json224
-rw-r--r--test/libsolidity/ASTJSON/function_type.sol1
-rw-r--r--test/libsolidity/ASTJSON/function_type_legacy.json265
-rw-r--r--test/libsolidity/ASTJSON/inheritance_specifier.json80
-rw-r--r--test/libsolidity/ASTJSON/inheritance_specifier.sol1
-rw-r--r--test/libsolidity/ASTJSON/inheritance_specifier_legacy.json105
-rw-r--r--test/libsolidity/ASTJSON/long_type_name_binary_operation.json175
-rw-r--r--test/libsolidity/ASTJSON/long_type_name_binary_operation.sol1
-rw-r--r--test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json207
-rw-r--r--test/libsolidity/ASTJSON/long_type_name_identifier.json181
-rw-r--r--test/libsolidity/ASTJSON/long_type_name_identifier.sol1
-rw-r--r--test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json219
-rw-r--r--test/libsolidity/ASTJSON/modifier_definition.json174
-rw-r--r--test/libsolidity/ASTJSON/modifier_definition.sol1
-rw-r--r--test/libsolidity/ASTJSON/modifier_definition_legacy.json211
-rw-r--r--test/libsolidity/ASTJSON/modifier_invocation.json174
-rw-r--r--test/libsolidity/ASTJSON/modifier_invocation.sol1
-rw-r--r--test/libsolidity/ASTJSON/modifier_invocation_legacy.json211
-rw-r--r--test/libsolidity/ASTJSON/non_utf8.json122
-rw-r--r--test/libsolidity/ASTJSON/non_utf8.sol1
-rw-r--r--test/libsolidity/ASTJSON/non_utf8_legacy.json155
-rw-r--r--test/libsolidity/ASTJSON/placeholder_statement.json64
-rw-r--r--test/libsolidity/ASTJSON/placeholder_statement.sol1
-rw-r--r--test/libsolidity/ASTJSON/placeholder_statement_legacy.json87
-rw-r--r--test/libsolidity/ASTJSON/short_type_name.json126
-rw-r--r--test/libsolidity/ASTJSON/short_type_name.sol1
-rw-r--r--test/libsolidity/ASTJSON/short_type_name_legacy.json162
-rw-r--r--test/libsolidity/ASTJSON/short_type_name_ref.json138
-rw-r--r--test/libsolidity/ASTJSON/short_type_name_ref.sol1
-rw-r--r--test/libsolidity/ASTJSON/short_type_name_ref_legacy.json175
-rw-r--r--test/libsolidity/ASTJSON/smoke.json33
-rw-r--r--test/libsolidity/ASTJSON/smoke.sol1
-rw-r--r--test/libsolidity/ASTJSON/smoke_legacy.json48
-rw-r--r--test/libsolidity/ASTJSON/source_location.json160
-rw-r--r--test/libsolidity/ASTJSON/source_location.sol1
-rw-r--r--test/libsolidity/ASTJSON/source_location_legacy.json198
-rw-r--r--test/libsolidity/ASTJSON/using_for_directive.json87
-rw-r--r--test/libsolidity/ASTJSON/using_for_directive.sol1
-rw-r--r--test/libsolidity/ASTJSON/using_for_directive_legacy.json110
-rw-r--r--test/libsolidity/ASTJSONTest.cpp201
-rw-r--r--test/libsolidity/ASTJSONTest.h58
-rw-r--r--test/libsolidity/ASTLegacyJSON.cpp324
-rw-r--r--test/libsolidity/SolidityABIJSON.cpp65
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp331
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp10
-rw-r--r--test/libsolidity/SolidityNatspecJSON.cpp51
-rw-r--r--test/libsolidity/SolidityTypes.cpp3
-rw-r--r--test/libsolidity/syntaxTests/constants/assign_constant_function_value_050.sol8
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_err.sol10
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_fine.sol4
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_warn.sol10
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_err.sol52
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol52
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_err.sol14
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_fine.sol1
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_warn.sol15
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/for_err.sol16
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/for_warn.sol16
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/if_err.sol18
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/if_warn.sol18
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_err.sol22
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_warn.sol22
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_err.sol18
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_warn.sol18
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_err.sol13
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_warn.sol13
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/while_err.sol11
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/while_warn.sol11
-rw-r--r--test/libsolidity/syntaxTests/emit/emit_empty.sol (renamed from test/libsolidity/syntaxTests/emit_empty.sol)0
-rw-r--r--test/libsolidity/syntaxTests/emit/emit_non_event.sol (renamed from test/libsolidity/syntaxTests/emit_non_event.sol)0
-rw-r--r--test/libsolidity/syntaxTests/events/event_nested_array.sol5
-rw-r--r--test/libsolidity/syntaxTests/events/event_nested_array_2.sol4
-rw-r--r--test/libsolidity/syntaxTests/events/event_nested_array_in_struct.sol6
-rw-r--r--test/libsolidity/syntaxTests/events/event_struct.sol6
-rw-r--r--test/libsolidity/syntaxTests/events/event_struct_indexed.sol6
-rw-r--r--test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol7
-rw-r--r--test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_V050.sol6
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol4
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol4
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_offset.sol9
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_slot.sol9
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol9
-rw-r--r--test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_050.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol12
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/166_assigning_state_to_const_variable_050.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/352_callcode_deprecated_v050.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/375_inline_assembly_unbalanced_two_stack_load.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/376_inline_assembly_in_modifier.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/377_inline_assembly_storage.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/378_inline_assembly_storage_in_modifiers.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/379_inline_assembly_constant_assign.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/380_inline_assembly_constant_access.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/381_inline_assembly_local_variable_access_out_of_functions.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/382_inline_assembly_local_variable_access_out_of_functions_storage_ptr.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/383_inline_assembly_storage_variable_access_out_of_functions.sol1
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/385_inline_assembly_calldata_variables.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol12
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/392_inline_assembly_050_jump.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/394_inline_assembly_050_leave_items_on_stack.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/422_interface_enums.sol1
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/564_events_without_emit_deprecated_v050.sol9
-rw-r--r--test/libsolidity/syntaxTests/parsing/enum_from_interface.sol9
-rw-r--r--test/libsolidity/syntaxTests/parsing/enum_from_interface_in_library.sol12
-rw-r--r--test/libsolidity/syntaxTests/parsing/enum_from_library.sol9
-rw-r--r--test/libsolidity/syntaxTests/parsing/enum_inheritance_contract.sol9
-rw-r--r--test/libsolidity/syntaxTests/parsing/enum_inheritance_interface.sol9
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/double_storage_crash.sol11
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/err_multiple_storage_storage_copies_fill_left.sol10
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/err_multiple_storage_storage_copies_fill_right.sol10
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/error_fill.sol5
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/large_component_count.sol1
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/assignment_local.sol11
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/assignment_state_variable.sol14
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/assignment_struct.sol17
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/mapping_return_external.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/mapping_return_internal.sol21
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/mapping_return_public.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/var_type_suggest.sol12
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol7
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol8
-rw-r--r--test/libsolidity/syntaxTests/visibility/interface/function_external.sol (renamed from test/libsolidity/syntaxTests/visibility/interface/function_external050.sol)1
-rw-r--r--test/libsolidity/syntaxTests/visibility/interface/function_public050.sol6
-rw-r--r--test/tools/CMakeLists.txt2
-rw-r--r--test/tools/isoltest.cpp65
151 files changed, 5769 insertions, 1068 deletions
diff --git a/test/boostTest.cpp b/test/boostTest.cpp
index f23355fd..d9e939eb 100644
--- a/test/boostTest.cpp
+++ b/test/boostTest.cpp
@@ -36,6 +36,7 @@
#pragma GCC diagnostic pop
#include <test/Options.h>
+#include <test/libsolidity/ASTJSONTest.h>
#include <test/libsolidity/SyntaxTest.h>
#include <boost/algorithm/string.hpp>
@@ -131,6 +132,12 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] )
"syntaxTests",
SyntaxTest::create
) > 0, "no syntax tests found");
+ solAssert(registerTests(
+ master,
+ dev::test::Options::get().testPath / "libsolidity",
+ "ASTJSON",
+ ASTJSONTest::create
+ ) > 0, "no JSON AST tests found");
if (dev::test::Options::get().disableIPC)
{
for (auto suite: {
diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh
index bc0ee786..7256386d 100755
--- a/test/cmdlineTests.sh
+++ b/test/cmdlineTests.sh
@@ -32,7 +32,7 @@ REPO_ROOT=$(cd $(dirname "$0")/.. && pwd)
echo $REPO_ROOT
SOLC="$REPO_ROOT/build/solc/solc"
-FULLARGS="--optimize --ignore-missing --combined-json abi,asm,ast,bin,bin-runtime,clone-bin,compact-format,devdoc,hashes,interface,metadata,opcodes,srcmap,srcmap-runtime,userdoc"
+FULLARGS="--optimize --ignore-missing --combined-json abi,asm,ast,bin,bin-runtime,compact-format,devdoc,hashes,interface,metadata,opcodes,srcmap,srcmap-runtime,userdoc"
echo "Checking that the bug list is up to date..."
"$REPO_ROOT"/scripts/update_bugs_by_version.py
@@ -94,6 +94,56 @@ printTask "Testing unknown options..."
fi
)
+# General helper function for testing SOLC behaviour, based on file name, compile opts, exit code, stdout and stderr.
+# An failure is expected.
+test_solc_file_input_failures() {
+ local filename="${1}"
+ local solc_args="${2}"
+ local stdout_expected="${3}"
+ local stderr_expected="${4}"
+ local stdout_path=`mktemp`
+ local stderr_path=`mktemp`
+
+ set +e
+ "$SOLC" "${filename}" ${solc_args} 1>$stdout_path 2>$stderr_path
+ exitCode=$?
+ set -e
+
+ if [[ $exitCode -eq 0 ]]; then
+ printError "Incorrect exit code. Expected failure (non-zero) but got success (0)."
+ rm -f $stdout_path $stderr_path
+ exit 1
+ fi
+
+ if [[ "$(cat $stdout_path)" != "${stdout_expected}" ]]; then
+ printError "Incorrect output on stderr received. Expected:"
+ echo -e "${stdout_expected}"
+
+ printError "But got:"
+ cat $stdout_path
+ rm -f $stdout_path $stderr_path
+ exit 1
+ fi
+
+ if [[ "$(cat $stderr_path)" != "${stderr_expected}" ]]; then
+ printError "Incorrect output on stderr received. Expected:"
+ echo -e "${stderr_expected}"
+
+ printError "But got:"
+ cat $stderr_path
+ rm -f $stdout_path $stderr_path
+ exit 1
+ fi
+
+ rm -f $stdout_path $stderr_path
+}
+
+printTask "Testing passing files that are not found..."
+test_solc_file_input_failures "file_not_found.sol" "" "" "\"file_not_found.sol\" is not found."
+
+printTask "Testing passing files that are not files..."
+test_solc_file_input_failures "." "" "" "\".\" is not a valid file."
+
printTask "Compiling various other contracts and libraries..."
(
cd "$REPO_ROOT"/test/compilationTests/
diff --git a/test/compilationTests/milestonetracker/RLP.sol b/test/compilationTests/milestonetracker/RLP.sol
index e261bf23..e1f44457 100644
--- a/test/compilationTests/milestonetracker/RLP.sol
+++ b/test/compilationTests/milestonetracker/RLP.sol
@@ -381,19 +381,16 @@ library RLP {
// we can write entire words, and just overwrite any excess.
assembly {
{
- let i := 0 // Start at arr + 0x20
let words := div(add(btsLen, 31), 32)
let rOffset := btsPtr
let wOffset := add(tgt, 0x20)
- tag_loop:
- jumpi(end, eq(i, words))
+
+ // Start at arr + 0x20
+ for { let i := 0 } not(eq(i, words)) { i := add(i, 1) }
{
let offset := mul(i, 0x20)
mstore(add(wOffset, offset), mload(add(rOffset, offset)))
- i := add(i, 1)
}
- jump(tag_loop)
- end:
mstore(add(tgt, add(0x20, mload(tgt))), 0)
}
}
diff --git a/test/libdevcore/StringUtils.cpp b/test/libdevcore/StringUtils.cpp
index 9ee93d02..94f1b753 100644
--- a/test/libdevcore/StringUtils.cpp
+++ b/test/libdevcore/StringUtils.cpp
@@ -81,6 +81,24 @@ BOOST_AUTO_TEST_CASE(test_alternatives_list)
BOOST_CHECK_EQUAL(quotedAlternativesList(strings), "\"a\", \"b\", \"c\" or \"d\"");
}
+BOOST_AUTO_TEST_CASE(test_human_readable_join)
+{
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({})), "");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a"})), "a");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b"})), "a, b");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b", "c"})), "a, b, c");
+
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({}), "; "), "");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a"}), "; "), "a");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b"}), "; "), "a; b");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b", "c"}), "; "), "a; b; c");
+
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({}), "; ", " or "), "");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a"}), "; ", " or "), "a");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b"}), "; ", " or "), "a or b");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b", "c"}), "; ", " or "), "a; b or c");
+}
+
BOOST_AUTO_TEST_SUITE_END()
diff --git a/test/libjulia/Simplifier.cpp b/test/libjulia/Simplifier.cpp
index 8ed8287a..e5b7e0d8 100644
--- a/test/libjulia/Simplifier.cpp
+++ b/test/libjulia/Simplifier.cpp
@@ -139,4 +139,14 @@ BOOST_AUTO_TEST_CASE(mod_and)
);
}
+BOOST_AUTO_TEST_CASE(not_applied)
+{
+ CHECK(
+ // The first argument of div is not constant.
+ // keccak256 is not movable.
+ "{ let a := div(keccak256(0, 0), 0) }",
+ "{ let a := div(keccak256(0, 0), 0) }"
+ );
+}
+
BOOST_AUTO_TEST_SUITE_END()
diff --git a/test/libsolidity/ASTJSON.cpp b/test/libsolidity/ASTJSON.cpp
deleted file mode 100644
index 482b05e6..00000000
--- a/test/libsolidity/ASTJSON.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- This file is part of solidity.
-
- solidity is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- solidity is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with solidity. If not, see <http://www.gnu.org/licenses/>.
-*/
-/**
- * @author Christian <c@ethdev.com>
- * @date 2016
- * Tests for the json ast output.
- */
-
-#include <test/Options.h>
-
-#include <libsolidity/interface/Exceptions.h>
-#include <libsolidity/interface/CompilerStack.h>
-#include <libsolidity/ast/ASTJsonConverter.h>
-
-#include <boost/test/unit_test.hpp>
-
-#include <string>
-
-using namespace std;
-
-namespace dev
-{
-namespace solidity
-{
-namespace test
-{
-
-BOOST_AUTO_TEST_SUITE(SolidityASTJSON)
-
-BOOST_AUTO_TEST_CASE(short_type_name)
-{
- CompilerStack c;
- c.addSource("a", "contract c { function f() public { uint[] memory x; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(false, sourceIndices).toJson(c.ast("a"));
- Json::Value varDecl = astJson["nodes"][0]["nodes"][0]["body"]["statements"][0]["declarations"][0];
- BOOST_CHECK_EQUAL(varDecl["storageLocation"], "memory");
- BOOST_CHECK_EQUAL(varDecl["typeDescriptions"]["typeIdentifier"], "t_array$_t_uint256_$dyn_memory_ptr");
- BOOST_CHECK_EQUAL(varDecl["typeDescriptions"]["typeString"], "uint256[]");
-}
-
-BOOST_AUTO_TEST_CASE(short_type_name_ref)
-{
- CompilerStack c;
- c.addSource("a", "contract c { function f() public { uint[][] memory rows; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(false, sourceIndices).toJson(c.ast("a"));
- Json::Value varDecl = astJson["nodes"][0]["nodes"][0]["body"]["statements"][0]["declarations"][0];
- BOOST_CHECK_EQUAL(varDecl["storageLocation"], "memory");
- BOOST_CHECK_EQUAL(varDecl["typeName"]["typeDescriptions"]["typeIdentifier"], "t_array$_t_array$_t_uint256_$dyn_storage_$dyn_storage_ptr");
- BOOST_CHECK_EQUAL(varDecl["typeName"]["typeDescriptions"]["typeString"], "uint256[][]");
-}
-
-BOOST_AUTO_TEST_CASE(long_type_name_binary_operation)
-{
- CompilerStack c;
- c.addSource("a", "contract c { function f() public { uint a = 2 + 3; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(false, sourceIndices).toJson(c.ast("a"));
- Json::Value varDecl = astJson["nodes"][0]["nodes"][0]["body"]["statements"][0]["initialValue"]["commonType"];
- BOOST_CHECK_EQUAL(varDecl["typeIdentifier"], "t_rational_5_by_1");
- BOOST_CHECK_EQUAL(varDecl["typeString"], "int_const 5");
-}
-
-BOOST_AUTO_TEST_CASE(long_type_name_identifier)
-{
- CompilerStack c;
- c.addSource("a", "contract c { uint[] a; function f() public { uint[] storage b = a; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(false, sourceIndices).toJson(c.ast("a"));
- Json::Value varDecl = astJson["nodes"][0]["nodes"][1]["body"]["statements"][0]["initialValue"];
- BOOST_CHECK_EQUAL(varDecl["typeDescriptions"]["typeIdentifier"], "t_array$_t_uint256_$dyn_storage");
- BOOST_CHECK_EQUAL(varDecl["typeDescriptions"]["typeString"], "uint256[] storage ref");
-}
-
-BOOST_AUTO_TEST_CASE(documentation)
-{
- CompilerStack c;
- c.addSource("a", "/**This contract is empty*/ contract C {}");
- c.addSource("b",
- "/**This contract is empty"
- " and has a line-breaking comment.*/"
- "contract C {}"
- );
- c.addSource("c",
- "contract C {"
- " /** Some comment on Evt.*/ event Evt();"
- " /** Some comment on mod.*/ modifier mod() { _; }"
- " /** Some comment on fn.*/ function fn() public {}"
- "}"
- );
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 0;
- sourceIndices["b"] = 1;
- sourceIndices["c"] = 2;
- //same tests for non-legacy mode
- Json::Value astJsonA = ASTJsonConverter(false, sourceIndices).toJson(c.ast("a"));
- Json::Value documentationA = astJsonA["nodes"][0]["documentation"];
- BOOST_CHECK_EQUAL(documentationA, "This contract is empty");
- Json::Value astJsonB = ASTJsonConverter(false, sourceIndices).toJson(c.ast("b"));
- Json::Value documentationB = astJsonB["nodes"][0]["documentation"];
- BOOST_CHECK_EQUAL(documentationB, "This contract is empty and has a line-breaking comment.");
- Json::Value astJsonC = ASTJsonConverter(false, sourceIndices).toJson(c.ast("c"));
- Json::Value documentationC0 = astJsonC["nodes"][0]["nodes"][0]["documentation"];
- Json::Value documentationC1 = astJsonC["nodes"][0]["nodes"][1]["documentation"];
- Json::Value documentationC2 = astJsonC["nodes"][0]["nodes"][2]["documentation"];
- BOOST_CHECK_EQUAL(documentationC0, "Some comment on Evt.");
- BOOST_CHECK_EQUAL(documentationC1, "Some comment on mod.");
- BOOST_CHECK_EQUAL(documentationC2, "Some comment on fn.");
-}
-
-
-BOOST_AUTO_TEST_SUITE_END()
-
-}
-}
-} // end namespaces
diff --git a/test/libsolidity/ASTJSON/array_type_name.json b/test/libsolidity/ASTJSON/array_type_name.json
new file mode 100644
index 00000000..e3a3bea9
--- /dev/null
+++ b/test/libsolidity/ASTJSON/array_type_name.json
@@ -0,0 +1,76 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 4
+ ]
+ },
+ "id" : 5,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 4,
+ "linearizedBaseContracts" :
+ [
+ 4
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "constant" : false,
+ "id" : 3,
+ "name" : "i",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 4,
+ "src" : "13:8:1",
+ "stateVariable" : true,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage",
+ "typeString" : "uint256[]"
+ },
+ "typeName" :
+ {
+ "baseType" :
+ {
+ "id" : 1,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "13:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "id" : 2,
+ "length" : null,
+ "nodeType" : "ArrayTypeName",
+ "src" : "13:6:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage_ptr",
+ "typeString" : "uint256[]"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "scope" : 5,
+ "src" : "0:24:1"
+ }
+ ],
+ "src" : "0:25:1"
+}
diff --git a/test/libsolidity/ASTJSON/array_type_name.sol b/test/libsolidity/ASTJSON/array_type_name.sol
new file mode 100644
index 00000000..202ecf02
--- /dev/null
+++ b/test/libsolidity/ASTJSON/array_type_name.sol
@@ -0,0 +1 @@
+contract C { uint[] i; }
diff --git a/test/libsolidity/ASTJSON/array_type_name_legacy.json b/test/libsolidity/ASTJSON/array_type_name_legacy.json
new file mode 100644
index 00000000..80feb344
--- /dev/null
+++ b/test/libsolidity/ASTJSON/array_type_name_legacy.json
@@ -0,0 +1,89 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 4
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 4
+ ],
+ "name" : "C",
+ "scope" : 5
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "i",
+ "scope" : 4,
+ "stateVariable" : true,
+ "storageLocation" : "default",
+ "type" : "uint256[]",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "length" : null,
+ "type" : "uint256[]"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 1,
+ "name" : "ElementaryTypeName",
+ "src" : "13:4:1"
+ }
+ ],
+ "id" : 2,
+ "name" : "ArrayTypeName",
+ "src" : "13:6:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "VariableDeclaration",
+ "src" : "13:8:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "ContractDefinition",
+ "src" : "0:24:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "SourceUnit",
+ "src" : "0:25:1"
+}
diff --git a/test/libsolidity/ASTJSON/documentation.json b/test/libsolidity/ASTJSON/documentation.json
new file mode 100644
index 00000000..403d4e72
--- /dev/null
+++ b/test/libsolidity/ASTJSON/documentation.json
@@ -0,0 +1,180 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 1
+ ]
+ },
+ "id" : 2,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : "This contract is empty",
+ "fullyImplemented" : true,
+ "id" : 1,
+ "linearizedBaseContracts" :
+ [
+ 1
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" : [],
+ "scope" : 2,
+ "src" : "28:13:1"
+ }
+ ],
+ "src" : "28:14:1"
+},
+{
+ "absolutePath" : "b",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 3
+ ]
+ },
+ "id" : 4,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : "This contract is empty\nand has a line-breaking comment.",
+ "fullyImplemented" : true,
+ "id" : 3,
+ "linearizedBaseContracts" :
+ [
+ 3
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" : [],
+ "scope" : 4,
+ "src" : "62:13:2"
+ }
+ ],
+ "src" : "62:14:2"
+},
+{
+ "absolutePath" : "c",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 15
+ ]
+ },
+ "id" : 16,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 15,
+ "linearizedBaseContracts" :
+ [
+ 15
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "anonymous" : false,
+ "documentation" : "Some comment on Evt.",
+ "id" : 6,
+ "name" : "Evt",
+ "nodeType" : "EventDefinition",
+ "parameters" :
+ {
+ "id" : 5,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "51:2:3"
+ },
+ "src" : "42:12:3"
+ },
+ {
+ "body" :
+ {
+ "id" : 9,
+ "nodeType" : "Block",
+ "src" : "99:6:3",
+ "statements" :
+ [
+ {
+ "id" : 8,
+ "nodeType" : "PlaceholderStatement",
+ "src" : "101:1:3"
+ }
+ ]
+ },
+ "documentation" : "Some comment on mod.",
+ "id" : 10,
+ "name" : "mod",
+ "nodeType" : "ModifierDefinition",
+ "parameters" :
+ {
+ "id" : 7,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "96:2:3"
+ },
+ "src" : "84:21:3",
+ "visibility" : "internal"
+ },
+ {
+ "body" :
+ {
+ "id" : 13,
+ "nodeType" : "Block",
+ "src" : "155:2:3",
+ "statements" : []
+ },
+ "documentation" : "Some comment on fn.",
+ "id" : 14,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" : [],
+ "name" : "fn",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 11,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "145:2:3"
+ },
+ "returnParameters" :
+ {
+ "id" : 12,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "155:0:3"
+ },
+ "scope" : 15,
+ "src" : "134:23:3",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 16,
+ "src" : "0:159:3"
+ }
+ ],
+ "src" : "0:160:3"
+}
diff --git a/test/libsolidity/ASTJSON/documentation.sol b/test/libsolidity/ASTJSON/documentation.sol
new file mode 100644
index 00000000..e65af9b4
--- /dev/null
+++ b/test/libsolidity/ASTJSON/documentation.sol
@@ -0,0 +1,17 @@
+// ---- SOURCE: a
+
+/**This contract is empty*/ contract C {}
+
+// ---- SOURCE: b
+
+/**This contract is empty
+ and has a line-breaking comment.*/
+contract C {}
+
+// ---- SOURCE: c
+
+contract C {
+ /** Some comment on Evt.*/ event Evt();
+ /** Some comment on mod.*/ modifier mod() { _; }
+ /** Some comment on fn.*/ function fn() public {}
+}
diff --git a/test/libsolidity/ASTJSON/documentation_legacy.json b/test/libsolidity/ASTJSON/documentation_legacy.json
new file mode 100644
index 00000000..5a890e50
--- /dev/null
+++ b/test/libsolidity/ASTJSON/documentation_legacy.json
@@ -0,0 +1,176 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "c",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 15
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 15
+ ],
+ "name" : "C",
+ "scope" : 16
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "anonymous" : false,
+ "documentation" : "Some comment on Evt.",
+ "name" : "Evt"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 5,
+ "name" : "ParameterList",
+ "src" : "51:2:3"
+ }
+ ],
+ "id" : 6,
+ "name" : "EventDefinition",
+ "src" : "42:12:3"
+ },
+ {
+ "attributes" :
+ {
+ "documentation" : "Some comment on mod.",
+ "name" : "mod",
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 7,
+ "name" : "ParameterList",
+ "src" : "96:2:3"
+ },
+ {
+ "children" :
+ [
+ {
+ "id" : 8,
+ "name" : "PlaceholderStatement",
+ "src" : "101:1:3"
+ }
+ ],
+ "id" : 9,
+ "name" : "Block",
+ "src" : "99:6:3"
+ }
+ ],
+ "id" : 10,
+ "name" : "ModifierDefinition",
+ "src" : "84:21:3"
+ },
+ {
+ "attributes" :
+ {
+ "documentation" : "Some comment on fn.",
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "fn",
+ "scope" : 15,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 11,
+ "name" : "ParameterList",
+ "src" : "145:2:3"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 12,
+ "name" : "ParameterList",
+ "src" : "155:0:3"
+ },
+ {
+ "attributes" :
+ {
+ "statements" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 13,
+ "name" : "Block",
+ "src" : "155:2:3"
+ }
+ ],
+ "id" : 14,
+ "name" : "FunctionDefinition",
+ "src" : "134:23:3"
+ }
+ ],
+ "id" : 15,
+ "name" : "ContractDefinition",
+ "src" : "0:159:3"
+ }
+ ],
+ "id" : 16,
+ "name" : "SourceUnit",
+ "src" : "0:160:3"
+}
diff --git a/test/libsolidity/ASTJSON/enum_value.json b/test/libsolidity/ASTJSON/enum_value.json
new file mode 100644
index 00000000..21afd9a7
--- /dev/null
+++ b/test/libsolidity/ASTJSON/enum_value.json
@@ -0,0 +1,57 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 4
+ ]
+ },
+ "id" : 5,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 4,
+ "linearizedBaseContracts" :
+ [
+ 4
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "canonicalName" : "C.E",
+ "id" : 3,
+ "members" :
+ [
+ {
+ "id" : 1,
+ "name" : "A",
+ "nodeType" : "EnumValue",
+ "src" : "22:1:1"
+ },
+ {
+ "id" : 2,
+ "name" : "B",
+ "nodeType" : "EnumValue",
+ "src" : "25:1:1"
+ }
+ ],
+ "name" : "E",
+ "nodeType" : "EnumDefinition",
+ "src" : "13:15:1"
+ }
+ ],
+ "scope" : 5,
+ "src" : "0:30:1"
+ }
+ ],
+ "src" : "0:31:1"
+}
diff --git a/test/libsolidity/ASTJSON/enum_value.sol b/test/libsolidity/ASTJSON/enum_value.sol
new file mode 100644
index 00000000..ef0875fb
--- /dev/null
+++ b/test/libsolidity/ASTJSON/enum_value.sol
@@ -0,0 +1 @@
+contract C { enum E { A, B } }
diff --git a/test/libsolidity/ASTJSON/enum_value_legacy.json b/test/libsolidity/ASTJSON/enum_value_legacy.json
new file mode 100644
index 00000000..d7782969
--- /dev/null
+++ b/test/libsolidity/ASTJSON/enum_value_legacy.json
@@ -0,0 +1,78 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 4
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 4
+ ],
+ "name" : "C",
+ "scope" : 5
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "canonicalName" : "C.E",
+ "name" : "E"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "A"
+ },
+ "id" : 1,
+ "name" : "EnumValue",
+ "src" : "22:1:1"
+ },
+ {
+ "attributes" :
+ {
+ "name" : "B"
+ },
+ "id" : 2,
+ "name" : "EnumValue",
+ "src" : "25:1:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "EnumDefinition",
+ "src" : "13:15:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "ContractDefinition",
+ "src" : "0:30:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "SourceUnit",
+ "src" : "0:31:1"
+}
diff --git a/test/libsolidity/ASTJSON/event_definition.json b/test/libsolidity/ASTJSON/event_definition.json
new file mode 100644
index 00000000..029062c3
--- /dev/null
+++ b/test/libsolidity/ASTJSON/event_definition.json
@@ -0,0 +1,50 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 3
+ ]
+ },
+ "id" : 4,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 3,
+ "linearizedBaseContracts" :
+ [
+ 3
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "anonymous" : false,
+ "documentation" : null,
+ "id" : 2,
+ "name" : "E",
+ "nodeType" : "EventDefinition",
+ "parameters" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "20:2:1"
+ },
+ "src" : "13:10:1"
+ }
+ ],
+ "scope" : 4,
+ "src" : "0:25:1"
+ }
+ ],
+ "src" : "0:26:1"
+}
diff --git a/test/libsolidity/ASTJSON/event_definition.sol b/test/libsolidity/ASTJSON/event_definition.sol
new file mode 100644
index 00000000..81b43c67
--- /dev/null
+++ b/test/libsolidity/ASTJSON/event_definition.sol
@@ -0,0 +1 @@
+contract C { event E(); }
diff --git a/test/libsolidity/ASTJSON/event_definition_legacy.json b/test/libsolidity/ASTJSON/event_definition_legacy.json
new file mode 100644
index 00000000..f5967bf4
--- /dev/null
+++ b/test/libsolidity/ASTJSON/event_definition_legacy.json
@@ -0,0 +1,74 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 3
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 3
+ ],
+ "name" : "C",
+ "scope" : 4
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "anonymous" : false,
+ "documentation" : null,
+ "name" : "E"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "20:2:1"
+ }
+ ],
+ "id" : 2,
+ "name" : "EventDefinition",
+ "src" : "13:10:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "ContractDefinition",
+ "src" : "0:25:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "SourceUnit",
+ "src" : "0:26:1"
+}
diff --git a/test/libsolidity/ASTJSON/function_type.json b/test/libsolidity/ASTJSON/function_type.json
new file mode 100644
index 00000000..7b10f0dc
--- /dev/null
+++ b/test/libsolidity/ASTJSON/function_type.json
@@ -0,0 +1,224 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 17
+ ]
+ },
+ "id" : 18,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 17,
+ "linearizedBaseContracts" :
+ [
+ 17
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 15,
+ "nodeType" : "Block",
+ "src" : "120:2:1",
+ "statements" : []
+ },
+ "documentation" : null,
+ "id" : 16,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" : [],
+ "name" : "f",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 7,
+ "nodeType" : "ParameterList",
+ "parameters" :
+ [
+ {
+ "constant" : false,
+ "id" : 6,
+ "name" : "x",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 16,
+ "src" : "24:44:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_function_external_payable$__$returns$_t_uint256_$",
+ "typeString" : "function () payable external returns (uint256)"
+ },
+ "typeName" :
+ {
+ "id" : 5,
+ "nodeType" : "FunctionTypeName",
+ "parameterTypes" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "32:2:1"
+ },
+ "returnParameterTypes" :
+ {
+ "id" : 4,
+ "nodeType" : "ParameterList",
+ "parameters" :
+ [
+ {
+ "constant" : false,
+ "id" : 3,
+ "name" : "",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 16,
+ "src" : "61:4:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ },
+ "typeName" :
+ {
+ "id" : 2,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "61:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "src" : "60:6:1"
+ },
+ "src" : "24:44:1",
+ "stateMutability" : "payable",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_function_external_payable$__$returns$_t_uint256_$",
+ "typeString" : "function () payable external returns (uint256)"
+ },
+ "visibility" : "external"
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "src" : "23:46:1"
+ },
+ "returnParameters" :
+ {
+ "id" : 14,
+ "nodeType" : "ParameterList",
+ "parameters" :
+ [
+ {
+ "constant" : false,
+ "id" : 13,
+ "name" : "",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 16,
+ "src" : "79:40:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_function_external_view$__$returns$_t_uint256_$",
+ "typeString" : "function () view external returns (uint256)"
+ },
+ "typeName" :
+ {
+ "id" : 12,
+ "nodeType" : "FunctionTypeName",
+ "parameterTypes" :
+ {
+ "id" : 8,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "87:2:1"
+ },
+ "returnParameterTypes" :
+ {
+ "id" : 11,
+ "nodeType" : "ParameterList",
+ "parameters" :
+ [
+ {
+ "constant" : false,
+ "id" : 10,
+ "name" : "",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 16,
+ "src" : "113:4:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ },
+ "typeName" :
+ {
+ "id" : 9,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "113:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "src" : "112:6:1"
+ },
+ "src" : "79:40:1",
+ "stateMutability" : "view",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_function_external_view$__$returns$_t_uint256_$",
+ "typeString" : "function () view external returns (uint256)"
+ },
+ "visibility" : "external"
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "src" : "78:41:1"
+ },
+ "scope" : 17,
+ "src" : "13:109:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 18,
+ "src" : "0:124:1"
+ }
+ ],
+ "src" : "0:125:1"
+}
diff --git a/test/libsolidity/ASTJSON/function_type.sol b/test/libsolidity/ASTJSON/function_type.sol
new file mode 100644
index 00000000..b63bcbf0
--- /dev/null
+++ b/test/libsolidity/ASTJSON/function_type.sol
@@ -0,0 +1 @@
+contract C { function f(function() external payable returns (uint) x) returns (function() external view returns (uint)) {} }
diff --git a/test/libsolidity/ASTJSON/function_type_legacy.json b/test/libsolidity/ASTJSON/function_type_legacy.json
new file mode 100644
index 00000000..952fd865
--- /dev/null
+++ b/test/libsolidity/ASTJSON/function_type_legacy.json
@@ -0,0 +1,265 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 17
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 17
+ ],
+ "name" : "C",
+ "scope" : 18
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "f",
+ "scope" : 17,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "x",
+ "scope" : 16,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "function () payable external returns (uint256)",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "stateMutability" : "payable",
+ "type" : "function () payable external returns (uint256)",
+ "visibility" : "external"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "32:2:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "",
+ "scope" : 16,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "uint256",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 2,
+ "name" : "ElementaryTypeName",
+ "src" : "61:4:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "VariableDeclaration",
+ "src" : "61:4:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "ParameterList",
+ "src" : "60:6:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "FunctionTypeName",
+ "src" : "24:44:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "VariableDeclaration",
+ "src" : "24:44:1"
+ }
+ ],
+ "id" : 7,
+ "name" : "ParameterList",
+ "src" : "23:46:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "",
+ "scope" : 16,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "function () view external returns (uint256)",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "stateMutability" : "view",
+ "type" : "function () view external returns (uint256)",
+ "visibility" : "external"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 8,
+ "name" : "ParameterList",
+ "src" : "87:2:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "",
+ "scope" : 16,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "uint256",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 9,
+ "name" : "ElementaryTypeName",
+ "src" : "113:4:1"
+ }
+ ],
+ "id" : 10,
+ "name" : "VariableDeclaration",
+ "src" : "113:4:1"
+ }
+ ],
+ "id" : 11,
+ "name" : "ParameterList",
+ "src" : "112:6:1"
+ }
+ ],
+ "id" : 12,
+ "name" : "FunctionTypeName",
+ "src" : "79:40:1"
+ }
+ ],
+ "id" : 13,
+ "name" : "VariableDeclaration",
+ "src" : "79:40:1"
+ }
+ ],
+ "id" : 14,
+ "name" : "ParameterList",
+ "src" : "78:41:1"
+ },
+ {
+ "attributes" :
+ {
+ "statements" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 15,
+ "name" : "Block",
+ "src" : "120:2:1"
+ }
+ ],
+ "id" : 16,
+ "name" : "FunctionDefinition",
+ "src" : "13:109:1"
+ }
+ ],
+ "id" : 17,
+ "name" : "ContractDefinition",
+ "src" : "0:124:1"
+ }
+ ],
+ "id" : 18,
+ "name" : "SourceUnit",
+ "src" : "0:125:1"
+}
diff --git a/test/libsolidity/ASTJSON/inheritance_specifier.json b/test/libsolidity/ASTJSON/inheritance_specifier.json
new file mode 100644
index 00000000..edef8677
--- /dev/null
+++ b/test/libsolidity/ASTJSON/inheritance_specifier.json
@@ -0,0 +1,80 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C1" :
+ [
+ 1
+ ],
+ "C2" :
+ [
+ 4
+ ]
+ },
+ "id" : 5,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 1,
+ "linearizedBaseContracts" :
+ [
+ 1
+ ],
+ "name" : "C1",
+ "nodeType" : "ContractDefinition",
+ "nodes" : [],
+ "scope" : 5,
+ "src" : "0:14:1"
+ },
+ {
+ "baseContracts" :
+ [
+ {
+ "arguments" : null,
+ "baseName" :
+ {
+ "contractScope" : null,
+ "id" : 2,
+ "name" : "C1",
+ "nodeType" : "UserDefinedTypeName",
+ "referencedDeclaration" : 1,
+ "src" : "30:2:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_contract$_C1_$1",
+ "typeString" : "contract C1"
+ }
+ },
+ "id" : 3,
+ "nodeType" : "InheritanceSpecifier",
+ "src" : "30:2:1"
+ }
+ ],
+ "contractDependencies" :
+ [
+ 1
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 4,
+ "linearizedBaseContracts" :
+ [
+ 4,
+ 1
+ ],
+ "name" : "C2",
+ "nodeType" : "ContractDefinition",
+ "nodes" : [],
+ "scope" : 5,
+ "src" : "15:20:1"
+ }
+ ],
+ "src" : "0:36:1"
+}
diff --git a/test/libsolidity/ASTJSON/inheritance_specifier.sol b/test/libsolidity/ASTJSON/inheritance_specifier.sol
new file mode 100644
index 00000000..02dbf0c5
--- /dev/null
+++ b/test/libsolidity/ASTJSON/inheritance_specifier.sol
@@ -0,0 +1 @@
+contract C1 {} contract C2 is C1 {}
diff --git a/test/libsolidity/ASTJSON/inheritance_specifier_legacy.json b/test/libsolidity/ASTJSON/inheritance_specifier_legacy.json
new file mode 100644
index 00000000..0fcf2939
--- /dev/null
+++ b/test/libsolidity/ASTJSON/inheritance_specifier_legacy.json
@@ -0,0 +1,105 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C1" :
+ [
+ 1
+ ],
+ "C2" :
+ [
+ 4
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 1
+ ],
+ "name" : "C1",
+ "nodes" :
+ [
+ null
+ ],
+ "scope" : 5
+ },
+ "id" : 1,
+ "name" : "ContractDefinition",
+ "src" : "0:14:1"
+ },
+ {
+ "attributes" :
+ {
+ "contractDependencies" :
+ [
+ 1
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 4,
+ 1
+ ],
+ "name" : "C2",
+ "nodes" :
+ [
+ null
+ ],
+ "scope" : 5
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "arguments" : null
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "contractScope" : null,
+ "name" : "C1",
+ "referencedDeclaration" : 1,
+ "type" : "contract C1"
+ },
+ "id" : 2,
+ "name" : "UserDefinedTypeName",
+ "src" : "30:2:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "InheritanceSpecifier",
+ "src" : "30:2:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "ContractDefinition",
+ "src" : "15:20:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "SourceUnit",
+ "src" : "0:36:1"
+}
diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation.json b/test/libsolidity/ASTJSON/long_type_name_binary_operation.json
new file mode 100644
index 00000000..fe3e73d2
--- /dev/null
+++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation.json
@@ -0,0 +1,175 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 11
+ ]
+ },
+ "id" : 12,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 11,
+ "linearizedBaseContracts" :
+ [
+ 11
+ ],
+ "name" : "c",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 9,
+ "nodeType" : "Block",
+ "src" : "33:19:1",
+ "statements" :
+ [
+ {
+ "assignments" :
+ [
+ 4
+ ],
+ "declarations" :
+ [
+ {
+ "constant" : false,
+ "id" : 4,
+ "name" : "a",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 9,
+ "src" : "35:6:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ },
+ "typeName" :
+ {
+ "id" : 3,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "35:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "id" : 8,
+ "initialValue" :
+ {
+ "argumentTypes" : null,
+ "commonType" :
+ {
+ "typeIdentifier" : "t_rational_5_by_1",
+ "typeString" : "int_const 5"
+ },
+ "id" : 7,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "leftExpression" :
+ {
+ "argumentTypes" : null,
+ "hexValue" : "32",
+ "id" : 5,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "kind" : "number",
+ "lValueRequested" : false,
+ "nodeType" : "Literal",
+ "src" : "44:1:1",
+ "subdenomination" : null,
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_rational_2_by_1",
+ "typeString" : "int_const 2"
+ },
+ "value" : "2"
+ },
+ "nodeType" : "BinaryOperation",
+ "operator" : "+",
+ "rightExpression" :
+ {
+ "argumentTypes" : null,
+ "hexValue" : "33",
+ "id" : 6,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "kind" : "number",
+ "lValueRequested" : false,
+ "nodeType" : "Literal",
+ "src" : "48:1:1",
+ "subdenomination" : null,
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_rational_3_by_1",
+ "typeString" : "int_const 3"
+ },
+ "value" : "3"
+ },
+ "src" : "44:5:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_rational_5_by_1",
+ "typeString" : "int_const 5"
+ }
+ },
+ "nodeType" : "VariableDeclarationStatement",
+ "src" : "35:14:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 10,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" : [],
+ "name" : "f",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "23:2:1"
+ },
+ "returnParameters" :
+ {
+ "id" : 2,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "33:0:1"
+ },
+ "scope" : 11,
+ "src" : "13:39:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 12,
+ "src" : "0:54:1"
+ }
+ ],
+ "src" : "0:55:1"
+}
diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation.sol b/test/libsolidity/ASTJSON/long_type_name_binary_operation.sol
new file mode 100644
index 00000000..f07029d7
--- /dev/null
+++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation.sol
@@ -0,0 +1 @@
+contract c { function f() public { uint a = 2 + 3; } }
diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json b/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json
new file mode 100644
index 00000000..d78d01ff
--- /dev/null
+++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json
@@ -0,0 +1,207 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 11
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 11
+ ],
+ "name" : "c",
+ "scope" : 12
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "f",
+ "scope" : 11,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "23:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 2,
+ "name" : "ParameterList",
+ "src" : "33:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "assignments" :
+ [
+ 4
+ ]
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "a",
+ "scope" : 9,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "uint256",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 3,
+ "name" : "ElementaryTypeName",
+ "src" : "35:4:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "VariableDeclaration",
+ "src" : "35:6:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "commonType" :
+ {
+ "typeIdentifier" : "t_rational_5_by_1",
+ "typeString" : "int_const 5"
+ },
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "operator" : "+",
+ "type" : "int_const 5"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "hexvalue" : "32",
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "subdenomination" : null,
+ "token" : "number",
+ "type" : "int_const 2",
+ "value" : "2"
+ },
+ "id" : 5,
+ "name" : "Literal",
+ "src" : "44:1:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "hexvalue" : "33",
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "subdenomination" : null,
+ "token" : "number",
+ "type" : "int_const 3",
+ "value" : "3"
+ },
+ "id" : 6,
+ "name" : "Literal",
+ "src" : "48:1:1"
+ }
+ ],
+ "id" : 7,
+ "name" : "BinaryOperation",
+ "src" : "44:5:1"
+ }
+ ],
+ "id" : 8,
+ "name" : "VariableDeclarationStatement",
+ "src" : "35:14:1"
+ }
+ ],
+ "id" : 9,
+ "name" : "Block",
+ "src" : "33:19:1"
+ }
+ ],
+ "id" : 10,
+ "name" : "FunctionDefinition",
+ "src" : "13:39:1"
+ }
+ ],
+ "id" : 11,
+ "name" : "ContractDefinition",
+ "src" : "0:54:1"
+ }
+ ],
+ "id" : 12,
+ "name" : "SourceUnit",
+ "src" : "0:55:1"
+}
diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier.json b/test/libsolidity/ASTJSON/long_type_name_identifier.json
new file mode 100644
index 00000000..0579967c
--- /dev/null
+++ b/test/libsolidity/ASTJSON/long_type_name_identifier.json
@@ -0,0 +1,181 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 14
+ ]
+ },
+ "id" : 15,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 14,
+ "linearizedBaseContracts" :
+ [
+ 14
+ ],
+ "name" : "c",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "constant" : false,
+ "id" : 3,
+ "name" : "a",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 14,
+ "src" : "13:8:1",
+ "stateVariable" : true,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage",
+ "typeString" : "uint256[]"
+ },
+ "typeName" :
+ {
+ "baseType" :
+ {
+ "id" : 1,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "13:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "id" : 2,
+ "length" : null,
+ "nodeType" : "ArrayTypeName",
+ "src" : "13:6:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage_ptr",
+ "typeString" : "uint256[]"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ },
+ {
+ "body" :
+ {
+ "id" : 12,
+ "nodeType" : "Block",
+ "src" : "43:25:1",
+ "statements" :
+ [
+ {
+ "assignments" :
+ [
+ 9
+ ],
+ "declarations" :
+ [
+ {
+ "constant" : false,
+ "id" : 9,
+ "name" : "b",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 12,
+ "src" : "45:16:1",
+ "stateVariable" : false,
+ "storageLocation" : "storage",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage_ptr",
+ "typeString" : "uint256[]"
+ },
+ "typeName" :
+ {
+ "baseType" :
+ {
+ "id" : 7,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "45:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "id" : 8,
+ "length" : null,
+ "nodeType" : "ArrayTypeName",
+ "src" : "45:6:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage_ptr",
+ "typeString" : "uint256[]"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "id" : 11,
+ "initialValue" :
+ {
+ "argumentTypes" : null,
+ "id" : 10,
+ "name" : "a",
+ "nodeType" : "Identifier",
+ "overloadedDeclarations" : [],
+ "referencedDeclaration" : 3,
+ "src" : "64:1:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage",
+ "typeString" : "uint256[] storage ref"
+ }
+ },
+ "nodeType" : "VariableDeclarationStatement",
+ "src" : "45:20:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 13,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" : [],
+ "name" : "f",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 4,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "33:2:1"
+ },
+ "returnParameters" :
+ {
+ "id" : 5,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "43:0:1"
+ },
+ "scope" : 14,
+ "src" : "23:45:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 15,
+ "src" : "0:70:1"
+ }
+ ],
+ "src" : "0:71:1"
+}
diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier.sol b/test/libsolidity/ASTJSON/long_type_name_identifier.sol
new file mode 100644
index 00000000..f03f7a84
--- /dev/null
+++ b/test/libsolidity/ASTJSON/long_type_name_identifier.sol
@@ -0,0 +1 @@
+contract c { uint[] a; function f() public { uint[] storage b = a; } }
diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json b/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json
new file mode 100644
index 00000000..a96ccef3
--- /dev/null
+++ b/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json
@@ -0,0 +1,219 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 14
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 14
+ ],
+ "name" : "c",
+ "scope" : 15
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "a",
+ "scope" : 14,
+ "stateVariable" : true,
+ "storageLocation" : "default",
+ "type" : "uint256[]",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "length" : null,
+ "type" : "uint256[]"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 1,
+ "name" : "ElementaryTypeName",
+ "src" : "13:4:1"
+ }
+ ],
+ "id" : 2,
+ "name" : "ArrayTypeName",
+ "src" : "13:6:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "VariableDeclaration",
+ "src" : "13:8:1"
+ },
+ {
+ "attributes" :
+ {
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "f",
+ "scope" : 14,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 4,
+ "name" : "ParameterList",
+ "src" : "33:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 5,
+ "name" : "ParameterList",
+ "src" : "43:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "assignments" :
+ [
+ 9
+ ]
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "b",
+ "scope" : 12,
+ "stateVariable" : false,
+ "storageLocation" : "storage",
+ "type" : "uint256[]",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "length" : null,
+ "type" : "uint256[]"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 7,
+ "name" : "ElementaryTypeName",
+ "src" : "45:4:1"
+ }
+ ],
+ "id" : 8,
+ "name" : "ArrayTypeName",
+ "src" : "45:6:1"
+ }
+ ],
+ "id" : 9,
+ "name" : "VariableDeclaration",
+ "src" : "45:16:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "overloadedDeclarations" :
+ [
+ null
+ ],
+ "referencedDeclaration" : 3,
+ "type" : "uint256[] storage ref",
+ "value" : "a"
+ },
+ "id" : 10,
+ "name" : "Identifier",
+ "src" : "64:1:1"
+ }
+ ],
+ "id" : 11,
+ "name" : "VariableDeclarationStatement",
+ "src" : "45:20:1"
+ }
+ ],
+ "id" : 12,
+ "name" : "Block",
+ "src" : "43:25:1"
+ }
+ ],
+ "id" : 13,
+ "name" : "FunctionDefinition",
+ "src" : "23:45:1"
+ }
+ ],
+ "id" : 14,
+ "name" : "ContractDefinition",
+ "src" : "0:70:1"
+ }
+ ],
+ "id" : 15,
+ "name" : "SourceUnit",
+ "src" : "0:71:1"
+}
diff --git a/test/libsolidity/ASTJSON/modifier_definition.json b/test/libsolidity/ASTJSON/modifier_definition.json
new file mode 100644
index 00000000..95554f03
--- /dev/null
+++ b/test/libsolidity/ASTJSON/modifier_definition.json
@@ -0,0 +1,174 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 14
+ ]
+ },
+ "id" : 15,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 14,
+ "linearizedBaseContracts" :
+ [
+ 14
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 5,
+ "nodeType" : "Block",
+ "src" : "32:6:1",
+ "statements" :
+ [
+ {
+ "id" : 4,
+ "nodeType" : "PlaceholderStatement",
+ "src" : "34:1:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 6,
+ "name" : "M",
+ "nodeType" : "ModifierDefinition",
+ "parameters" :
+ {
+ "id" : 3,
+ "nodeType" : "ParameterList",
+ "parameters" :
+ [
+ {
+ "constant" : false,
+ "id" : 2,
+ "name" : "i",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 6,
+ "src" : "24:6:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ },
+ "typeName" :
+ {
+ "id" : 1,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "24:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "src" : "23:8:1"
+ },
+ "src" : "13:25:1",
+ "visibility" : "internal"
+ },
+ {
+ "body" :
+ {
+ "id" : 12,
+ "nodeType" : "Block",
+ "src" : "64:2:1",
+ "statements" : []
+ },
+ "documentation" : null,
+ "id" : 13,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ {
+ "arguments" :
+ [
+ {
+ "argumentTypes" : null,
+ "hexValue" : "31",
+ "id" : 9,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "kind" : "number",
+ "lValueRequested" : false,
+ "nodeType" : "Literal",
+ "src" : "54:1:1",
+ "subdenomination" : null,
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_rational_1_by_1",
+ "typeString" : "int_const 1"
+ },
+ "value" : "1"
+ }
+ ],
+ "id" : 10,
+ "modifierName" :
+ {
+ "argumentTypes" : null,
+ "id" : 8,
+ "name" : "M",
+ "nodeType" : "Identifier",
+ "overloadedDeclarations" : [],
+ "referencedDeclaration" : 6,
+ "src" : "52:1:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_modifier$_t_uint256_$",
+ "typeString" : "modifier (uint256)"
+ }
+ },
+ "nodeType" : "ModifierInvocation",
+ "src" : "52:4:1"
+ }
+ ],
+ "name" : "F",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 7,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "49:2:1"
+ },
+ "returnParameters" :
+ {
+ "id" : 11,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "64:0:1"
+ },
+ "scope" : 14,
+ "src" : "39:27:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 15,
+ "src" : "0:68:1"
+ }
+ ],
+ "src" : "0:69:1"
+}
diff --git a/test/libsolidity/ASTJSON/modifier_definition.sol b/test/libsolidity/ASTJSON/modifier_definition.sol
new file mode 100644
index 00000000..96474e0f
--- /dev/null
+++ b/test/libsolidity/ASTJSON/modifier_definition.sol
@@ -0,0 +1 @@
+contract C { modifier M(uint i) { _; } function F() M(1) public {} }
diff --git a/test/libsolidity/ASTJSON/modifier_definition_legacy.json b/test/libsolidity/ASTJSON/modifier_definition_legacy.json
new file mode 100644
index 00000000..e1e797ba
--- /dev/null
+++ b/test/libsolidity/ASTJSON/modifier_definition_legacy.json
@@ -0,0 +1,211 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 14
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 14
+ ],
+ "name" : "C",
+ "scope" : 15
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "documentation" : null,
+ "name" : "M",
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "i",
+ "scope" : 6,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "uint256",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 1,
+ "name" : "ElementaryTypeName",
+ "src" : "24:4:1"
+ }
+ ],
+ "id" : 2,
+ "name" : "VariableDeclaration",
+ "src" : "24:6:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "ParameterList",
+ "src" : "23:8:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "id" : 4,
+ "name" : "PlaceholderStatement",
+ "src" : "34:1:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "Block",
+ "src" : "32:6:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "ModifierDefinition",
+ "src" : "13:25:1"
+ },
+ {
+ "attributes" :
+ {
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "name" : "F",
+ "scope" : 14,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 7,
+ "name" : "ParameterList",
+ "src" : "49:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 11,
+ "name" : "ParameterList",
+ "src" : "64:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "overloadedDeclarations" :
+ [
+ null
+ ],
+ "referencedDeclaration" : 6,
+ "type" : "modifier (uint256)",
+ "value" : "M"
+ },
+ "id" : 8,
+ "name" : "Identifier",
+ "src" : "52:1:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "hexvalue" : "31",
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "subdenomination" : null,
+ "token" : "number",
+ "type" : "int_const 1",
+ "value" : "1"
+ },
+ "id" : 9,
+ "name" : "Literal",
+ "src" : "54:1:1"
+ }
+ ],
+ "id" : 10,
+ "name" : "ModifierInvocation",
+ "src" : "52:4:1"
+ },
+ {
+ "attributes" :
+ {
+ "statements" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 12,
+ "name" : "Block",
+ "src" : "64:2:1"
+ }
+ ],
+ "id" : 13,
+ "name" : "FunctionDefinition",
+ "src" : "39:27:1"
+ }
+ ],
+ "id" : 14,
+ "name" : "ContractDefinition",
+ "src" : "0:68:1"
+ }
+ ],
+ "id" : 15,
+ "name" : "SourceUnit",
+ "src" : "0:69:1"
+}
diff --git a/test/libsolidity/ASTJSON/modifier_invocation.json b/test/libsolidity/ASTJSON/modifier_invocation.json
new file mode 100644
index 00000000..95554f03
--- /dev/null
+++ b/test/libsolidity/ASTJSON/modifier_invocation.json
@@ -0,0 +1,174 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 14
+ ]
+ },
+ "id" : 15,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 14,
+ "linearizedBaseContracts" :
+ [
+ 14
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 5,
+ "nodeType" : "Block",
+ "src" : "32:6:1",
+ "statements" :
+ [
+ {
+ "id" : 4,
+ "nodeType" : "PlaceholderStatement",
+ "src" : "34:1:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 6,
+ "name" : "M",
+ "nodeType" : "ModifierDefinition",
+ "parameters" :
+ {
+ "id" : 3,
+ "nodeType" : "ParameterList",
+ "parameters" :
+ [
+ {
+ "constant" : false,
+ "id" : 2,
+ "name" : "i",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 6,
+ "src" : "24:6:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ },
+ "typeName" :
+ {
+ "id" : 1,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "24:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "src" : "23:8:1"
+ },
+ "src" : "13:25:1",
+ "visibility" : "internal"
+ },
+ {
+ "body" :
+ {
+ "id" : 12,
+ "nodeType" : "Block",
+ "src" : "64:2:1",
+ "statements" : []
+ },
+ "documentation" : null,
+ "id" : 13,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ {
+ "arguments" :
+ [
+ {
+ "argumentTypes" : null,
+ "hexValue" : "31",
+ "id" : 9,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "kind" : "number",
+ "lValueRequested" : false,
+ "nodeType" : "Literal",
+ "src" : "54:1:1",
+ "subdenomination" : null,
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_rational_1_by_1",
+ "typeString" : "int_const 1"
+ },
+ "value" : "1"
+ }
+ ],
+ "id" : 10,
+ "modifierName" :
+ {
+ "argumentTypes" : null,
+ "id" : 8,
+ "name" : "M",
+ "nodeType" : "Identifier",
+ "overloadedDeclarations" : [],
+ "referencedDeclaration" : 6,
+ "src" : "52:1:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_modifier$_t_uint256_$",
+ "typeString" : "modifier (uint256)"
+ }
+ },
+ "nodeType" : "ModifierInvocation",
+ "src" : "52:4:1"
+ }
+ ],
+ "name" : "F",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 7,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "49:2:1"
+ },
+ "returnParameters" :
+ {
+ "id" : 11,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "64:0:1"
+ },
+ "scope" : 14,
+ "src" : "39:27:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 15,
+ "src" : "0:68:1"
+ }
+ ],
+ "src" : "0:69:1"
+}
diff --git a/test/libsolidity/ASTJSON/modifier_invocation.sol b/test/libsolidity/ASTJSON/modifier_invocation.sol
new file mode 100644
index 00000000..96474e0f
--- /dev/null
+++ b/test/libsolidity/ASTJSON/modifier_invocation.sol
@@ -0,0 +1 @@
+contract C { modifier M(uint i) { _; } function F() M(1) public {} }
diff --git a/test/libsolidity/ASTJSON/modifier_invocation_legacy.json b/test/libsolidity/ASTJSON/modifier_invocation_legacy.json
new file mode 100644
index 00000000..e1e797ba
--- /dev/null
+++ b/test/libsolidity/ASTJSON/modifier_invocation_legacy.json
@@ -0,0 +1,211 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 14
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 14
+ ],
+ "name" : "C",
+ "scope" : 15
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "documentation" : null,
+ "name" : "M",
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "i",
+ "scope" : 6,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "uint256",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 1,
+ "name" : "ElementaryTypeName",
+ "src" : "24:4:1"
+ }
+ ],
+ "id" : 2,
+ "name" : "VariableDeclaration",
+ "src" : "24:6:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "ParameterList",
+ "src" : "23:8:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "id" : 4,
+ "name" : "PlaceholderStatement",
+ "src" : "34:1:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "Block",
+ "src" : "32:6:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "ModifierDefinition",
+ "src" : "13:25:1"
+ },
+ {
+ "attributes" :
+ {
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "name" : "F",
+ "scope" : 14,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 7,
+ "name" : "ParameterList",
+ "src" : "49:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 11,
+ "name" : "ParameterList",
+ "src" : "64:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "overloadedDeclarations" :
+ [
+ null
+ ],
+ "referencedDeclaration" : 6,
+ "type" : "modifier (uint256)",
+ "value" : "M"
+ },
+ "id" : 8,
+ "name" : "Identifier",
+ "src" : "52:1:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "hexvalue" : "31",
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "subdenomination" : null,
+ "token" : "number",
+ "type" : "int_const 1",
+ "value" : "1"
+ },
+ "id" : 9,
+ "name" : "Literal",
+ "src" : "54:1:1"
+ }
+ ],
+ "id" : 10,
+ "name" : "ModifierInvocation",
+ "src" : "52:4:1"
+ },
+ {
+ "attributes" :
+ {
+ "statements" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 12,
+ "name" : "Block",
+ "src" : "64:2:1"
+ }
+ ],
+ "id" : 13,
+ "name" : "FunctionDefinition",
+ "src" : "39:27:1"
+ }
+ ],
+ "id" : 14,
+ "name" : "ContractDefinition",
+ "src" : "0:68:1"
+ }
+ ],
+ "id" : 15,
+ "name" : "SourceUnit",
+ "src" : "0:69:1"
+}
diff --git a/test/libsolidity/ASTJSON/non_utf8.json b/test/libsolidity/ASTJSON/non_utf8.json
new file mode 100644
index 00000000..307259e9
--- /dev/null
+++ b/test/libsolidity/ASTJSON/non_utf8.json
@@ -0,0 +1,122 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 8
+ ]
+ },
+ "id" : 9,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 8,
+ "linearizedBaseContracts" :
+ [
+ 8
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 6,
+ "nodeType" : "Block",
+ "src" : "33:20:1",
+ "statements" :
+ [
+ {
+ "assignments" :
+ [
+ 3
+ ],
+ "declarations" :
+ [
+ {
+ "constant" : false,
+ "id" : 3,
+ "name" : "x",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 6,
+ "src" : "35:5:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_string_memory_ptr",
+ "typeString" : "string"
+ },
+ "typeName" : null,
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "id" : 5,
+ "initialValue" :
+ {
+ "argumentTypes" : null,
+ "hexValue" : "ff",
+ "id" : 4,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "kind" : "string",
+ "lValueRequested" : false,
+ "nodeType" : "Literal",
+ "src" : "43:7:1",
+ "subdenomination" : null,
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_stringliteral_8b1a944cf13a9a1c08facb2c9e98623ef3254d2ddb48113885c3e8e97fec8db9",
+ "typeString" : "literal_string (contains invalid UTF-8 sequence at position 0)"
+ },
+ "value" : null
+ },
+ "nodeType" : "VariableDeclarationStatement",
+ "src" : "35:15:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 7,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" : [],
+ "name" : "f",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "23:2:1"
+ },
+ "returnParameters" :
+ {
+ "id" : 2,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "33:0:1"
+ },
+ "scope" : 8,
+ "src" : "13:40:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 9,
+ "src" : "0:55:1"
+ }
+ ],
+ "src" : "0:56:1"
+}
diff --git a/test/libsolidity/ASTJSON/non_utf8.sol b/test/libsolidity/ASTJSON/non_utf8.sol
new file mode 100644
index 00000000..b83f3d70
--- /dev/null
+++ b/test/libsolidity/ASTJSON/non_utf8.sol
@@ -0,0 +1 @@
+contract C { function f() public { var x = hex"ff"; } }
diff --git a/test/libsolidity/ASTJSON/non_utf8_legacy.json b/test/libsolidity/ASTJSON/non_utf8_legacy.json
new file mode 100644
index 00000000..b1f847f7
--- /dev/null
+++ b/test/libsolidity/ASTJSON/non_utf8_legacy.json
@@ -0,0 +1,155 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 8
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 8
+ ],
+ "name" : "C",
+ "scope" : 9
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "f",
+ "scope" : 8,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "23:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 2,
+ "name" : "ParameterList",
+ "src" : "33:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "assignments" :
+ [
+ 3
+ ]
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "x",
+ "scope" : 6,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "string",
+ "typeName" : null,
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" : [],
+ "id" : 3,
+ "name" : "VariableDeclaration",
+ "src" : "35:5:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "hexvalue" : "ff",
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "subdenomination" : null,
+ "token" : "string",
+ "type" : "literal_string (contains invalid UTF-8 sequence at position 0)",
+ "value" : null
+ },
+ "id" : 4,
+ "name" : "Literal",
+ "src" : "43:7:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "VariableDeclarationStatement",
+ "src" : "35:15:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "Block",
+ "src" : "33:20:1"
+ }
+ ],
+ "id" : 7,
+ "name" : "FunctionDefinition",
+ "src" : "13:40:1"
+ }
+ ],
+ "id" : 8,
+ "name" : "ContractDefinition",
+ "src" : "0:55:1"
+ }
+ ],
+ "id" : 9,
+ "name" : "SourceUnit",
+ "src" : "0:56:1"
+}
diff --git a/test/libsolidity/ASTJSON/placeholder_statement.json b/test/libsolidity/ASTJSON/placeholder_statement.json
new file mode 100644
index 00000000..496e1500
--- /dev/null
+++ b/test/libsolidity/ASTJSON/placeholder_statement.json
@@ -0,0 +1,64 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 5
+ ]
+ },
+ "id" : 6,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 5,
+ "linearizedBaseContracts" :
+ [
+ 5
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 3,
+ "nodeType" : "Block",
+ "src" : "24:6:1",
+ "statements" :
+ [
+ {
+ "id" : 2,
+ "nodeType" : "PlaceholderStatement",
+ "src" : "26:1:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 4,
+ "name" : "M",
+ "nodeType" : "ModifierDefinition",
+ "parameters" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "24:0:1"
+ },
+ "src" : "13:17:1",
+ "visibility" : "internal"
+ }
+ ],
+ "scope" : 6,
+ "src" : "0:32:1"
+ }
+ ],
+ "src" : "0:33:1"
+}
diff --git a/test/libsolidity/ASTJSON/placeholder_statement.sol b/test/libsolidity/ASTJSON/placeholder_statement.sol
new file mode 100644
index 00000000..cb2c0990
--- /dev/null
+++ b/test/libsolidity/ASTJSON/placeholder_statement.sol
@@ -0,0 +1 @@
+contract C { modifier M { _; } }
diff --git a/test/libsolidity/ASTJSON/placeholder_statement_legacy.json b/test/libsolidity/ASTJSON/placeholder_statement_legacy.json
new file mode 100644
index 00000000..a5582976
--- /dev/null
+++ b/test/libsolidity/ASTJSON/placeholder_statement_legacy.json
@@ -0,0 +1,87 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 5
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 5
+ ],
+ "name" : "C",
+ "scope" : 6
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "documentation" : null,
+ "name" : "M",
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "24:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "id" : 2,
+ "name" : "PlaceholderStatement",
+ "src" : "26:1:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "Block",
+ "src" : "24:6:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "ModifierDefinition",
+ "src" : "13:17:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "ContractDefinition",
+ "src" : "0:32:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "SourceUnit",
+ "src" : "0:33:1"
+}
diff --git a/test/libsolidity/ASTJSON/short_type_name.json b/test/libsolidity/ASTJSON/short_type_name.json
new file mode 100644
index 00000000..502c1e31
--- /dev/null
+++ b/test/libsolidity/ASTJSON/short_type_name.json
@@ -0,0 +1,126 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 10
+ ]
+ },
+ "id" : 11,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 10,
+ "linearizedBaseContracts" :
+ [
+ 10
+ ],
+ "name" : "c",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 8,
+ "nodeType" : "Block",
+ "src" : "33:20:1",
+ "statements" :
+ [
+ {
+ "assignments" :
+ [
+ 6
+ ],
+ "declarations" :
+ [
+ {
+ "constant" : false,
+ "id" : 6,
+ "name" : "x",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 8,
+ "src" : "35:15:1",
+ "stateVariable" : false,
+ "storageLocation" : "memory",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_memory_ptr",
+ "typeString" : "uint256[]"
+ },
+ "typeName" :
+ {
+ "baseType" :
+ {
+ "id" : 4,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "35:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "id" : 5,
+ "length" : null,
+ "nodeType" : "ArrayTypeName",
+ "src" : "35:6:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage_ptr",
+ "typeString" : "uint256[]"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "id" : 7,
+ "initialValue" : null,
+ "nodeType" : "VariableDeclarationStatement",
+ "src" : "35:15:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 9,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" : [],
+ "name" : "f",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "23:2:1"
+ },
+ "returnParameters" :
+ {
+ "id" : 2,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "33:0:1"
+ },
+ "scope" : 10,
+ "src" : "13:40:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 11,
+ "src" : "0:55:1"
+ }
+ ],
+ "src" : "0:56:1"
+}
diff --git a/test/libsolidity/ASTJSON/short_type_name.sol b/test/libsolidity/ASTJSON/short_type_name.sol
new file mode 100644
index 00000000..533874ae
--- /dev/null
+++ b/test/libsolidity/ASTJSON/short_type_name.sol
@@ -0,0 +1 @@
+contract c { function f() public { uint[] memory x; } }
diff --git a/test/libsolidity/ASTJSON/short_type_name_legacy.json b/test/libsolidity/ASTJSON/short_type_name_legacy.json
new file mode 100644
index 00000000..761bcd3b
--- /dev/null
+++ b/test/libsolidity/ASTJSON/short_type_name_legacy.json
@@ -0,0 +1,162 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 10
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 10
+ ],
+ "name" : "c",
+ "scope" : 11
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "f",
+ "scope" : 10,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "23:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 2,
+ "name" : "ParameterList",
+ "src" : "33:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "assignments" :
+ [
+ 6
+ ],
+ "initialValue" : null
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "x",
+ "scope" : 8,
+ "stateVariable" : false,
+ "storageLocation" : "memory",
+ "type" : "uint256[]",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "length" : null,
+ "type" : "uint256[]"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 4,
+ "name" : "ElementaryTypeName",
+ "src" : "35:4:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "ArrayTypeName",
+ "src" : "35:6:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "VariableDeclaration",
+ "src" : "35:15:1"
+ }
+ ],
+ "id" : 7,
+ "name" : "VariableDeclarationStatement",
+ "src" : "35:15:1"
+ }
+ ],
+ "id" : 8,
+ "name" : "Block",
+ "src" : "33:20:1"
+ }
+ ],
+ "id" : 9,
+ "name" : "FunctionDefinition",
+ "src" : "13:40:1"
+ }
+ ],
+ "id" : 10,
+ "name" : "ContractDefinition",
+ "src" : "0:55:1"
+ }
+ ],
+ "id" : 11,
+ "name" : "SourceUnit",
+ "src" : "0:56:1"
+}
diff --git a/test/libsolidity/ASTJSON/short_type_name_ref.json b/test/libsolidity/ASTJSON/short_type_name_ref.json
new file mode 100644
index 00000000..b0c3ad97
--- /dev/null
+++ b/test/libsolidity/ASTJSON/short_type_name_ref.json
@@ -0,0 +1,138 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 11
+ ]
+ },
+ "id" : 12,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 11,
+ "linearizedBaseContracts" :
+ [
+ 11
+ ],
+ "name" : "c",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 9,
+ "nodeType" : "Block",
+ "src" : "33:25:1",
+ "statements" :
+ [
+ {
+ "assignments" :
+ [
+ 7
+ ],
+ "declarations" :
+ [
+ {
+ "constant" : false,
+ "id" : 7,
+ "name" : "rows",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 9,
+ "src" : "35:20:1",
+ "stateVariable" : false,
+ "storageLocation" : "memory",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_array$_t_uint256_$dyn_memory_$dyn_memory_ptr",
+ "typeString" : "uint256[][]"
+ },
+ "typeName" :
+ {
+ "baseType" :
+ {
+ "baseType" :
+ {
+ "id" : 4,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "35:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "id" : 5,
+ "length" : null,
+ "nodeType" : "ArrayTypeName",
+ "src" : "35:6:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage_ptr",
+ "typeString" : "uint256[]"
+ }
+ },
+ "id" : 6,
+ "length" : null,
+ "nodeType" : "ArrayTypeName",
+ "src" : "35:8:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_array$_t_uint256_$dyn_storage_$dyn_storage_ptr",
+ "typeString" : "uint256[][]"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "id" : 8,
+ "initialValue" : null,
+ "nodeType" : "VariableDeclarationStatement",
+ "src" : "35:20:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 10,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" : [],
+ "name" : "f",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "23:2:1"
+ },
+ "returnParameters" :
+ {
+ "id" : 2,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "33:0:1"
+ },
+ "scope" : 11,
+ "src" : "13:45:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 12,
+ "src" : "0:60:1"
+ }
+ ],
+ "src" : "0:61:1"
+}
diff --git a/test/libsolidity/ASTJSON/short_type_name_ref.sol b/test/libsolidity/ASTJSON/short_type_name_ref.sol
new file mode 100644
index 00000000..a808b982
--- /dev/null
+++ b/test/libsolidity/ASTJSON/short_type_name_ref.sol
@@ -0,0 +1 @@
+contract c { function f() public { uint[][] memory rows; } }
diff --git a/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json b/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json
new file mode 100644
index 00000000..d426a384
--- /dev/null
+++ b/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json
@@ -0,0 +1,175 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 11
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 11
+ ],
+ "name" : "c",
+ "scope" : 12
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "f",
+ "scope" : 11,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "23:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 2,
+ "name" : "ParameterList",
+ "src" : "33:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "assignments" :
+ [
+ 7
+ ],
+ "initialValue" : null
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "rows",
+ "scope" : 9,
+ "stateVariable" : false,
+ "storageLocation" : "memory",
+ "type" : "uint256[][]",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "length" : null,
+ "type" : "uint256[][]"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "length" : null,
+ "type" : "uint256[]"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 4,
+ "name" : "ElementaryTypeName",
+ "src" : "35:4:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "ArrayTypeName",
+ "src" : "35:6:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "ArrayTypeName",
+ "src" : "35:8:1"
+ }
+ ],
+ "id" : 7,
+ "name" : "VariableDeclaration",
+ "src" : "35:20:1"
+ }
+ ],
+ "id" : 8,
+ "name" : "VariableDeclarationStatement",
+ "src" : "35:20:1"
+ }
+ ],
+ "id" : 9,
+ "name" : "Block",
+ "src" : "33:25:1"
+ }
+ ],
+ "id" : 10,
+ "name" : "FunctionDefinition",
+ "src" : "13:45:1"
+ }
+ ],
+ "id" : 11,
+ "name" : "ContractDefinition",
+ "src" : "0:60:1"
+ }
+ ],
+ "id" : 12,
+ "name" : "SourceUnit",
+ "src" : "0:61:1"
+}
diff --git a/test/libsolidity/ASTJSON/smoke.json b/test/libsolidity/ASTJSON/smoke.json
new file mode 100644
index 00000000..f5369bfc
--- /dev/null
+++ b/test/libsolidity/ASTJSON/smoke.json
@@ -0,0 +1,33 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 1
+ ]
+ },
+ "id" : 2,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 1,
+ "linearizedBaseContracts" :
+ [
+ 1
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" : [],
+ "scope" : 2,
+ "src" : "0:13:1"
+ }
+ ],
+ "src" : "0:14:1"
+}
diff --git a/test/libsolidity/ASTJSON/smoke.sol b/test/libsolidity/ASTJSON/smoke.sol
new file mode 100644
index 00000000..2dde0d20
--- /dev/null
+++ b/test/libsolidity/ASTJSON/smoke.sol
@@ -0,0 +1 @@
+contract C {}
diff --git a/test/libsolidity/ASTJSON/smoke_legacy.json b/test/libsolidity/ASTJSON/smoke_legacy.json
new file mode 100644
index 00000000..e01a3c9b
--- /dev/null
+++ b/test/libsolidity/ASTJSON/smoke_legacy.json
@@ -0,0 +1,48 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 1
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 1
+ ],
+ "name" : "C",
+ "nodes" :
+ [
+ null
+ ],
+ "scope" : 2
+ },
+ "id" : 1,
+ "name" : "ContractDefinition",
+ "src" : "0:13:1"
+ }
+ ],
+ "id" : 2,
+ "name" : "SourceUnit",
+ "src" : "0:14:1"
+}
diff --git a/test/libsolidity/ASTJSON/source_location.json b/test/libsolidity/ASTJSON/source_location.json
new file mode 100644
index 00000000..8d8acb0f
--- /dev/null
+++ b/test/libsolidity/ASTJSON/source_location.json
@@ -0,0 +1,160 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 11
+ ]
+ },
+ "id" : 12,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 11,
+ "linearizedBaseContracts" :
+ [
+ 11
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 9,
+ "nodeType" : "Block",
+ "src" : "26:19:1",
+ "statements" :
+ [
+ {
+ "assignments" :
+ [
+ 3
+ ],
+ "declarations" :
+ [
+ {
+ "constant" : false,
+ "id" : 3,
+ "name" : "x",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 9,
+ "src" : "28:5:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint8",
+ "typeString" : "uint8"
+ },
+ "typeName" : null,
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "id" : 5,
+ "initialValue" :
+ {
+ "argumentTypes" : null,
+ "hexValue" : "32",
+ "id" : 4,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "kind" : "number",
+ "lValueRequested" : false,
+ "nodeType" : "Literal",
+ "src" : "36:1:1",
+ "subdenomination" : null,
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_rational_2_by_1",
+ "typeString" : "int_const 2"
+ },
+ "value" : "2"
+ },
+ "nodeType" : "VariableDeclarationStatement",
+ "src" : "28:9:1"
+ },
+ {
+ "expression" :
+ {
+ "argumentTypes" : null,
+ "id" : 7,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : false,
+ "lValueRequested" : false,
+ "nodeType" : "UnaryOperation",
+ "operator" : "++",
+ "prefix" : false,
+ "src" : "39:3:1",
+ "subExpression" :
+ {
+ "argumentTypes" : null,
+ "id" : 6,
+ "name" : "x",
+ "nodeType" : "Identifier",
+ "overloadedDeclarations" : [],
+ "referencedDeclaration" : 3,
+ "src" : "39:1:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint8",
+ "typeString" : "uint8"
+ }
+ },
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint8",
+ "typeString" : "uint8"
+ }
+ },
+ "id" : 8,
+ "nodeType" : "ExpressionStatement",
+ "src" : "39:3:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 10,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" : [],
+ "name" : "f",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "23:2:1"
+ },
+ "returnParameters" :
+ {
+ "id" : 2,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "26:0:1"
+ },
+ "scope" : 11,
+ "src" : "13:32:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 12,
+ "src" : "0:47:1"
+ }
+ ],
+ "src" : "0:48:1"
+}
diff --git a/test/libsolidity/ASTJSON/source_location.sol b/test/libsolidity/ASTJSON/source_location.sol
new file mode 100644
index 00000000..1fcec2e6
--- /dev/null
+++ b/test/libsolidity/ASTJSON/source_location.sol
@@ -0,0 +1 @@
+contract C { function f() { var x = 2; x++; } }
diff --git a/test/libsolidity/ASTJSON/source_location_legacy.json b/test/libsolidity/ASTJSON/source_location_legacy.json
new file mode 100644
index 00000000..327cd6da
--- /dev/null
+++ b/test/libsolidity/ASTJSON/source_location_legacy.json
@@ -0,0 +1,198 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 11
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 11
+ ],
+ "name" : "C",
+ "scope" : 12
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "f",
+ "scope" : 11,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "23:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 2,
+ "name" : "ParameterList",
+ "src" : "26:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "assignments" :
+ [
+ 3
+ ]
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "x",
+ "scope" : 9,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "uint8",
+ "typeName" : null,
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" : [],
+ "id" : 3,
+ "name" : "VariableDeclaration",
+ "src" : "28:5:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "hexvalue" : "32",
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "subdenomination" : null,
+ "token" : "number",
+ "type" : "int_const 2",
+ "value" : "2"
+ },
+ "id" : 4,
+ "name" : "Literal",
+ "src" : "36:1:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "VariableDeclarationStatement",
+ "src" : "28:9:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : false,
+ "lValueRequested" : false,
+ "operator" : "++",
+ "prefix" : false,
+ "type" : "uint8"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "overloadedDeclarations" :
+ [
+ null
+ ],
+ "referencedDeclaration" : 3,
+ "type" : "uint8",
+ "value" : "x"
+ },
+ "id" : 6,
+ "name" : "Identifier",
+ "src" : "39:1:1"
+ }
+ ],
+ "id" : 7,
+ "name" : "UnaryOperation",
+ "src" : "39:3:1"
+ }
+ ],
+ "id" : 8,
+ "name" : "ExpressionStatement",
+ "src" : "39:3:1"
+ }
+ ],
+ "id" : 9,
+ "name" : "Block",
+ "src" : "26:19:1"
+ }
+ ],
+ "id" : 10,
+ "name" : "FunctionDefinition",
+ "src" : "13:32:1"
+ }
+ ],
+ "id" : 11,
+ "name" : "ContractDefinition",
+ "src" : "0:47:1"
+ }
+ ],
+ "id" : 12,
+ "name" : "SourceUnit",
+ "src" : "0:48:1"
+}
diff --git a/test/libsolidity/ASTJSON/using_for_directive.json b/test/libsolidity/ASTJSON/using_for_directive.json
new file mode 100644
index 00000000..33caabb4
--- /dev/null
+++ b/test/libsolidity/ASTJSON/using_for_directive.json
@@ -0,0 +1,87 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 5
+ ],
+ "L" :
+ [
+ 1
+ ]
+ },
+ "id" : 6,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "library",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 1,
+ "linearizedBaseContracts" :
+ [
+ 1
+ ],
+ "name" : "L",
+ "nodeType" : "ContractDefinition",
+ "nodes" : [],
+ "scope" : 6,
+ "src" : "0:12:1"
+ },
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 5,
+ "linearizedBaseContracts" :
+ [
+ 5
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "id" : 4,
+ "libraryName" :
+ {
+ "contractScope" : null,
+ "id" : 2,
+ "name" : "L",
+ "nodeType" : "UserDefinedTypeName",
+ "referencedDeclaration" : 1,
+ "src" : "32:1:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_contract$_L_$1",
+ "typeString" : "library L"
+ }
+ },
+ "nodeType" : "UsingForDirective",
+ "src" : "26:17:1",
+ "typeName" :
+ {
+ "id" : 3,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "38:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ }
+ }
+ ],
+ "scope" : 6,
+ "src" : "13:32:1"
+ }
+ ],
+ "src" : "0:46:1"
+}
diff --git a/test/libsolidity/ASTJSON/using_for_directive.sol b/test/libsolidity/ASTJSON/using_for_directive.sol
new file mode 100644
index 00000000..a882ad88
--- /dev/null
+++ b/test/libsolidity/ASTJSON/using_for_directive.sol
@@ -0,0 +1 @@
+library L {} contract C { using L for uint; }
diff --git a/test/libsolidity/ASTJSON/using_for_directive_legacy.json b/test/libsolidity/ASTJSON/using_for_directive_legacy.json
new file mode 100644
index 00000000..0827ef90
--- /dev/null
+++ b/test/libsolidity/ASTJSON/using_for_directive_legacy.json
@@ -0,0 +1,110 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 5
+ ],
+ "L" :
+ [
+ 1
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "library",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 1
+ ],
+ "name" : "L",
+ "nodes" :
+ [
+ null
+ ],
+ "scope" : 6
+ },
+ "id" : 1,
+ "name" : "ContractDefinition",
+ "src" : "0:12:1"
+ },
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 5
+ ],
+ "name" : "C",
+ "scope" : 6
+ },
+ "children" :
+ [
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "contractScope" : null,
+ "name" : "L",
+ "referencedDeclaration" : 1,
+ "type" : "library L"
+ },
+ "id" : 2,
+ "name" : "UserDefinedTypeName",
+ "src" : "32:1:1"
+ },
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 3,
+ "name" : "ElementaryTypeName",
+ "src" : "38:4:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "UsingForDirective",
+ "src" : "26:17:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "ContractDefinition",
+ "src" : "13:32:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "SourceUnit",
+ "src" : "0:46:1"
+}
diff --git a/test/libsolidity/ASTJSONTest.cpp b/test/libsolidity/ASTJSONTest.cpp
new file mode 100644
index 00000000..05839c1f
--- /dev/null
+++ b/test/libsolidity/ASTJSONTest.cpp
@@ -0,0 +1,201 @@
+/*
+ This file is part of solidity.
+
+ solidity is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ solidity is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with solidity. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <test/libsolidity/ASTJSONTest.h>
+#include <test/Options.h>
+#include <libsolidity/ast/ASTJsonConverter.h>
+#include <libsolidity/interface/CompilerStack.h>
+#include <boost/algorithm/string.hpp>
+#include <boost/algorithm/string/predicate.hpp>
+#include <boost/throw_exception.hpp>
+#include <cctype>
+#include <fstream>
+#include <memory>
+#include <stdexcept>
+
+using namespace dev;
+using namespace solidity;
+using namespace dev::solidity::test;
+using namespace dev::solidity::test::formatting;
+using namespace std;
+namespace fs = boost::filesystem;
+using namespace boost::unit_test;
+
+ASTJSONTest::ASTJSONTest(string const& _filename)
+{
+ if (!boost::algorithm::ends_with(_filename, ".sol"))
+ BOOST_THROW_EXCEPTION(runtime_error("Invalid test contract file name: \"" + _filename + "\"."));
+
+ m_astFilename = _filename.substr(0, _filename.size() - 4) + ".json";
+ m_legacyAstFilename = _filename.substr(0, _filename.size() - 4) + "_legacy.json";
+
+ ifstream file(_filename);
+ if (!file)
+ BOOST_THROW_EXCEPTION(runtime_error("Cannot open test contract: \"" + _filename + "\"."));
+ file.exceptions(ios::badbit);
+
+ string sourceName;
+ string source;
+ string line;
+ string const sourceDelimiter("// ---- SOURCE: ");
+ string const delimiter("// ----");
+ while (getline(file, line))
+ {
+ if (boost::algorithm::starts_with(line, sourceDelimiter))
+ {
+ if (!sourceName.empty())
+ m_sources.emplace_back(sourceName, source);
+
+ sourceName = line.substr(sourceDelimiter.size(), string::npos);
+ source = string();
+ }
+ else if (!line.empty() && !boost::algorithm::starts_with(line, delimiter))
+ source += line + "\n";
+ }
+
+ m_sources.emplace_back(sourceName.empty() ? "a" : sourceName, source);
+
+ file.close();
+ file.open(m_astFilename);
+ if (file)
+ {
+ string line;
+ while (getline(file, line))
+ m_expectation += line + "\n";
+ }
+
+ file.close();
+ file.open(m_legacyAstFilename);
+ if (file)
+ {
+ string line;
+ while (getline(file, line))
+ m_expectationLegacy += line + "\n";
+ }
+}
+
+bool ASTJSONTest::run(ostream& _stream, string const& _linePrefix, bool const _formatted)
+{
+ CompilerStack c;
+
+ map<string, unsigned> sourceIndices;
+ for (size_t i = 0; i < m_sources.size(); i++)
+ {
+ c.addSource(m_sources[i].first, m_sources[i].second);
+ sourceIndices[m_sources[i].first] = i + 1;
+ }
+
+ c.setEVMVersion(dev::test::Options::get().evmVersion());
+ c.parseAndAnalyze();
+
+ for (size_t i = 0; i < m_sources.size(); i++)
+ {
+ ostringstream result;
+ ASTJsonConverter(false, sourceIndices).print(result, c.ast(m_sources[i].first));
+ m_result += result.str();
+ if (i != m_sources.size() - 1)
+ m_result += ",";
+ m_result += "\n";
+ }
+
+ bool resultsMatch = true;
+
+ if (m_expectation != m_result)
+ {
+ string nextIndentLevel = _linePrefix + " ";
+ FormattedScope(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Expected result:" << endl;
+ {
+ istringstream stream(m_expectation);
+ string line;
+ while (getline(stream, line))
+ _stream << nextIndentLevel << line << endl;
+ }
+ _stream << endl;
+ FormattedScope(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Obtained result:" << endl;
+ {
+ istringstream stream(m_result);
+ string line;
+ while (getline(stream, line))
+ _stream << nextIndentLevel << line << endl;
+ }
+ _stream << endl;
+ resultsMatch = false;
+ }
+
+ for (size_t i = 0; i < m_sources.size(); i++)
+ {
+ ostringstream result;
+ ASTJsonConverter(true, sourceIndices).print(result, c.ast(m_sources[i].first));
+ m_resultLegacy = result.str();
+ if (i != m_sources.size() - 1)
+ m_resultLegacy += ",";
+ m_resultLegacy += "\n";
+ }
+
+ if (m_expectationLegacy != m_resultLegacy)
+ {
+ string nextIndentLevel = _linePrefix + " ";
+ FormattedScope(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Expected result (legacy):" << endl;
+ {
+ istringstream stream(m_expectationLegacy);
+ string line;
+ while (getline(stream, line))
+ _stream << nextIndentLevel << line << endl;
+ }
+ _stream << endl;
+ FormattedScope(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Obtained result (legacy):" << endl;
+ {
+ istringstream stream(m_resultLegacy);
+ string line;
+ while (getline(stream, line))
+ _stream << nextIndentLevel << line << endl;
+ }
+ _stream << endl;
+ resultsMatch = false;
+ }
+
+ return resultsMatch;
+}
+
+void ASTJSONTest::printSource(ostream& _stream, string const& _linePrefix, bool const) const
+{
+ for (auto const& source: m_sources)
+ {
+ if (m_sources.size() > 1 || source.first != "a")
+ _stream << _linePrefix << "// ---- SOURCE: " << source.first << endl << endl;
+ stringstream stream(source.second);
+ string line;
+ while (getline(stream, line))
+ _stream << _linePrefix << line << endl;
+ _stream << endl;
+ }
+}
+
+void ASTJSONTest::printUpdatedExpectations(std::ostream&, std::string const&) const
+{
+ ofstream file(m_astFilename.c_str());
+ if (!file) BOOST_THROW_EXCEPTION(runtime_error("Cannot write AST expectation to \"" + m_astFilename + "\"."));
+ file.exceptions(ios::badbit);
+ file << m_result;
+ file.flush();
+ file.close();
+ file.open(m_legacyAstFilename.c_str());
+ if (!file) BOOST_THROW_EXCEPTION(runtime_error("Cannot write legacy AST expectation to \"" + m_legacyAstFilename + "\"."));
+ file << m_resultLegacy;
+ file.flush();
+ file.close();
+}
diff --git a/test/libsolidity/ASTJSONTest.h b/test/libsolidity/ASTJSONTest.h
new file mode 100644
index 00000000..6f24bb60
--- /dev/null
+++ b/test/libsolidity/ASTJSONTest.h
@@ -0,0 +1,58 @@
+/*
+ This file is part of solidity.
+
+ solidity is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ solidity is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with solidity. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#pragma once
+
+#include <test/libsolidity/FormattedScope.h>
+#include <test/libsolidity/TestCase.h>
+
+#include <iosfwd>
+#include <string>
+#include <vector>
+#include <utility>
+
+namespace dev
+{
+namespace solidity
+{
+namespace test
+{
+
+class ASTJSONTest: public TestCase
+{
+public:
+ static std::unique_ptr<TestCase> create(std::string const& _filename)
+ { return std::unique_ptr<TestCase>(new ASTJSONTest(_filename)); }
+ ASTJSONTest(std::string const& _filename);
+
+ virtual bool run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) override;
+
+ virtual void printSource(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) const override;
+ virtual void printUpdatedExpectations(std::ostream& _stream, std::string const& _linePrefix) const override;
+private:
+ std::vector<std::pair<std::string, std::string>> m_sources;
+ std::string m_expectation;
+ std::string m_expectationLegacy;
+ std::string m_astFilename;
+ std::string m_legacyAstFilename;
+ std::string m_result;
+ std::string m_resultLegacy;
+};
+
+}
+}
+}
diff --git a/test/libsolidity/ASTLegacyJSON.cpp b/test/libsolidity/ASTLegacyJSON.cpp
deleted file mode 100644
index 69cb1bb9..00000000
--- a/test/libsolidity/ASTLegacyJSON.cpp
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- This file is part of solidity.
-
- solidity is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- solidity is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with solidity. If not, see <http://www.gnu.org/licenses/>.
-*/
-/**
- * @author Christian <c@ethdev.com>
- * @date 2016
- * Tests for the json ast output.
- */
-
-#include <test/Options.h>
-
-#include <libsolidity/interface/Exceptions.h>
-#include <libsolidity/interface/CompilerStack.h>
-#include <libsolidity/ast/ASTJsonConverter.h>
-
-#include <boost/test/unit_test.hpp>
-
-#include <string>
-
-using namespace std;
-
-namespace dev
-{
-namespace solidity
-{
-namespace test
-{
-
-BOOST_AUTO_TEST_SUITE(SolidityASTLegacyJSON)
-
-BOOST_AUTO_TEST_CASE(smoke_test)
-{
- CompilerStack c;
- c.addSource("a", "contract C {}");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- BOOST_CHECK_EQUAL(astJson["name"], "SourceUnit");
-}
-
-BOOST_AUTO_TEST_CASE(source_location)
-{
- CompilerStack c;
- c.addSource("a", "contract C { function f() { var x = 2; x++; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- BOOST_CHECK_EQUAL(astJson["name"], "SourceUnit");
- BOOST_CHECK_EQUAL(astJson["children"][0]["name"], "ContractDefinition");
- BOOST_CHECK_EQUAL(astJson["children"][0]["children"][0]["name"], "FunctionDefinition");
- BOOST_CHECK_EQUAL(astJson["children"][0]["children"][0]["src"], "13:32:1");
-
-}
-
-BOOST_AUTO_TEST_CASE(inheritance_specifier)
-{
- CompilerStack c;
- c.addSource("a", "contract C1 {} contract C2 is C1 {}");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- BOOST_CHECK_EQUAL(astJson["children"][1]["attributes"]["name"], "C2");
- BOOST_CHECK_EQUAL(astJson["children"][1]["children"][0]["name"], "InheritanceSpecifier");
- BOOST_CHECK_EQUAL(astJson["children"][1]["children"][0]["src"], "30:2:1");
- BOOST_CHECK_EQUAL(astJson["children"][1]["children"][0]["children"][0]["name"], "UserDefinedTypeName");
- BOOST_CHECK_EQUAL(astJson["children"][1]["children"][0]["children"][0]["attributes"]["name"], "C1");
-}
-
-BOOST_AUTO_TEST_CASE(using_for_directive)
-{
- CompilerStack c;
- c.addSource("a", "library L {} contract C { using L for uint; }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value usingFor = astJson["children"][1]["children"][0];
- BOOST_CHECK_EQUAL(usingFor["name"], "UsingForDirective");
- BOOST_CHECK_EQUAL(usingFor["src"], "26:17:1");
- BOOST_CHECK_EQUAL(usingFor["children"][0]["name"], "UserDefinedTypeName");
- BOOST_CHECK_EQUAL(usingFor["children"][0]["attributes"]["name"], "L");
- BOOST_CHECK_EQUAL(usingFor["children"][1]["name"], "ElementaryTypeName");
- BOOST_CHECK_EQUAL(usingFor["children"][1]["attributes"]["name"], "uint");
-}
-
-BOOST_AUTO_TEST_CASE(enum_value)
-{
- CompilerStack c;
- c.addSource("a", "contract C { enum E { A, B } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value enumDefinition = astJson["children"][0]["children"][0];
- BOOST_CHECK_EQUAL(enumDefinition["children"][0]["name"], "EnumValue");
- BOOST_CHECK_EQUAL(enumDefinition["children"][0]["attributes"]["name"], "A");
- BOOST_CHECK_EQUAL(enumDefinition["children"][0]["src"], "22:1:1");
- BOOST_CHECK_EQUAL(enumDefinition["children"][1]["name"], "EnumValue");
- BOOST_CHECK_EQUAL(enumDefinition["children"][1]["attributes"]["name"], "B");
- BOOST_CHECK_EQUAL(enumDefinition["children"][1]["src"], "25:1:1");
-}
-
-BOOST_AUTO_TEST_CASE(modifier_definition)
-{
- CompilerStack c;
- c.addSource("a", "contract C { modifier M(uint i) { _; } function F() M(1) public {} }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value modifier = astJson["children"][0]["children"][0];
- BOOST_CHECK_EQUAL(modifier["name"], "ModifierDefinition");
- BOOST_CHECK_EQUAL(modifier["attributes"]["name"], "M");
- BOOST_CHECK_EQUAL(modifier["src"], "13:25:1");
-}
-
-BOOST_AUTO_TEST_CASE(modifier_invocation)
-{
- CompilerStack c;
- c.addSource("a", "contract C { modifier M(uint i) { _; } function F() M(1) public {} }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value modifier = astJson["children"][0]["children"][1]["children"][2];
- BOOST_CHECK_EQUAL(modifier["name"], "ModifierInvocation");
- BOOST_CHECK_EQUAL(modifier["src"], "52:4:1");
- BOOST_CHECK_EQUAL(modifier["children"][0]["attributes"]["type"], "modifier (uint256)");
- BOOST_CHECK_EQUAL(modifier["children"][0]["attributes"]["value"], "M");
- BOOST_CHECK_EQUAL(modifier["children"][1]["attributes"]["value"], "1");
-}
-
-BOOST_AUTO_TEST_CASE(event_definition)
-{
- CompilerStack c;
- c.addSource("a", "contract C { event E(); }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value event = astJson["children"][0]["children"][0];
- BOOST_CHECK_EQUAL(event["name"], "EventDefinition");
- BOOST_CHECK_EQUAL(event["attributes"]["name"], "E");
- BOOST_CHECK_EQUAL(event["src"], "13:10:1");
-}
-
-BOOST_AUTO_TEST_CASE(array_type_name)
-{
- CompilerStack c;
- c.addSource("a", "contract C { uint[] i; }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value arrayDecl = astJson["children"][0]["children"][0]["attributes"];
- BOOST_CHECK_EQUAL(arrayDecl["storageLocation"], "default");
- BOOST_CHECK_EQUAL(arrayDecl["type"], "uint256[]");
- Json::Value array = astJson["children"][0]["children"][0]["children"][0];
- BOOST_CHECK_EQUAL(array["name"], "ArrayTypeName");
- BOOST_CHECK_EQUAL(array["src"], "13:6:1");
-}
-
-BOOST_AUTO_TEST_CASE(short_type_name)
-{
- CompilerStack c;
- c.addSource("a", "contract c { function f() public { uint[] memory x; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value arrayDecl = astJson["children"][0]["children"][0]["children"][2]["children"][0]["children"][0];
- BOOST_CHECK_EQUAL(arrayDecl["attributes"]["storageLocation"], "memory");
- BOOST_CHECK_EQUAL(arrayDecl["attributes"]["type"], "uint256[]");
-}
-
-BOOST_AUTO_TEST_CASE(short_type_name_ref)
-{
- CompilerStack c;
- c.addSource("a", "contract c { function f() public { uint[][] memory rows; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value arrayDecl = astJson["children"][0]["children"][0]["children"][2]["children"][0]["children"][0];
- BOOST_CHECK_EQUAL(arrayDecl["attributes"]["storageLocation"], "memory");
- BOOST_CHECK_EQUAL(arrayDecl["attributes"]["type"], "uint256[][]");
-}
-
-BOOST_AUTO_TEST_CASE(placeholder_statement)
-{
- CompilerStack c;
- c.addSource("a", "contract C { modifier M { _; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value placeholder = astJson["children"][0]["children"][0]["children"][1]["children"][0];
- BOOST_CHECK_EQUAL(placeholder["name"], "PlaceholderStatement");
- BOOST_CHECK_EQUAL(placeholder["src"], "26:1:1");
-}
-
-BOOST_AUTO_TEST_CASE(non_utf8)
-{
- CompilerStack c;
- c.addSource("a", "contract C { function f() public { var x = hex\"ff\"; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value varDecl = astJson["children"][0]["children"][0]["children"][2]["children"][0]["children"][0];
- BOOST_CHECK_EQUAL(varDecl["attributes"]["type"], "string");
- BOOST_CHECK_EQUAL(varDecl["attributes"]["typeName"], Json::nullValue);
- Json::Value literal = astJson["children"][0]["children"][0]["children"][2]["children"][0]["children"][1];
- BOOST_CHECK_EQUAL(literal["name"], "Literal");
- BOOST_CHECK_EQUAL(literal["attributes"]["hexvalue"], "ff");
- BOOST_CHECK_EQUAL(literal["attributes"]["token"], "string");
- BOOST_CHECK_EQUAL(literal["attributes"]["value"], Json::nullValue);
- BOOST_CHECK(literal["attributes"]["type"].asString().find("invalid") != string::npos);
-}
-
-BOOST_AUTO_TEST_CASE(function_type)
-{
- CompilerStack c;
- c.addSource("a",
- "contract C { function f(function() external payable returns (uint) x) "
- "returns (function() external view returns (uint)) {} }"
- );
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value fun = astJson["children"][0]["children"][0];
- BOOST_CHECK_EQUAL(fun["name"], "FunctionDefinition");
- Json::Value argument = fun["children"][0]["children"][0];
- BOOST_CHECK_EQUAL(argument["name"], "VariableDeclaration");
- BOOST_CHECK_EQUAL(argument["attributes"]["name"], "x");
- BOOST_CHECK_EQUAL(argument["attributes"]["type"], "function () payable external returns (uint256)");
- Json::Value funType = argument["children"][0];
- BOOST_CHECK_EQUAL(funType["attributes"]["constant"], false);
- BOOST_CHECK_EQUAL(funType["attributes"]["payable"], true);
- BOOST_CHECK_EQUAL(funType["attributes"]["visibility"], "external");
- Json::Value retval = fun["children"][1]["children"][0];
- BOOST_CHECK_EQUAL(retval["name"], "VariableDeclaration");
- BOOST_CHECK_EQUAL(retval["attributes"]["name"], "");
- BOOST_CHECK_EQUAL(retval["attributes"]["type"], "function () view external returns (uint256)");
- funType = retval["children"][0];
- BOOST_CHECK_EQUAL(funType["attributes"]["constant"], true);
- BOOST_CHECK_EQUAL(funType["attributes"]["payable"], false);
- BOOST_CHECK_EQUAL(funType["attributes"]["visibility"], "external");
-}
-
-BOOST_AUTO_TEST_CASE(documentation)
-{
- CompilerStack c;
- c.addSource("a", "/**This contract is empty*/ contract C {}");
- c.addSource("b",
- "/**This contract is empty"
- " and has a line-breaking comment.*/"
- "contract C {}"
- );
- c.addSource("c",
- "contract C {"
- " /** Some comment on Evt.*/ event Evt();"
- " /** Some comment on mod.*/ modifier mod() { _; }"
- " /** Some comment on fn.*/ function fn() public {}"
- "}"
- );
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 0;
- sourceIndices["b"] = 1;
- sourceIndices["c"] = 2;
- Json::Value astJsonA = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value documentationA = astJsonA["children"][0]["attributes"]["documentation"];
- BOOST_CHECK_EQUAL(documentationA, "This contract is empty");
- Json::Value astJsonB = ASTJsonConverter(true, sourceIndices).toJson(c.ast("b"));
- Json::Value documentationB = astJsonB["children"][0]["attributes"]["documentation"];
- BOOST_CHECK_EQUAL(documentationB, "This contract is empty and has a line-breaking comment.");
- Json::Value astJsonC = ASTJsonConverter(true, sourceIndices).toJson(c.ast("c"));
- Json::Value documentationC0 = astJsonC["children"][0]["children"][0]["attributes"]["documentation"];
- Json::Value documentationC1 = astJsonC["children"][0]["children"][1]["attributes"]["documentation"];
- Json::Value documentationC2 = astJsonC["children"][0]["children"][2]["attributes"]["documentation"];
- BOOST_CHECK_EQUAL(documentationC0, "Some comment on Evt.");
- BOOST_CHECK_EQUAL(documentationC1, "Some comment on mod.");
- BOOST_CHECK_EQUAL(documentationC2, "Some comment on fn.");
-}
-
-
-BOOST_AUTO_TEST_SUITE_END()
-
-}
-}
-} // end namespaces
diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp
index 14413ca0..fdb11504 100644
--- a/test/libsolidity/SolidityABIJSON.cpp
+++ b/test/libsolidity/SolidityABIJSON.cpp
@@ -40,7 +40,7 @@ class JSONInterfaceChecker
public:
JSONInterfaceChecker(): m_compilerStack() {}
- void checkInterface(std::string const& _code, std::string const& _expectedInterfaceString)
+ void checkInterface(std::string const& _code, std::string const& _contractName, std::string const& _expectedInterfaceString)
{
m_compilerStack.reset(false);
m_compilerStack.addSource("", "pragma solidity >=0.0;\n" + _code);
@@ -48,7 +48,7 @@ public:
m_compilerStack.setOptimiserSettings(dev::test::Options::get().optimize);
BOOST_REQUIRE_MESSAGE(m_compilerStack.parseAndAnalyze(), "Parsing contract failed");
- Json::Value generatedInterface = m_compilerStack.contractABI(m_compilerStack.lastContractName());
+ Json::Value generatedInterface = m_compilerStack.contractABI(_contractName);
Json::Value expectedInterface;
BOOST_REQUIRE(jsonParseStrict(_expectedInterfaceString, expectedInterface));
BOOST_CHECK_MESSAGE(
@@ -94,7 +94,7 @@ BOOST_AUTO_TEST_CASE(basic_test)
}
])";
- checkInterface(sourceCode, interface);
+ checkInterface(sourceCode, "test", interface);
}
BOOST_AUTO_TEST_CASE(empty_contract)
@@ -104,7 +104,7 @@ BOOST_AUTO_TEST_CASE(empty_contract)
)";
char const* interface = "[]";
- checkInterface(sourceCode, interface);
+ checkInterface(sourceCode, "test", interface);
}
BOOST_AUTO_TEST_CASE(multiple_methods)
@@ -157,7 +157,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods)
}
])";
- checkInterface(sourceCode, interface);
+ checkInterface(sourceCode, "test", interface);
}
BOOST_AUTO_TEST_CASE(multiple_params)
@@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(multiple_params)
}
])";
- checkInterface(sourceCode, interface);
+ checkInterface(sourceCode, "test", interface);
}
BOOST_AUTO_TEST_CASE(multiple_methods_order)
@@ -248,7 +248,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order)
}
])";
- checkInterface(sourceCode, interface);
+ checkInterface(sourceCode, "test", interface);
}
BOOST_AUTO_TEST_CASE(view_function)
@@ -303,7 +303,7 @@ BOOST_AUTO_TEST_CASE(view_function)
}
])";
- checkInterface(sourceCode, interface);
+ checkInterface(sourceCode, "test", interface);
}
BOOST_AUTO_TEST_CASE(pure_function)
@@ -358,7 +358,7 @@ BOOST_AUTO_TEST_CASE(pure_function)
}
])";
- checkInterface(sourceCode, interface);
+ checkInterface(sourceCode, "test", interface);
}
BOOST_AUTO_TEST_CASE(events)
@@ -436,7 +436,7 @@ BOOST_AUTO_TEST_CASE(events)
])";
- checkInterface(sourceCode, interface);
+ checkInterface(sourceCode, "test", interface);
}
BOOST_AUTO_TEST_CASE(events_anonymous)
@@ -456,7 +456,7 @@ BOOST_AUTO_TEST_CASE(events_anonymous)
])";
- checkInterface(sourceCode, interface);
+ checkInterface(sourceCode, "test", interface);
}
BOOST_AUTO_TEST_CASE(inherited)
@@ -531,7 +531,7 @@ BOOST_AUTO_TEST_CASE(inherited)
}])";
- checkInterface(sourceCode, interface);
+ checkInterface(sourceCode, "Derived", interface);
}
BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one)
{
@@ -575,7 +575,7 @@ BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one)
}
])";
- checkInterface(sourceCode, interface);
+ checkInterface(sourceCode, "test", interface);
}
BOOST_AUTO_TEST_CASE(empty_name_return_parameter)
@@ -609,7 +609,7 @@ BOOST_AUTO_TEST_CASE(empty_name_return_parameter)
]
}
])";
- checkInterface(sourceCode, interface);
+ checkInterface(sourceCode, "test", interface);
}
BOOST_AUTO_TEST_CASE(constructor_abi)
@@ -641,7 +641,7 @@ BOOST_AUTO_TEST_CASE(constructor_abi)
"type": "constructor"
}
])";
- checkInterface(sourceCode, interface);
+ checkInterface(sourceCode, "test", interface);
}
BOOST_AUTO_TEST_CASE(payable_constructor_abi)
@@ -673,7 +673,7 @@ BOOST_AUTO_TEST_CASE(payable_constructor_abi)
"type": "constructor"
}
])";
- checkInterface(sourceCode, interface);
+ checkInterface(sourceCode, "test", interface);
}
BOOST_AUTO_TEST_CASE(return_param_in_abi)
@@ -719,7 +719,7 @@ BOOST_AUTO_TEST_CASE(return_param_in_abi)
}
]
)";
- checkInterface(sourceCode, interface);
+ checkInterface(sourceCode, "test", interface);
}
BOOST_AUTO_TEST_CASE(strings_and_arrays)
@@ -748,7 +748,7 @@ BOOST_AUTO_TEST_CASE(strings_and_arrays)
}
]
)";
- checkInterface(sourceCode, interface);
+ checkInterface(sourceCode, "test", interface);
}
BOOST_AUTO_TEST_CASE(library_function)
@@ -756,7 +756,7 @@ BOOST_AUTO_TEST_CASE(library_function)
char const* sourceCode = R"(
library test {
struct StructType { uint a; }
- function f(StructType storage b, uint[] storage c, test d) public returns (uint[] memory e, StructType storage f) {}
+ function f(StructType storage b, uint[] storage c, test d) public returns (uint[] memory e, StructType storage f) { f = f; }
}
)";
@@ -780,7 +780,7 @@ BOOST_AUTO_TEST_CASE(library_function)
}
]
)";
- checkInterface(sourceCode, interface);
+ checkInterface(sourceCode, "test", interface);
}
BOOST_AUTO_TEST_CASE(include_fallback_function)
@@ -800,7 +800,7 @@ BOOST_AUTO_TEST_CASE(include_fallback_function)
}
]
)";
- checkInterface(sourceCode, interface);
+ checkInterface(sourceCode, "test", interface);
}
BOOST_AUTO_TEST_CASE(payable_function)
@@ -834,7 +834,7 @@ BOOST_AUTO_TEST_CASE(payable_function)
}
]
)";
- checkInterface(sourceCode, interface);
+ checkInterface(sourceCode, "test", interface);
}
BOOST_AUTO_TEST_CASE(payable_fallback_function)
@@ -854,7 +854,7 @@ BOOST_AUTO_TEST_CASE(payable_fallback_function)
}
]
)";
- checkInterface(sourceCode, interface);
+ checkInterface(sourceCode, "test", interface);
}
BOOST_AUTO_TEST_CASE(function_type)
@@ -881,12 +881,12 @@ BOOST_AUTO_TEST_CASE(function_type)
}
]
)";
- checkInterface(sourceCode, interface);
+ checkInterface(sourceCode, "test", interface);
}
BOOST_AUTO_TEST_CASE(return_structs)
{
- char const* text = R"(
+ char const* sourceCode = R"(
pragma experimental ABIEncoderV2;
contract C {
struct S { uint a; T[] sub; }
@@ -931,12 +931,12 @@ BOOST_AUTO_TEST_CASE(return_structs)
"type" : "function"
}]
)";
- checkInterface(text, interface);
+ checkInterface(sourceCode, "C", interface);
}
BOOST_AUTO_TEST_CASE(return_structs_with_contracts)
{
- char const* text = R"(
+ char const* sourceCode = R"(
pragma experimental ABIEncoderV2;
contract C {
struct S { C[] x; C y; }
@@ -974,12 +974,13 @@ BOOST_AUTO_TEST_CASE(return_structs_with_contracts)
"type": "function"
}]
)";
- checkInterface(text, interface);
+ checkInterface(sourceCode, "C", interface);
}
BOOST_AUTO_TEST_CASE(event_structs)
{
- char const* text = R"(
+ char const* sourceCode = R"(
+ pragma experimental ABIEncoderV2;
contract C {
struct S { uint a; T[] sub; bytes b; }
struct T { uint[2] x; }
@@ -1031,12 +1032,12 @@ BOOST_AUTO_TEST_CASE(event_structs)
"type": "event"
}]
)";
- checkInterface(text, interface);
+ checkInterface(sourceCode, "C", interface);
}
BOOST_AUTO_TEST_CASE(structs_in_libraries)
{
- char const* text = R"(
+ char const* sourceCode = R"(
pragma experimental ABIEncoderV2;
library L {
struct S { uint a; T[] sub; bytes b; }
@@ -1095,7 +1096,7 @@ BOOST_AUTO_TEST_CASE(structs_in_libraries)
"type": "function"
}]
)";
- checkInterface(text, interface);
+ checkInterface(sourceCode, "L", interface);
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index e9e7c93b..a6c1372b 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -1478,6 +1478,73 @@ BOOST_AUTO_TEST_CASE(multi_level_mapping)
testContractAgainstCpp("f(uint256,uint256,uint256)", f, u256(5), u256(4), u256(0));
}
+BOOST_AUTO_TEST_CASE(mapping_local_assignment)
+{
+ char const* sourceCode = R"(
+ contract test {
+ mapping(uint8 => uint8) m1;
+ mapping(uint8 => uint8) m2;
+ function f() public returns (uint8, uint8, uint8, uint8) {
+ mapping(uint8 => uint8) storage m = m1;
+ m[1] = 42;
+
+ m = m2;
+ m[2] = 21;
+
+ return (m1[1], m1[2], m2[1], m2[2]);
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(byte(42), byte(0), byte(0), byte(21)));
+}
+
+BOOST_AUTO_TEST_CASE(mapping_local_tuple_assignment)
+{
+ char const* sourceCode = R"(
+ contract test {
+ mapping(uint8 => uint8) m1;
+ mapping(uint8 => uint8) m2;
+ function f() public returns (uint8, uint8, uint8, uint8) {
+ mapping(uint8 => uint8) storage m = m1;
+ m[1] = 42;
+
+ uint8 v;
+ (m, v) = (m2, 21);
+ m[2] = v;
+
+ return (m1[1], m1[2], m2[1], m2[2]);
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(byte(42), byte(0), byte(0), byte(21)));
+}
+
+BOOST_AUTO_TEST_CASE(mapping_local_compound_assignment)
+{
+ char const* sourceCode = R"(
+ contract test {
+ mapping(uint8 => uint8) m1;
+ mapping(uint8 => uint8) m2;
+ function f() public returns (uint8, uint8, uint8, uint8) {
+ mapping(uint8 => uint8) storage m = m1;
+ m[1] = 42;
+
+ (m = m2)[2] = 21;
+
+ return (m1[1], m1[2], m2[1], m2[2]);
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(byte(42), byte(0), byte(0), byte(21)));
+}
+
+
BOOST_AUTO_TEST_CASE(structs)
{
char const* sourceCode = R"(
@@ -4510,6 +4577,50 @@ BOOST_AUTO_TEST_CASE(constructing_enums_from_ints)
ABI_CHECK(callContractFunction("test()"), encodeArgs(1));
}
+BOOST_AUTO_TEST_CASE(enum_referencing)
+{
+ char const* sourceCode = R"(
+ interface I {
+ enum Direction { A, B, Left, Right }
+ }
+ library L {
+ enum Direction { Left, Right }
+ function f() public pure returns (Direction) {
+ return Direction.Right;
+ }
+ function g() public pure returns (I.Direction) {
+ return I.Direction.Right;
+ }
+ }
+ contract C is I {
+ function f() public pure returns (Direction) {
+ return Direction.Right;
+ }
+ function g() public pure returns (I.Direction) {
+ return I.Direction.Right;
+ }
+ function h() public pure returns (L.Direction) {
+ return L.Direction.Right;
+ }
+ function x() public pure returns (L.Direction) {
+ return L.f();
+ }
+ function y() public pure returns (I.Direction) {
+ return L.g();
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "L");
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(1));
+ ABI_CHECK(callContractFunction("g()"), encodeArgs(3));
+ compileAndRun(sourceCode, 0, "C", bytes(), map<string, Address>{{"L", m_contractAddress}});
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(3));
+ ABI_CHECK(callContractFunction("g()"), encodeArgs(3));
+ ABI_CHECK(callContractFunction("h()"), encodeArgs(1));
+ ABI_CHECK(callContractFunction("x()"), encodeArgs(1));
+ ABI_CHECK(callContractFunction("y()"), encodeArgs(3));
+}
+
BOOST_AUTO_TEST_CASE(inline_member_init)
{
char const* sourceCode = R"(
@@ -8910,52 +9021,6 @@ BOOST_AUTO_TEST_CASE(inline_assembly_storage_access_via_pointer)
ABI_CHECK(callContractFunction("separator2()"), encodeArgs(u256(0)));
}
-BOOST_AUTO_TEST_CASE(inline_assembly_jumps)
-{
- char const* sourceCode = R"(
- contract C {
- function f() public {
- assembly {
- let n := calldataload(4)
- let a := 1
- let b := a
- loop:
- jumpi(loopend, eq(n, 0))
- a add swap1
- n := sub(n, 1)
- jump(loop)
- loopend:
- mstore(0, a)
- return(0, 0x20)
- }
- }
- }
- )";
- compileAndRun(sourceCode, 0, "C");
- ABI_CHECK(callContractFunction("f()", u256(5)), encodeArgs(u256(13)));
- ABI_CHECK(callContractFunction("f()", u256(7)), encodeArgs(u256(34)));
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_function_access)
-{
- char const* sourceCode = R"(
- contract C {
- uint public x;
- function g(uint y) public { x = 2 * y; assembly { stop } }
- function f(uint _x) public {
- assembly {
- _x
- jump(g)
- pop
- }
- }
- }
- )";
- compileAndRun(sourceCode, 0, "C");
- ABI_CHECK(callContractFunction("f(uint256)", u256(5)), encodeArgs());
- ABI_CHECK(callContractFunction("x()"), encodeArgs(u256(10)));
-}
-
BOOST_AUTO_TEST_CASE(inline_assembly_function_call)
{
char const* sourceCode = R"(
@@ -11261,7 +11326,7 @@ BOOST_AUTO_TEST_CASE(invalid_instruction)
contract C {
function f() public {
assembly {
- invalid
+ invalid()
}
}
}
@@ -11688,19 +11753,10 @@ BOOST_AUTO_TEST_CASE(keccak256_assembly)
ret := keccak256(0, 0)
}
}
- function g() public pure returns (bytes32 ret) {
- assembly {
- 0
- 0
- keccak256
- =: ret
- }
- }
}
)";
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f()"), fromHex("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"));
- ABI_CHECK(callContractFunction("g()"), fromHex("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"));
}
BOOST_AUTO_TEST_CASE(multi_modifiers)
@@ -12477,6 +12533,80 @@ BOOST_AUTO_TEST_CASE(abi_encode_with_signaturev2)
ABI_CHECK(callContractFunction("f4()"), expectation);
}
+BOOST_AUTO_TEST_CASE(abi_encode_empty_string)
+{
+ char const* sourceCode = R"(
+ // Tests that this will not end up using a "bytes0" type
+ // (which would assert)
+ contract C {
+ function f() public pure returns (bytes memory, bytes memory) {
+ return (abi.encode(""), abi.encodePacked(""));
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(
+ 0x40, 0xc0,
+ 0x60, 0x20, 0x00, 0x00,
+ 0x00
+ ));
+}
+
+BOOST_AUTO_TEST_CASE(abi_encode_empty_string_v2)
+{
+ char const* sourceCode = R"(
+ // Tests that this will not end up using a "bytes0" type
+ // (which would assert)
+ pragma experimental ABIEncoderV2;
+ contract C {
+ function f() public pure returns (bytes memory, bytes memory) {
+ return (abi.encode(""), abi.encodePacked(""));
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(
+ 0x40, 0xa0,
+ 0x40, 0x20, 0x00,
+ 0x00
+ ));
+}
+
+BOOST_AUTO_TEST_CASE(abi_encode_rational)
+{
+ char const* sourceCode = R"(
+ // Tests that rational numbers (even negative ones) are encoded properly.
+ contract C {
+ function f() public pure returns (bytes memory) {
+ return abi.encode(1, -2);
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(
+ 0x20,
+ 0x40, u256(1), u256(-2)
+ ));
+}
+
+BOOST_AUTO_TEST_CASE(abi_encode_rational_v2)
+{
+ char const* sourceCode = R"(
+ // Tests that rational numbers (even negative ones) are encoded properly.
+ pragma experimental ABIEncoderV2;
+ contract C {
+ function f() public pure returns (bytes memory) {
+ return abi.encode(1, -2);
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(
+ 0x20,
+ 0x40, u256(1), u256(-2)
+ ));
+}
+
BOOST_AUTO_TEST_CASE(abi_encode_call)
{
char const* sourceCode = R"T(
@@ -12547,50 +12677,6 @@ BOOST_AUTO_TEST_CASE(staticcall_for_view_and_pure)
}
}
-BOOST_AUTO_TEST_CASE(swap_peephole_optimisation)
-{
- char const* sourceCode = R"(
- contract C {
- function lt(uint a, uint b) public returns (bool c) {
- assembly {
- a
- b
- swap1
- lt
- =: c
- }
- }
- function add(uint a, uint b) public returns (uint c) {
- assembly {
- a
- b
- swap1
- add
- =: c
- }
- }
- function div(uint a, uint b) public returns (uint c) {
- assembly {
- a
- b
- swap1
- div
- =: c
- }
- }
- }
- )";
- compileAndRun(sourceCode);
- BOOST_CHECK(callContractFunction("lt(uint256,uint256)", u256(1), u256(2)) == encodeArgs(u256(1)));
- BOOST_CHECK(callContractFunction("lt(uint256,uint256)", u256(2), u256(1)) == encodeArgs(u256(0)));
- BOOST_CHECK(callContractFunction("add(uint256,uint256)", u256(1), u256(2)) == encodeArgs(u256(3)));
- BOOST_CHECK(callContractFunction("add(uint256,uint256)", u256(100), u256(200)) == encodeArgs(u256(300)));
- BOOST_CHECK(callContractFunction("div(uint256,uint256)", u256(2), u256(1)) == encodeArgs(u256(2)));
- BOOST_CHECK(callContractFunction("div(uint256,uint256)", u256(200), u256(10)) == encodeArgs(u256(20)));
- BOOST_CHECK(callContractFunction("div(uint256,uint256)", u256(1), u256(0)) == encodeArgs(u256(0)));
- BOOST_CHECK(callContractFunction("div(uint256,uint256)", u256(0), u256(1)) == encodeArgs(u256(0)));
-}
-
BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople)
{
if (!dev::test::Options::get().evmVersion().hasBitwiseShifting())
@@ -12599,26 +12685,17 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople)
contract C {
function shl(uint a, uint b) public returns (uint c) {
assembly {
- a
- b
- shl
- =: c
+ c := shl(b, a)
}
}
function shr(uint a, uint b) public returns (uint c) {
assembly {
- a
- b
- shr
- =: c
+ c := shr(b, a)
}
}
function sar(uint a, uint b) public returns (uint c) {
assembly {
- a
- b
- sar
- =: c
+ c := sar(b, a)
}
}
}
@@ -12646,10 +12723,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
function shl_1() public returns (bool) {
uint c;
assembly {
- 1
- 2
- shl
- =: c
+ c := shl(2, 1)
}
assert(c == 4);
return true;
@@ -12657,10 +12731,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
function shl_2() public returns (bool) {
uint c;
assembly {
- 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
- 1
- shl
- =: c
+ c := shl(1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
}
assert(c == 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe);
return true;
@@ -12668,10 +12739,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
function shl_3() public returns (bool) {
uint c;
assembly {
- 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
- 256
- shl
- =: c
+ c := shl(256, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
}
assert(c == 0);
return true;
@@ -12679,10 +12747,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
function shr_1() public returns (bool) {
uint c;
assembly {
- 3
- 1
- shr
- =: c
+ c := shr(1, 3)
}
assert(c == 1);
return true;
@@ -12690,10 +12755,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
function shr_2() public returns (bool) {
uint c;
assembly {
- 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
- 1
- shr
- =: c
+ c := shr(1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
}
assert(c == 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
return true;
@@ -12701,10 +12763,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
function shr_3() public returns (bool) {
uint c;
assembly {
- 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
- 256
- shr
- =: c
+ c := shr(256, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
}
assert(c == 0);
return true;
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index d025e65a..41814888 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -390,12 +390,10 @@ BOOST_AUTO_TEST_CASE(unsatisfied_version)
BOOST_AUTO_TEST_CASE(returndatasize_as_variable)
{
char const* text = R"(
- contract c { function f() public { uint returndatasize; assembly { returndatasize }}}
+ contract C { function f() public pure { uint returndatasize; returndatasize; assembly { pop(returndatasize()) }}}
)";
vector<pair<Error::Type, std::string>> expectations(vector<pair<Error::Type, std::string>>{
- {Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"},
- {Error::Type::Warning, "The use of non-functional instructions is deprecated."},
- {Error::Type::DeclarationError, "Unbalanced stack"}
+ {Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"}
});
if (!dev::test::Options::get().evmVersion().supportsReturndata())
expectations.emplace_back(make_pair(Error::Type::Warning, std::string("\"returndatasize\" instruction is only available for Byzantium-compatible")));
@@ -405,15 +403,13 @@ BOOST_AUTO_TEST_CASE(returndatasize_as_variable)
BOOST_AUTO_TEST_CASE(create2_as_variable)
{
char const* text = R"(
- contract c { function f() public { uint create2; assembly { create2(0, 0, 0, 0) } }}
+ contract c { function f() public { uint create2; create2; assembly { pop(create2(0, 0, 0, 0)) } }}
)";
// This needs special treatment, because the message mentions the EVM version,
// so cannot be run via isoltest.
CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{
{Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"},
{Error::Type::Warning, "The \"create2\" instruction is not supported by the VM version"},
- {Error::Type::DeclarationError, "Unbalanced stack"},
- {Error::Type::Warning, "not supposed to return values"}
}));
}
diff --git a/test/libsolidity/SolidityNatspecJSON.cpp b/test/libsolidity/SolidityNatspecJSON.cpp
index 98a3bba9..cc44b578 100644
--- a/test/libsolidity/SolidityNatspecJSON.cpp
+++ b/test/libsolidity/SolidityNatspecJSON.cpp
@@ -41,6 +41,7 @@ public:
void checkNatspec(
std::string const& _code,
+ std::string const& _contractName,
std::string const& _expectedDocumentationString,
bool _userDocumentation
)
@@ -52,9 +53,9 @@ public:
Json::Value generatedDocumentation;
if (_userDocumentation)
- generatedDocumentation = m_compilerStack.natspecUser(m_compilerStack.lastContractName());
+ generatedDocumentation = m_compilerStack.natspecUser(_contractName);
else
- generatedDocumentation = m_compilerStack.natspecDev(m_compilerStack.lastContractName());
+ generatedDocumentation = m_compilerStack.natspecDev(_contractName);
Json::Value expectedDocumentation;
jsonParseStrict(_expectedDocumentationString, expectedDocumentation);
BOOST_CHECK_MESSAGE(
@@ -93,7 +94,7 @@ BOOST_AUTO_TEST_CASE(user_basic_test)
" \"mul(uint256)\":{ \"notice\": \"Multiplies `a` by 7\"}"
"}}";
- checkNatspec(sourceCode, natspec, true);
+ checkNatspec(sourceCode, "test", natspec, true);
}
BOOST_AUTO_TEST_CASE(dev_and_user_basic_test)
@@ -119,8 +120,8 @@ BOOST_AUTO_TEST_CASE(dev_and_user_basic_test)
" \"mul(uint256)\":{ \"notice\": \"Multiplies `a` by 7\"}"
"}}";
- checkNatspec(sourceCode, devNatspec, false);
- checkNatspec(sourceCode, userNatspec, true);
+ checkNatspec(sourceCode, "test", devNatspec, false);
+ checkNatspec(sourceCode, "test", userNatspec, true);
}
BOOST_AUTO_TEST_CASE(user_multiline_comment)
@@ -140,7 +141,7 @@ BOOST_AUTO_TEST_CASE(user_multiline_comment)
" \"mul_and_add(uint256,uint256)\":{ \"notice\": \"Multiplies `a` by 7 and then adds `b`\"}"
"}}";
- checkNatspec(sourceCode, natspec, true);
+ checkNatspec(sourceCode, "test", natspec, true);
}
BOOST_AUTO_TEST_CASE(user_multiple_functions)
@@ -171,7 +172,7 @@ BOOST_AUTO_TEST_CASE(user_multiple_functions)
" \"sub(int256)\":{ \"notice\": \"Subtracts 3 from `input`\"}"
"}}";
- checkNatspec(sourceCode, natspec, true);
+ checkNatspec(sourceCode, "test", natspec, true);
}
BOOST_AUTO_TEST_CASE(user_empty_contract)
@@ -182,7 +183,7 @@ BOOST_AUTO_TEST_CASE(user_empty_contract)
char const* natspec = "{\"methods\":{} }";
- checkNatspec(sourceCode, natspec, true);
+ checkNatspec(sourceCode, "test", natspec, true);
}
BOOST_AUTO_TEST_CASE(dev_and_user_no_doc)
@@ -201,8 +202,8 @@ BOOST_AUTO_TEST_CASE(dev_and_user_no_doc)
char const* devNatspec = "{\"methods\":{}}";
char const* userNatspec = "{\"methods\":{}}";
- checkNatspec(sourceCode, devNatspec, false);
- checkNatspec(sourceCode, userNatspec, true);
+ checkNatspec(sourceCode, "test", devNatspec, false);
+ checkNatspec(sourceCode, "test", userNatspec, true);
}
BOOST_AUTO_TEST_CASE(dev_desc_after_nl)
@@ -228,7 +229,7 @@ BOOST_AUTO_TEST_CASE(dev_desc_after_nl)
" }\n"
"}}";
- checkNatspec(sourceCode, natspec, false);
+ checkNatspec(sourceCode, "test", natspec, false);
}
BOOST_AUTO_TEST_CASE(dev_multiple_params)
@@ -253,7 +254,7 @@ BOOST_AUTO_TEST_CASE(dev_multiple_params)
" }\n"
"}}";
- checkNatspec(sourceCode, natspec, false);
+ checkNatspec(sourceCode, "test", natspec, false);
}
BOOST_AUTO_TEST_CASE(dev_multiple_params_mixed_whitespace)
@@ -276,7 +277,7 @@ BOOST_AUTO_TEST_CASE(dev_multiple_params_mixed_whitespace)
" }\n"
"}}";
- checkNatspec(sourceCode, natspec, false);
+ checkNatspec(sourceCode, "test", natspec, false);
}
BOOST_AUTO_TEST_CASE(dev_mutiline_param_description)
@@ -302,7 +303,7 @@ BOOST_AUTO_TEST_CASE(dev_mutiline_param_description)
" }\n"
"}}";
- checkNatspec(sourceCode, natspec, false);
+ checkNatspec(sourceCode, "test", natspec, false);
}
BOOST_AUTO_TEST_CASE(dev_multiple_functions)
@@ -353,7 +354,7 @@ BOOST_AUTO_TEST_CASE(dev_multiple_functions)
" }\n"
"}}";
- checkNatspec(sourceCode, natspec, false);
+ checkNatspec(sourceCode, "test", natspec, false);
}
BOOST_AUTO_TEST_CASE(dev_return)
@@ -381,7 +382,7 @@ BOOST_AUTO_TEST_CASE(dev_return)
" }\n"
"}}";
- checkNatspec(sourceCode, natspec, false);
+ checkNatspec(sourceCode, "test", natspec, false);
}
BOOST_AUTO_TEST_CASE(dev_return_desc_after_nl)
{
@@ -411,7 +412,7 @@ BOOST_AUTO_TEST_CASE(dev_return_desc_after_nl)
" }\n"
"}}";
- checkNatspec(sourceCode, natspec, false);
+ checkNatspec(sourceCode, "test", natspec, false);
}
@@ -443,7 +444,7 @@ BOOST_AUTO_TEST_CASE(dev_multiline_return)
" }\n"
"}}";
- checkNatspec(sourceCode, natspec, false);
+ checkNatspec(sourceCode, "test", natspec, false);
}
BOOST_AUTO_TEST_CASE(dev_multiline_comment)
@@ -476,7 +477,7 @@ BOOST_AUTO_TEST_CASE(dev_multiline_comment)
" }\n"
"}}";
- checkNatspec(sourceCode, natspec, false);
+ checkNatspec(sourceCode, "test", natspec, false);
}
BOOST_AUTO_TEST_CASE(dev_contract_no_doc)
@@ -496,7 +497,7 @@ BOOST_AUTO_TEST_CASE(dev_contract_no_doc)
" }\n"
"}";
- checkNatspec(sourceCode, natspec, false);
+ checkNatspec(sourceCode, "test", natspec, false);
}
BOOST_AUTO_TEST_CASE(dev_contract_doc)
@@ -520,7 +521,7 @@ BOOST_AUTO_TEST_CASE(dev_contract_doc)
" }\n"
"}";
- checkNatspec(sourceCode, natspec, false);
+ checkNatspec(sourceCode, "test", natspec, false);
}
BOOST_AUTO_TEST_CASE(dev_author_at_function)
@@ -546,7 +547,7 @@ BOOST_AUTO_TEST_CASE(dev_author_at_function)
" }\n"
"}";
- checkNatspec(sourceCode, natspec, false);
+ checkNatspec(sourceCode, "test", natspec, false);
}
BOOST_AUTO_TEST_CASE(natspec_notice_without_tag)
@@ -569,7 +570,7 @@ BOOST_AUTO_TEST_CASE(natspec_notice_without_tag)
}
)ABCDEF";
- checkNatspec(sourceCode, natspec, true);
+ checkNatspec(sourceCode, "test", natspec, true);
}
BOOST_AUTO_TEST_CASE(natspec_multiline_notice_without_tag)
@@ -592,7 +593,7 @@ BOOST_AUTO_TEST_CASE(natspec_multiline_notice_without_tag)
}
)ABCDEF";
- checkNatspec(sourceCode, natspec, true);
+ checkNatspec(sourceCode, "test", natspec, true);
}
BOOST_AUTO_TEST_CASE(empty_comment)
@@ -608,7 +609,7 @@ BOOST_AUTO_TEST_CASE(empty_comment)
}
)ABCDEF";
- checkNatspec(sourceCode, natspec, true);
+ checkNatspec(sourceCode, "test", natspec, true);
}
BOOST_AUTO_TEST_CASE(dev_title_at_function_error)
diff --git a/test/libsolidity/SolidityTypes.cpp b/test/libsolidity/SolidityTypes.cpp
index b8b537e5..db0e3b66 100644
--- a/test/libsolidity/SolidityTypes.cpp
+++ b/test/libsolidity/SolidityTypes.cpp
@@ -157,6 +157,9 @@ BOOST_AUTO_TEST_CASE(type_identifiers)
BOOST_CHECK_EQUAL(RationalNumberType(rational(7, 1)).identifier(), "t_rational_7_by_1");
BOOST_CHECK_EQUAL(RationalNumberType(rational(200, 77)).identifier(), "t_rational_200_by_77");
BOOST_CHECK_EQUAL(RationalNumberType(rational(2 * 200, 2 * 77)).identifier(), "t_rational_200_by_77");
+ BOOST_CHECK_EQUAL(RationalNumberType(rational(-2 * 200, -2 * 77)).identifier(), "t_rational_200_by_77");
+ BOOST_CHECK_EQUAL(RationalNumberType(rational(-2 * 200, 2 * 77)).identifier(), "t_rational_minus_200_by_77");
+ BOOST_CHECK_EQUAL(RationalNumberType(rational(2 * 200, -2 * 77)).identifier(), "t_rational_minus_200_by_77");
BOOST_CHECK_EQUAL(
StringLiteralType(Literal(SourceLocation{}, Token::StringLiteral, make_shared<string>("abc - def"))).identifier(),
"t_stringliteral_196a9142ee0d40e274a6482393c762b16dd8315713207365e1e13d8d85b74fc4"
diff --git a/test/libsolidity/syntaxTests/constants/assign_constant_function_value_050.sol b/test/libsolidity/syntaxTests/constants/assign_constant_function_value_050.sol
deleted file mode 100644
index 2c92899d..00000000
--- a/test/libsolidity/syntaxTests/constants/assign_constant_function_value_050.sol
+++ /dev/null
@@ -1,8 +0,0 @@
-pragma experimental "v0.5.0";
-
-contract C {
- function () pure returns (uint) x;
- uint constant y = x();
-}
-// ----
-// TypeError: (105-108): Initial value for constant variable has to be compile-time constant.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_err.sol
new file mode 100644
index 00000000..5fde497c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_err.sol
@@ -0,0 +1,10 @@
+contract C {
+ struct S { bool f; }
+ S s;
+ function f() internal pure returns (S storage) {
+ assembly {
+ }
+ }
+}
+// ----
+// TypeError: (87-88): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_fine.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_fine.sol
index 65902cc8..0d3db856 100644
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_fine.sol
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_fine.sol
@@ -8,7 +8,7 @@ contract C {
}
function g(bool flag) internal returns (S storage c) {
// control flow in assembly will not be analyzed for now,
- // so this will not issue a warning
+ // so this will not issue an error
assembly {
if flag {
sstore(c_slot, sload(s_slot))
@@ -17,7 +17,7 @@ contract C {
}
function h() internal returns (S storage c) {
// any reference from assembly will be sufficient for now,
- // so this will not issue a warning
+ // so this will not issue an error
assembly {
sstore(s_slot, sload(c_slot))
}
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_warn.sol
deleted file mode 100644
index 09c13847..00000000
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_warn.sol
+++ /dev/null
@@ -1,10 +0,0 @@
-contract C {
- struct S { bool f; }
- S s;
- function f() internal pure returns (S storage) {
- assembly {
- }
- }
-}
-// ----
-// Warning: (87-88): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_err.sol
new file mode 100644
index 00000000..eb574c96
--- /dev/null
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_err.sol
@@ -0,0 +1,52 @@
+contract C {
+ struct S { bool f; }
+ S s;
+ function f() internal view returns (S storage c) {
+ do {
+ break;
+ c = s;
+ } while(false);
+ }
+ function g() internal view returns (S storage c) {
+ do {
+ if (s.f) {
+ continue;
+ c = s;
+ }
+ else {
+ }
+ } while(false);
+ }
+ function h() internal view returns (S storage c) {
+ do {
+ if (s.f) {
+ break;
+ }
+ else {
+ c = s;
+ }
+ } while(false);
+ }
+ function i() internal view returns (S storage c) {
+ do {
+ if (s.f) {
+ continue;
+ }
+ else {
+ c = s;
+ }
+ } while(false);
+ }
+ function j() internal view returns (S storage c) {
+ do {
+ continue;
+ c = s;
+ } while(false);
+ }
+}
+// ----
+// TypeError: (87-98): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (223-234): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (440-451): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (654-665): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (871-882): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol
deleted file mode 100644
index 7d001c19..00000000
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol
+++ /dev/null
@@ -1,52 +0,0 @@
-contract C {
- struct S { bool f; }
- S s;
- function f() internal view returns (S storage c) {
- do {
- break;
- c = s;
- } while(false);
- }
- function g() internal view returns (S storage c) {
- do {
- if (s.f) {
- continue;
- c = s;
- }
- else {
- }
- } while(false);
- }
- function h() internal view returns (S storage c) {
- do {
- if (s.f) {
- break;
- }
- else {
- c = s;
- }
- } while(false);
- }
- function i() internal view returns (S storage c) {
- do {
- if (s.f) {
- continue;
- }
- else {
- c = s;
- }
- } while(false);
- }
- function j() internal view returns (S storage c) {
- do {
- continue;
- c = s;
- } while(false);
- }
-}
-// ----
-// Warning: (87-98): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (223-234): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (440-451): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (654-665): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (871-882): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_err.sol
new file mode 100644
index 00000000..0d266ccf
--- /dev/null
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_err.sol
@@ -0,0 +1,14 @@
+contract C {
+ struct S { bool f; }
+ S s;
+ function f() internal pure returns (S storage) { return; }
+ function g() internal view returns (S storage c, S storage) { c = s; return; }
+ function h() internal view returns (S storage, S storage d) { d = s; return; }
+ function i() internal pure returns (S storage, S storage) { return; }
+}
+// ----
+// TypeError: (87-88): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (163-164): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (233-234): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (316-317): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (327-328): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_fine.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_fine.sol
index 3a0a30ea..6d72e4ef 100644
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_fine.sol
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_fine.sol
@@ -2,5 +2,6 @@ contract C {
struct S { bool f; }
S s;
function f() internal view returns (S storage c, S storage d) { c = s; d = s; return; }
+ function g() internal view returns (S storage, S storage) { return (s,s); }
}
// ----
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_warn.sol
deleted file mode 100644
index 0a5b2fbf..00000000
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_warn.sol
+++ /dev/null
@@ -1,15 +0,0 @@
-contract C {
- struct S { bool f; }
- S s;
- function f() internal pure returns (S storage) { return; }
- function g() internal view returns (S storage c, S storage) { c = s; return; }
- function h() internal view returns (S storage, S storage d) { d = s; return; }
- function i() internal pure returns (S storage, S storage) { return; }
- function j() internal view returns (S storage, S storage) { return (s,s); }
-}
-// ----
-// Warning: (87-88): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (163-164): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (233-234): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (316-317): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (327-328): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_err.sol
new file mode 100644
index 00000000..9aa580a4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_err.sol
@@ -0,0 +1,16 @@
+contract C {
+ struct S { bool f; }
+ S s;
+ function f() internal view returns (S storage c) {
+ for(;; c = s) {
+ }
+ }
+ function g() internal view returns (S storage c) {
+ for(;;) {
+ c = s;
+ }
+ }
+}
+// ----
+// TypeError: (87-98): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (182-193): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_warn.sol
deleted file mode 100644
index ba9a2440..00000000
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_warn.sol
+++ /dev/null
@@ -1,16 +0,0 @@
-contract C {
- struct S { bool f; }
- S s;
- function f() internal view returns (S storage c) {
- for(;; c = s) {
- }
- }
- function g() internal view returns (S storage c) {
- for(;;) {
- c = s;
- }
- }
-}
-// ----
-// Warning: (87-98): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (182-193): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_err.sol
new file mode 100644
index 00000000..f3e55318
--- /dev/null
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_err.sol
@@ -0,0 +1,18 @@
+contract C {
+ struct S { bool f; }
+ S s;
+ function f(bool flag) internal view returns (S storage c) {
+ if (flag) c = s;
+ }
+ function g(bool flag) internal returns (S storage c) {
+ if (flag) c = s;
+ else
+ {
+ if (!flag) c = s;
+ else s.f = true;
+ }
+ }
+}
+// ----
+// TypeError: (96-107): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (186-197): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_warn.sol
deleted file mode 100644
index c257c252..00000000
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_warn.sol
+++ /dev/null
@@ -1,18 +0,0 @@
-contract C {
- struct S { bool f; }
- S s;
- function f(bool flag) internal view returns (S storage c) {
- if (flag) c = s;
- }
- function g(bool flag) internal returns (S storage c) {
- if (flag) c = s;
- else
- {
- if (!flag) c = s;
- else s.f = true;
- }
- }
-}
-// ----
-// Warning: (96-107): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (186-197): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_err.sol
new file mode 100644
index 00000000..a0047782
--- /dev/null
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_err.sol
@@ -0,0 +1,22 @@
+contract C {
+ modifier revertIfNoReturn() {
+ _;
+ revert();
+ }
+ modifier ifFlag(bool flag) {
+ if (flag)
+ _;
+ }
+ struct S { uint a; }
+ S s;
+ function f(bool flag) ifFlag(flag) internal view returns(S storage) {
+ return s;
+ }
+
+ function g(bool flag) ifFlag(flag) revertIfNoReturn() internal view returns(S storage) {
+ return s;
+ }
+}
+// ----
+// TypeError: (249-250): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (367-368): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_warn.sol
deleted file mode 100644
index 50c6dd99..00000000
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_warn.sol
+++ /dev/null
@@ -1,22 +0,0 @@
-contract C {
- modifier revertIfNoReturn() {
- _;
- revert();
- }
- modifier ifFlag(bool flag) {
- if (flag)
- _;
- }
- struct S { uint a; }
- S s;
- function f(bool flag) ifFlag(flag) internal view returns(S storage) {
- return s;
- }
-
- function g(bool flag) ifFlag(flag) revertIfNoReturn() internal view returns(S storage) {
- return s;
- }
-}
-// ----
-// Warning: (249-250): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (367-368): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_err.sol
new file mode 100644
index 00000000..d0ad8245
--- /dev/null
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_err.sol
@@ -0,0 +1,18 @@
+contract C {
+ struct S { bool f; }
+ S s;
+ function f() internal view returns (S storage c) {
+ false && (c = s).f;
+ }
+ function g() internal view returns (S storage c) {
+ true || (c = s).f;
+ }
+ function h() internal view returns (S storage c) {
+ // expect error, although this is always fine
+ true && (false || (c = s).f);
+ }
+}
+// ----
+// TypeError: (87-98): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (176-187): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (264-275): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_warn.sol
deleted file mode 100644
index 9f660f11..00000000
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_warn.sol
+++ /dev/null
@@ -1,18 +0,0 @@
-contract C {
- struct S { bool f; }
- S s;
- function f() internal view returns (S storage c) {
- false && (c = s).f;
- }
- function g() internal view returns (S storage c) {
- true || (c = s).f;
- }
- function h() internal view returns (S storage c) {
- // expect warning, although this is always fine
- true && (false || (c = s).f);
- }
-}
-// ----
-// Warning: (87-98): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (176-187): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (264-275): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_err.sol
new file mode 100644
index 00000000..6d10287b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_err.sol
@@ -0,0 +1,13 @@
+contract C {
+ struct S { bool f; }
+ S s;
+ function f(bool flag) internal view returns (S storage c) {
+ flag ? (c = s).f : false;
+ }
+ function g(bool flag) internal view returns (S storage c) {
+ flag ? false : (c = s).f;
+ }
+}
+// ----
+// TypeError: (96-107): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (200-211): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_warn.sol
deleted file mode 100644
index 57561fbb..00000000
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_warn.sol
+++ /dev/null
@@ -1,13 +0,0 @@
-contract C {
- struct S { bool f; }
- S s;
- function f(bool flag) internal view returns (S storage c) {
- flag ? (c = s).f : false;
- }
- function g(bool flag) internal view returns (S storage c) {
- flag ? false : (c = s).f;
- }
-}
-// ----
-// Warning: (96-107): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (200-211): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_err.sol
new file mode 100644
index 00000000..e7b4fae7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_err.sol
@@ -0,0 +1,11 @@
+contract C {
+ struct S { bool f; }
+ S s;
+ function f() internal view returns (S storage c) {
+ while(false) {
+ c = s;
+ }
+ }
+}
+// ----
+// TypeError: (87-98): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_warn.sol
deleted file mode 100644
index 26db892f..00000000
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_warn.sol
+++ /dev/null
@@ -1,11 +0,0 @@
-contract C {
- struct S { bool f; }
- S s;
- function f() internal view returns (S storage c) {
- while(false) {
- c = s;
- }
- }
-}
-// ----
-// Warning: (87-98): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
diff --git a/test/libsolidity/syntaxTests/emit_empty.sol b/test/libsolidity/syntaxTests/emit/emit_empty.sol
index 819d88fe..819d88fe 100644
--- a/test/libsolidity/syntaxTests/emit_empty.sol
+++ b/test/libsolidity/syntaxTests/emit/emit_empty.sol
diff --git a/test/libsolidity/syntaxTests/emit_non_event.sol b/test/libsolidity/syntaxTests/emit/emit_non_event.sol
index d5045ddf..d5045ddf 100644
--- a/test/libsolidity/syntaxTests/emit_non_event.sol
+++ b/test/libsolidity/syntaxTests/emit/emit_non_event.sol
diff --git a/test/libsolidity/syntaxTests/events/event_nested_array.sol b/test/libsolidity/syntaxTests/events/event_nested_array.sol
new file mode 100644
index 00000000..70af63b6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/events/event_nested_array.sol
@@ -0,0 +1,5 @@
+contract c {
+ event E(uint[][]);
+}
+// ----
+// TypeError: (25-33): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.
diff --git a/test/libsolidity/syntaxTests/events/event_nested_array_2.sol b/test/libsolidity/syntaxTests/events/event_nested_array_2.sol
new file mode 100644
index 00000000..5825650e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/events/event_nested_array_2.sol
@@ -0,0 +1,4 @@
+contract c {
+ event E(uint[2][]);
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/events/event_nested_array_in_struct.sol b/test/libsolidity/syntaxTests/events/event_nested_array_in_struct.sol
new file mode 100644
index 00000000..fd59e962
--- /dev/null
+++ b/test/libsolidity/syntaxTests/events/event_nested_array_in_struct.sol
@@ -0,0 +1,6 @@
+contract c {
+ struct S { uint x; uint[][] arr; }
+ event E(S);
+}
+// ----
+// TypeError: (61-62): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.
diff --git a/test/libsolidity/syntaxTests/events/event_struct.sol b/test/libsolidity/syntaxTests/events/event_struct.sol
new file mode 100644
index 00000000..c955dc5e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/events/event_struct.sol
@@ -0,0 +1,6 @@
+contract c {
+ struct S { uint a ; }
+ event E(S);
+}
+// ----
+// TypeError: (51-52): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.
diff --git a/test/libsolidity/syntaxTests/events/event_struct_indexed.sol b/test/libsolidity/syntaxTests/events/event_struct_indexed.sol
new file mode 100644
index 00000000..69ee5017
--- /dev/null
+++ b/test/libsolidity/syntaxTests/events/event_struct_indexed.sol
@@ -0,0 +1,6 @@
+contract c {
+ struct S { uint a ; }
+ event E(S indexed);
+}
+// ----
+// TypeError: (51-52): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.
diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol
deleted file mode 100644
index 8d5df5bf..00000000
--- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_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: (156-160): 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
deleted file mode 100644
index f9325f99..00000000
--- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_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: (110-114): Base constructor arguments given twice.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol b/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol
index cbea8991..ac1f541e 100644
--- a/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol
+++ b/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol
@@ -11,6 +11,6 @@ contract C {
}
// ----
// TypeError: (87-88): Expected 1 arguments but got 0.
-// Warning: (87-90): Top-level expressions are not supposed to return values (this expression returns -1 values). Use ``pop()`` or assign them.
+// SyntaxError: (87-90): Top-level expressions are not supposed to return values (this expression returns -1 values). Use ``pop()`` or assign them.
// TypeError: (108-109): Expected 1 arguments but got 2.
-// Warning: (108-115): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
+// SyntaxError: (108-115): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol b/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol
index 5de492e1..150fb938 100644
--- a/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol
+++ b/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol
@@ -8,6 +8,6 @@ contract C {
}
}
// ----
-// Warning: (63-64): The use of labels is deprecated. Please use "if", "switch", "for" or function calls instead.
-// Warning: (63-64): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
+// SyntaxError: (63-64): The use of labels is disallowed. Please use "if", "switch", "for" or function calls instead.
+// SyntaxError: (63-64): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
// TypeError: (73-74): Attempt to call label instead of function.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_offset.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_offset.sol
new file mode 100644
index 00000000..ec23a263
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_offset.sol
@@ -0,0 +1,9 @@
+contract C {
+ function f() public pure {
+ assembly {
+ _offset
+ }
+ }
+}
+// ----
+// DeclarationError: (75-82): In variable names _slot and _offset can only be used as a suffix.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_slot.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_slot.sol
new file mode 100644
index 00000000..d493a68a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_slot.sol
@@ -0,0 +1,9 @@
+contract C {
+ function f() public pure {
+ assembly {
+ _slot
+ }
+ }
+}
+// ----
+// DeclarationError: (75-80): In variable names _slot and _offset can only be used as a suffix.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol
new file mode 100644
index 00000000..9165654f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol
@@ -0,0 +1,9 @@
+contract C {
+ function f() pure public {
+ assembly {
+ let x := f_slot
+ }
+ }
+}
+// ----
+// TypeError: (84-90): The suffixes _offset and _slot can only be used on storage variables.
diff --git a/test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_050.sol b/test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_050.sol
deleted file mode 100644
index af1babbc..00000000
--- a/test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_050.sol
+++ /dev/null
@@ -1,10 +0,0 @@
-pragma experimental "v0.5.0";
-contract C
-{
- modifier only_owner() { _; }
- function foo() only_owner public;
- function bar() public only_owner;
-}
-// ----
-// SyntaxError: (80-113): Functions without implementation cannot have modifiers.
-// SyntaxError: (118-151): Functions without implementation cannot have modifiers.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol
deleted file mode 100644
index 27b1ea96..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol
+++ /dev/null
@@ -1,12 +0,0 @@
-contract test {
- struct str {
- mapping(uint=>uint) map;
- }
- str data;
- function fun() public {
- mapping(uint=>uint) storage a = data.map;
- data.map = a;
- }
-}
-// ----
-// TypeError: (172-184): Mappings cannot be assigned to.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/166_assigning_state_to_const_variable_050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/166_assigning_state_to_const_variable_050.sol
deleted file mode 100644
index dc0a6e63..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/166_assigning_state_to_const_variable_050.sol
+++ /dev/null
@@ -1,7 +0,0 @@
-pragma experimental "v0.5.0";
-
-contract C {
- address constant x = msg.sender;
-}
-// ----
-// TypeError: (69-79): Initial value for constant variable has to be compile-time constant.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/352_callcode_deprecated_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/352_callcode_deprecated_v050.sol
deleted file mode 100644
index c0e29b38..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/352_callcode_deprecated_v050.sol
+++ /dev/null
@@ -1,8 +0,0 @@
-pragma experimental "v0.5.0";
-contract test {
- function f() pure public {
- address(0x12).callcode;
- }
-}
-// ----
-// TypeError: (85-107): "callcode" has been deprecated in favour of "delegatecall".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol
index 273e1844..e9599f4b 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol
@@ -6,5 +6,5 @@ contract test {
}
}
// ----
-// Warning: (73-74): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
+// SyntaxError: (73-74): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
// DeclarationError: (59-84): Unbalanced stack at the end of a block: 1 surplus item(s).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol
index bda090b4..342afc46 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol
@@ -6,5 +6,5 @@ contract test {
}
}
// ----
-// Warning: (73-76): The use of non-functional instructions is deprecated. Please use functional notation instead.
+// SyntaxError: (73-76): The use of non-functional instructions is disallowed. Please use functional notation instead.
// DeclarationError: (59-86): Unbalanced stack at the end of a block: 1 missing item(s).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/375_inline_assembly_unbalanced_two_stack_load.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/375_inline_assembly_unbalanced_two_stack_load.sol
index 4cda64e7..ca1e15a9 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/375_inline_assembly_unbalanced_two_stack_load.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/375_inline_assembly_unbalanced_two_stack_load.sol
@@ -1,4 +1,3 @@
-pragma experimental "v0.5.0";
contract c {
uint8 x;
function f() public {
@@ -6,4 +5,4 @@ contract c {
}
}
// ----
-// TypeError: (105-106): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes.
+// TypeError: (75-76): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/376_inline_assembly_in_modifier.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/376_inline_assembly_in_modifier.sol
index d6dcc4d0..0032f99e 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/376_inline_assembly_in_modifier.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/376_inline_assembly_in_modifier.sol
@@ -1,4 +1,3 @@
-pragma experimental "v0.5.0";
contract test {
modifier m {
uint a = 1;
@@ -11,4 +10,4 @@ contract test {
}
}
// ----
-// Warning: (152-181): Function state mutability can be restricted to pure
+// Warning: (122-151): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/377_inline_assembly_storage.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/377_inline_assembly_storage.sol
index 9a2065e2..3dfb458a 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/377_inline_assembly_storage.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/377_inline_assembly_storage.sol
@@ -1,4 +1,3 @@
-pragma experimental "v0.5.0";
contract test {
uint x = 1;
function f() public {
@@ -8,4 +7,4 @@ contract test {
}
}
// ----
-// TypeError: (119-120): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes.
+// TypeError: (89-90): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/378_inline_assembly_storage_in_modifiers.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/378_inline_assembly_storage_in_modifiers.sol
index b99179ef..b9b92d47 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/378_inline_assembly_storage_in_modifiers.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/378_inline_assembly_storage_in_modifiers.sol
@@ -1,4 +1,3 @@
-pragma experimental "v0.5.0";
contract test {
uint x = 1;
modifier m {
@@ -11,4 +10,4 @@ contract test {
}
}
// ----
-// TypeError: (110-111): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes.
+// TypeError: (80-81): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/379_inline_assembly_constant_assign.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/379_inline_assembly_constant_assign.sol
index 866232dd..c8928804 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/379_inline_assembly_constant_assign.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/379_inline_assembly_constant_assign.sol
@@ -1,4 +1,3 @@
-pragma experimental "v0.5.0";
contract test {
uint constant x = 1;
function f() public {
@@ -8,4 +7,4 @@ contract test {
}
}
// ----
-// TypeError: (128-129): Constant variables not supported by inline assembly.
+// TypeError: (98-99): Constant variables not supported by inline assembly.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/380_inline_assembly_constant_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/380_inline_assembly_constant_access.sol
index a41858a0..03ff9166 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/380_inline_assembly_constant_access.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/380_inline_assembly_constant_access.sol
@@ -1,4 +1,3 @@
-pragma experimental "v0.5.0";
contract test {
uint constant x = 1;
function f() public {
@@ -8,4 +7,4 @@ contract test {
}
}
// ----
-// TypeError: (137-138): Constant variables not supported by inline assembly.
+// TypeError: (107-108): Constant variables not supported by inline assembly.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/381_inline_assembly_local_variable_access_out_of_functions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/381_inline_assembly_local_variable_access_out_of_functions.sol
index 93004ef6..877f5783 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/381_inline_assembly_local_variable_access_out_of_functions.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/381_inline_assembly_local_variable_access_out_of_functions.sol
@@ -1,4 +1,3 @@
-pragma experimental "v0.5.0";
contract test {
function f() public {
uint a;
@@ -8,4 +7,4 @@ contract test {
}
}
// ----
-// DeclarationError: (144-145): Cannot access local Solidity variables from inside an inline assembly function.
+// DeclarationError: (114-115): Cannot access local Solidity variables from inside an inline assembly function.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/382_inline_assembly_local_variable_access_out_of_functions_storage_ptr.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/382_inline_assembly_local_variable_access_out_of_functions_storage_ptr.sol
index 913ea725..65d614a3 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/382_inline_assembly_local_variable_access_out_of_functions_storage_ptr.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/382_inline_assembly_local_variable_access_out_of_functions_storage_ptr.sol
@@ -1,4 +1,3 @@
-pragma experimental "v0.5.0";
contract test {
uint[] r;
function f() public {
@@ -9,4 +8,4 @@ contract test {
}
}
// ----
-// DeclarationError: (172-180): Cannot access local Solidity variables from inside an inline assembly function.
+// DeclarationError: (142-150): Cannot access local Solidity variables from inside an inline assembly function.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/383_inline_assembly_storage_variable_access_out_of_functions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/383_inline_assembly_storage_variable_access_out_of_functions.sol
index 7528f355..abe9067a 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/383_inline_assembly_storage_variable_access_out_of_functions.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/383_inline_assembly_storage_variable_access_out_of_functions.sol
@@ -1,4 +1,3 @@
-pragma experimental "v0.5.0";
contract test {
uint a;
function f() pure public {
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/385_inline_assembly_calldata_variables.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/385_inline_assembly_calldata_variables.sol
index d95fd978..9e324ce1 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/385_inline_assembly_calldata_variables.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/385_inline_assembly_calldata_variables.sol
@@ -1,4 +1,3 @@
-pragma experimental "v0.5.0";
contract C {
function f(bytes bytesAsCalldata) external {
assembly {
@@ -7,4 +6,4 @@ contract C {
}
}
// ----
-// TypeError: (132-147): Call data elements cannot be accessed directly. Copy to a local variable first or use "calldataload" or "calldatacopy" with manually determined offsets and sizes.
+// TypeError: (102-117): Call data elements cannot be accessed directly. Copy to a local variable first or use "calldataload" or "calldatacopy" with manually determined offsets and sizes.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol
deleted file mode 100644
index a5f0f96c..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol
+++ /dev/null
@@ -1,11 +0,0 @@
-pragma experimental "v0.5.0";
-contract C {
- function f() pure public {
- assembly {
- 1
- }
- }
-}
-// ----
-// SyntaxError: (105-106): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
-// DeclarationError: (91-116): Unbalanced stack at the end of a block: 1 surplus item(s).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol
index 7b68c60b..62fe7171 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol
@@ -6,5 +6,5 @@ contract C {
}
}
// ----
-// Warning: (75-76): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
+// SyntaxError: (75-76): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
// DeclarationError: (61-86): Unbalanced stack at the end of a block: 1 surplus item(s).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol
deleted file mode 100644
index 4a7aca8a..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol
+++ /dev/null
@@ -1,12 +0,0 @@
-pragma experimental "v0.5.0";
-contract C {
- function f() view public {
- assembly {
- address
- pop
- }
- }
-}
-// ----
-// SyntaxError: (105-112): The use of non-functional instructions is deprecated. Please use functional notation instead.
-// SyntaxError: (125-128): The use of non-functional instructions is deprecated. Please use functional notation instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol
index c44412cf..7315d5d1 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol
@@ -7,5 +7,5 @@ contract C {
}
}
// ----
-// Warning: (75-82): The use of non-functional instructions is deprecated. Please use functional notation instead.
-// Warning: (95-98): The use of non-functional instructions is deprecated. Please use functional notation instead.
+// SyntaxError: (75-82): The use of non-functional instructions is disallowed. Please use functional notation instead.
+// SyntaxError: (95-98): The use of non-functional instructions is disallowed. Please use functional notation instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol
deleted file mode 100644
index 77a73ebc..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol
+++ /dev/null
@@ -1,11 +0,0 @@
-pragma experimental "v0.5.0";
-contract C {
- function f() pure public {
- assembly {
- label:
- }
- }
-}
-// ----
-// SyntaxError: (105-110): The use of labels is deprecated. Please use "if", "switch", "for" or function calls instead.
-// SyntaxError: (105-110): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol
index 15bd6660..0d7bacb4 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol
@@ -6,5 +6,5 @@ contract C {
}
}
// ----
-// Warning: (75-80): The use of labels is deprecated. Please use "if", "switch", "for" or function calls instead.
-// Warning: (75-80): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
+// SyntaxError: (75-80): The use of labels is disallowed. Please use "if", "switch", "for" or function calls instead.
+// SyntaxError: (75-80): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/392_inline_assembly_050_jump.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/392_inline_assembly_050_jump.sol
deleted file mode 100644
index 0c98ada1..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/392_inline_assembly_050_jump.sol
+++ /dev/null
@@ -1,10 +0,0 @@
-pragma experimental "v0.5.0";
-contract C {
- function f() pure public {
- assembly {
- jump(2)
- }
- }
-}
-// ----
-// SyntaxError: (105-112): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol
index c3c82ce8..6cb35d6d 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol
@@ -6,5 +6,4 @@ contract C {
}
}
// ----
-// Warning: (75-82): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
-// TypeError: (75-82): Function declared as pure, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
+// SyntaxError: (75-82): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/394_inline_assembly_050_leave_items_on_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/394_inline_assembly_050_leave_items_on_stack.sol
deleted file mode 100644
index f72fe741..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/394_inline_assembly_050_leave_items_on_stack.sol
+++ /dev/null
@@ -1,11 +0,0 @@
-pragma experimental "v0.5.0";
-contract C {
- function f() pure public {
- assembly {
- mload(0)
- }
- }
-}
-// ----
-// SyntaxError: (105-113): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
-// DeclarationError: (91-123): Unbalanced stack at the end of a block: 1 surplus item(s).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol
index 56043ccf..8538a2a0 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol
@@ -6,5 +6,5 @@ contract C {
}
}
// ----
-// Warning: (75-83): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
+// SyntaxError: (75-83): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
// DeclarationError: (61-93): Unbalanced stack at the end of a block: 1 surplus item(s).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/422_interface_enums.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/422_interface_enums.sol
index 5513817d..1533e7ff 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/422_interface_enums.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/422_interface_enums.sol
@@ -2,4 +2,3 @@ interface I {
enum A { B, C }
}
// ----
-// TypeError: (18-33): Enumerable cannot be declared in interfaces.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/564_events_without_emit_deprecated_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/564_events_without_emit_deprecated_v050.sol
deleted file mode 100644
index e148d65a..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/564_events_without_emit_deprecated_v050.sol
+++ /dev/null
@@ -1,9 +0,0 @@
-pragma experimental "v0.5.0";
-contract C {
- event e();
- function f() public {
- e();
- }
-}
-// ----
-// TypeError: (92-95): Event invocations have to be prefixed by "emit".
diff --git a/test/libsolidity/syntaxTests/parsing/enum_from_interface.sol b/test/libsolidity/syntaxTests/parsing/enum_from_interface.sol
new file mode 100644
index 00000000..0fe0fbae
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/enum_from_interface.sol
@@ -0,0 +1,9 @@
+interface I {
+ enum Direction { Left, Right }
+}
+
+contract D {
+ function f() public pure returns (I.Direction) {
+ return I.Direction.Left;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/enum_from_interface_in_library.sol b/test/libsolidity/syntaxTests/parsing/enum_from_interface_in_library.sol
new file mode 100644
index 00000000..8d9003eb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/enum_from_interface_in_library.sol
@@ -0,0 +1,12 @@
+interface I {
+ enum Direction { Left, Right }
+}
+
+library L {
+ function f() public pure returns (I.Direction) {
+ return I.Direction.Left;
+ }
+ function g() internal pure returns (I.Direction) {
+ return I.Direction.Left;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/enum_from_library.sol b/test/libsolidity/syntaxTests/parsing/enum_from_library.sol
new file mode 100644
index 00000000..ab762a82
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/enum_from_library.sol
@@ -0,0 +1,9 @@
+library L {
+ enum Direction { Left, Right }
+}
+
+contract D {
+ function f() public pure returns (L.Direction) {
+ return L.Direction.Left;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/enum_inheritance_contract.sol b/test/libsolidity/syntaxTests/parsing/enum_inheritance_contract.sol
new file mode 100644
index 00000000..e5b98352
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/enum_inheritance_contract.sol
@@ -0,0 +1,9 @@
+contract C {
+ enum Direction { Left, Right }
+}
+
+contract D is C {
+ function f() public pure returns (Direction) {
+ return Direction.Left;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/enum_inheritance_interface.sol b/test/libsolidity/syntaxTests/parsing/enum_inheritance_interface.sol
new file mode 100644
index 00000000..75858744
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/enum_inheritance_interface.sol
@@ -0,0 +1,9 @@
+interface I {
+ enum Direction { Left, Right }
+}
+
+contract D is I {
+ function f() public pure returns (Direction) {
+ return Direction.Left;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/double_storage_crash.sol b/test/libsolidity/syntaxTests/tupleAssignments/double_storage_crash.sol
new file mode 100644
index 00000000..3cff3a9a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/tupleAssignments/double_storage_crash.sol
@@ -0,0 +1,11 @@
+// This used to crash in certain compiler versions.
+contract CrashContract {
+ struct S { uint a; }
+ S x;
+ function f() public {
+ (x, x) = 1(x, x);
+ }
+}
+// ----
+// TypeError: (170-177): Type is not callable
+// TypeError: (170-177): Type tuple() is not implicitly convertible to expected type tuple(struct CrashContract.S storage ref,struct CrashContract.S storage ref).
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/err_multiple_storage_storage_copies_fill_left.sol b/test/libsolidity/syntaxTests/tupleAssignments/err_multiple_storage_storage_copies_fill_left.sol
deleted file mode 100644
index 902d8b98..00000000
--- a/test/libsolidity/syntaxTests/tupleAssignments/err_multiple_storage_storage_copies_fill_left.sol
+++ /dev/null
@@ -1,10 +0,0 @@
-contract C {
- struct S { uint a; uint b; }
- S x; S y;
- function f() public {
- (,x, y) = (1, 2, y, x);
- }
-}
-// ----
-// TypeError: (89-101): Type tuple(int_const 1,int_const 2,struct C.S storage ref,struct C.S storage ref) is not implicitly convertible to expected type tuple(,struct C.S storage ref,struct C.S storage ref).
-// 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.
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/err_multiple_storage_storage_copies_fill_right.sol b/test/libsolidity/syntaxTests/tupleAssignments/err_multiple_storage_storage_copies_fill_right.sol
deleted file mode 100644
index 51556aab..00000000
--- a/test/libsolidity/syntaxTests/tupleAssignments/err_multiple_storage_storage_copies_fill_right.sol
+++ /dev/null
@@ -1,10 +0,0 @@
-contract C {
- struct S { uint a; uint b; }
- S x; S y;
- function f() public {
- (x, y, ) = (y, x, 1, 2);
- }
-}
-// ----
-// TypeError: (90-102): Type tuple(struct C.S storage ref,struct C.S storage ref,int_const 1,int_const 2) is not implicitly convertible to expected type tuple(struct C.S storage ref,struct C.S storage ref,).
-// 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.
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/error_fill.sol b/test/libsolidity/syntaxTests/tupleAssignments/error_fill.sol
index ae722391..32b381bb 100644
--- a/test/libsolidity/syntaxTests/tupleAssignments/error_fill.sol
+++ b/test/libsolidity/syntaxTests/tupleAssignments/error_fill.sol
@@ -1,4 +1,3 @@
-pragma experimental "v0.5.0";
contract C {
function f() public pure returns (uint, uint, bytes32) {
uint a;
@@ -8,5 +7,5 @@ contract C {
}
}
// ----
-// TypeError: (133-136): Type tuple(uint256,uint256,bytes32) is not implicitly convertible to expected type tuple(uint256,).
-// TypeError: (147-150): Type tuple(uint256,uint256,bytes32) is not implicitly convertible to expected type tuple(,bytes32).
+// TypeError: (103-106): Type tuple(uint256,uint256,bytes32) is not implicitly convertible to expected type tuple(uint256,).
+// TypeError: (117-120): Type tuple(uint256,uint256,bytes32) is not implicitly convertible to expected type tuple(,bytes32).
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/large_component_count.sol b/test/libsolidity/syntaxTests/tupleAssignments/large_component_count.sol
index bbf21d7e..f14641cb 100644
--- a/test/libsolidity/syntaxTests/tupleAssignments/large_component_count.sol
+++ b/test/libsolidity/syntaxTests/tupleAssignments/large_component_count.sol
@@ -1,4 +1,3 @@
-pragma experimental "v0.5.0";
contract C {
function g() public pure returns (
uint,
diff --git a/test/libsolidity/syntaxTests/types/mapping/assignment_local.sol b/test/libsolidity/syntaxTests/types/mapping/assignment_local.sol
new file mode 100644
index 00000000..a329c91e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/assignment_local.sol
@@ -0,0 +1,11 @@
+contract test {
+ mapping(uint=>uint) map;
+ function fun() public view {
+ mapping(uint=>uint) storage a = map;
+ mapping(uint=>uint) storage b = map;
+ b = a;
+ (b) = a;
+ (b, b) = (a, a);
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/types/mapping/assignment_state_variable.sol b/test/libsolidity/syntaxTests/types/mapping/assignment_state_variable.sol
new file mode 100644
index 00000000..1323afe6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/assignment_state_variable.sol
@@ -0,0 +1,14 @@
+contract test {
+ mapping(uint=>uint) map;
+ function fun() public {
+ mapping(uint=>uint) storage a = map;
+ map = a;
+ (map) = a;
+ (map, map) = (a, a);
+ }
+}
+// ----
+// TypeError: (126-129): Mappings cannot be assigned to.
+// TypeError: (144-147): Mappings cannot be assigned to.
+// TypeError: (163-166): Mappings cannot be assigned to.
+// TypeError: (168-171): Mappings cannot be assigned to.
diff --git a/test/libsolidity/syntaxTests/types/mapping/assignment_struct.sol b/test/libsolidity/syntaxTests/types/mapping/assignment_struct.sol
new file mode 100644
index 00000000..b89241ed
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/assignment_struct.sol
@@ -0,0 +1,17 @@
+contract test {
+ struct str {
+ mapping(uint=>uint) map;
+ }
+ str data;
+ function fun() public {
+ mapping(uint=>uint) storage a = data.map;
+ data.map = a;
+ (data.map) = a;
+ (data.map, data.map) = (a, a);
+ }
+}
+// ----
+// TypeError: (172-180): Mappings cannot be assigned to.
+// TypeError: (195-203): Mappings cannot be assigned to.
+// TypeError: (219-227): Mappings cannot be assigned to.
+// TypeError: (229-237): Mappings cannot be assigned to.
diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_return_external.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_return_external.sol
new file mode 100644
index 00000000..85121241
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/mapping_return_external.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() external pure returns (mapping(uint=>uint) storage m) {
+ }
+}
+// ----
+// TypeError: (53-82): Type is required to live outside storage.
+// TypeError: (53-82): Internal or recursive type is not allowed for public or external functions.
diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_return_internal.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_return_internal.sol
new file mode 100644
index 00000000..a46003f8
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/mapping_return_internal.sol
@@ -0,0 +1,21 @@
+// This should be allowed in a future release.
+contract C {
+ mapping(uint=>uint) m;
+ function f() internal view returns (mapping(uint=>uint) storage) {
+ return m;
+ }
+ function g() private view returns (mapping(uint=>uint) storage) {
+ return m;
+ }
+ function h() internal view returns (mapping(uint=>uint) storage r) {
+ r = m;
+ }
+ function i() private view returns (mapping(uint=>uint) storage r) {
+ (r,r) = (m,m);
+ }
+}
+// ----
+// TypeError: (127-146): Type is required to live outside storage.
+// TypeError: (221-240): Type is required to live outside storage.
+// TypeError: (316-345): Type is required to live outside storage.
+// TypeError: (409-438): Type is required to live outside storage.
diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_return_public.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_return_public.sol
new file mode 100644
index 00000000..383fa797
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/mapping_return_public.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public pure returns (mapping(uint=>uint) storage m) {
+ }
+}
+// ----
+// TypeError: (51-80): Type is required to live outside storage.
+// TypeError: (51-80): Internal or recursive type is not allowed for public or external functions.
diff --git a/test/libsolidity/syntaxTests/types/var_type_suggest.sol b/test/libsolidity/syntaxTests/types/var_type_suggest.sol
index 176fab96..cc35fdd6 100644
--- a/test/libsolidity/syntaxTests/types/var_type_suggest.sol
+++ b/test/libsolidity/syntaxTests/types/var_type_suggest.sol
@@ -12,6 +12,10 @@ contract C {
var myblockhash = block.blockhash;
var (a, b) = (2, "troi");
var (x,, z) = h();
+ var (c, d) = ("");
+ var (k, l) = (2);
+ var (m, n) = 1;
+ var (o, p) = "";
}
}
// ----
@@ -21,3 +25,11 @@ contract C {
// SyntaxError: (293-326): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax.
// SyntaxError: (336-360): Use of the "var" keyword is disallowed. Use explicit declaration `(uint8 a, string memory b) = ...´ instead.
// SyntaxError: (370-387): Use of the "var" keyword is disallowed. Use explicit declaration `(uint256 x, , uint256 z) = ...´ instead.
+// TypeError: (397-414): Different number of components on the left hand side (2) than on the right hand side (1).
+// SyntaxError: (397-414): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax.
+// TypeError: (424-440): Different number of components on the left hand side (2) than on the right hand side (1).
+// SyntaxError: (424-440): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax.
+// TypeError: (450-464): Different number of components on the left hand side (2) than on the right hand side (1).
+// SyntaxError: (450-464): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax.
+// TypeError: (474-489): Different number of components on the left hand side (2) than on the right hand side (1).
+// SyntaxError: (474-489): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax.
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol
deleted file mode 100644
index 418be561..00000000
--- a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol
+++ /dev/null
@@ -1,7 +0,0 @@
-contract C {
- function k() public {
- assembly { jump(2) }
- }
-}
-// ----
-// Warning: (58-65): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol
deleted file mode 100644
index c1729db7..00000000
--- a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol
+++ /dev/null
@@ -1,8 +0,0 @@
-contract C {
- function k() public view {
- assembly { jump(2) }
- }
-}
-// ----
-// Warning: (63-70): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
-// TypeError: (63-70): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_external050.sol b/test/libsolidity/syntaxTests/visibility/interface/function_external.sol
index 3f0a9aca..ed409e58 100644
--- a/test/libsolidity/syntaxTests/visibility/interface/function_external050.sol
+++ b/test/libsolidity/syntaxTests/visibility/interface/function_external.sol
@@ -1,4 +1,3 @@
-pragma experimental "v0.5.0";
interface I {
function f() external;
}
diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_public050.sol b/test/libsolidity/syntaxTests/visibility/interface/function_public050.sol
deleted file mode 100644
index e0c04095..00000000
--- a/test/libsolidity/syntaxTests/visibility/interface/function_public050.sol
+++ /dev/null
@@ -1,6 +0,0 @@
-pragma experimental "v0.5.0";
-interface I {
- function f() public;
-}
-// ----
-// TypeError: (45-65): Functions in interfaces must be declared external.
diff --git a/test/tools/CMakeLists.txt b/test/tools/CMakeLists.txt
index 257b4f24..d6df0ac8 100644
--- a/test/tools/CMakeLists.txt
+++ b/test/tools/CMakeLists.txt
@@ -3,5 +3,5 @@ target_link_libraries(solfuzzer PRIVATE libsolc evmasm ${Boost_PROGRAM_OPTIONS_L
add_executable(isoltest isoltest.cpp ../Options.cpp ../libsolidity/TestCase.cpp ../libsolidity/SyntaxTest.cpp
../libsolidity/AnalysisFramework.cpp ../libsolidity/SolidityExecutionFramework.cpp ../ExecutionFramework.cpp
- ../RPCSession.cpp)
+ ../RPCSession.cpp ../libsolidity/ASTJSONTest.cpp)
target_link_libraries(isoltest PRIVATE libsolc solidity evmasm ${Boost_PROGRAM_OPTIONS_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
diff --git a/test/tools/isoltest.cpp b/test/tools/isoltest.cpp
index bd4b0db9..ad6b456d 100644
--- a/test/tools/isoltest.cpp
+++ b/test/tools/isoltest.cpp
@@ -18,6 +18,7 @@
#include <libdevcore/CommonIO.h>
#include <test/libsolidity/AnalysisFramework.h>
#include <test/libsolidity/SyntaxTest.h>
+#include <test/libsolidity/ASTJSONTest.h>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/replace.hpp>
@@ -44,8 +45,8 @@ namespace fs = boost::filesystem;
struct TestStats
{
int successCount;
- int runCount;
- operator bool() const { return successCount == runCount; }
+ int testCount;
+ operator bool() const { return successCount == testCount; }
};
class TestTool
@@ -87,13 +88,15 @@ private:
Request handleResponse(bool const _exception);
TestCase::TestCaseCreator m_testCaseCreator;
- bool const m_formatted;
+ bool const m_formatted = false;
string const m_name;
fs::path const m_path;
unique_ptr<TestCase> m_test;
+ static bool m_exitRequested;
};
string TestTool::editor;
+bool TestTool::m_exitRequested = false;
TestTool::Result TestTool::process()
{
@@ -194,7 +197,7 @@ TestStats TestTool::processPath(
std::queue<fs::path> paths;
paths.push(_path);
int successCount = 0;
- int runCount = 0;
+ int testCount = 0;
while (!paths.empty())
{
@@ -211,10 +214,15 @@ TestStats TestTool::processPath(
if (fs::is_directory(entry.path()) || TestCase::isTestFilename(entry.path().filename()))
paths.push(currentPath / entry.path().filename());
}
+ else if (m_exitRequested)
+ {
+ ++testCount;
+ paths.pop();
+ }
else
{
+ ++testCount;
TestTool testTool(_testCaseCreator, currentPath.string(), fullpath, _formatted);
- ++runCount;
auto result = testTool.process();
switch(result)
@@ -224,10 +232,12 @@ TestStats TestTool::processPath(
switch(testTool.handleResponse(result == Result::Exception))
{
case Request::Quit:
- return { successCount, runCount };
+ paths.pop();
+ m_exitRequested = true;
+ break;
case Request::Rerun:
cout << "Re-running test case..." << endl;
- --runCount;
+ --testCount;
break;
case Request::Skip:
paths.pop();
@@ -242,7 +252,7 @@ TestStats TestTool::processPath(
}
}
- return { successCount, runCount };
+ return { successCount, testCount };
}
@@ -336,22 +346,53 @@ Allowed options)",
}
}
+ TestStats global_stats { 0, 0 };
+
fs::path syntaxTestPath = testPath / "libsolidity" / "syntaxTests";
if (fs::exists(syntaxTestPath) && fs::is_directory(syntaxTestPath))
{
auto stats = TestTool::processPath(SyntaxTest::create, testPath / "libsolidity", "syntaxTests", formatted);
- cout << endl << "Summary: ";
+ cout << endl << "Syntax Test Summary: ";
FormattedScope(cout, formatted, {BOLD, stats ? GREEN : RED}) <<
- stats.successCount << "/" << stats.runCount;
- cout << " tests successful." << endl;
+ stats.successCount << "/" << stats.testCount;
+ cout << " tests successful." << endl << endl;
- return stats ? 0 : 1;
+ global_stats.testCount += stats.testCount;
+ global_stats.successCount += stats.successCount;
}
else
{
cerr << "Syntax tests not found. Use the --testpath argument." << endl;
return 1;
}
+
+ fs::path astJsonTestPath = testPath / "libsolidity" / "ASTJSON";
+
+ if (fs::exists(astJsonTestPath) && fs::is_directory(astJsonTestPath))
+ {
+ auto stats = TestTool::processPath(ASTJSONTest::create, testPath / "libsolidity", "ASTJSON", formatted);
+
+ cout << endl << "JSON AST Test Summary: ";
+ FormattedScope(cout, formatted, {BOLD, stats ? GREEN : RED}) <<
+ stats.successCount << "/" << stats.testCount;
+ cout << " tests successful." << endl << endl;
+
+ global_stats.testCount += stats.testCount;
+ global_stats.successCount += stats.successCount;
+ }
+ else
+ {
+ cerr << "JSON AST tests not found." << endl;
+ return 1;
+ }
+
+ cout << endl << "Summary: ";
+ FormattedScope(cout, formatted, {BOLD, global_stats ? GREEN : RED}) <<
+ global_stats.successCount << "/" << global_stats.testCount;
+ cout << " tests successful." << endl;
+
+
+ return global_stats ? 0 : 1;
}