diff options
Diffstat (limited to 'test/libsolidity')
144 files changed, 2308 insertions, 957 deletions
diff --git a/test/libsolidity/AnalysisFramework.cpp b/test/libsolidity/AnalysisFramework.cpp index 4538757d..72b86767 100644 --- a/test/libsolidity/AnalysisFramework.cpp +++ b/test/libsolidity/AnalysisFramework.cpp @@ -56,12 +56,23 @@ AnalysisFramework::parseAnalyseAndReturnError( m_compiler.analyze(); + ErrorList errors = filterErrors(m_compiler.errors(), _reportWarnings); + if (errors.size() > 1 && !_allowMultipleErrors) + BOOST_FAIL("Multiple errors found: " + formatErrors()); + + return make_pair(&m_compiler.ast(""), std::move(errors)); +} + +ErrorList AnalysisFramework::filterErrors(ErrorList const& _errorList, bool _includeWarnings) const +{ ErrorList errors; - for (auto const& currentError: m_compiler.errors()) + for (auto const& currentError: _errorList) { solAssert(currentError->comment(), ""); if (currentError->type() == Error::Type::Warning) { + if (!_includeWarnings) + continue; bool ignoreWarning = false; for (auto const& filter: m_warningsToFilter) if (currentError->comment()->find(filter) == 0) @@ -73,17 +84,10 @@ AnalysisFramework::parseAnalyseAndReturnError( continue; } - if (_reportWarnings || (currentError->type() != Error::Type::Warning)) - { - if (!_allowMultipleErrors && !errors.empty()) - { - BOOST_FAIL("Multiple errors found: " + formatErrors()); - } - errors.emplace_back(std::move(currentError)); - } + errors.emplace_back(currentError); } - return make_pair(&m_compiler.ast(""), errors); + return errors; } SourceUnit const* AnalysisFramework::parseAndAnalyse(string const& _source) @@ -110,7 +114,7 @@ ErrorList AnalysisFramework::expectError(std::string const& _source, bool _warni return sourceAndErrors.second; } -string AnalysisFramework::formatErrors() +string AnalysisFramework::formatErrors() const { string message; for (auto const& error: m_compiler.errors()) @@ -118,7 +122,7 @@ string AnalysisFramework::formatErrors() return message; } -string AnalysisFramework::formatError(Error const& _error) +string AnalysisFramework::formatError(Error const& _error) const { return SourceReferenceFormatter::formatExceptionInformation( _error, diff --git a/test/libsolidity/AnalysisFramework.h b/test/libsolidity/AnalysisFramework.h index 6ecf4a5a..05490a42 100644 --- a/test/libsolidity/AnalysisFramework.h +++ b/test/libsolidity/AnalysisFramework.h @@ -57,8 +57,8 @@ protected: bool success(std::string const& _source); ErrorList expectError(std::string const& _source, bool _warning = false, bool _allowMultiple = false); - std::string formatErrors(); - std::string formatError(Error const& _error); + std::string formatErrors() const; + std::string formatError(Error const& _error) const; static ContractDefinition const* retrieveContractByName(SourceUnit const& _source, std::string const& _name); static FunctionTypePointer retrieveFunctionBySignature( @@ -66,6 +66,9 @@ protected: std::string const& _signature ); + // filter out the warnings in m_warningsToFilter or all warnings if _includeWarnings is false + ErrorList filterErrors(ErrorList const& _errorList, bool _includeWarnings) const; + std::vector<std::string> m_warningsToFilter = {"This is a pre-release compiler version"}; dev::solidity::CompilerStack m_compiler; }; diff --git a/test/libsolidity/FormattedScope.h b/test/libsolidity/FormattedScope.h index 78560848..923404f0 100644 --- a/test/libsolidity/FormattedScope.h +++ b/test/libsolidity/FormattedScope.h @@ -38,6 +38,8 @@ static constexpr char const* GREEN = "\033[1;32m"; static constexpr char const* YELLOW = "\033[1;33m"; static constexpr char const* CYAN = "\033[1;36m"; static constexpr char const* BOLD = "\033[1m"; +static constexpr char const* RED_BACKGROUND = "\033[48;5;160m"; +static constexpr char const* ORANGE_BACKGROUND = "\033[48;5;166m"; static constexpr char const* INVERSE = "\033[7m"; } diff --git a/test/libsolidity/GasMeter.cpp b/test/libsolidity/GasMeter.cpp index fd2017f9..0d66456c 100644 --- a/test/libsolidity/GasMeter.cpp +++ b/test/libsolidity/GasMeter.cpp @@ -294,6 +294,19 @@ BOOST_AUTO_TEST_CASE(extcodesize_gas) testRunTimeGas("f()", vector<bytes>{encodeArgs()}); } +BOOST_AUTO_TEST_CASE(regular_functions_exclude_fallback) +{ + // A bug in the estimator caused the costs for a specific function + // to always include the costs for the fallback. + char const* sourceCode = R"( + contract A { + uint public x; + function() { x = 2; } + } + )"; + testCreationTimeGas(sourceCode); + testRunTimeGas("x()", vector<bytes>{encodeArgs()}); +} BOOST_AUTO_TEST_SUITE_END() } diff --git a/test/libsolidity/InlineAssembly.cpp b/test/libsolidity/InlineAssembly.cpp index 34ca33e3..0ced1792 100644 --- a/test/libsolidity/InlineAssembly.cpp +++ b/test/libsolidity/InlineAssembly.cpp @@ -783,6 +783,8 @@ BOOST_AUTO_TEST_CASE(shift) BOOST_AUTO_TEST_CASE(shift_constantinople_warning) { + if (dev::test::Options::get().evmVersion().hasBitwiseShifting()) + return; CHECK_PARSE_WARNING("{ pop(shl(10, 32)) }", Warning, "The \"shl\" instruction is only available for Constantinople-compatible VMs."); CHECK_PARSE_WARNING("{ pop(shr(10, 32)) }", Warning, "The \"shr\" instruction is only available for Constantinople-compatible VMs."); CHECK_PARSE_WARNING("{ pop(sar(10, 32)) }", Warning, "The \"sar\" instruction is only available for Constantinople-compatible VMs."); diff --git a/test/libsolidity/JSONCompiler.cpp b/test/libsolidity/JSONCompiler.cpp index aed0a370..cdcc22a6 100644 --- a/test/libsolidity/JSONCompiler.cpp +++ b/test/libsolidity/JSONCompiler.cpp @@ -111,12 +111,12 @@ BOOST_AUTO_TEST_CASE(basic_compilation) BOOST_CHECK(contract["bytecode"].isString()); BOOST_CHECK_EQUAL( dev::test::bytecodeSansMetadata(contract["bytecode"].asString()), - "60606040523415600e57600080fd5b603580601b6000396000f3006060604052600080fd00" + "60806040523415600e57600080fd5b603580601b6000396000f3006080604052600080fd00" ); BOOST_CHECK(contract["runtimeBytecode"].isString()); BOOST_CHECK_EQUAL( dev::test::bytecodeSansMetadata(contract["runtimeBytecode"].asString()), - "6060604052600080fd00" + "6080604052600080fd00" ); BOOST_CHECK(contract["functionHashes"].isObject()); BOOST_CHECK(contract["gasEstimates"].isObject()); @@ -153,12 +153,12 @@ BOOST_AUTO_TEST_CASE(single_compilation) BOOST_CHECK(contract["bytecode"].isString()); BOOST_CHECK_EQUAL( dev::test::bytecodeSansMetadata(contract["bytecode"].asString()), - "60606040523415600e57600080fd5b603580601b6000396000f3006060604052600080fd00" + "60806040523415600e57600080fd5b603580601b6000396000f3006080604052600080fd00" ); BOOST_CHECK(contract["runtimeBytecode"].isString()); BOOST_CHECK_EQUAL( dev::test::bytecodeSansMetadata(contract["runtimeBytecode"].asString()), - "6060604052600080fd00" + "6080604052600080fd00" ); BOOST_CHECK(contract["functionHashes"].isObject()); BOOST_CHECK(contract["gasEstimates"].isObject()); diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 38d3ce4d..39f4b03e 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -4884,6 +4884,48 @@ BOOST_AUTO_TEST_CASE(array_push) ABI_CHECK(callContractFunction("test()"), encodeArgs(5, 4, 3, 3)); } +BOOST_AUTO_TEST_CASE(array_push_struct) +{ + char const* sourceCode = R"( + contract c { + struct S { uint16 a; uint16 b; uint16[3] c; uint16[] d; } + S[] data; + function test() returns (uint16, uint16, uint16, uint16) { + S memory s; + s.a = 2; + s.b = 3; + s.c[2] = 4; + s.d = new uint16[](4); + s.d[2] = 5; + data.push(s); + return (data[0].a, data[0].b, data[0].c[2], data[0].d[2]); + } + } + )"; + compileAndRun(sourceCode); + ABI_CHECK(callContractFunction("test()"), encodeArgs(2, 3, 4, 5)); +} + +BOOST_AUTO_TEST_CASE(array_push_packed_array) +{ + char const* sourceCode = R"( + contract c { + uint80[] x; + function test() returns (uint80, uint80, uint80, uint80) { + x.push(1); + x.push(2); + x.push(3); + x.push(4); + x.push(5); + x.length = 4; + return (x[0], x[1], x[2], x[3]); + } + } + )"; + compileAndRun(sourceCode); + ABI_CHECK(callContractFunction("test()"), encodeArgs(1, 2, 3, 4)); +} + BOOST_AUTO_TEST_CASE(byte_array_push) { char const* sourceCode = R"( @@ -4904,6 +4946,29 @@ BOOST_AUTO_TEST_CASE(byte_array_push) ABI_CHECK(callContractFunction("test()"), encodeArgs(false)); } +BOOST_AUTO_TEST_CASE(byte_array_push_transition) +{ + // Tests transition between short and long encoding + char const* sourceCode = R"( + contract c { + bytes data; + function test() returns (uint) { + for (uint i = 1; i < 40; i++) + { + data.push(byte(i)); + if (data.length != i) return 0x1000 + i; + if (data[data.length - 1] != byte(i)) return i; + } + for (i = 1; i < 40; i++) + if (data[i - 1] != byte(i)) return 0x1000000 + i; + return 0; + } + } + )"; + compileAndRun(sourceCode); + ABI_CHECK(callContractFunction("test()"), encodeArgs(0)); +} + BOOST_AUTO_TEST_CASE(external_array_args) { char const* sourceCode = R"( @@ -5126,7 +5191,7 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base) } uint public m_i; } - contract Derived is Base(2) { + contract Derived is Base { function Derived(uint i) Base(i) {} } @@ -5146,10 +5211,10 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base_base) } uint public m_i; } - contract Base1 is Base(3) { + contract Base1 is Base { function Base1(uint k) Base(k*k) {} } - contract Derived is Base(3), Base1(2) { + contract Derived is Base, Base1 { function Derived(uint i) Base(i) Base1(i) {} } @@ -5170,7 +5235,7 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base_base_with_gap) uint public m_i; } contract Base1 is Base(3) {} - contract Derived is Base(2), Base1 { + contract Derived is Base, Base1 { function Derived(uint i) Base(i) {} } contract Final is Derived(4) { @@ -7687,7 +7752,6 @@ BOOST_AUTO_TEST_CASE(create_memory_array_allocation_size) ABI_CHECK(callContractFunction("f()"), encodeArgs(0x40, 0x40, 0x20 + 256)); } - BOOST_AUTO_TEST_CASE(memory_arrays_of_various_sizes) { // Computes binomial coefficients the chinese way @@ -7710,6 +7774,41 @@ BOOST_AUTO_TEST_CASE(memory_arrays_of_various_sizes) ABI_CHECK(callContractFunction("f(uint256,uint256)", encodeArgs(u256(9), u256(5))), encodeArgs(u256(70))); } +BOOST_AUTO_TEST_CASE(create_multiple_dynamic_arrays) +{ + char const* sourceCode = R"( + contract C { + function f() returns (uint) { + uint[][] memory x = new uint[][](42); + assert(x[0].length == 0); + x[0] = new uint[](1); + x[0][0] = 1; + assert(x[4].length == 0); + x[4] = new uint[](1); + x[4][0] = 2; + assert(x[10].length == 0); + x[10] = new uint[](1); + x[10][0] = 44; + uint[][] memory y = new uint[][](24); + assert(y[0].length == 0); + y[0] = new uint[](1); + y[0][0] = 1; + assert(y[4].length == 0); + y[4] = new uint[](1); + y[4][0] = 2; + assert(y[10].length == 0); + y[10] = new uint[](1); + y[10][0] = 88; + if ((x[0][0] == y[0][0]) && (x[4][0] == y[4][0]) && (x[10][0] == 44) && (y[10][0] == 88)) + return 7; + return 0; + } + } + )"; + compileAndRun(sourceCode, 0, "C"); + ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(7))); +} + BOOST_AUTO_TEST_CASE(memory_overwrite) { char const* sourceCode = R"( @@ -10998,6 +11097,179 @@ 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) returns (bool c) { + assembly { + a + b + swap1 + lt + =: c + } + } + function add(uint a, uint b) returns (uint c) { + assembly { + a + b + swap1 + add + =: c + } + } + function div(uint a, uint b) 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()) + return; + char const* sourceCode = R"( + contract C { + function shl(uint a, uint b) returns (uint c) { + assembly { + a + b + shl + =: c + } + } + function shr(uint a, uint b) returns (uint c) { + assembly { + a + b + shr + =: c + } + } + function sar(uint a, uint b) returns (uint c) { + assembly { + a + b + sar + =: c + } + } + } + )"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("shl(uint256,uint256)", u256(1), u256(2)) == encodeArgs(u256(4))); + BOOST_CHECK(callContractFunction("shl(uint256,uint256)", u256("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), u256(1)) == encodeArgs(u256("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"))); + BOOST_CHECK(callContractFunction("shl(uint256,uint256)", u256("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), u256(256)) == encodeArgs(u256(0))); + BOOST_CHECK(callContractFunction("shr(uint256,uint256)", u256(3), u256(1)) == encodeArgs(u256(1))); + BOOST_CHECK(callContractFunction("shr(uint256,uint256)", u256("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), u256(1)) == encodeArgs(u256("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"))); + BOOST_CHECK(callContractFunction("shr(uint256,uint256)", u256("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), u256(255)) == encodeArgs(u256(1))); + BOOST_CHECK(callContractFunction("shr(uint256,uint256)", u256("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), u256(256)) == encodeArgs(u256(0))); + BOOST_CHECK(callContractFunction("sar(uint256,uint256)", u256(3), u256(1)) == encodeArgs(u256(1))); + BOOST_CHECK(callContractFunction("sar(uint256,uint256)", u256("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), u256(1)) == encodeArgs(u256("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"))); + BOOST_CHECK(callContractFunction("sar(uint256,uint256)", u256("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), u256(255)) == encodeArgs(u256("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"))); + BOOST_CHECK(callContractFunction("sar(uint256,uint256)", u256("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), u256(256)) == encodeArgs(u256("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"))); +} + +BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople) +{ + if (!dev::test::Options::get().evmVersion().hasBitwiseShifting()) + return; + char const* sourceCode = R"( + contract C { + function shl_1() returns (bool) { + uint c; + assembly { + 1 + 2 + shl + =: c + } + assert(c == 4); + return true; + } + function shl_2() returns (bool) { + uint c; + assembly { + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + 1 + shl + =: c + } + assert(c == 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe); + return true; + } + function shl_3() returns (bool) { + uint c; + assembly { + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + 256 + shl + =: c + } + assert(c == 0); + return true; + } + function shr_1() returns (bool) { + uint c; + assembly { + 3 + 1 + shr + =: c + } + assert(c == 1); + return true; + } + function shr_2() returns (bool) { + uint c; + assembly { + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + 1 + shr + =: c + } + assert(c == 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); + return true; + } + function shr_3() returns (bool) { + uint c; + assembly { + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + 256 + shr + =: c + } + assert(c == 0); + return true; + } + } + )"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("shl_1()") == encodeArgs(u256(1))); + BOOST_CHECK(callContractFunction("shl_2()") == encodeArgs(u256(1))); + BOOST_CHECK(callContractFunction("shl_3()") == encodeArgs(u256(1))); + BOOST_CHECK(callContractFunction("shr_1()") == encodeArgs(u256(1))); + BOOST_CHECK(callContractFunction("shr_2()") == encodeArgs(u256(1))); + BOOST_CHECK(callContractFunction("shr_3()") == encodeArgs(u256(1))); +} + BOOST_AUTO_TEST_SUITE_END() } diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index dcdc1519..18a414e0 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -92,61 +92,6 @@ BOOST_AUTO_TEST_CASE(reference_to_later_declaration) CHECK_SUCCESS(text); } -BOOST_AUTO_TEST_CASE(struct_definition_directly_recursive) -{ - char const* text = R"( - contract test { - struct MyStructName { - address addr; - MyStructName x; - } - } - )"; - CHECK_ERROR(text, TypeError, "Recursive struct definition."); -} - -BOOST_AUTO_TEST_CASE(struct_definition_indirectly_recursive) -{ - char const* text = R"( - contract test { - struct MyStructName1 { - address addr; - uint256 count; - MyStructName2 x; - } - struct MyStructName2 { - MyStructName1 x; - } - } - )"; - CHECK_ERROR(text, TypeError, "Recursive struct definition."); -} - -BOOST_AUTO_TEST_CASE(struct_definition_not_really_recursive) -{ - char const* text = R"( - contract test { - struct s1 { uint a; } - struct s2 { s1 x; s1 y; } - } - )"; - CHECK_SUCCESS(text); -} - -BOOST_AUTO_TEST_CASE(struct_definition_recursion_via_mapping) -{ - char const* text = R"( - contract test { - struct MyStructName1 { - address addr; - uint256 count; - mapping(uint => MyStructName1) x; - } - } - )"; - CHECK_SUCCESS(text); -} - BOOST_AUTO_TEST_CASE(type_inference_smoke_test) { char const* text = R"( @@ -962,6 +907,35 @@ BOOST_AUTO_TEST_CASE(base_constructor_arguments_override) CHECK_SUCCESS(text); } +BOOST_AUTO_TEST_CASE(new_constructor_syntax) +{ + char const* text = R"( + contract A { constructor() public {} } + )"; + CHECK_SUCCESS_NO_WARNINGS(text); +} + +BOOST_AUTO_TEST_CASE(old_constructor_syntax) +{ + char const* text = R"( + contract A { function A() public {} } + )"; + CHECK_WARNING( + text, + "Defining constructors as functions with the same name as the contract is deprecated." + ); + + text = R"( + pragma experimental "v0.5.0"; + contract A { function A() public {} } + )"; + CHECK_ERROR( + text, + SyntaxError, + "Functions are not allowed to have the same name as the contract." + ); +} + BOOST_AUTO_TEST_CASE(implicit_derived_to_base_conversion) { char const* text = R"( @@ -1001,139 +975,6 @@ BOOST_AUTO_TEST_CASE(super_excludes_current_contract) CHECK_ERROR(text, TypeError, "Member \"f\" not found or not visible after argument-dependent lookup in contract super B"); } -BOOST_AUTO_TEST_CASE(function_modifier_invocation) -{ - char const* text = R"( - contract B { - function f() mod1(2, true) mod2("0123456") pure public { } - modifier mod1(uint a, bool b) { if (b) _; } - modifier mod2(bytes7 a) { while (a == "1234567") _; } - } - )"; - CHECK_SUCCESS(text); -} - -BOOST_AUTO_TEST_CASE(invalid_function_modifier_type) -{ - char const* text = R"( - contract B { - function f() mod1(true) public { } - modifier mod1(uint a) { if (a > 0) _; } - } - )"; - CHECK_ERROR(text, TypeError, "Invalid type for argument in modifier invocation. Invalid implicit conversion from bool to uint256 requested."); -} - -BOOST_AUTO_TEST_CASE(function_modifier_invocation_parameters) -{ - char const* text = R"( - contract B { - function f(uint8 a) mod1(a, true) mod2(r) public returns (bytes7 r) { } - modifier mod1(uint a, bool b) { if (b) _; } - modifier mod2(bytes7 a) { while (a == "1234567") _; } - } - )"; - CHECK_SUCCESS(text); -} - -BOOST_AUTO_TEST_CASE(function_modifier_invocation_local_variables) -{ - char const* text = R"( - contract B { - function f() mod(x) pure public { uint x = 7; } - modifier mod(uint a) { if (a > 0) _; } - } - )"; - CHECK_SUCCESS_NO_WARNINGS(text); -} - -BOOST_AUTO_TEST_CASE(function_modifier_invocation_local_variables050) -{ - char const* text = R"( - pragma experimental "v0.5.0"; - contract B { - function f() mod(x) pure public { uint x = 7; } - modifier mod(uint a) { if (a > 0) _; } - } - )"; - CHECK_ERROR(text, DeclarationError, "Undeclared identifier."); -} - -BOOST_AUTO_TEST_CASE(function_modifier_double_invocation) -{ - char const* text = R"( - contract B { - function f(uint x) mod(x) mod(2) public { } - modifier mod(uint a) { if (a > 0) _; } - } - )"; - CHECK_SUCCESS(text); -} - -BOOST_AUTO_TEST_CASE(base_constructor_double_invocation) -{ - char const* text = R"( - contract C { function C(uint a) public {} } - contract B is C { - function B() C(2) C(2) public {} - } - )"; - CHECK_ERROR(text, DeclarationError, "Base constructor already provided"); -} - -BOOST_AUTO_TEST_CASE(legal_modifier_override) -{ - char const* text = R"( - contract A { modifier mod(uint a) { _; } } - contract B is A { modifier mod(uint a) { _; } } - )"; - CHECK_SUCCESS(text); -} - -BOOST_AUTO_TEST_CASE(illegal_modifier_override) -{ - char const* text = R"( - contract A { modifier mod(uint a) { _; } } - contract B is A { modifier mod(uint8 a) { _; } } - )"; - CHECK_ERROR(text, TypeError, "Override changes modifier signature."); -} - -BOOST_AUTO_TEST_CASE(modifier_overrides_function) -{ - char const* text = R"( - contract A { modifier mod(uint a) { _; } } - contract B is A { function mod(uint a) public { } } - )"; - CHECK_ALLOW_MULTI(text, (vector<pair<Error::Type, string>>{ - {Error::Type::DeclarationError, "Identifier already declared"}, - {Error::Type::TypeError, "Override changes modifier to function"} - })); -} - -BOOST_AUTO_TEST_CASE(function_overrides_modifier) -{ - char const* text = R"( - contract A { function mod(uint a) public { } } - contract B is A { modifier mod(uint a) { _; } } - )"; - CHECK_ALLOW_MULTI(text, (vector<pair<Error::Type, string>>{ - {Error::Type::DeclarationError, "Identifier already declared"}, - {Error::Type::TypeError, "Override changes function to modifier"} - })); -} - -BOOST_AUTO_TEST_CASE(modifier_returns_value) -{ - char const* text = R"( - contract A { - function f(uint a) mod(2) public returns (uint r) { } - modifier mod(uint a) { _; return 7; } - } - )"; - CHECK_ERROR(text, TypeError, "Return arguments not allowed."); -} - BOOST_AUTO_TEST_CASE(state_variable_accessors) { char const* text = R"( @@ -4202,21 +4043,6 @@ BOOST_AUTO_TEST_CASE(conditional_with_all_types) CHECK_SUCCESS(text); } -BOOST_AUTO_TEST_CASE(constructor_call_invalid_arg_count) -{ - // This caused a segfault in an earlier version - char const* text = R"( - contract C { - function C(){} - } - contract D is C { - function D() C(5){} - } - )"; - - CHECK_ERROR(text, TypeError, "Wrong argument count for modifier invocation: 1 arguments given but expected 0."); -} - BOOST_AUTO_TEST_CASE(index_access_for_bytes) { char const* text = R"( @@ -5081,16 +4907,6 @@ BOOST_AUTO_TEST_CASE(no_warn_about_callcode_as_function) CHECK_SUCCESS_NO_WARNINGS(text); } -BOOST_AUTO_TEST_CASE(modifier_without_underscore) -{ - char const* text = R"( - contract test { - modifier m() {} - } - )"; - CHECK_ERROR(text, SyntaxError, "Modifier body does not contain '_'."); -} - BOOST_AUTO_TEST_CASE(payable_in_library) { char const* text = R"( @@ -5290,319 +5106,6 @@ BOOST_AUTO_TEST_CASE(using_directive_for_missing_selftype) CHECK_ERROR(text, TypeError, "Member \"b\" not found or not visible after argument-dependent lookup in bytes memory"); } -BOOST_AUTO_TEST_CASE(function_type) -{ - char const* text = R"( - contract C { - function f() public { - function(uint) returns (uint) x; - } - } - )"; - CHECK_SUCCESS(text); -} - -BOOST_AUTO_TEST_CASE(function_type_parameter) -{ - char const* text = R"( - contract C { - function f(function(uint) external returns (uint) g) public returns (function(uint) external returns (uint)) { - return g; - } - } - )"; - CHECK_SUCCESS(text); -} - -BOOST_AUTO_TEST_CASE(function_type_returned) -{ - char const* text = R"( - contract C { - function f() public returns (function(uint) external returns (uint) g) { - return g; - } - } - )"; - CHECK_SUCCESS(text); -} - -BOOST_AUTO_TEST_CASE(private_function_type) -{ - char const* text = R"( - contract C { - function f() public { - function(uint) private returns (uint) x; - } - } - )"; - CHECK_ERROR(text, TypeError, "Invalid visibility, can only be \"external\" or \"internal\"."); -} - -BOOST_AUTO_TEST_CASE(public_function_type) -{ - char const* text = R"( - contract C { - function f() public { - function(uint) public returns (uint) x; - } - } - )"; - CHECK_ERROR(text, TypeError, "Invalid visibility, can only be \"external\" or \"internal\"."); -} - -BOOST_AUTO_TEST_CASE(payable_internal_function_type) -{ - char const* text = R"( - contract C { - function (uint) internal payable returns (uint) x; - } - )"; - CHECK_ERROR(text, TypeError, "Only external function types can be payable."); -} - -BOOST_AUTO_TEST_CASE(payable_internal_function_type_is_not_fatal) -{ - char const* text = R"( - contract C { - function (uint) internal payable returns (uint) x; - - function g() { - x = g; - } - } - )"; - CHECK_ERROR_ALLOW_MULTI(text, TypeError, (std::vector<std::string>{"Only external function types can be payable."})); -} - -BOOST_AUTO_TEST_CASE(call_value_on_non_payable_function_type) -{ - char const* text = R"( - contract C { - function (uint) external returns (uint) x; - function f() public { - x.value(2)(); - } - } - )"; - CHECK_ERROR(text, TypeError, "Member \"value\" not found or not visible after argument-dependent lookup in function (uint256) external returns (uint256) - did you forget the \"payable\" modifier?"); -} - -BOOST_AUTO_TEST_CASE(external_function_type_returning_internal) -{ - char const* text = R"( - contract C { - function() external returns (function () internal) x; - } - )"; - CHECK_ERROR(text, TypeError, "Internal type cannot be used for external function type."); -} - -BOOST_AUTO_TEST_CASE(external_function_type_taking_internal) -{ - char const* text = R"( - contract C { - function(function () internal) external x; - } - )"; - CHECK_ERROR(text, TypeError, "Internal type cannot be used for external function type."); -} - -BOOST_AUTO_TEST_CASE(call_value_on_payable_function_type) -{ - char const* text = R"( - contract C { - function (uint) external payable returns (uint) x; - function f() public { - x.value(2)(1); - } - } - )"; - CHECK_SUCCESS(text); -} - -BOOST_AUTO_TEST_CASE(internal_function_as_external_parameter) -{ - // It should not be possible to give internal functions - // as parameters to external functions. - char const* text = R"( - contract C { - function f(function(uint) internal returns (uint) x) public { - } - } - )"; - CHECK_ERROR(text, TypeError, "Internal or recursive type is not allowed for public or external functions."); -} - -BOOST_AUTO_TEST_CASE(internal_function_returned_from_public_function) -{ - // It should not be possible to return internal functions from external functions. - char const* text = R"( - contract C { - function f() public returns (function(uint) internal returns (uint) x) { - } - } - )"; - CHECK_ERROR(text, TypeError, "Internal or recursive type is not allowed for public or external functions."); -} - -BOOST_AUTO_TEST_CASE(internal_function_as_external_parameter_in_library_internal) -{ - char const* text = R"( - library L { - function f(function(uint) internal returns (uint) x) internal { - } - } - )"; - CHECK_SUCCESS(text); -} - -BOOST_AUTO_TEST_CASE(internal_function_as_external_parameter_in_library_external) -{ - char const* text = R"( - library L { - function f(function(uint) internal returns (uint) x) public { - } - } - )"; - CHECK_ERROR(text, TypeError, "Internal or recursive type is not allowed for public or external functions."); -} - -BOOST_AUTO_TEST_CASE(function_type_arrays) -{ - char const* text = R"( - contract C { - function(uint) external returns (uint)[] public x; - function(uint) internal returns (uint)[10] y; - function f() public { - function(uint) returns (uint)[10] memory a; - function(uint) returns (uint)[10] storage b = y; - function(uint) external returns (uint)[] memory c; - c = new function(uint) external returns (uint)[](200); - a; b; - } - } - )"; - CHECK_SUCCESS(text); -} - -BOOST_AUTO_TEST_CASE(delete_function_type) -{ - char const* text = R"( - contract C { - function(uint) external returns (uint) x; - function(uint) internal returns (uint) y; - function f() public { - delete x; - var a = y; - delete a; - delete y; - var c = f; - delete c; - function(uint) internal returns (uint) g; - delete g; - } - } - )"; - CHECK_SUCCESS(text); -} - -BOOST_AUTO_TEST_CASE(delete_function_type_invalid) -{ - char const* text = R"( - contract C { - function f() public { - delete f; - } - } - )"; - CHECK_ERROR(text, TypeError, "Expression has to be an lvalue."); -} - -BOOST_AUTO_TEST_CASE(delete_external_function_type_invalid) -{ - char const* text = R"( - contract C { - function f() public { - delete this.f; - } - } - )"; - CHECK_ERROR(text, TypeError, "Expression has to be an lvalue."); -} - -BOOST_AUTO_TEST_CASE(external_function_to_function_type_calldata_parameter) -{ - // This is a test that checks that the type of the `bytes` parameter is - // correctly changed from its own type `bytes calldata` to `bytes memory` - // when converting to a function type. - char const* text = R"( - contract C { - function f(function(bytes memory) external g) public { } - function callback(bytes) external {} - function g() public { - f(this.callback); - } - } - )"; - CHECK_SUCCESS(text); -} - -BOOST_AUTO_TEST_CASE(external_function_type_to_address) -{ - char const* text = R"( - contract C { - function f() public returns (address) { - return address(this.f); - } - } - )"; - CHECK_SUCCESS(text); -} - -BOOST_AUTO_TEST_CASE(internal_function_type_to_address) -{ - char const* text = R"( - contract C { - function f() public returns (address) { - return address(f); - } - } - )"; - CHECK_ERROR(text, TypeError, "Explicit type conversion not allowed"); -} - -BOOST_AUTO_TEST_CASE(external_function_type_to_uint) -{ - char const* text = R"( - contract C { - function f() public returns (uint) { - return uint(this.f); - } - } - )"; - CHECK_ERROR(text, TypeError, "Explicit type conversion not allowed"); -} - -BOOST_AUTO_TEST_CASE(warn_function_type_parameters_with_names) -{ - char const* text = R"( - contract C { - function(uint a) f; - } - )"; - CHECK_WARNING(text, "Naming function type parameters is deprecated."); -} - -BOOST_AUTO_TEST_CASE(warn_function_type_return_parameters_with_names) -{ - char const* text = R"( - contract C { - function(uint) returns (bool ret) f; - } - )"; - CHECK_WARNING(text, "Naming function type return parameters is deprecated."); -} - BOOST_AUTO_TEST_CASE(shift_constant_left_negative_rvalue) { char const* text = R"( @@ -6193,44 +5696,6 @@ BOOST_AUTO_TEST_CASE(read_returned_struct) )"; CHECK_WARNING(text, "Experimental features"); } - -BOOST_AUTO_TEST_CASE(return_recursive_structs) -{ - char const* text = R"( - contract C { - struct S { uint a; S[] sub; } - function f() returns (uint, S) { - } - } - )"; - CHECK_ERROR(text, TypeError, "Internal or recursive type is not allowed for public or external functions."); -} - -BOOST_AUTO_TEST_CASE(return_recursive_structs2) -{ - char const* text = R"( - contract C { - struct S { uint a; S[2][] sub; } - function f() returns (uint, S) { - } - } - )"; - CHECK_ERROR(text, TypeError, "Internal or recursive type is not allowed for public or external functions."); -} - -BOOST_AUTO_TEST_CASE(return_recursive_structs3) -{ - char const* text = R"( - contract C { - struct S { uint a; S[][][] sub; } - struct T { S s; } - function f() returns (uint x, T t) { - } - } - )"; - CHECK_ERROR(text, TypeError, "Internal or recursive type is not allowed for public or external functions."); -} - BOOST_AUTO_TEST_CASE(address_checksum_type_deduction) { char const* text = R"( @@ -6353,38 +5818,6 @@ BOOST_AUTO_TEST_CASE(address_methods) CHECK_SUCCESS(text); } -BOOST_AUTO_TEST_CASE(cyclic_dependency_for_constants) -{ - char const* text = R"( - contract C { - uint constant a = a; - } - )"; - CHECK_ERROR(text, TypeError, "cyclic dependency via a"); - text = R"( - contract C { - uint constant a = b * c; - uint constant b = 7; - uint constant c = b + uint(keccak256(d)); - uint constant d = 2 + a; - } - )"; - CHECK_ERROR_ALLOW_MULTI(text, TypeError, (std::vector<std::string>{ - "a has a cyclic dependency via c", - "c has a cyclic dependency via d", - "d has a cyclic dependency via a" - })); - text = R"( - contract C { - uint constant a = b * c; - uint constant b = 7; - uint constant c = 4 + uint(keccak256(d)); - uint constant d = 2 + b; - } - )"; - CHECK_SUCCESS(text); -} - BOOST_AUTO_TEST_CASE(interface) { char const* text = R"( @@ -6916,7 +6349,7 @@ BOOST_AUTO_TEST_CASE(shadowing_builtins_ignores_constructor) { char const* text = R"( contract C { - function C() public {} + constructor() public {} } )"; CHECK_SUCCESS_NO_WARNINGS(text); @@ -7328,7 +6761,7 @@ BOOST_AUTO_TEST_CASE(using_this_in_constructor) { char const* text = R"( contract C { - function C() public { + constructor() public { this.f(); } function f() pure public { @@ -7816,171 +7249,6 @@ BOOST_AUTO_TEST_CASE(address_overload_resolution) CHECK_SUCCESS(text); } -BOOST_AUTO_TEST_CASE(array_length_too_large) -{ - char const* text = R"( - contract C { - uint[8**90] ids; - } - )"; - CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal or constant expression."); -} - -BOOST_AUTO_TEST_CASE(array_length_not_convertible_to_integer) -{ - char const* text = R"( - contract C { - uint[true] ids; - } - )"; - CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal or constant expression."); -} - -BOOST_AUTO_TEST_CASE(array_length_constant_var) -{ - char const* text = R"( - contract C { - uint constant LEN = 10; - uint[LEN] ids; - } - )"; - CHECK_SUCCESS(text); -} - -BOOST_AUTO_TEST_CASE(array_length_non_integer_constant_var) -{ - char const* text = R"( - contract C { - bool constant LEN = true; - uint[LEN] ids; - } - )"; - CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal or constant expression."); -} - -BOOST_AUTO_TEST_CASE(array_length_cannot_be_function) -{ - char const* text = R"( - contract C { - function f() {} - uint[f] ids; - } - )"; - CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal or constant expression."); -} - -BOOST_AUTO_TEST_CASE(array_length_can_be_recursive_constant) -{ - char const* text = R"( - contract C { - uint constant L = 5; - uint constant LEN = L + 4 * L; - uint[LEN] ids; - } - )"; - CHECK_SUCCESS(text); -} - -BOOST_AUTO_TEST_CASE(array_length_cannot_be_function_call) -{ - char const* text = R"( - contract C { - function f(uint x) {} - uint constant LEN = f(); - uint[LEN] ids; - } - )"; - CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal or constant expression."); -} - -BOOST_AUTO_TEST_CASE(array_length_const_cannot_be_fractional) -{ - char const* text = R"( - contract C { - fixed constant L = 10.5; - uint[L] ids; - } - )"; - CHECK_ERROR(text, TypeError, "Array with fractional length specified"); -} - -BOOST_AUTO_TEST_CASE(array_length_can_be_constant_in_struct) -{ - char const* text = R"( - contract C { - uint constant LEN = 10; - struct Test { - uint[LEN] ids; - } - } - )"; - CHECK_SUCCESS(text); -} - -BOOST_AUTO_TEST_CASE(array_length_can_be_constant_in_function) -{ - char const* text = R"( - contract C { - uint constant LEN = 10; - function f() { - uint[LEN] a; - } - } - )"; - CHECK_SUCCESS(text); -} - -BOOST_AUTO_TEST_CASE(array_length_cannot_be_constant_function_parameter) -{ - char const* text = R"( - contract C { - function f(uint constant LEN) { - uint[LEN] a; - } - } - )"; - CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal or constant expression."); -} - -BOOST_AUTO_TEST_CASE(array_length_with_cyclic_constant) -{ - char const* text = R"( - contract C { - uint constant LEN = LEN; - function f() { - uint[LEN] a; - } - } - )"; - CHECK_ERROR(text, TypeError, "Cyclic constant definition (or maximum recursion depth exhausted)."); -} - -BOOST_AUTO_TEST_CASE(array_length_with_complex_cyclic_constant) -{ - char const* text = R"( - contract C { - uint constant L2 = LEN - 10; - uint constant L1 = L2 / 10; - uint constant LEN = 10 + L1 * 5; - function f() { - uint[LEN] a; - } - } - )"; - CHECK_ERROR(text, TypeError, "Cyclic constant definition (or maximum recursion depth exhausted)."); -} - -BOOST_AUTO_TEST_CASE(array_length_with_pure_functions) -{ - char const* text = R"( - contract C { - uint constant LEN = keccak256(ripemd160(33)); - uint[LEN] ids; - } - )"; - CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal or constant expression."); -} - BOOST_AUTO_TEST_CASE(array_length_invalid_expression) { char const* text = R"( diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp index cf4550c7..5326feaf 100644 --- a/test/libsolidity/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -93,8 +93,10 @@ public: { m_contractAddress = m_nonOptimizedContract; bytes nonOptimizedOutput = callContractFunction(_sig, _arguments...); + m_gasUsedNonOptimized = m_gasUsed; m_contractAddress = m_optimizedContract; bytes optimizedOutput = callContractFunction(_sig, _arguments...); + m_gasUsedOptimized = m_gasUsed; BOOST_CHECK_MESSAGE(!optimizedOutput.empty(), "No optimized output for " + _sig); BOOST_CHECK_MESSAGE(!nonOptimizedOutput.empty(), "No un-optimized output for " + _sig); BOOST_CHECK_MESSAGE(nonOptimizedOutput == optimizedOutput, "Computed values do not match." @@ -120,6 +122,8 @@ public: } protected: + u256 m_gasUsedOptimized; + u256 m_gasUsedNonOptimized; bytes m_nonOptimizedBytecode; bytes m_optimizedBytecode; Address m_optimizedContract; @@ -584,6 +588,26 @@ BOOST_AUTO_TEST_CASE(invalid_state_at_control_flow_join) compareVersions("test()"); } +BOOST_AUTO_TEST_CASE(init_empty_dynamic_arrays) +{ + // This is not so much an optimizer test, but rather a test + // that allocating empty arrays is implemented efficiently. + // In particular, initializing a dynamic memory array does + // not use any memory. + char const* sourceCode = R"( + contract Test { + function f() pure returns (uint r) { + uint[][] memory x = new uint[][](20000); + return x.length; + } + } + )"; + compileBothVersions(sourceCode); + compareVersions("f()"); + BOOST_CHECK_LE(m_gasUsedNonOptimized, 1900000); + BOOST_CHECK_LE(1600000, m_gasUsedNonOptimized); +} + BOOST_AUTO_TEST_CASE(optimise_multi_stores) { char const* sourceCode = R"( @@ -603,8 +627,8 @@ BOOST_AUTO_TEST_CASE(optimise_multi_stores) )"; compileBothVersions(sourceCode); compareVersions("f()"); - BOOST_CHECK_EQUAL(numInstructions(m_nonOptimizedBytecode, Instruction::SSTORE), 13); - BOOST_CHECK_EQUAL(numInstructions(m_optimizedBytecode, Instruction::SSTORE), 11); + BOOST_CHECK_EQUAL(numInstructions(m_nonOptimizedBytecode, Instruction::SSTORE), 9); + BOOST_CHECK_EQUAL(numInstructions(m_optimizedBytecode, Instruction::SSTORE), 8); } BOOST_AUTO_TEST_SUITE_END() diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp index 4e862f60..93e6bcaa 100644 --- a/test/libsolidity/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -112,26 +112,6 @@ while(0) BOOST_AUTO_TEST_SUITE(SolidityParser) -BOOST_AUTO_TEST_CASE(smoke_test) -{ - char const* text = R"( - contract test { - uint256 stateVariable1; - } - )"; - BOOST_CHECK(successParse(text)); -} - -BOOST_AUTO_TEST_CASE(missing_variable_name_in_declaration) -{ - char const* text = R"( - contract test { - uint256 ; - } - )"; - CHECK_PARSE_ERROR(text, "Expected identifier"); -} - BOOST_AUTO_TEST_CASE(empty_function) { char const* text = R"( diff --git a/test/libsolidity/SolidityTypes.cpp b/test/libsolidity/SolidityTypes.cpp index bc9f2fe1..738b24bc 100644 --- a/test/libsolidity/SolidityTypes.cpp +++ b/test/libsolidity/SolidityTypes.cpp @@ -123,6 +123,7 @@ BOOST_AUTO_TEST_CASE(type_identifiers) BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("bytes32")->identifier(), "t_bytes32"); BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("bool")->identifier(), "t_bool"); BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("bytes")->identifier(), "t_bytes_storage_ptr"); + BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("bytes memory")->identifier(), "t_bytes_memory_ptr"); BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("string")->identifier(), "t_string_storage_ptr"); ArrayType largeintArray(DataLocation::Memory, Type::fromElementaryTypeName("int128"), u256("2535301200456458802993406410752")); BOOST_CHECK_EQUAL(largeintArray.identifier(), "t_array$_t_int128_$2535301200456458802993406410752_memory_ptr"); diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp index dd6eb7c4..b285a2a0 100644 --- a/test/libsolidity/StandardCompiler.cpp +++ b/test/libsolidity/StandardCompiler.cpp @@ -261,14 +261,14 @@ BOOST_AUTO_TEST_CASE(basic_compilation) BOOST_CHECK(contract["evm"]["bytecode"]["object"].isString()); BOOST_CHECK_EQUAL( dev::test::bytecodeSansMetadata(contract["evm"]["bytecode"]["object"].asString()), - "60606040523415600e57600080fd5b603580601b6000396000f3006060604052600080fd00" + "60806040523415600e57600080fd5b603580601b6000396000f3006080604052600080fd00" ); BOOST_CHECK(contract["evm"]["assembly"].isString()); BOOST_CHECK(contract["evm"]["assembly"].asString().find( - " /* \"fileA\":0:14 contract A { } */\n mstore(0x40, 0x60)\n jumpi(tag_1, iszero(callvalue))\n" + " /* \"fileA\":0:14 contract A { } */\n mstore(0x40, 0x80)\n jumpi(tag_1, iszero(callvalue))\n" " 0x0\n dup1\n revert\ntag_1:\n dataSize(sub_0)\n dup1\n dataOffset(sub_0)\n 0x0\n codecopy\n 0x0\n" " return\nstop\n\nsub_0: assembly {\n /* \"fileA\":0:14 contract A { } */\n" - " mstore(0x40, 0x60)\n 0x0\n dup1\n revert\n\n" + " mstore(0x40, 0x80)\n 0x0\n dup1\n revert\n\n" " auxdata: 0xa165627a7a7230582") == 0); BOOST_CHECK(contract["evm"]["gasEstimates"].isObject()); BOOST_CHECK_EQUAL( diff --git a/test/libsolidity/SyntaxTest.cpp b/test/libsolidity/SyntaxTest.cpp index ca051138..1c2355d5 100644 --- a/test/libsolidity/SyntaxTest.cpp +++ b/test/libsolidity/SyntaxTest.cpp @@ -16,6 +16,7 @@ */ #include <test/libsolidity/SyntaxTest.h> +#include <test/Options.h> #include <boost/algorithm/string.hpp> #include <boost/algorithm/string/predicate.hpp> #include <boost/throw_exception.hpp> @@ -33,17 +34,38 @@ namespace fs = boost::filesystem; using namespace boost::unit_test; template<typename IteratorType> -void skipWhitespace(IteratorType& it, IteratorType end) +void skipWhitespace(IteratorType& _it, IteratorType _end) { - while (it != end && isspace(*it)) - ++it; + while (_it != _end && isspace(*_it)) + ++_it; } template<typename IteratorType> -void skipSlashes(IteratorType& it, IteratorType end) +void skipSlashes(IteratorType& _it, IteratorType _end) { - while (it != end && *it == '/') - ++it; + while (_it != _end && *_it == '/') + ++_it; +} + +void expect(string::iterator& _it, string::iterator _end, string::value_type _c) +{ + if (_it == _end || *_it != _c) + throw runtime_error(string("Invalid test expectation. Expected: \"") + _c + "\"."); + ++_it; +} + +int parseUnsignedInteger(string::iterator &_it, string::iterator _end) +{ + if (_it == _end || !isdigit(*_it)) + throw runtime_error("Invalid test expectation. Source location expected."); + int result = 0; + while (_it != _end && isdigit(*_it)) + { + result *= 10; + result += *_it - '0'; + ++_it; + } + return result; } SyntaxTest::SyntaxTest(string const& _filename) @@ -59,93 +81,79 @@ SyntaxTest::SyntaxTest(string const& _filename) bool SyntaxTest::run(ostream& _stream, string const& _linePrefix, bool const _formatted) { - m_errorList = parseAnalyseAndReturnError(m_source, true, true, true).second; - if (!matchesExpectations(m_errorList)) + string const versionPragma = "pragma solidity >=0.0;\n"; + m_compiler.reset(); + m_compiler.addSource("", versionPragma + m_source); + m_compiler.setEVMVersion(dev::test::Options::get().evmVersion()); + + if (m_compiler.parse()) + m_compiler.analyze(); + + for (auto const& currentError: filterErrors(m_compiler.errors(), true)) + { + int locationStart = -1, locationEnd = -1; + if (auto location = boost::get_error_info<errinfo_sourceLocation>(*currentError)) + { + // ignore the version pragma inserted by the testing tool when calculating locations. + if (location->start >= static_cast<int>(versionPragma.size())) + locationStart = location->start - versionPragma.size(); + if (location->end >= static_cast<int>(versionPragma.size())) + locationEnd = location->end - versionPragma.size(); + } + m_errorList.emplace_back(SyntaxTestError{ + currentError->typeName(), + errorMessage(*currentError), + locationStart, + locationEnd + }); + } + + if (m_expectations != m_errorList) { - std::string nextIndentLevel = _linePrefix + " "; + string nextIndentLevel = _linePrefix + " "; FormattedScope(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Expected result:" << endl; - printExpected(_stream, nextIndentLevel, _formatted); - FormattedScope(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Obtained result:\n"; - printErrorList(_stream, m_errorList, nextIndentLevel, false, false, _formatted); + printErrorList(_stream, m_expectations, nextIndentLevel, _formatted); + FormattedScope(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Obtained result:" << endl; + printErrorList(_stream, m_errorList, nextIndentLevel, _formatted); return false; } return true; } -void SyntaxTest::printExpected(ostream& _stream, string const& _linePrefix, bool const _formatted) const -{ - if (m_expectations.empty()) - FormattedScope(_stream, _formatted, {BOLD, GREEN}) << _linePrefix << "Success" << endl; - else - for (auto const& expectation: m_expectations) - { - FormattedScope(_stream, _formatted, {BOLD, expectation.type == "Warning" ? YELLOW : RED}) << - _linePrefix << expectation.type << ": "; - _stream << expectation.message << endl; - } -} - void SyntaxTest::printErrorList( ostream& _stream, - ErrorList const& _errorList, + vector<SyntaxTestError> const& _errorList, string const& _linePrefix, - bool const _ignoreWarnings, - bool const _lineNumbers, bool const _formatted -) const +) { if (_errorList.empty()) FormattedScope(_stream, _formatted, {BOLD, GREEN}) << _linePrefix << "Success" << endl; else for (auto const& error: _errorList) { - bool isWarning = (error->type() == Error::Type::Warning); - if (isWarning && _ignoreWarnings) continue; - { - FormattedScope scope(_stream, _formatted, {BOLD, isWarning ? YELLOW : RED}); + FormattedScope scope(_stream, _formatted, {BOLD, (error.type == "Warning") ? YELLOW : RED}); _stream << _linePrefix; - if (_lineNumbers) - { - int line = offsetToLineNumber( - boost::get_error_info<errinfo_sourceLocation>(*error)->start - ); - if (line >= 0) - _stream << "(" << line << "): "; - } - _stream << error->typeName() << ": "; + _stream << error.type << ": "; + } + if (error.locationStart >= 0 || error.locationEnd >= 0) + { + _stream << "("; + if (error.locationStart >= 0) + _stream << error.locationStart; + _stream << "-"; + if (error.locationEnd >= 0) + _stream << error.locationEnd; + _stream << "): "; } - _stream << errorMessage(*error) << endl; + _stream << error.message << endl; } } -int SyntaxTest::offsetToLineNumber(int _location) const +string SyntaxTest::errorMessage(Exception const& _e) { - // parseAnalyseAndReturnError(...) prepends a version pragma - _location -= strlen("pragma solidity >=0.0;\n"); - if (_location < 0 || static_cast<size_t>(_location) >= m_source.size()) - return -1; - else - return 1 + std::count(m_source.begin(), m_source.begin() + _location, '\n'); -} - -bool SyntaxTest::matchesExpectations(ErrorList const& _errorList) const -{ - if (_errorList.size() != m_expectations.size()) - return false; - else - for (size_t i = 0; i < _errorList.size(); i++) - if ( - (_errorList[i]->typeName() != m_expectations[i].type) || - (errorMessage(*_errorList[i]) != m_expectations[i].message) - ) - return false; - return true; -} - -string SyntaxTest::errorMessage(Error const& _e) -{ - if (_e.comment()) + if (_e.comment() && !_e.comment()->empty()) return boost::replace_all_copy(*_e.comment(), "\n", "\\n"); else return "NONE"; @@ -164,9 +172,9 @@ string SyntaxTest::parseSource(istream& _stream) return source; } -vector<SyntaxTestExpectation> SyntaxTest::parseExpectations(istream& _stream) +vector<SyntaxTestError> SyntaxTest::parseExpectations(istream& _stream) { - vector<SyntaxTestExpectation> expectations; + vector<SyntaxTestError> expectations; string line; while (getline(_stream, line)) { @@ -187,8 +195,28 @@ vector<SyntaxTestExpectation> SyntaxTest::parseExpectations(istream& _stream) skipWhitespace(it, line.end()); + int locationStart = -1; + int locationEnd = -1; + + if (it != line.end() && *it == '(') + { + ++it; + locationStart = parseUnsignedInteger(it, line.end()); + expect(it, line.end(), '-'); + locationEnd = parseUnsignedInteger(it, line.end()); + expect(it, line.end(), ')'); + expect(it, line.end(), ':'); + } + + skipWhitespace(it, line.end()); + string errorMessage(it, line.end()); - expectations.emplace_back(SyntaxTestExpectation{move(errorType), move(errorMessage)}); + expectations.emplace_back(SyntaxTestError{ + move(errorType), + move(errorMessage), + locationStart, + locationEnd + }); } return expectations; } @@ -239,9 +267,11 @@ int SyntaxTest::registerTests( _suite.add(make_test_case( [fullpath] { - std::stringstream errorStream; - if (!SyntaxTest(fullpath.string()).run(errorStream)) - BOOST_ERROR("Test expectation mismatch.\n" + errorStream.str()); + BOOST_REQUIRE_NO_THROW({ + stringstream errorStream; + if (!SyntaxTest(fullpath.string()).run(errorStream)) + BOOST_ERROR("Test expectation mismatch.\n" + errorStream.str()); + }); }, _path.stem().string(), *filenames.back(), diff --git a/test/libsolidity/SyntaxTest.h b/test/libsolidity/SyntaxTest.h index cb6ee05c..6159e789 100644 --- a/test/libsolidity/SyntaxTest.h +++ b/test/libsolidity/SyntaxTest.h @@ -36,10 +36,19 @@ namespace solidity namespace test { -struct SyntaxTestExpectation +struct SyntaxTestError { std::string type; std::string message; + int locationStart; + int locationEnd; + bool operator==(SyntaxTestError const& _rhs) const + { + return type == _rhs.type && + message == _rhs.message && + locationStart == _rhs.locationStart && + locationEnd == _rhs.locationEnd; + } }; @@ -50,21 +59,16 @@ public: bool run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false); - std::vector<SyntaxTestExpectation> const& expectations() const { return m_expectations; } + std::vector<SyntaxTestError> const& expectations() const { return m_expectations; } std::string const& source() const { return m_source; } - ErrorList const& errorList() const { return m_errorList; } - ErrorList const& compilerErrors() const { return m_compiler.errors(); } + std::vector<SyntaxTestError> const& errorList() const { return m_errorList; } - void printExpected(std::ostream& _stream, std::string const& _linePrefix, bool const _formatted = false) const; - - void printErrorList( + static void printErrorList( std::ostream& _stream, - ErrorList const& _errors, + std::vector<SyntaxTestError> const& _errors, std::string const& _linePrefix, - bool const _ignoreWarnings, - bool const _lineNumbers, bool const _formatted = false - ) const; + ); static int registerTests( boost::unit_test::test_suite& _suite, @@ -72,16 +76,14 @@ public: boost::filesystem::path const& _path ); static bool isTestFilename(boost::filesystem::path const& _filename); + static std::string errorMessage(Exception const& _e); private: - bool matchesExpectations(ErrorList const& _errors) const; - static std::string errorMessage(Error const& _e); static std::string parseSource(std::istream& _stream); - static std::vector<SyntaxTestExpectation> parseExpectations(std::istream& _stream); - int offsetToLineNumber(int _location) const; + static std::vector<SyntaxTestError> parseExpectations(std::istream& _stream); std::string m_source; - std::vector<SyntaxTestExpectation> m_expectations; - ErrorList m_errorList; + std::vector<SyntaxTestError> m_expectations; + std::vector<SyntaxTestError> m_errorList; }; } diff --git a/test/libsolidity/syntaxTests/arrayLength/array_length_cannot_be_constant_function_parameter.sol b/test/libsolidity/syntaxTests/arrayLength/array_length_cannot_be_constant_function_parameter.sol new file mode 100644 index 00000000..11d40f26 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/array_length_cannot_be_constant_function_parameter.sol @@ -0,0 +1,7 @@ +contract C { + function f(uint constant LEN) { + uint[LEN] a; + } +} +// ---- +// TypeError: (62-65): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_function.sol b/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_function.sol new file mode 100644 index 00000000..92536dd5 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_function.sol @@ -0,0 +1,8 @@ +contract C { + uint constant LEN = 10; + function f() public pure { + uint[LEN] memory a; + a; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_struct.sol b/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_struct.sol new file mode 100644 index 00000000..89e174f2 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_struct.sol @@ -0,0 +1,7 @@ +contract C { + uint constant LEN = 10; + struct Test { + uint[LEN] ids; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/arrayLength/can_be_recursive_constant.sol b/test/libsolidity/syntaxTests/arrayLength/can_be_recursive_constant.sol new file mode 100644 index 00000000..6810a9d6 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/can_be_recursive_constant.sol @@ -0,0 +1,6 @@ +contract C { + uint constant L = 5; + uint constant LEN = L + 4 * L; + uint[LEN] ids; +} +// ---- diff --git a/test/libsolidity/syntaxTests/arrayLength/cannot_be_function.sol b/test/libsolidity/syntaxTests/arrayLength/cannot_be_function.sol new file mode 100644 index 00000000..ac3abc4c --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/cannot_be_function.sol @@ -0,0 +1,6 @@ +contract C { + function f() {} + uint[f] ids; +} +// ---- +// TypeError: (42-43): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/cannot_be_function_call.sol b/test/libsolidity/syntaxTests/arrayLength/cannot_be_function_call.sol new file mode 100644 index 00000000..a6863955 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/cannot_be_function_call.sol @@ -0,0 +1,7 @@ +contract C { + function f(uint x) {} + uint constant LEN = f(); + uint[LEN] ids; +} +// ---- +// TypeError: (77-80): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/complex_cyclic_constant.sol b/test/libsolidity/syntaxTests/arrayLength/complex_cyclic_constant.sol new file mode 100644 index 00000000..254f9f02 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/complex_cyclic_constant.sol @@ -0,0 +1,10 @@ +contract C { + uint constant L2 = LEN - 10; + uint constant L1 = L2 / 10; + uint constant LEN = 10 + L1 * 5; + function f() { + uint[LEN] a; + } +} +// ---- +// TypeError: (36-39): Cyclic constant definition (or maximum recursion depth exhausted). diff --git a/test/libsolidity/syntaxTests/arrayLength/const_cannot_be_fractional.sol b/test/libsolidity/syntaxTests/arrayLength/const_cannot_be_fractional.sol new file mode 100644 index 00000000..397bbbcd --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/const_cannot_be_fractional.sol @@ -0,0 +1,6 @@ +contract C { + fixed constant L = 10.5; + uint[L] ids; +} +// ---- +// TypeError: (51-52): Array with fractional length specified. diff --git a/test/libsolidity/syntaxTests/arrayLength/constant_var.sol b/test/libsolidity/syntaxTests/arrayLength/constant_var.sol new file mode 100644 index 00000000..41750250 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/constant_var.sol @@ -0,0 +1,5 @@ +contract C { + uint constant LEN = 10; + uint[LEN] ids; +} +// ----
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/arrayLength/cyclic_constant.sol b/test/libsolidity/syntaxTests/arrayLength/cyclic_constant.sol new file mode 100644 index 00000000..91ba9045 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/cyclic_constant.sol @@ -0,0 +1,8 @@ +contract C { + uint constant LEN = LEN; + function f() { + uint[LEN] a; + } +} +// ---- +// TypeError: (37-40): Cyclic constant definition (or maximum recursion depth exhausted). diff --git a/test/libsolidity/syntaxTests/arrayLength/inline_array.sol b/test/libsolidity/syntaxTests/arrayLength/inline_array.sol new file mode 100644 index 00000000..a30745d3 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/inline_array.sol @@ -0,0 +1,5 @@ +contract C { + uint[[2]] a15; +} +// ---- +// TypeError: (22-25): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_1.sol b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_1.sol new file mode 100644 index 00000000..c92861eb --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_1.sol @@ -0,0 +1,5 @@ +contract C { + uint[-true] ids; +} +// ---- +// TypeError: (22-27): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_2.sol b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_2.sol new file mode 100644 index 00000000..92e3c3cf --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_2.sol @@ -0,0 +1,5 @@ +contract C { + uint[true/1] ids; +} +// ---- +// TypeError: (22-28): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_3.sol b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_3.sol new file mode 100644 index 00000000..26add45c --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_3.sol @@ -0,0 +1,5 @@ +contract C { + uint[1/true] ids; +} +// ---- +// TypeError: (22-28): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_4.sol b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_4.sol new file mode 100644 index 00000000..a0d58f4a --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_4.sol @@ -0,0 +1,5 @@ +contract C { + uint[1.111111E1111111111111] ids; +} +// ---- +// TypeError: (22-44): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_5.sol b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_5.sol new file mode 100644 index 00000000..38a80867 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_5.sol @@ -0,0 +1,5 @@ +contract C { + uint[3/0] ids; +} +// ---- +// TypeError: (22-25): Operator / not compatible with types int_const 3 and int_const 0 diff --git a/test/libsolidity/syntaxTests/arrayLength/non_integer_constant_var.sol b/test/libsolidity/syntaxTests/arrayLength/non_integer_constant_var.sol new file mode 100644 index 00000000..7a853a34 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/non_integer_constant_var.sol @@ -0,0 +1,6 @@ +contract C { + bool constant LEN = true; + uint[LEN] ids; +} +// ---- +// TypeError: (52-55): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/not_convertible_to_integer.sol b/test/libsolidity/syntaxTests/arrayLength/not_convertible_to_integer.sol new file mode 100644 index 00000000..b44ccfe9 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/not_convertible_to_integer.sol @@ -0,0 +1,5 @@ +contract C { + uint[true] ids; +} +// ---- +// TypeError: (22-26): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/parentheses.sol b/test/libsolidity/syntaxTests/arrayLength/parentheses.sol new file mode 100644 index 00000000..40f55ad6 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/parentheses.sol @@ -0,0 +1,25 @@ +contract C { + uint constant L1 = (2); + uint constant L2 = ((2)); + uint constant L3 = ((((2)))); + uint constant L4 = (2 + 1); + uint constant L5 = ((2 + 1)); + uint constant L6 = (((2) + ((1)))); + uint constant L7 = (2 + 1) / 1; + uint constant L8 = (2 + ((1))) / (1); + uint[L1] a1; + uint[L2] a2; + uint[L3] a3; + uint[L4] a4; + uint[L5] a5; + uint[L6] a6; + uint[L7] a7; + uint[L8] a8; + uint[(2)] a9; + uint[(2 + 1)] a10; + uint[(2 + 1) + 1] a11; + uint[((2) + 1) + 1] a12; + uint[(2 + 1) + ((1))] a13; + uint[(((2) + 1)) + (((1)))] a14; + uint[((((2) + 1)) + (((1))))%1] a15; +} diff --git a/test/libsolidity/syntaxTests/arrayLength/pure_functions.sol b/test/libsolidity/syntaxTests/arrayLength/pure_functions.sol new file mode 100644 index 00000000..b620db76 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/pure_functions.sol @@ -0,0 +1,6 @@ +contract C { + uint constant LEN = keccak256(ripemd160(33)); + uint[LEN] ids; +} +// ---- +// TypeError: (72-75): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/too_large.sol b/test/libsolidity/syntaxTests/arrayLength/too_large.sol new file mode 100644 index 00000000..c90a7494 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/too_large.sol @@ -0,0 +1,5 @@ +contract C { + uint[8**90] ids; +} +// ---- +// TypeError: (22-27): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/tuples.sol b/test/libsolidity/syntaxTests/arrayLength/tuples.sol new file mode 100644 index 00000000..bc10b3b5 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/tuples.sol @@ -0,0 +1,5 @@ +contract C { + uint[(1,2)] a15; +} +// ---- +// TypeError: (22-27): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_1.sol b/test/libsolidity/syntaxTests/constants/cyclic_dependency_1.sol new file mode 100644 index 00000000..cb553fbe --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/cyclic_dependency_1.sol @@ -0,0 +1,5 @@ +contract C { + uint constant a = a; +} +// ---- +// TypeError: (17-36): The value of the constant a has a cyclic dependency via a. diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_2.sol b/test/libsolidity/syntaxTests/constants/cyclic_dependency_2.sol new file mode 100644 index 00000000..00f9bb0f --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/cyclic_dependency_2.sol @@ -0,0 +1,10 @@ +contract C { + uint constant a = b * c; + uint constant b = 7; + uint constant c = b + uint(keccak256(d)); + uint constant d = 2 + a; +} +// ---- +// TypeError: (17-40): The value of the constant a has a cyclic dependency via c. +// TypeError: (71-111): The value of the constant c has a cyclic dependency via d. +// TypeError: (117-140): The value of the constant d has a cyclic dependency via a. diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_3.sol b/test/libsolidity/syntaxTests/constants/cyclic_dependency_3.sol new file mode 100644 index 00000000..969ed50d --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/cyclic_dependency_3.sol @@ -0,0 +1,11 @@ +contract C { + uint constant x = a; + uint constant a = b * c; + uint constant b = c; + uint constant c = b; +} +// ---- +// TypeError: (17-36): The value of the constant x has a cyclic dependency via a. +// TypeError: (42-65): The value of the constant a has a cyclic dependency via b. +// TypeError: (71-90): The value of the constant b has a cyclic dependency via c. +// TypeError: (96-115): The value of the constant c has a cyclic dependency via b. diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_4.sol b/test/libsolidity/syntaxTests/constants/cyclic_dependency_4.sol new file mode 100644 index 00000000..f01cb98e --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/cyclic_dependency_4.sol @@ -0,0 +1,6 @@ +contract C { + uint constant a = b * c; + uint constant b = 7; + uint constant c = 4 + uint(keccak256(d)); + uint constant d = 2 + b; +}
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/double_stateVariable_declaration.sol b/test/libsolidity/syntaxTests/double_stateVariable_declaration.sol index c5507b64..fda4a17a 100644 --- a/test/libsolidity/syntaxTests/double_stateVariable_declaration.sol +++ b/test/libsolidity/syntaxTests/double_stateVariable_declaration.sol @@ -3,4 +3,4 @@ contract test { uint128 variable; } // ---- -// DeclarationError: Identifier already declared. +// DeclarationError: (36-52): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/double_variable_declaration.sol b/test/libsolidity/syntaxTests/double_variable_declaration.sol index 3349cfec..9ab87959 100644 --- a/test/libsolidity/syntaxTests/double_variable_declaration.sol +++ b/test/libsolidity/syntaxTests/double_variable_declaration.sol @@ -5,4 +5,4 @@ contract test { } } // ---- -// DeclarationError: Identifier already declared. +// DeclarationError: (71-80): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/double_variable_declaration_050.sol b/test/libsolidity/syntaxTests/double_variable_declaration_050.sol index 9c2d40d5..2f47e6dc 100644 --- a/test/libsolidity/syntaxTests/double_variable_declaration_050.sol +++ b/test/libsolidity/syntaxTests/double_variable_declaration_050.sol @@ -6,6 +6,6 @@ contract test { } } // ---- -// Warning: This declaration shadows an existing declaration. -// Warning: Unused local variable. -// Warning: Unused local variable. +// Warning: (101-110): This declaration shadows an existing declaration. +// Warning: (76-85): Unused local variable. +// Warning: (101-110): Unused local variable. diff --git a/test/libsolidity/syntaxTests/empty_struct.sol b/test/libsolidity/syntaxTests/empty_struct.sol index dcced618..12655309 100644 --- a/test/libsolidity/syntaxTests/empty_struct.sol +++ b/test/libsolidity/syntaxTests/empty_struct.sol @@ -2,4 +2,4 @@ contract test { struct A {} } // ---- -// Warning: Defining empty structs is deprecated. +// Warning: (17-28): Defining empty structs is deprecated. diff --git a/test/libsolidity/syntaxTests/empty_struct_050.sol b/test/libsolidity/syntaxTests/empty_struct_050.sol index dbec93c4..886f1f83 100644 --- a/test/libsolidity/syntaxTests/empty_struct_050.sol +++ b/test/libsolidity/syntaxTests/empty_struct_050.sol @@ -3,4 +3,4 @@ contract test { struct A {} } // ---- -// SyntaxError: Defining empty structs is disallowed. +// SyntaxError: (47-58): Defining empty structs is disallowed. diff --git a/test/libsolidity/syntaxTests/functionTypes/call_value_on_non_payable_function_type.sol b/test/libsolidity/syntaxTests/functionTypes/call_value_on_non_payable_function_type.sol new file mode 100644 index 00000000..87c3b05b --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/call_value_on_non_payable_function_type.sol @@ -0,0 +1,8 @@ +contract C { + function (uint) external returns (uint) x; + function f() public { + x.value(2)(); + } +} +// ---- +// TypeError: (94-101): Member "value" not found or not visible after argument-dependent lookup in function (uint256) external returns (uint256) - did you forget the "payable" modifier? diff --git a/test/libsolidity/syntaxTests/functionTypes/call_value_on_payable_function_type.sol b/test/libsolidity/syntaxTests/functionTypes/call_value_on_payable_function_type.sol new file mode 100644 index 00000000..ca2a0196 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/call_value_on_payable_function_type.sol @@ -0,0 +1,6 @@ +contract C { + function (uint) external payable returns (uint) x; + function f() public { + x.value(2)(1); + } +} diff --git a/test/libsolidity/syntaxTests/functionTypes/delete_external_function_type_invalid.sol b/test/libsolidity/syntaxTests/functionTypes/delete_external_function_type_invalid.sol new file mode 100644 index 00000000..2711dae8 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/delete_external_function_type_invalid.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + delete this.f; + } +} +// ---- +// TypeError: (54-60): Expression has to be an lvalue. diff --git a/test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol b/test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol new file mode 100644 index 00000000..a6fe6c22 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol @@ -0,0 +1,17 @@ +contract C { + function(uint) external returns (uint) x; + function(uint) internal returns (uint) y; + function f() public { + delete x; + var a = y; + delete a; + delete y; + var c = f; + delete c; + function(uint) internal returns (uint) g; + delete g; + } +} +// ---- +// Warning: (157-162): Use of the "var" keyword is deprecated. +// Warning: (212-217): Use of the "var" keyword is deprecated. diff --git a/test/libsolidity/syntaxTests/functionTypes/delete_function_type_invalid.sol b/test/libsolidity/syntaxTests/functionTypes/delete_function_type_invalid.sol new file mode 100644 index 00000000..60da19e4 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/delete_function_type_invalid.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + delete f; + } +} +// ---- +// TypeError: (54-55): Expression has to be an lvalue. diff --git a/test/libsolidity/syntaxTests/functionTypes/external_function_to_function_type_calldata_parameter.sol b/test/libsolidity/syntaxTests/functionTypes/external_function_to_function_type_calldata_parameter.sol new file mode 100644 index 00000000..eb4f0693 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/external_function_to_function_type_calldata_parameter.sol @@ -0,0 +1,10 @@ +// This is a test that checks that the type of the `bytes` parameter is +// correctly changed from its own type `bytes calldata` to `bytes memory` +// when converting to a function type. +contract C { + function f(function(bytes memory) pure external /*g*/) pure public { } + function callback(bytes) pure external {} + function g() view public { + f(this.callback); + } +} diff --git a/test/libsolidity/syntaxTests/functionTypes/external_function_type_public_variable.sol b/test/libsolidity/syntaxTests/functionTypes/external_function_type_public_variable.sol new file mode 100644 index 00000000..0a6d1e53 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/external_function_type_public_variable.sol @@ -0,0 +1,11 @@ +contract C { + function (uint) external public x; + + function g(uint) public { + x = this.g; + } + function f() public view returns (function(uint) external) { + return this.x(); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/functionTypes/external_function_type_returning_internal.sol b/test/libsolidity/syntaxTests/functionTypes/external_function_type_returning_internal.sol new file mode 100644 index 00000000..8b14d3dc --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/external_function_type_returning_internal.sol @@ -0,0 +1,5 @@ +contract C { + function() external returns (function () internal) x; +} +// ---- +// TypeError: (46-67): Internal type cannot be used for external function type. diff --git a/test/libsolidity/syntaxTests/functionTypes/external_function_type_taking_internal.sol b/test/libsolidity/syntaxTests/functionTypes/external_function_type_taking_internal.sol new file mode 100644 index 00000000..3e264c8c --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/external_function_type_taking_internal.sol @@ -0,0 +1,5 @@ +contract C { + function(function () internal) external x; +} +// ---- +// TypeError: (26-47): Internal type cannot be used for external function type. diff --git a/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_address.sol b/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_address.sol new file mode 100644 index 00000000..b86425db --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_address.sol @@ -0,0 +1,5 @@ +contract C { + function f() public view returns (address) { + return address(this.f); + } +} diff --git a/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_uint.sol b/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_uint.sol new file mode 100644 index 00000000..f4287223 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_uint.sol @@ -0,0 +1,7 @@ +contract C { + function f() public returns (uint) { + return uint(this.f); + } +} +// ---- +// TypeError: (69-81): Explicit type conversion not allowed from "function () external returns (uint256)" to "uint256". diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type.sol b/test/libsolidity/syntaxTests/functionTypes/function_type.sol new file mode 100644 index 00000000..23d50136 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_type.sol @@ -0,0 +1,6 @@ +contract C { + function f() pure public { + function(uint) returns (uint) x; + x; + } +} diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_arrays.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_arrays.sol new file mode 100644 index 00000000..ec23d637 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_arrays.sol @@ -0,0 +1,11 @@ +contract C { + function(uint) external returns (uint)[] public x; + function(uint) internal returns (uint)[10] y; + function f() view public { + function(uint) returns (uint)[10] memory a; + function(uint) returns (uint)[10] storage b = y; + function(uint) external returns (uint)[] memory c; + c = new function(uint) external returns (uint)[](200); + a; b; + } +} diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_constructor.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_constructor.sol new file mode 100644 index 00000000..95ebc179 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_constructor.sol @@ -0,0 +1,7 @@ +contract C { + // Fool parser into parsing a constructor as a function type. + constructor() x; +} +// ---- +// Warning: (83-99): Modifiers of functions without implementation are ignored. +// DeclarationError: (97-98): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_constructor_local.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_constructor_local.sol new file mode 100644 index 00000000..b7763d28 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_constructor_local.sol @@ -0,0 +1,8 @@ +contract C { + // Fool parser into parsing a constructor as a function type. + function f() { + constructor() x; + } +} +// ---- +// ParserError: (118-118): Expected token Semicolon got 'Identifier' diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_internal_public_variable.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_internal_public_variable.sol new file mode 100644 index 00000000..4eb53227 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_internal_public_variable.sol @@ -0,0 +1,5 @@ +contract C { + function(bytes memory) internal public a; +} +// ---- +// TypeError: (17-57): Internal or recursive type is not allowed for public state variables. diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_parameter.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_parameter.sol new file mode 100644 index 00000000..da66ec8a --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_parameter.sol @@ -0,0 +1,7 @@ +contract C { + uint x; + function f(function(uint) external returns (uint) g) public returns (function(uint) external returns (uint)) { + x = 2; + return g; + } +} diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_returned.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_returned.sol new file mode 100644 index 00000000..9cd313c8 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_returned.sol @@ -0,0 +1,5 @@ +contract C { + function f() public pure returns (function(uint) pure external returns (uint) g) { + return g; + } +} diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_variable_external_internal.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_variable_external_internal.sol new file mode 100644 index 00000000..f0240472 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_variable_external_internal.sol @@ -0,0 +1,6 @@ +contract test { + function fa(bytes memory) public { } + function(bytes memory) external internal a = fa; +} +// ---- +// TypeError: (106-108): Type function (bytes memory) is not implicitly convertible to expected type function (bytes memory) external. diff --git a/test/libsolidity/syntaxTests/functionTypes/function_types_internal_visibility_error.sol b/test/libsolidity/syntaxTests/functionTypes/function_types_internal_visibility_error.sol new file mode 100644 index 00000000..36206d63 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_types_internal_visibility_error.sol @@ -0,0 +1,7 @@ +contract C { + // This is an error, you should explicitly use + // `external public` to fix it - `internal public` does not exist. + function(bytes memory) public a; +} +// ---- +// TypeError: (139-170): Invalid visibility, can only be "external" or "internal". diff --git a/test/libsolidity/syntaxTests/functionTypes/function_types_variable_visibility.sol b/test/libsolidity/syntaxTests/functionTypes/function_types_variable_visibility.sol new file mode 100644 index 00000000..91c2420a --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_types_variable_visibility.sol @@ -0,0 +1,9 @@ +contract C { + function(bytes memory) a1; + function(bytes memory) internal b1; + function(bytes memory) internal internal b2; + function(bytes memory) external c1; + function(bytes memory) external internal c2; + function(bytes memory) external public c3; +} +// ---- diff --git a/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter.sol b/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter.sol new file mode 100644 index 00000000..fa92d559 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter.sol @@ -0,0 +1,8 @@ +// It should not be possible to give internal functions +// as parameters to external functions. +contract C { + function f(function(uint) internal returns (uint) x) public { + } +} +// ---- +// TypeError: (124-164): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter_in_library_external.sol b/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter_in_library_external.sol new file mode 100644 index 00000000..b37fb285 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter_in_library_external.sol @@ -0,0 +1,6 @@ +library L { + function f(function(uint) internal returns (uint) x) public { + } +} +// ---- +// TypeError: (27-67): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter_in_library_internal.sol b/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter_in_library_internal.sol new file mode 100644 index 00000000..7ffa447e --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter_in_library_internal.sol @@ -0,0 +1,4 @@ +library L { + function f(function(uint) internal returns (uint) /*x*/) pure internal { + } +} diff --git a/test/libsolidity/syntaxTests/functionTypes/internal_function_returned_from_public_function.sol b/test/libsolidity/syntaxTests/functionTypes/internal_function_returned_from_public_function.sol new file mode 100644 index 00000000..41fcd0a4 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/internal_function_returned_from_public_function.sol @@ -0,0 +1,7 @@ +// It should not be possible to return internal functions from external functions. +contract C { + function f() public returns (function(uint) internal returns (uint) x) { + } +} +// ---- +// TypeError: (129-169): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/functionTypes/internal_function_type_to_address.sol b/test/libsolidity/syntaxTests/functionTypes/internal_function_type_to_address.sol new file mode 100644 index 00000000..b75a0d43 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/internal_function_type_to_address.sol @@ -0,0 +1,7 @@ +contract C { + function f() public returns (address) { + return address(f); + } +} +// ---- +// TypeError: (72-82): Explicit type conversion not allowed from "function () returns (address)" to "address". diff --git a/test/libsolidity/syntaxTests/functionTypes/payable_internal_function_type.sol b/test/libsolidity/syntaxTests/functionTypes/payable_internal_function_type.sol new file mode 100644 index 00000000..a7cb9d92 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/payable_internal_function_type.sol @@ -0,0 +1,5 @@ +contract C { + function (uint) internal payable returns (uint) x; +} +// ---- +// TypeError: (17-66): Only external function types can be payable. diff --git a/test/libsolidity/syntaxTests/functionTypes/payable_internal_function_type_is_not_fatal.sol b/test/libsolidity/syntaxTests/functionTypes/payable_internal_function_type_is_not_fatal.sol new file mode 100644 index 00000000..5c6dc056 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/payable_internal_function_type_is_not_fatal.sol @@ -0,0 +1,9 @@ +contract C { + function (uint) internal payable returns (uint) x; + + function g() public { + x = g; + } +} +// ---- +// TypeError: (17-66): Only external function types can be payable. diff --git a/test/libsolidity/syntaxTests/functionTypes/private_function_type.sol b/test/libsolidity/syntaxTests/functionTypes/private_function_type.sol new file mode 100644 index 00000000..9d4f0a09 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/private_function_type.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + function(uint) private returns (uint) x; + } +} +// ---- +// TypeError: (47-86): Invalid visibility, can only be "external" or "internal". diff --git a/test/libsolidity/syntaxTests/functionTypes/public_function_type.sol b/test/libsolidity/syntaxTests/functionTypes/public_function_type.sol new file mode 100644 index 00000000..756766d3 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/public_function_type.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + function(uint) public returns (uint) x; + } +} +// ---- +// TypeError: (47-85): Invalid visibility, can only be "external" or "internal". diff --git a/test/libsolidity/syntaxTests/functionTypes/valid_function_type_variables.sol b/test/libsolidity/syntaxTests/functionTypes/valid_function_type_variables.sol new file mode 100644 index 00000000..10c6767c --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/valid_function_type_variables.sol @@ -0,0 +1,23 @@ +contract test { + function fa(uint) {} + function fb(uint) internal {} + function fc(uint) internal {} + function fd(uint) external {} + function fe(uint) external {} + function ff(uint) internal {} + function fg(uint) internal pure {} + function fh(uint) pure internal {} + + function(uint) a = fa; + function(uint) internal b = fb; // (explicit internal applies to the function type) + function(uint) internal internal c = fc; + function(uint) external d = this.fd; + function(uint) external internal e = this.fe; + function(uint) internal public f = ff; + function(uint) internal pure public g = fg; + function(uint) pure internal public h = fh; +} +// ---- +// TypeError: (545-582): Internal or recursive type is not allowed for public state variables. +// TypeError: (588-630): Internal or recursive type is not allowed for public state variables. +// TypeError: (636-678): Internal or recursive type is not allowed for public state variables. diff --git a/test/libsolidity/syntaxTests/functionTypes/warn_function_type_parameters_with_names.sol b/test/libsolidity/syntaxTests/functionTypes/warn_function_type_parameters_with_names.sol new file mode 100644 index 00000000..072c7eb7 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/warn_function_type_parameters_with_names.sol @@ -0,0 +1,5 @@ +contract C { + function(uint a) f; +} +// ---- +// Warning: (26-32): Naming function type parameters is deprecated. diff --git a/test/libsolidity/syntaxTests/functionTypes/warn_function_type_return_parameters_with_names.sol b/test/libsolidity/syntaxTests/functionTypes/warn_function_type_return_parameters_with_names.sol new file mode 100644 index 00000000..67a74e54 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/warn_function_type_return_parameters_with_names.sol @@ -0,0 +1,5 @@ +contract C { + function(uint) returns (bool ret) f; +} +// ---- +// Warning: (41-49): Naming function type return parameters is deprecated. diff --git a/test/libsolidity/syntaxTests/inheritance/allow_empty_duplicated_super_constructor_call.sol b/test/libsolidity/syntaxTests/inheritance/allow_empty_duplicated_super_constructor_call.sol new file mode 100644 index 00000000..ce9d5f5f --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/allow_empty_duplicated_super_constructor_call.sol @@ -0,0 +1,2 @@ +contract A { constructor() public { } } +contract B is A { constructor() A() public { } } diff --git a/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol b/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol index 76df0657..0b18b995 100644 --- a/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol +++ b/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol @@ -1,6 +1,7 @@ contract Base { - function Base(uint) public {} + constructor(uint) public {} } contract Derived is Base(2) { } contract Derived2 is Base(), Derived() { } -contract Derived3 is Base, Derived {} +// ---- +// Warning: (101-107): Wrong argument count for constructor call: 0 arguments given but expected 1. diff --git a/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses_V050.sol b/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses_V050.sol new file mode 100644 index 00000000..db04ab8c --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses_V050.sol @@ -0,0 +1,9 @@ +pragma experimental "v0.5.0"; + +contract Base { + constructor(uint) public {} +} +contract Derived is Base(2) { } +contract Derived2 is Base(), Derived() { } +// ---- +// TypeError: (132-138): Wrong argument count for constructor call: 0 arguments given but expected 1. diff --git a/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol b/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol new file mode 100644 index 00000000..015b33e5 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol @@ -0,0 +1,9 @@ +contract Base { + constructor(uint) public { } +} +contract Base1 is Base(3) {} +contract Derived is Base, Base1 { + constructor(uint i) Base(i) public {} +} +// ---- +// Warning: (138-145): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/base_arguments_no_parentheses.sol b/test/libsolidity/syntaxTests/inheritance/base_arguments_no_parentheses.sol new file mode 100644 index 00000000..24cca8f0 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/base_arguments_no_parentheses.sol @@ -0,0 +1,5 @@ +contract Base { + constructor(uint) public {} +} +contract Derived is Base(2) { } +contract Derived2 is Base, Derived {} diff --git a/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol b/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol new file mode 100644 index 00000000..6cf68d2a --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol @@ -0,0 +1,4 @@ +contract A { constructor() public { } } +contract B is A { constructor() A public { } } +// ---- +// Warning: (72-73): Modifier-style base constructor call without arguments. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol new file mode 100644 index 00000000..24cff54d --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol @@ -0,0 +1,5 @@ +contract A { constructor(uint) public { } } +contract B is A(2) { constructor() public { } } +contract C is B { constructor() A(3) public { } } +// ---- +// Warning: (125-129): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol new file mode 100644 index 00000000..8d5df5bf --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol @@ -0,0 +1,7 @@ +pragma experimental "v0.5.0"; + +contract A { constructor(uint) public { } } +contract B is A(2) { constructor() public { } } +contract C is B { constructor() A(3) public { } } +// ---- +// DeclarationError: (156-160): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol new file mode 100644 index 00000000..9ceaea5e --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol @@ -0,0 +1,4 @@ +contract A { constructor(uint) public { } } +contract B is A(2) { constructor() A(3) public { } } +// ---- +// Warning: (79-83): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_V050.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_V050.sol new file mode 100644 index 00000000..f9325f99 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_V050.sol @@ -0,0 +1,6 @@ +pragma experimental "v0.5.0"; + +contract A { constructor(uint) public { } } +contract B is A(2) { constructor() A(3) public { } } +// ---- +// DeclarationError: (110-114): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol new file mode 100644 index 00000000..e5c2aa36 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol @@ -0,0 +1,7 @@ +contract C { constructor(uint) public {} } +contract A is C(2) {} +contract B is C(2) {} +contract D is A, B { constructor() C(3) public {} } +// ---- +// Warning: (122-126): Base constructor arguments given twice. +// Warning: (122-126): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol new file mode 100644 index 00000000..1abf2992 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol @@ -0,0 +1,6 @@ +contract C { constructor(uint) public {} } +contract A is C(2) {} +contract B is C(2) {} +contract D is A, B {} +// ---- +// Warning: (87-108): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol new file mode 100644 index 00000000..e15242db --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol @@ -0,0 +1,6 @@ +contract C { constructor(uint) public {} } +contract A is C { constructor() C(2) public {} } +contract B is C { constructor() C(2) public {} } +contract D is A, B { } +// ---- +// Warning: (141-163): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol b/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol index 82aba308..c55c41f2 100644 --- a/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol +++ b/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol @@ -1,10 +1,10 @@ contract Base { - function Base(uint, uint) public {} + constructor(uint, uint) public {} } contract Derived is Base(2) { } contract Derived2 is Base { - function Derived2() Base(2) public { } + constructor() Base(2) public { } } // ---- -// TypeError: Wrong argument count for constructor call: 1 arguments given but expected 2. -// TypeError: Wrong argument count for modifier invocation: 1 arguments given but expected 2. +// TypeError: (74-81): Wrong argument count for constructor call: 1 arguments given but expected 2. +// TypeError: (130-137): Wrong argument count for modifier invocation: 1 arguments given but expected 2. diff --git a/test/libsolidity/syntaxTests/literal_comparisons.sol b/test/libsolidity/syntaxTests/literal_comparisons.sol new file mode 100644 index 00000000..dd2afcaa --- /dev/null +++ b/test/libsolidity/syntaxTests/literal_comparisons.sol @@ -0,0 +1,7 @@ +contract test { + function f(int8 x) public pure { + if (x == 1) {} + if (1 == x) {} + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol b/test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol new file mode 100644 index 00000000..bdbab5d8 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol @@ -0,0 +1,7 @@ +contract C { constructor(uint a) public {} } +contract B is C { + constructor() C(2) C(2) public {} +} +// ---- +// Warning: (81-85): Base constructor arguments given twice. +// DeclarationError: (86-90): Base constructor already provided. diff --git a/test/libsolidity/syntaxTests/modifiers/constructor_call_invalid_arg_count.sol b/test/libsolidity/syntaxTests/modifiers/constructor_call_invalid_arg_count.sol new file mode 100644 index 00000000..4a2b5c4a --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/constructor_call_invalid_arg_count.sol @@ -0,0 +1,9 @@ +// This caused a segfault in an earlier version +contract C { + constructor() public {} +} +contract D is C { + constructor() C(5) public {} +} +// ---- +// TypeError: (127-131): Wrong argument count for modifier invocation: 1 arguments given but expected 0. diff --git a/test/libsolidity/syntaxTests/modifiers/function_modifier_double_invocation.sol b/test/libsolidity/syntaxTests/modifiers/function_modifier_double_invocation.sol new file mode 100644 index 00000000..75624192 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/function_modifier_double_invocation.sol @@ -0,0 +1,4 @@ +contract B { + function f(uint x) mod(x) mod(2) public pure { } + modifier mod(uint a) { if (a > 0) _; } +} diff --git a/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation.sol b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation.sol new file mode 100644 index 00000000..e15fcf49 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation.sol @@ -0,0 +1,5 @@ +contract B { + function f() mod1(2, true) mod2("0123456") pure public { } + modifier mod1(uint a, bool b) { if (b) _; } + modifier mod2(bytes7 a) { while (a == "1234567") _; } +} diff --git a/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables.sol b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables.sol new file mode 100644 index 00000000..00031924 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables.sol @@ -0,0 +1,4 @@ +contract B { + function f() mod(x) pure public { uint x = 7; } + modifier mod(uint a) { if (a > 0) _; } +} diff --git a/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables050.sol b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables050.sol new file mode 100644 index 00000000..c19ccf2c --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables050.sol @@ -0,0 +1,7 @@ +pragma experimental "v0.5.0"; +contract B { + function f() mod(x) pure public { uint x = 7; } + modifier mod(uint a) { if (a > 0) _; } +} +// ---- +// DeclarationError: (64-65): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_parameters.sol b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_parameters.sol new file mode 100644 index 00000000..de2a8f48 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_parameters.sol @@ -0,0 +1,5 @@ +contract B { + function f(uint8 a) mod1(a, true) mod2(r) pure public returns (bytes7 r) { } + modifier mod1(uint a, bool b) { if (b) _; } + modifier mod2(bytes7 a) { while (a == "1234567") _; } +} diff --git a/test/libsolidity/syntaxTests/modifiers/function_overrides_modifier.sol b/test/libsolidity/syntaxTests/modifiers/function_overrides_modifier.sol new file mode 100644 index 00000000..a64c2790 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/function_overrides_modifier.sol @@ -0,0 +1,5 @@ +contract A { function mod(uint a) public { } } +contract B is A { modifier mod(uint a) { _; } } +// ---- +// DeclarationError: (65-92): Identifier already declared. +// TypeError: (65-92): Override changes function to modifier. diff --git a/test/libsolidity/syntaxTests/modifiers/illegal_modifier_override.sol b/test/libsolidity/syntaxTests/modifiers/illegal_modifier_override.sol new file mode 100644 index 00000000..958be686 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/illegal_modifier_override.sol @@ -0,0 +1,4 @@ +contract A { modifier mod(uint a) { _; } } +contract B is A { modifier mod(uint8 a) { _; } } +// ---- +// TypeError: (61-89): Override changes modifier signature. diff --git a/test/libsolidity/syntaxTests/modifiers/invalid_function_modifier_type.sol b/test/libsolidity/syntaxTests/modifiers/invalid_function_modifier_type.sol new file mode 100644 index 00000000..c1e3108b --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/invalid_function_modifier_type.sol @@ -0,0 +1,6 @@ +contract B { + function f() mod1(true) public { } + modifier mod1(uint a) { if (a > 0) _; } +} +// ---- +// TypeError: (35-39): Invalid type for argument in modifier invocation. Invalid implicit conversion from bool to uint256 requested. diff --git a/test/libsolidity/syntaxTests/modifiers/legal_modifier_override.sol b/test/libsolidity/syntaxTests/modifiers/legal_modifier_override.sol new file mode 100644 index 00000000..51c3fd80 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/legal_modifier_override.sol @@ -0,0 +1,2 @@ +contract A { modifier mod(uint a) { _; } } +contract B is A { modifier mod(uint a) { _; } } diff --git a/test/libsolidity/syntaxTests/modifiers/modifier_overrides_function.sol b/test/libsolidity/syntaxTests/modifiers/modifier_overrides_function.sol new file mode 100644 index 00000000..a43646c3 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/modifier_overrides_function.sol @@ -0,0 +1,5 @@ +contract A { modifier mod(uint a) { _; } } +contract B is A { function mod(uint a) public { } } +// ---- +// DeclarationError: (61-92): Identifier already declared. +// TypeError: (13-40): Override changes modifier to function. diff --git a/test/libsolidity/syntaxTests/modifiers/modifier_returns_value.sol b/test/libsolidity/syntaxTests/modifiers/modifier_returns_value.sol new file mode 100644 index 00000000..d22e836c --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/modifier_returns_value.sol @@ -0,0 +1,6 @@ +contract A { + function f(uint a) mod(2) public returns (uint r) { } + modifier mod(uint a) { _; return 7; } +} +// ---- +// TypeError: (101-109): Return arguments not allowed. diff --git a/test/libsolidity/syntaxTests/modifiers/modifier_without_underscore.sol b/test/libsolidity/syntaxTests/modifiers/modifier_without_underscore.sol new file mode 100644 index 00000000..6198d3c5 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/modifier_without_underscore.sol @@ -0,0 +1,5 @@ +contract test { + modifier m() {} +} +// ---- +// SyntaxError: (33-35): Modifier body does not contain '_'. diff --git a/test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_050.sol b/test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_050.sol new file mode 100644 index 00000000..af1babbc --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_050.sol @@ -0,0 +1,10 @@ +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/modifiers/modifiers_on_abstract_functions_no_parser_error.sol b/test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_no_parser_error.sol new file mode 100644 index 00000000..e18c5cf9 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_no_parser_error.sol @@ -0,0 +1,13 @@ +// Previous versions of Solidity turned this +// into a parser error (they wrongly recognized +// these functions as state variables of +// function type). +contract C +{ + modifier only_owner() { _; } + function foo() only_owner public; + function bar() public only_owner; +} +// ---- +// Warning: (203-236): Modifiers of functions without implementation are ignored. +// Warning: (241-274): Modifiers of functions without implementation are ignored. diff --git a/test/libsolidity/syntaxTests/more_than_256_declarationerrors.sol b/test/libsolidity/syntaxTests/more_than_256_declarationerrors.sol new file mode 100644 index 00000000..2d75f29b --- /dev/null +++ b/test/libsolidity/syntaxTests/more_than_256_declarationerrors.sol @@ -0,0 +1,524 @@ +contract C { + function f() { + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + } +} +// ---- +// DeclarationError: (34-35): Undeclared identifier. +// DeclarationError: (45-46): Undeclared identifier. +// DeclarationError: (56-57): Undeclared identifier. +// DeclarationError: (67-68): Undeclared identifier. +// DeclarationError: (78-79): Undeclared identifier. +// DeclarationError: (89-90): Undeclared identifier. +// DeclarationError: (100-101): Undeclared identifier. +// DeclarationError: (111-112): Undeclared identifier. +// DeclarationError: (122-123): Undeclared identifier. +// DeclarationError: (133-134): Undeclared identifier. +// DeclarationError: (144-145): Undeclared identifier. +// DeclarationError: (155-156): Undeclared identifier. +// DeclarationError: (166-167): Undeclared identifier. +// DeclarationError: (177-178): Undeclared identifier. +// DeclarationError: (188-189): Undeclared identifier. +// DeclarationError: (199-200): Undeclared identifier. +// DeclarationError: (210-211): Undeclared identifier. +// DeclarationError: (221-222): Undeclared identifier. +// DeclarationError: (232-233): Undeclared identifier. +// DeclarationError: (243-244): Undeclared identifier. +// DeclarationError: (254-255): Undeclared identifier. +// DeclarationError: (265-266): Undeclared identifier. +// DeclarationError: (276-277): Undeclared identifier. +// DeclarationError: (287-288): Undeclared identifier. +// DeclarationError: (298-299): Undeclared identifier. +// DeclarationError: (309-310): Undeclared identifier. +// DeclarationError: (320-321): Undeclared identifier. +// DeclarationError: (331-332): Undeclared identifier. +// DeclarationError: (342-343): Undeclared identifier. +// DeclarationError: (353-354): Undeclared identifier. +// DeclarationError: (364-365): Undeclared identifier. +// DeclarationError: (375-376): Undeclared identifier. +// DeclarationError: (386-387): Undeclared identifier. +// DeclarationError: (397-398): Undeclared identifier. +// DeclarationError: (408-409): Undeclared identifier. +// DeclarationError: (419-420): Undeclared identifier. +// DeclarationError: (430-431): Undeclared identifier. +// DeclarationError: (441-442): Undeclared identifier. +// DeclarationError: (452-453): Undeclared identifier. +// DeclarationError: (463-464): Undeclared identifier. +// DeclarationError: (474-475): Undeclared identifier. +// DeclarationError: (485-486): Undeclared identifier. +// DeclarationError: (496-497): Undeclared identifier. +// DeclarationError: (507-508): Undeclared identifier. +// DeclarationError: (518-519): Undeclared identifier. +// DeclarationError: (529-530): Undeclared identifier. +// DeclarationError: (540-541): Undeclared identifier. +// DeclarationError: (551-552): Undeclared identifier. +// DeclarationError: (562-563): Undeclared identifier. +// DeclarationError: (573-574): Undeclared identifier. +// DeclarationError: (584-585): Undeclared identifier. +// DeclarationError: (595-596): Undeclared identifier. +// DeclarationError: (606-607): Undeclared identifier. +// DeclarationError: (617-618): Undeclared identifier. +// DeclarationError: (628-629): Undeclared identifier. +// DeclarationError: (639-640): Undeclared identifier. +// DeclarationError: (650-651): Undeclared identifier. +// DeclarationError: (661-662): Undeclared identifier. +// DeclarationError: (672-673): Undeclared identifier. +// DeclarationError: (683-684): Undeclared identifier. +// DeclarationError: (694-695): Undeclared identifier. +// DeclarationError: (705-706): Undeclared identifier. +// DeclarationError: (716-717): Undeclared identifier. +// DeclarationError: (727-728): Undeclared identifier. +// DeclarationError: (738-739): Undeclared identifier. +// DeclarationError: (749-750): Undeclared identifier. +// DeclarationError: (760-761): Undeclared identifier. +// DeclarationError: (771-772): Undeclared identifier. +// DeclarationError: (782-783): Undeclared identifier. +// DeclarationError: (793-794): Undeclared identifier. +// DeclarationError: (804-805): Undeclared identifier. +// DeclarationError: (815-816): Undeclared identifier. +// DeclarationError: (826-827): Undeclared identifier. +// DeclarationError: (837-838): Undeclared identifier. +// DeclarationError: (848-849): Undeclared identifier. +// DeclarationError: (859-860): Undeclared identifier. +// DeclarationError: (870-871): Undeclared identifier. +// DeclarationError: (881-882): Undeclared identifier. +// DeclarationError: (892-893): Undeclared identifier. +// DeclarationError: (903-904): Undeclared identifier. +// DeclarationError: (914-915): Undeclared identifier. +// DeclarationError: (925-926): Undeclared identifier. +// DeclarationError: (936-937): Undeclared identifier. +// DeclarationError: (947-948): Undeclared identifier. +// DeclarationError: (958-959): Undeclared identifier. +// DeclarationError: (969-970): Undeclared identifier. +// DeclarationError: (980-981): Undeclared identifier. +// DeclarationError: (991-992): Undeclared identifier. +// DeclarationError: (1002-1003): Undeclared identifier. +// DeclarationError: (1013-1014): Undeclared identifier. +// DeclarationError: (1024-1025): Undeclared identifier. +// DeclarationError: (1035-1036): Undeclared identifier. +// DeclarationError: (1046-1047): Undeclared identifier. +// DeclarationError: (1057-1058): Undeclared identifier. +// DeclarationError: (1068-1069): Undeclared identifier. +// DeclarationError: (1079-1080): Undeclared identifier. +// DeclarationError: (1090-1091): Undeclared identifier. +// DeclarationError: (1101-1102): Undeclared identifier. +// DeclarationError: (1112-1113): Undeclared identifier. +// DeclarationError: (1123-1124): Undeclared identifier. +// DeclarationError: (1134-1135): Undeclared identifier. +// DeclarationError: (1145-1146): Undeclared identifier. +// DeclarationError: (1156-1157): Undeclared identifier. +// DeclarationError: (1167-1168): Undeclared identifier. +// DeclarationError: (1178-1179): Undeclared identifier. +// DeclarationError: (1189-1190): Undeclared identifier. +// DeclarationError: (1200-1201): Undeclared identifier. +// DeclarationError: (1211-1212): Undeclared identifier. +// DeclarationError: (1222-1223): Undeclared identifier. +// DeclarationError: (1233-1234): Undeclared identifier. +// DeclarationError: (1244-1245): Undeclared identifier. +// DeclarationError: (1255-1256): Undeclared identifier. +// DeclarationError: (1266-1267): Undeclared identifier. +// DeclarationError: (1277-1278): Undeclared identifier. +// DeclarationError: (1288-1289): Undeclared identifier. +// DeclarationError: (1299-1300): Undeclared identifier. +// DeclarationError: (1310-1311): Undeclared identifier. +// DeclarationError: (1321-1322): Undeclared identifier. +// DeclarationError: (1332-1333): Undeclared identifier. +// DeclarationError: (1343-1344): Undeclared identifier. +// DeclarationError: (1354-1355): Undeclared identifier. +// DeclarationError: (1365-1366): Undeclared identifier. +// DeclarationError: (1376-1377): Undeclared identifier. +// DeclarationError: (1387-1388): Undeclared identifier. +// DeclarationError: (1398-1399): Undeclared identifier. +// DeclarationError: (1409-1410): Undeclared identifier. +// DeclarationError: (1420-1421): Undeclared identifier. +// DeclarationError: (1431-1432): Undeclared identifier. +// DeclarationError: (1442-1443): Undeclared identifier. +// DeclarationError: (1453-1454): Undeclared identifier. +// DeclarationError: (1464-1465): Undeclared identifier. +// DeclarationError: (1475-1476): Undeclared identifier. +// DeclarationError: (1486-1487): Undeclared identifier. +// DeclarationError: (1497-1498): Undeclared identifier. +// DeclarationError: (1508-1509): Undeclared identifier. +// DeclarationError: (1519-1520): Undeclared identifier. +// DeclarationError: (1530-1531): Undeclared identifier. +// DeclarationError: (1541-1542): Undeclared identifier. +// DeclarationError: (1552-1553): Undeclared identifier. +// DeclarationError: (1563-1564): Undeclared identifier. +// DeclarationError: (1574-1575): Undeclared identifier. +// DeclarationError: (1585-1586): Undeclared identifier. +// DeclarationError: (1596-1597): Undeclared identifier. +// DeclarationError: (1607-1608): Undeclared identifier. +// DeclarationError: (1618-1619): Undeclared identifier. +// DeclarationError: (1629-1630): Undeclared identifier. +// DeclarationError: (1640-1641): Undeclared identifier. +// DeclarationError: (1651-1652): Undeclared identifier. +// DeclarationError: (1662-1663): Undeclared identifier. +// DeclarationError: (1673-1674): Undeclared identifier. +// DeclarationError: (1684-1685): Undeclared identifier. +// DeclarationError: (1695-1696): Undeclared identifier. +// DeclarationError: (1706-1707): Undeclared identifier. +// DeclarationError: (1717-1718): Undeclared identifier. +// DeclarationError: (1728-1729): Undeclared identifier. +// DeclarationError: (1739-1740): Undeclared identifier. +// DeclarationError: (1750-1751): Undeclared identifier. +// DeclarationError: (1761-1762): Undeclared identifier. +// DeclarationError: (1772-1773): Undeclared identifier. +// DeclarationError: (1783-1784): Undeclared identifier. +// DeclarationError: (1794-1795): Undeclared identifier. +// DeclarationError: (1805-1806): Undeclared identifier. +// DeclarationError: (1816-1817): Undeclared identifier. +// DeclarationError: (1827-1828): Undeclared identifier. +// DeclarationError: (1838-1839): Undeclared identifier. +// DeclarationError: (1849-1850): Undeclared identifier. +// DeclarationError: (1860-1861): Undeclared identifier. +// DeclarationError: (1871-1872): Undeclared identifier. +// DeclarationError: (1882-1883): Undeclared identifier. +// DeclarationError: (1893-1894): Undeclared identifier. +// DeclarationError: (1904-1905): Undeclared identifier. +// DeclarationError: (1915-1916): Undeclared identifier. +// DeclarationError: (1926-1927): Undeclared identifier. +// DeclarationError: (1937-1938): Undeclared identifier. +// DeclarationError: (1948-1949): Undeclared identifier. +// DeclarationError: (1959-1960): Undeclared identifier. +// DeclarationError: (1970-1971): Undeclared identifier. +// DeclarationError: (1981-1982): Undeclared identifier. +// DeclarationError: (1992-1993): Undeclared identifier. +// DeclarationError: (2003-2004): Undeclared identifier. +// DeclarationError: (2014-2015): Undeclared identifier. +// DeclarationError: (2025-2026): Undeclared identifier. +// DeclarationError: (2036-2037): Undeclared identifier. +// DeclarationError: (2047-2048): Undeclared identifier. +// DeclarationError: (2058-2059): Undeclared identifier. +// DeclarationError: (2069-2070): Undeclared identifier. +// DeclarationError: (2080-2081): Undeclared identifier. +// DeclarationError: (2091-2092): Undeclared identifier. +// DeclarationError: (2102-2103): Undeclared identifier. +// DeclarationError: (2113-2114): Undeclared identifier. +// DeclarationError: (2124-2125): Undeclared identifier. +// DeclarationError: (2135-2136): Undeclared identifier. +// DeclarationError: (2146-2147): Undeclared identifier. +// DeclarationError: (2157-2158): Undeclared identifier. +// DeclarationError: (2168-2169): Undeclared identifier. +// DeclarationError: (2179-2180): Undeclared identifier. +// DeclarationError: (2190-2191): Undeclared identifier. +// DeclarationError: (2201-2202): Undeclared identifier. +// DeclarationError: (2212-2213): Undeclared identifier. +// DeclarationError: (2223-2224): Undeclared identifier. +// DeclarationError: (2234-2235): Undeclared identifier. +// DeclarationError: (2245-2246): Undeclared identifier. +// DeclarationError: (2256-2257): Undeclared identifier. +// DeclarationError: (2267-2268): Undeclared identifier. +// DeclarationError: (2278-2279): Undeclared identifier. +// DeclarationError: (2289-2290): Undeclared identifier. +// DeclarationError: (2300-2301): Undeclared identifier. +// DeclarationError: (2311-2312): Undeclared identifier. +// DeclarationError: (2322-2323): Undeclared identifier. +// DeclarationError: (2333-2334): Undeclared identifier. +// DeclarationError: (2344-2345): Undeclared identifier. +// DeclarationError: (2355-2356): Undeclared identifier. +// DeclarationError: (2366-2367): Undeclared identifier. +// DeclarationError: (2377-2378): Undeclared identifier. +// DeclarationError: (2388-2389): Undeclared identifier. +// DeclarationError: (2399-2400): Undeclared identifier. +// DeclarationError: (2410-2411): Undeclared identifier. +// DeclarationError: (2421-2422): Undeclared identifier. +// DeclarationError: (2432-2433): Undeclared identifier. +// DeclarationError: (2443-2444): Undeclared identifier. +// DeclarationError: (2454-2455): Undeclared identifier. +// DeclarationError: (2465-2466): Undeclared identifier. +// DeclarationError: (2476-2477): Undeclared identifier. +// DeclarationError: (2487-2488): Undeclared identifier. +// DeclarationError: (2498-2499): Undeclared identifier. +// DeclarationError: (2509-2510): Undeclared identifier. +// DeclarationError: (2520-2521): Undeclared identifier. +// DeclarationError: (2531-2532): Undeclared identifier. +// DeclarationError: (2542-2543): Undeclared identifier. +// DeclarationError: (2553-2554): Undeclared identifier. +// DeclarationError: (2564-2565): Undeclared identifier. +// DeclarationError: (2575-2576): Undeclared identifier. +// DeclarationError: (2586-2587): Undeclared identifier. +// DeclarationError: (2597-2598): Undeclared identifier. +// DeclarationError: (2608-2609): Undeclared identifier. +// DeclarationError: (2619-2620): Undeclared identifier. +// DeclarationError: (2630-2631): Undeclared identifier. +// DeclarationError: (2641-2642): Undeclared identifier. +// DeclarationError: (2652-2653): Undeclared identifier. +// DeclarationError: (2663-2664): Undeclared identifier. +// DeclarationError: (2674-2675): Undeclared identifier. +// DeclarationError: (2685-2686): Undeclared identifier. +// DeclarationError: (2696-2697): Undeclared identifier. +// DeclarationError: (2707-2708): Undeclared identifier. +// DeclarationError: (2718-2719): Undeclared identifier. +// DeclarationError: (2729-2730): Undeclared identifier. +// DeclarationError: (2740-2741): Undeclared identifier. +// DeclarationError: (2751-2752): Undeclared identifier. +// DeclarationError: (2762-2763): Undeclared identifier. +// DeclarationError: (2773-2774): Undeclared identifier. +// DeclarationError: (2784-2785): Undeclared identifier. +// DeclarationError: (2795-2796): Undeclared identifier. +// DeclarationError: (2806-2807): Undeclared identifier. +// DeclarationError: (2817-2818): Undeclared identifier. +// DeclarationError: (2828-2829): Undeclared identifier. +// DeclarationError: (2839-2840): Undeclared identifier. +// Warning: There are more than 256 errors. Aborting. diff --git a/test/libsolidity/syntaxTests/more_than_256_syntaxerrors.sol b/test/libsolidity/syntaxTests/more_than_256_syntaxerrors.sol new file mode 100644 index 00000000..2c9b8a42 --- /dev/null +++ b/test/libsolidity/syntaxTests/more_than_256_syntaxerrors.sol @@ -0,0 +1,524 @@ +contract C { + function f() { + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + } +} +// ---- +// SyntaxError: (34-42): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (48-56): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (62-70): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (76-84): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (90-98): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (104-112): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (118-126): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (132-140): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (146-154): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (160-168): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (174-182): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (188-196): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (202-210): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (216-224): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (230-238): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (244-252): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (258-266): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (272-280): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (286-294): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (300-308): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (314-322): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (328-336): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (342-350): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (356-364): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (370-378): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (384-392): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (398-406): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (412-420): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (426-434): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (440-448): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (454-462): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (468-476): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (482-490): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (496-504): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (510-518): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (524-532): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (538-546): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (552-560): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (566-574): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (580-588): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (594-602): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (608-616): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (622-630): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (636-644): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (650-658): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (664-672): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (678-686): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (692-700): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (706-714): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (720-728): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (734-742): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (748-756): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (762-770): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (776-784): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (790-798): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (804-812): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (818-826): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (832-840): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (846-854): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (860-868): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (874-882): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (888-896): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (902-910): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (916-924): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (930-938): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (944-952): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (958-966): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (972-980): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (986-994): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1000-1008): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1014-1022): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1028-1036): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1042-1050): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1056-1064): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1070-1078): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1084-1092): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1098-1106): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1112-1120): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1126-1134): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1140-1148): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1154-1162): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1168-1176): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1182-1190): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1196-1204): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1210-1218): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1224-1232): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1238-1246): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1252-1260): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1266-1274): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1280-1288): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1294-1302): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1308-1316): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1322-1330): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1336-1344): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1350-1358): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1364-1372): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1378-1386): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1392-1400): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1406-1414): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1420-1428): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1434-1442): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1448-1456): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1462-1470): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1476-1484): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1490-1498): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1504-1512): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1518-1526): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1532-1540): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1546-1554): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1560-1568): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1574-1582): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1588-1596): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1602-1610): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1616-1624): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1630-1638): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1644-1652): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1658-1666): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1672-1680): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1686-1694): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1700-1708): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1714-1722): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1728-1736): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1742-1750): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1756-1764): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1770-1778): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1784-1792): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1798-1806): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1812-1820): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1826-1834): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1840-1848): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1854-1862): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1868-1876): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1882-1890): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1896-1904): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1910-1918): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1924-1932): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1938-1946): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1952-1960): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1966-1974): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1980-1988): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1994-2002): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2008-2016): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2022-2030): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2036-2044): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2050-2058): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2064-2072): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2078-2086): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2092-2100): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2106-2114): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2120-2128): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2134-2142): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2148-2156): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2162-2170): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2176-2184): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2190-2198): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2204-2212): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2218-2226): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2232-2240): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2246-2254): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2260-2268): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2274-2282): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2288-2296): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2302-2310): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2316-2324): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2330-2338): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2344-2352): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2358-2366): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2372-2380): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2386-2394): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2400-2408): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2414-2422): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2428-2436): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2442-2450): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2456-2464): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2470-2478): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2484-2492): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2498-2506): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2512-2520): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2526-2534): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2540-2548): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2554-2562): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2568-2576): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2582-2590): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2596-2604): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2610-2618): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2624-2632): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2638-2646): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2652-2660): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2666-2674): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2680-2688): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2694-2702): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2708-2716): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2722-2730): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2736-2744): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2750-2758): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2764-2772): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2778-2786): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2792-2800): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2806-2814): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2820-2828): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2834-2842): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2848-2856): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2862-2870): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2876-2884): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2890-2898): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2904-2912): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2918-2926): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2932-2940): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2946-2954): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2960-2968): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2974-2982): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2988-2996): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3002-3010): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3016-3024): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3030-3038): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3044-3052): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3058-3066): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3072-3080): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3086-3094): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3100-3108): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3114-3122): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3128-3136): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3142-3150): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3156-3164): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3170-3178): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3184-3192): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3198-3206): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3212-3220): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3226-3234): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3240-3248): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3254-3262): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3268-3276): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3282-3290): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3296-3304): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3310-3318): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3324-3332): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3338-3346): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3352-3360): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3366-3374): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3380-3388): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3394-3402): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3408-3416): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3422-3430): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3436-3444): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3450-3458): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3464-3472): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3478-3486): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3492-3500): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3506-3514): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3520-3528): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3534-3542): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3548-3556): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3562-3570): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3576-3584): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3590-3598): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3604-3612): "continue" has to be in a "for" or "while" loop. +// Warning: There are more than 256 errors. Aborting. diff --git a/test/libsolidity/syntaxTests/parsing/missing_variable_name_in_declaration.sol b/test/libsolidity/syntaxTests/parsing/missing_variable_name_in_declaration.sol new file mode 100644 index 00000000..fd3067e3 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/missing_variable_name_in_declaration.sol @@ -0,0 +1,5 @@ +contract test { + uint256 ; +} +// ---- +// ParserError: (28-28): Expected identifier, got 'Semicolon' diff --git a/test/libsolidity/syntaxTests/parsing/smoke_test.sol b/test/libsolidity/syntaxTests/parsing/smoke_test.sol new file mode 100644 index 00000000..d328b167 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/smoke_test.sol @@ -0,0 +1,4 @@ +contract test { + uint256 stateVariable1; +} +// ---- diff --git a/test/libsolidity/syntaxTests/scoping/double_function_declaration.sol b/test/libsolidity/syntaxTests/scoping/double_function_declaration.sol index 2841fd38..dfd67aaa 100644 --- a/test/libsolidity/syntaxTests/scoping/double_function_declaration.sol +++ b/test/libsolidity/syntaxTests/scoping/double_function_declaration.sol @@ -3,4 +3,4 @@ contract test { function fun() public { } } // ---- -// DeclarationError: Function with same name and arguments defined twice. +// DeclarationError: (20-45): Function with same name and arguments defined twice. diff --git a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope.sol b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope.sol index ea61d0f3..d90ec2d7 100644 --- a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope.sol +++ b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope.sol @@ -5,4 +5,4 @@ contract test { } } // ---- -// DeclarationError: Identifier already declared. +// DeclarationError: (77-83): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_050.sol b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_050.sol index 22195963..06bfe7be 100644 --- a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_050.sol +++ b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_050.sol @@ -6,5 +6,5 @@ contract test { } } // ---- -// Warning: Unused local variable. -// Warning: Unused local variable. +// Warning: (87-93): Unused local variable. +// Warning: (107-113): Unused local variable. diff --git a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation.sol b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation.sol index 6af89c93..1a5ff2f9 100644 --- a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation.sol +++ b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation.sol @@ -5,4 +5,4 @@ contract test { } } // ---- -// DeclarationError: Identifier already declared. +// DeclarationError: (75-81): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation_050.sol b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation_050.sol index 73cddfed..20ea0349 100644 --- a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation_050.sol +++ b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation_050.sol @@ -6,5 +6,5 @@ contract test { } } // ---- -// Warning: Unused local variable. -// Warning: Unused local variable. +// Warning: (87-93): Unused local variable. +// Warning: (105-111): Unused local variable. diff --git a/test/libsolidity/syntaxTests/scoping/name_shadowing.sol b/test/libsolidity/syntaxTests/scoping/name_shadowing.sol index d16877f9..67ada4a4 100644 --- a/test/libsolidity/syntaxTests/scoping/name_shadowing.sol +++ b/test/libsolidity/syntaxTests/scoping/name_shadowing.sol @@ -3,5 +3,4 @@ contract test { function f() pure public { uint32 variable; variable = 2; } } // ---- -// Warning: This declaration shadows an existing declaration. - +// Warning: (69-84): This declaration shadows an existing declaration. diff --git a/test/libsolidity/syntaxTests/scoping/scoping.sol b/test/libsolidity/syntaxTests/scoping/scoping.sol index f47a3e99..34b055d9 100644 --- a/test/libsolidity/syntaxTests/scoping/scoping.sol +++ b/test/libsolidity/syntaxTests/scoping/scoping.sol @@ -8,4 +8,4 @@ contract test { } } // ---- -// DeclarationError: Undeclared identifier. +// DeclarationError: (123-124): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/scoping/scoping_activation.sol b/test/libsolidity/syntaxTests/scoping/scoping_activation.sol index 0ed74a00..7334bc49 100644 --- a/test/libsolidity/syntaxTests/scoping/scoping_activation.sol +++ b/test/libsolidity/syntaxTests/scoping/scoping_activation.sol @@ -6,4 +6,4 @@ contract test { } } // ---- -// DeclarationError: Undeclared identifier. Did you mean "x"? +// DeclarationError: (85-86): Undeclared identifier. Did you mean "x"? diff --git a/test/libsolidity/syntaxTests/scoping/scoping_for3.sol b/test/libsolidity/syntaxTests/scoping/scoping_for3.sol index 9bc7d569..1814cb47 100644 --- a/test/libsolidity/syntaxTests/scoping/scoping_for3.sol +++ b/test/libsolidity/syntaxTests/scoping/scoping_for3.sol @@ -8,4 +8,4 @@ contract test { } } // ---- -// DeclarationError: Undeclared identifier. +// DeclarationError: (154-155): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/scoping/scoping_for_decl_in_body.sol b/test/libsolidity/syntaxTests/scoping/scoping_for_decl_in_body.sol index 07503983..3e80b385 100644 --- a/test/libsolidity/syntaxTests/scoping/scoping_for_decl_in_body.sol +++ b/test/libsolidity/syntaxTests/scoping/scoping_for_decl_in_body.sol @@ -7,4 +7,4 @@ contract test { } } // ---- -// DeclarationError: Undeclared identifier. +// DeclarationError: (93-94): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/scoping/scoping_self_use_050.sol b/test/libsolidity/syntaxTests/scoping/scoping_self_use_050.sol index e942020e..ab3dcefb 100644 --- a/test/libsolidity/syntaxTests/scoping/scoping_self_use_050.sol +++ b/test/libsolidity/syntaxTests/scoping/scoping_self_use_050.sol @@ -5,4 +5,4 @@ contract test { } } // ---- -// DeclarationError: Undeclared identifier. Did you mean "a"? +// DeclarationError: (94-95): Undeclared identifier. Did you mean "a"? diff --git a/test/libsolidity/syntaxTests/smoke_test.sol b/test/libsolidity/syntaxTests/smoke_test.sol index 2d48098a..6abaff18 100644 --- a/test/libsolidity/syntaxTests/smoke_test.sol +++ b/test/libsolidity/syntaxTests/smoke_test.sol @@ -3,4 +3,4 @@ contract test { function fun(uint256 arg1) public { uint256 y; y = arg1; } } // ---- -// Warning: Function state mutability can be restricted to pure +// Warning: (42-100): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol index 9f57c3a4..c98d7a57 100644 --- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol @@ -5,7 +5,7 @@ contract C { } } // ---- -// TypeError: This type cannot be encoded. -// TypeError: This type cannot be encoded. -// TypeError: This type cannot be encoded. -// TypeError: This type cannot be encoded. +// TypeError: (74-83): This type cannot be encoded. +// TypeError: (85-86): This type cannot be encoded. +// TypeError: (88-98): This type cannot be encoded. +// TypeError: (100-115): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol index a7d13215..f1b5606e 100644 --- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol @@ -6,8 +6,8 @@ contract C { } } // ---- -// TypeError: This type cannot be encoded. -// TypeError: This type cannot be encoded. -// TypeError: This type cannot be encoded. -// TypeError: This type cannot be encoded. -// TypeError: This type cannot be encoded. +// TypeError: (80-106): This type cannot be encoded. +// TypeError: (108-113): This type cannot be encoded. +// TypeError: (160-164): This type cannot be encoded. +// TypeError: (166-168): This type cannot be encoded. +// TypeError: (170-176): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol index 378155e9..cc354819 100644 --- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol @@ -9,6 +9,6 @@ contract C { } } // ---- -// Warning: Defining empty structs is deprecated. -// TypeError: This type cannot be encoded. -// TypeError: This type cannot be encoded. +// Warning: (51-63): Defining empty structs is deprecated. +// TypeError: (131-132): This type cannot be encoded. +// TypeError: (134-135): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol index 6e073fd8..d10c1718 100644 --- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol @@ -9,9 +9,9 @@ contract C { } } // ---- -// Warning: Defining empty structs is deprecated. -// TypeError: This type cannot be encoded. -// TypeError: This type cannot be encoded. -// TypeError: This type cannot be encoded. -// TypeError: This type cannot be encoded. -// TypeError: This type cannot be encoded. +// Warning: (51-63): Defining empty structs is deprecated. +// TypeError: (168-169): This type cannot be encoded. +// TypeError: (171-172): This type cannot be encoded. +// TypeError: (179-180): This type cannot be encoded. +// TypeError: (182-186): This type cannot be encoded. +// TypeError: (188-194): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/structs/recursion/multi_struct_composition.sol b/test/libsolidity/syntaxTests/structs/recursion/multi_struct_composition.sol new file mode 100644 index 00000000..895bb6c5 --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/multi_struct_composition.sol @@ -0,0 +1,15 @@ +pragma experimental ABIEncoderV2; + +contract C { + struct T { U u; V v; } + + struct U { W w; } + + struct V { W w; } + + struct W { uint x; } + + function f(T) public pure { } +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/structs/recursion/parallel_structs.sol b/test/libsolidity/syntaxTests/structs/recursion/parallel_structs.sol new file mode 100644 index 00000000..96362ef0 --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/parallel_structs.sol @@ -0,0 +1,15 @@ +pragma experimental ABIEncoderV2; + +contract TestContract +{ + struct SubStruct { + uint256 id; + } + struct TestStruct { + SubStruct subStruct1; + SubStruct subStruct2; + } + function addTestStruct(TestStruct) public pure {} +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs.sol b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs.sol new file mode 100644 index 00000000..4966a731 --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs.sol @@ -0,0 +1,7 @@ +contract C { + struct S { uint a; S[] sub; } + function f() public pure returns (uint, S) { + } +} +// ---- +// TypeError: (91-92): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs2.sol b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs2.sol new file mode 100644 index 00000000..68113924 --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs2.sol @@ -0,0 +1,7 @@ +contract C { + struct S { uint a; S[2][] sub; } + function f() public pure returns (uint, S) { + } +} +// ---- +// TypeError: (94-95): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs3.sol b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs3.sol new file mode 100644 index 00000000..47690d9b --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs3.sol @@ -0,0 +1,8 @@ +contract C { + struct S { uint a; S[][][] sub; } + struct T { S s; } + function f() public pure returns (uint x, T t) { + } +} +// ---- +// TypeError: (119-122): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_directly_recursive.sol b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_directly_recursive.sol new file mode 100644 index 00000000..bcffe383 --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_directly_recursive.sol @@ -0,0 +1,8 @@ +contract Test { + struct MyStructName { + address addr; + MyStructName x; + } +} +// ---- +// TypeError: (20-93): Recursive struct definition. diff --git a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive.sol b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive.sol new file mode 100644 index 00000000..64dab8d0 --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive.sol @@ -0,0 +1,12 @@ +contract Test { + struct MyStructName1 { + address addr; + uint256 count; + MyStructName2 x; + } + struct MyStructName2 { + MyStructName1 x; + } +} +// ---- +// TypeError: (20-118): Recursive struct definition. diff --git a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_not_really_recursive.sol b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_not_really_recursive.sol new file mode 100644 index 00000000..6ec4ee01 --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_not_really_recursive.sol @@ -0,0 +1,4 @@ +contract Test { + struct S1 { uint a; } + struct S2 { S1 x; S1 y; } +} diff --git a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_recursion_via_mapping.sol b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_recursion_via_mapping.sol new file mode 100644 index 00000000..926981b3 --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_recursion_via_mapping.sol @@ -0,0 +1,7 @@ +contract Test { + struct MyStructName1 { + address addr; + uint256 count; + mapping(uint => MyStructName1) x; + } +} diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_default.sol b/test/libsolidity/syntaxTests/visibility/interface/function_default.sol index 7b9044dd..72ce3b40 100644 --- a/test/libsolidity/syntaxTests/visibility/interface/function_default.sol +++ b/test/libsolidity/syntaxTests/visibility/interface/function_default.sol @@ -2,5 +2,5 @@ interface I { function f(); } // ---- -// Warning: Functions in interfaces should be declared external. -// Warning: No visibility specified. Defaulting to "public". In interfaces it defaults to external. +// Warning: (15-28): Functions in interfaces should be declared external. +// Warning: (15-28): No visibility specified. Defaulting to "public". In interfaces it defaults to external. diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_default050.sol b/test/libsolidity/syntaxTests/visibility/interface/function_default050.sol index 127d4e92..513df26b 100644 --- a/test/libsolidity/syntaxTests/visibility/interface/function_default050.sol +++ b/test/libsolidity/syntaxTests/visibility/interface/function_default050.sol @@ -3,5 +3,5 @@ interface I { function f(); } // ---- -// SyntaxError: No visibility specified. -// TypeError: Functions in interfaces must be declared external. +// SyntaxError: (45-58): No visibility specified. +// TypeError: (45-58): Functions in interfaces must be declared external. diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_internal.sol b/test/libsolidity/syntaxTests/visibility/interface/function_internal.sol index a1cf5246..ac62e69b 100644 --- a/test/libsolidity/syntaxTests/visibility/interface/function_internal.sol +++ b/test/libsolidity/syntaxTests/visibility/interface/function_internal.sol @@ -2,4 +2,4 @@ interface I { function f() internal; } // ---- -// TypeError: Functions in interfaces cannot be internal or private. +// TypeError: (15-37): Functions in interfaces cannot be internal or private. diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_private.sol b/test/libsolidity/syntaxTests/visibility/interface/function_private.sol index 887ebd4b..881e647e 100644 --- a/test/libsolidity/syntaxTests/visibility/interface/function_private.sol +++ b/test/libsolidity/syntaxTests/visibility/interface/function_private.sol @@ -2,4 +2,4 @@ interface I { function f() private; } // ---- -// TypeError: Functions in interfaces cannot be internal or private. +// TypeError: (15-36): Functions in interfaces cannot be internal or private. diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_public.sol b/test/libsolidity/syntaxTests/visibility/interface/function_public.sol index 146d4f5b..891d9fdf 100644 --- a/test/libsolidity/syntaxTests/visibility/interface/function_public.sol +++ b/test/libsolidity/syntaxTests/visibility/interface/function_public.sol @@ -2,4 +2,4 @@ interface I { function f() public; } // ---- -// Warning: Functions in interfaces should be declared external.
\ No newline at end of file +// Warning: (15-35): Functions in interfaces should be declared external. diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_public050.sol b/test/libsolidity/syntaxTests/visibility/interface/function_public050.sol index f957f0b4..e0c04095 100644 --- a/test/libsolidity/syntaxTests/visibility/interface/function_public050.sol +++ b/test/libsolidity/syntaxTests/visibility/interface/function_public050.sol @@ -3,4 +3,4 @@ interface I { function f() public; } // ---- -// TypeError: Functions in interfaces must be declared external.
\ No newline at end of file +// TypeError: (45-65): Functions in interfaces must be declared external. |