diff options
Diffstat (limited to 'test/libsolidity')
87 files changed, 1218 insertions, 439 deletions
diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp index 497ee867..736aa46c 100644 --- a/test/libsolidity/SMTChecker.cpp +++ b/test/libsolidity/SMTChecker.cpp @@ -110,7 +110,7 @@ BOOST_AUTO_TEST_CASE(simple_assert) function f(uint a) public pure { assert(a == 2); } } )"; - CHECK_WARNING(text, "Assertion violation happens here for"); + CHECK_WARNING(text, "Assertion violation happens here"); } BOOST_AUTO_TEST_CASE(simple_assert_with_require) diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp index 14413ca0..f2d6d66f 100644 --- a/test/libsolidity/SolidityABIJSON.cpp +++ b/test/libsolidity/SolidityABIJSON.cpp @@ -756,7 +756,7 @@ BOOST_AUTO_TEST_CASE(library_function) char const* sourceCode = R"( library test { struct StructType { uint a; } - function f(StructType storage b, uint[] storage c, test d) public returns (uint[] memory e, StructType storage f) {} + function f(StructType storage b, uint[] storage c, test d) public returns (uint[] memory e, StructType storage f) { f = f; } } )"; diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 223250fa..45a56b22 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -8910,52 +8910,6 @@ BOOST_AUTO_TEST_CASE(inline_assembly_storage_access_via_pointer) ABI_CHECK(callContractFunction("separator2()"), encodeArgs(u256(0))); } -BOOST_AUTO_TEST_CASE(inline_assembly_jumps) -{ - char const* sourceCode = R"( - contract C { - function f() public { - assembly { - let n := calldataload(4) - let a := 1 - let b := a - loop: - jumpi(loopend, eq(n, 0)) - a add swap1 - n := sub(n, 1) - jump(loop) - loopend: - mstore(0, a) - return(0, 0x20) - } - } - } - )"; - compileAndRun(sourceCode, 0, "C"); - ABI_CHECK(callContractFunction("f()", u256(5)), encodeArgs(u256(13))); - ABI_CHECK(callContractFunction("f()", u256(7)), encodeArgs(u256(34))); -} - -BOOST_AUTO_TEST_CASE(inline_assembly_function_access) -{ - char const* sourceCode = R"( - contract C { - uint public x; - function g(uint y) public { x = 2 * y; assembly { stop } } - function f(uint _x) public { - assembly { - _x - jump(g) - pop - } - } - } - )"; - compileAndRun(sourceCode, 0, "C"); - ABI_CHECK(callContractFunction("f(uint256)", u256(5)), encodeArgs()); - ABI_CHECK(callContractFunction("x()"), encodeArgs(u256(10))); -} - BOOST_AUTO_TEST_CASE(inline_assembly_function_call) { char const* sourceCode = R"( @@ -9420,7 +9374,7 @@ BOOST_AUTO_TEST_CASE(failed_create) contract C { uint public x; constructor() public payable {} - function f(uint amount) public returns (address) { + function f(uint amount) public returns (D) { x++; return (new D).value(amount)(); } @@ -9428,7 +9382,7 @@ BOOST_AUTO_TEST_CASE(failed_create) if (depth < 1024) return this.stack(depth - 1); else - return f(0); + return address(f(0)); } } )"; @@ -11261,7 +11215,7 @@ BOOST_AUTO_TEST_CASE(invalid_instruction) contract C { function f() public { assembly { - invalid + invalid() } } } @@ -11688,19 +11642,10 @@ BOOST_AUTO_TEST_CASE(keccak256_assembly) ret := keccak256(0, 0) } } - function g() public pure returns (bytes32 ret) { - assembly { - 0 - 0 - keccak256 - =: ret - } - } } )"; compileAndRun(sourceCode, 0, "C"); ABI_CHECK(callContractFunction("f()"), fromHex("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")); - ABI_CHECK(callContractFunction("g()"), fromHex("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")); } BOOST_AUTO_TEST_CASE(multi_modifiers) @@ -12524,10 +12469,10 @@ BOOST_AUTO_TEST_CASE(staticcall_for_view_and_pure) return (new C()).f(); } function fview() public returns (uint) { - return (CView(new C())).f(); + return (CView(address(new C()))).f(); } function fpure() public returns (uint) { - return (CPure(new C())).f(); + return (CPure(address(new C()))).f(); } } )"; @@ -12547,50 +12492,6 @@ BOOST_AUTO_TEST_CASE(staticcall_for_view_and_pure) } } -BOOST_AUTO_TEST_CASE(swap_peephole_optimisation) -{ - char const* sourceCode = R"( - contract C { - function lt(uint a, uint b) public returns (bool c) { - assembly { - a - b - swap1 - lt - =: c - } - } - function add(uint a, uint b) public returns (uint c) { - assembly { - a - b - swap1 - add - =: c - } - } - function div(uint a, uint b) public returns (uint c) { - assembly { - a - b - swap1 - div - =: c - } - } - } - )"; - compileAndRun(sourceCode); - BOOST_CHECK(callContractFunction("lt(uint256,uint256)", u256(1), u256(2)) == encodeArgs(u256(1))); - BOOST_CHECK(callContractFunction("lt(uint256,uint256)", u256(2), u256(1)) == encodeArgs(u256(0))); - BOOST_CHECK(callContractFunction("add(uint256,uint256)", u256(1), u256(2)) == encodeArgs(u256(3))); - BOOST_CHECK(callContractFunction("add(uint256,uint256)", u256(100), u256(200)) == encodeArgs(u256(300))); - BOOST_CHECK(callContractFunction("div(uint256,uint256)", u256(2), u256(1)) == encodeArgs(u256(2))); - BOOST_CHECK(callContractFunction("div(uint256,uint256)", u256(200), u256(10)) == encodeArgs(u256(20))); - BOOST_CHECK(callContractFunction("div(uint256,uint256)", u256(1), u256(0)) == encodeArgs(u256(0))); - BOOST_CHECK(callContractFunction("div(uint256,uint256)", u256(0), u256(1)) == encodeArgs(u256(0))); -} - BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople) { if (!dev::test::Options::get().evmVersion().hasBitwiseShifting()) @@ -12599,26 +12500,17 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople) contract C { function shl(uint a, uint b) public returns (uint c) { assembly { - a - b - shl - =: c + c := shl(b, a) } } function shr(uint a, uint b) public returns (uint c) { assembly { - a - b - shr - =: c + c := shr(b, a) } } function sar(uint a, uint b) public returns (uint c) { assembly { - a - b - sar - =: c + c := sar(b, a) } } } @@ -12646,10 +12538,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople) function shl_1() public returns (bool) { uint c; assembly { - 1 - 2 - shl - =: c + c := shl(2, 1) } assert(c == 4); return true; @@ -12657,10 +12546,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople) function shl_2() public returns (bool) { uint c; assembly { - 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff - 1 - shl - =: c + c := shl(1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } assert(c == 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe); return true; @@ -12668,10 +12554,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople) function shl_3() public returns (bool) { uint c; assembly { - 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff - 256 - shl - =: c + c := shl(256, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } assert(c == 0); return true; @@ -12679,10 +12562,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople) function shr_1() public returns (bool) { uint c; assembly { - 3 - 1 - shr - =: c + c := shr(1, 3) } assert(c == 1); return true; @@ -12690,10 +12570,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople) function shr_2() public returns (bool) { uint c; assembly { - 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff - 1 - shr - =: c + c := shr(1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } assert(c == 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); return true; @@ -12701,10 +12578,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople) function shr_3() public returns (bool) { uint c; assembly { - 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff - 256 - shr - =: c + c := shr(256, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } assert(c == 0); return true; diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index d025e65a..41814888 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -390,12 +390,10 @@ BOOST_AUTO_TEST_CASE(unsatisfied_version) BOOST_AUTO_TEST_CASE(returndatasize_as_variable) { char const* text = R"( - contract c { function f() public { uint returndatasize; assembly { returndatasize }}} + contract C { function f() public pure { uint returndatasize; returndatasize; assembly { pop(returndatasize()) }}} )"; vector<pair<Error::Type, std::string>> expectations(vector<pair<Error::Type, std::string>>{ - {Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"}, - {Error::Type::Warning, "The use of non-functional instructions is deprecated."}, - {Error::Type::DeclarationError, "Unbalanced stack"} + {Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"} }); if (!dev::test::Options::get().evmVersion().supportsReturndata()) expectations.emplace_back(make_pair(Error::Type::Warning, std::string("\"returndatasize\" instruction is only available for Byzantium-compatible"))); @@ -405,15 +403,13 @@ BOOST_AUTO_TEST_CASE(returndatasize_as_variable) BOOST_AUTO_TEST_CASE(create2_as_variable) { char const* text = R"( - contract c { function f() public { uint create2; assembly { create2(0, 0, 0, 0) } }} + contract c { function f() public { uint create2; create2; assembly { pop(create2(0, 0, 0, 0)) } }} )"; // This needs special treatment, because the message mentions the EVM version, // so cannot be run via isoltest. CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{ {Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"}, {Error::Type::Warning, "The \"create2\" instruction is not supported by the VM version"}, - {Error::Type::DeclarationError, "Unbalanced stack"}, - {Error::Type::Warning, "not supposed to return values"} })); } diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp index 3e2dce26..119f80d1 100644 --- a/test/libsolidity/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -74,9 +74,9 @@ public: unsigned const _optimizeRuns = 200 ) { - m_nonOptimizedBytecode = compileAndRunWithOptimizer(_sourceCode, _value, _contractName, false, _optimizeRuns); + m_nonOptimizedBytecode = compileAndRunWithOptimizer("pragma solidity >=0.0;\n" + _sourceCode, _value, _contractName, false, _optimizeRuns); m_nonOptimizedContract = m_contractAddress; - m_optimizedBytecode = compileAndRunWithOptimizer(_sourceCode, _value, _contractName, true, _optimizeRuns); + m_optimizedBytecode = compileAndRunWithOptimizer("pragma solidity >=0.0;\n" + _sourceCode, _value, _contractName, true, _optimizeRuns); size_t nonOptimizedSize = numInstructions(m_nonOptimizedBytecode); size_t optimizedSize = numInstructions(m_optimizedBytecode); BOOST_CHECK_MESSAGE( @@ -441,8 +441,6 @@ BOOST_AUTO_TEST_CASE(constant_optimization_early_exit) // This tests that the constant optimizer does not try to find the best representation // indefinitely but instead stops after some number of iterations. char const* sourceCode = R"( - pragma solidity ^0.4.0; - contract HexEncoding { function hexEncodeTest(address addr) public returns (bytes32 ret) { uint x = uint(addr) / 2**32; diff --git a/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol b/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol index 2a199b3a..17cb701d 100644 --- a/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol +++ b/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol @@ -3,11 +3,11 @@ contract B { A a; constructor() public { - a = new A(this); + a = new A(address(this)); } } contract A { - constructor(address a) internal {} + constructor(address) internal {} } // ---- // TypeError: (141-146): Contract with internal constructor cannot be created directly. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_err.sol new file mode 100644 index 00000000..5fde497c --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_err.sol @@ -0,0 +1,10 @@ +contract C { + struct S { bool f; } + S s; + function f() internal pure returns (S storage) { + assembly { + } + } +} +// ---- +// TypeError: (87-88): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_fine.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_fine.sol index 65902cc8..0d3db856 100644 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_fine.sol +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_fine.sol @@ -8,7 +8,7 @@ contract C { } function g(bool flag) internal returns (S storage c) { // control flow in assembly will not be analyzed for now, - // so this will not issue a warning + // so this will not issue an error assembly { if flag { sstore(c_slot, sload(s_slot)) @@ -17,7 +17,7 @@ contract C { } function h() internal returns (S storage c) { // any reference from assembly will be sufficient for now, - // so this will not issue a warning + // so this will not issue an error assembly { sstore(s_slot, sload(c_slot)) } diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_warn.sol deleted file mode 100644 index 09c13847..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_warn.sol +++ /dev/null @@ -1,10 +0,0 @@ -contract C { - struct S { bool f; } - S s; - function f() internal pure returns (S storage) { - assembly { - } - } -} -// ---- -// Warning: (87-88): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_err.sol new file mode 100644 index 00000000..eb574c96 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_err.sol @@ -0,0 +1,52 @@ +contract C { + struct S { bool f; } + S s; + function f() internal view returns (S storage c) { + do { + break; + c = s; + } while(false); + } + function g() internal view returns (S storage c) { + do { + if (s.f) { + continue; + c = s; + } + else { + } + } while(false); + } + function h() internal view returns (S storage c) { + do { + if (s.f) { + break; + } + else { + c = s; + } + } while(false); + } + function i() internal view returns (S storage c) { + do { + if (s.f) { + continue; + } + else { + c = s; + } + } while(false); + } + function j() internal view returns (S storage c) { + do { + continue; + c = s; + } while(false); + } +} +// ---- +// TypeError: (87-98): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (223-234): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (440-451): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (654-665): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (871-882): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol deleted file mode 100644 index 7d001c19..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol +++ /dev/null @@ -1,52 +0,0 @@ -contract C { - struct S { bool f; } - S s; - function f() internal view returns (S storage c) { - do { - break; - c = s; - } while(false); - } - function g() internal view returns (S storage c) { - do { - if (s.f) { - continue; - c = s; - } - else { - } - } while(false); - } - function h() internal view returns (S storage c) { - do { - if (s.f) { - break; - } - else { - c = s; - } - } while(false); - } - function i() internal view returns (S storage c) { - do { - if (s.f) { - continue; - } - else { - c = s; - } - } while(false); - } - function j() internal view returns (S storage c) { - do { - continue; - c = s; - } while(false); - } -} -// ---- -// Warning: (87-98): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (223-234): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (440-451): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (654-665): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (871-882): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_err.sol new file mode 100644 index 00000000..0d266ccf --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_err.sol @@ -0,0 +1,14 @@ +contract C { + struct S { bool f; } + S s; + function f() internal pure returns (S storage) { return; } + function g() internal view returns (S storage c, S storage) { c = s; return; } + function h() internal view returns (S storage, S storage d) { d = s; return; } + function i() internal pure returns (S storage, S storage) { return; } +} +// ---- +// TypeError: (87-88): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (163-164): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (233-234): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (316-317): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (327-328): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_fine.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_fine.sol index 3a0a30ea..6d72e4ef 100644 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_fine.sol +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_fine.sol @@ -2,5 +2,6 @@ contract C { struct S { bool f; } S s; function f() internal view returns (S storage c, S storage d) { c = s; d = s; return; } + function g() internal view returns (S storage, S storage) { return (s,s); } } // ---- diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_warn.sol deleted file mode 100644 index 0a5b2fbf..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_warn.sol +++ /dev/null @@ -1,15 +0,0 @@ -contract C { - struct S { bool f; } - S s; - function f() internal pure returns (S storage) { return; } - function g() internal view returns (S storage c, S storage) { c = s; return; } - function h() internal view returns (S storage, S storage d) { d = s; return; } - function i() internal pure returns (S storage, S storage) { return; } - function j() internal view returns (S storage, S storage) { return (s,s); } -} -// ---- -// Warning: (87-88): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (163-164): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (233-234): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (316-317): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (327-328): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_err.sol new file mode 100644 index 00000000..9aa580a4 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_err.sol @@ -0,0 +1,16 @@ +contract C { + struct S { bool f; } + S s; + function f() internal view returns (S storage c) { + for(;; c = s) { + } + } + function g() internal view returns (S storage c) { + for(;;) { + c = s; + } + } +} +// ---- +// TypeError: (87-98): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (182-193): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_warn.sol deleted file mode 100644 index ba9a2440..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_warn.sol +++ /dev/null @@ -1,16 +0,0 @@ -contract C { - struct S { bool f; } - S s; - function f() internal view returns (S storage c) { - for(;; c = s) { - } - } - function g() internal view returns (S storage c) { - for(;;) { - c = s; - } - } -} -// ---- -// Warning: (87-98): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (182-193): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_err.sol new file mode 100644 index 00000000..f3e55318 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_err.sol @@ -0,0 +1,18 @@ +contract C { + struct S { bool f; } + S s; + function f(bool flag) internal view returns (S storage c) { + if (flag) c = s; + } + function g(bool flag) internal returns (S storage c) { + if (flag) c = s; + else + { + if (!flag) c = s; + else s.f = true; + } + } +} +// ---- +// TypeError: (96-107): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (186-197): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_warn.sol deleted file mode 100644 index c257c252..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_warn.sol +++ /dev/null @@ -1,18 +0,0 @@ -contract C { - struct S { bool f; } - S s; - function f(bool flag) internal view returns (S storage c) { - if (flag) c = s; - } - function g(bool flag) internal returns (S storage c) { - if (flag) c = s; - else - { - if (!flag) c = s; - else s.f = true; - } - } -} -// ---- -// Warning: (96-107): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (186-197): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_err.sol new file mode 100644 index 00000000..a0047782 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_err.sol @@ -0,0 +1,22 @@ +contract C { + modifier revertIfNoReturn() { + _; + revert(); + } + modifier ifFlag(bool flag) { + if (flag) + _; + } + struct S { uint a; } + S s; + function f(bool flag) ifFlag(flag) internal view returns(S storage) { + return s; + } + + function g(bool flag) ifFlag(flag) revertIfNoReturn() internal view returns(S storage) { + return s; + } +} +// ---- +// TypeError: (249-250): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (367-368): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_warn.sol deleted file mode 100644 index 50c6dd99..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_warn.sol +++ /dev/null @@ -1,22 +0,0 @@ -contract C { - modifier revertIfNoReturn() { - _; - revert(); - } - modifier ifFlag(bool flag) { - if (flag) - _; - } - struct S { uint a; } - S s; - function f(bool flag) ifFlag(flag) internal view returns(S storage) { - return s; - } - - function g(bool flag) ifFlag(flag) revertIfNoReturn() internal view returns(S storage) { - return s; - } -} -// ---- -// Warning: (249-250): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (367-368): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_err.sol new file mode 100644 index 00000000..d0ad8245 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_err.sol @@ -0,0 +1,18 @@ +contract C { + struct S { bool f; } + S s; + function f() internal view returns (S storage c) { + false && (c = s).f; + } + function g() internal view returns (S storage c) { + true || (c = s).f; + } + function h() internal view returns (S storage c) { + // expect error, although this is always fine + true && (false || (c = s).f); + } +} +// ---- +// TypeError: (87-98): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (176-187): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (264-275): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_warn.sol deleted file mode 100644 index 9f660f11..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_warn.sol +++ /dev/null @@ -1,18 +0,0 @@ -contract C { - struct S { bool f; } - S s; - function f() internal view returns (S storage c) { - false && (c = s).f; - } - function g() internal view returns (S storage c) { - true || (c = s).f; - } - function h() internal view returns (S storage c) { - // expect warning, although this is always fine - true && (false || (c = s).f); - } -} -// ---- -// Warning: (87-98): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (176-187): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (264-275): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_err.sol new file mode 100644 index 00000000..6d10287b --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_err.sol @@ -0,0 +1,13 @@ +contract C { + struct S { bool f; } + S s; + function f(bool flag) internal view returns (S storage c) { + flag ? (c = s).f : false; + } + function g(bool flag) internal view returns (S storage c) { + flag ? false : (c = s).f; + } +} +// ---- +// TypeError: (96-107): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. +// TypeError: (200-211): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_warn.sol deleted file mode 100644 index 57561fbb..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_warn.sol +++ /dev/null @@ -1,13 +0,0 @@ -contract C { - struct S { bool f; } - S s; - function f(bool flag) internal view returns (S storage c) { - flag ? (c = s).f : false; - } - function g(bool flag) internal view returns (S storage c) { - flag ? false : (c = s).f; - } -} -// ---- -// Warning: (96-107): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. -// Warning: (200-211): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_err.sol new file mode 100644 index 00000000..e7b4fae7 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_err.sol @@ -0,0 +1,11 @@ +contract C { + struct S { bool f; } + S s; + function f() internal view returns (S storage c) { + while(false) { + c = s; + } + } +} +// ---- +// TypeError: (87-98): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_warn.sol deleted file mode 100644 index 26db892f..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_warn.sol +++ /dev/null @@ -1,11 +0,0 @@ -contract C { - struct S { bool f; } - S s; - function f() internal view returns (S storage c) { - while(false) { - c = s; - } - } -} -// ---- -// Warning: (87-98): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning. diff --git a/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol b/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol index 6cf68d2a..8f5ceef8 100644 --- a/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol +++ b/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol @@ -1,4 +1,4 @@ contract A { constructor() public { } } contract B is A { constructor() A public { } } // ---- -// Warning: (72-73): Modifier-style base constructor call without arguments. +// DeclarationError: (72-73): Modifier-style base constructor call without arguments. diff --git a/test/libsolidity/syntaxTests/inheritance/modifiers_in_constructor_context.sol b/test/libsolidity/syntaxTests/inheritance/modifiers_in_constructor_context.sol new file mode 100644 index 00000000..d8ce0e48 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/modifiers_in_constructor_context.sol @@ -0,0 +1,9 @@ +// This generated an invalid warning on m1 in some compiler versions. +contract A { + constructor() m1 public { } + modifier m1 { _; } +} +contract B is A { + modifier m2 { _; } + constructor() A() m1 m2 public { } +} diff --git a/test/libsolidity/syntaxTests/inheritance/override/function_state_variable.sol b/test/libsolidity/syntaxTests/inheritance/override/function_state_variable.sol new file mode 100644 index 00000000..023a161a --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/function_state_variable.sol @@ -0,0 +1,2 @@ +interface ERC20 { function x() external returns (uint); } +contract C is ERC20 { uint public x; } diff --git a/test/libsolidity/syntaxTests/inheritance/override/state_variable_function.sol b/test/libsolidity/syntaxTests/inheritance/override/state_variable_function.sol new file mode 100644 index 00000000..0f05cc8e --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/state_variable_function.sol @@ -0,0 +1,8 @@ +contract A { + uint public x; +} +contract C is A { + function x() public returns (uint); +} +// ---- +// DeclarationError: (50-85): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol b/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol index cbea8991..ac1f541e 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol @@ -11,6 +11,6 @@ contract C { } // ---- // TypeError: (87-88): Expected 1 arguments but got 0. -// Warning: (87-90): Top-level expressions are not supposed to return values (this expression returns -1 values). Use ``pop()`` or assign them. +// SyntaxError: (87-90): Top-level expressions are not supposed to return values (this expression returns -1 values). Use ``pop()`` or assign them. // TypeError: (108-109): Expected 1 arguments but got 2. -// Warning: (108-115): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. +// SyntaxError: (108-115): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol b/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol index 5de492e1..150fb938 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol @@ -8,6 +8,6 @@ contract C { } } // ---- -// Warning: (63-64): The use of labels is deprecated. Please use "if", "switch", "for" or function calls instead. -// Warning: (63-64): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead. +// SyntaxError: (63-64): The use of labels is disallowed. Please use "if", "switch", "for" or function calls instead. +// SyntaxError: (63-64): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead. // TypeError: (73-74): Attempt to call label instead of function. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol index b6dd12b8..07113093 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol @@ -1,6 +1,6 @@ contract C { uint[] x; - function() external { + function() external { uint[] storage y = x; assembly { pop(y) @@ -8,4 +8,4 @@ contract C { } } // ---- -// TypeError: (119-120): You have to use the _slot or _offset suffix to access storage reference variables. +// TypeError: (118-119): You have to use the _slot or _offset suffix to access storage reference variables. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol index d5c8eaf5..dc742142 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol @@ -1,6 +1,6 @@ contract C { uint[] x; - function() external { + function() external { uint[] storage y = x; assembly { y_slot := 1 @@ -9,5 +9,5 @@ contract C { } } // ---- -// TypeError: (115-121): Storage variables cannot be assigned to. -// TypeError: (139-147): Storage variables cannot be assigned to. +// TypeError: (114-120): Storage variables cannot be assigned to. +// TypeError: (138-146): Storage variables cannot be assigned to. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol index 84f98ed9..b01a7705 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol @@ -1,6 +1,6 @@ contract C { uint[] x; - function() external { + function() external { uint[] storage y = x; assembly { pop(y_slot) diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol index 4025e11c..704b712d 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol @@ -1,6 +1,6 @@ contract C { uint[] x; - function() external { + function() external { uint[] memory y = x; assembly { pop(y_slot) @@ -9,5 +9,5 @@ contract C { } } // ---- -// TypeError: (118-124): The suffixes _offset and _slot can only be used on storage variables. -// TypeError: (142-150): The suffixes _offset and _slot can only be used on storage variables. +// TypeError: (117-123): The suffixes _offset and _slot can only be used on storage variables. +// TypeError: (141-149): The suffixes _offset and _slot can only be used on storage variables. diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiSingleVariableDeclaration.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiSingleVariableDeclaration.sol index 182ba072..7db98577 100644 --- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiSingleVariableDeclaration.sol +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiSingleVariableDeclaration.sol @@ -3,4 +3,4 @@ contract C { (uint a) = f(); a; } -} +} diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalidType.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalidType.sol index 2b765837..85094d00 100644 --- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalidType.sol +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalidType.sol @@ -3,7 +3,7 @@ contract C { (uint a, string memory b,,) = f(); a; b; } -} +} // ---- // TypeError: (85-118): Type string memory is not implicitly convertible to expected type uint256. // TypeError: (85-118): Type uint256 is not implicitly convertible to expected type string memory. diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol index 224d9614..1f9e52d1 100644 --- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol @@ -5,6 +5,6 @@ contract C { } a; } -} +} // ---- // DeclarationError: (99-100): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol index 242a1f39..45b8858b 100644 --- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol @@ -4,7 +4,7 @@ contract C { (uint a, uint b, uint c) = (a, b, c); } } -} +} // ---- // DeclarationError: (79-80): Undeclared identifier. "a" is not (or not yet) visible at this point. // DeclarationError: (82-83): Undeclared identifier. "b" is not (or not yet) visible at this point. diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationThatIsExpression.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationThatIsExpression.sol index 8ae0eaac..00458908 100644 --- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationThatIsExpression.sol +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationThatIsExpression.sol @@ -4,6 +4,6 @@ contract C { function f() internal pure returns (uint, uint, uint, S storage, uint, uint) { (,,,s.x[2](),,) = f(); } -} +} // ---- // TypeError: (160-168): Expression has to be an lvalue. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword.sol deleted file mode 100644 index 1b6bbae7..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword.sol +++ /dev/null @@ -1,11 +0,0 @@ -contract test { - function f() public { - uintM something = 3; - intM should = 4; - bytesM fail = "now"; - } -} -// ---- -// DeclarationError: (50-55): Identifier not found or not unique. -// DeclarationError: (79-83): Identifier not found or not unique. -// DeclarationError: (104-110): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_1.sol new file mode 100644 index 00000000..0d0a0797 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_1.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + uintM something = 3; + } +} +// ---- +// DeclarationError: (50-55): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_2.sol new file mode 100644 index 00000000..b9590a8c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_2.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + intM should = 4; + } +} +// ---- +// DeclarationError: (50-54): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_3.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_3.sol new file mode 100644 index 00000000..85d4c25b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_3.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + bytesM fail = "now"; + } +} +// ---- +// DeclarationError: (50-56): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol index 273e1844..e9599f4b 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol @@ -6,5 +6,5 @@ contract test { } } // ---- -// Warning: (73-74): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. +// SyntaxError: (73-74): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. // DeclarationError: (59-84): Unbalanced stack at the end of a block: 1 surplus item(s). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol index bda090b4..342afc46 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol @@ -6,5 +6,5 @@ contract test { } } // ---- -// Warning: (73-76): The use of non-functional instructions is deprecated. Please use functional notation instead. +// SyntaxError: (73-76): The use of non-functional instructions is disallowed. Please use functional notation instead. // DeclarationError: (59-86): Unbalanced stack at the end of a block: 1 missing item(s). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol deleted file mode 100644 index a5f0f96c..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol +++ /dev/null @@ -1,11 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function f() pure public { - assembly { - 1 - } - } -} -// ---- -// SyntaxError: (105-106): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. -// DeclarationError: (91-116): Unbalanced stack at the end of a block: 1 surplus item(s). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol index 7b68c60b..62fe7171 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol @@ -6,5 +6,5 @@ contract C { } } // ---- -// Warning: (75-76): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. +// SyntaxError: (75-76): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. // DeclarationError: (61-86): Unbalanced stack at the end of a block: 1 surplus item(s). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol deleted file mode 100644 index 4a7aca8a..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol +++ /dev/null @@ -1,12 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function f() view public { - assembly { - address - pop - } - } -} -// ---- -// SyntaxError: (105-112): The use of non-functional instructions is deprecated. Please use functional notation instead. -// SyntaxError: (125-128): The use of non-functional instructions is deprecated. Please use functional notation instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol index c44412cf..7315d5d1 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol @@ -7,5 +7,5 @@ contract C { } } // ---- -// Warning: (75-82): The use of non-functional instructions is deprecated. Please use functional notation instead. -// Warning: (95-98): The use of non-functional instructions is deprecated. Please use functional notation instead. +// SyntaxError: (75-82): The use of non-functional instructions is disallowed. Please use functional notation instead. +// SyntaxError: (95-98): The use of non-functional instructions is disallowed. Please use functional notation instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol deleted file mode 100644 index 77a73ebc..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol +++ /dev/null @@ -1,11 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function f() pure public { - assembly { - label: - } - } -} -// ---- -// SyntaxError: (105-110): The use of labels is deprecated. Please use "if", "switch", "for" or function calls instead. -// SyntaxError: (105-110): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol index 15bd6660..0d7bacb4 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol @@ -6,5 +6,5 @@ contract C { } } // ---- -// Warning: (75-80): The use of labels is deprecated. Please use "if", "switch", "for" or function calls instead. -// Warning: (75-80): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead. +// SyntaxError: (75-80): The use of labels is disallowed. Please use "if", "switch", "for" or function calls instead. +// SyntaxError: (75-80): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol index c3c82ce8..6cb35d6d 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol @@ -6,5 +6,4 @@ contract C { } } // ---- -// Warning: (75-82): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead. -// TypeError: (75-82): Function declared as pure, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. +// SyntaxError: (75-82): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol index 56043ccf..8538a2a0 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol @@ -6,5 +6,5 @@ contract C { } } // ---- -// Warning: (75-83): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. +// SyntaxError: (75-83): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. // DeclarationError: (61-93): Unbalanced stack at the end of a block: 1 surplus item(s). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol index 56fc4051..d052dab5 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol @@ -8,4 +8,5 @@ contract C { } } // ---- +// DeclarationError: (150-179): Identifier already declared. // DeclarationError: (114-120): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/570_function_type_undeclared_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/570_function_type_undeclared_type.sol new file mode 100644 index 00000000..962f4fe4 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/570_function_type_undeclared_type.sol @@ -0,0 +1,5 @@ +contract C { + function a(function(Nested)) external pure {} +} +// ---- +// DeclarationError: (37-43): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/571_function_type_undeclared_type_external.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/571_function_type_undeclared_type_external.sol new file mode 100644 index 00000000..735af9e9 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/571_function_type_undeclared_type_external.sol @@ -0,0 +1,5 @@ +contract C { + function a(function(Nested) external) external pure {} +} +// ---- +// DeclarationError: (37-43): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/572_function_type_undeclared_type_multi_nested.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/572_function_type_undeclared_type_multi_nested.sol new file mode 100644 index 00000000..ffb467cd --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/572_function_type_undeclared_type_multi_nested.sol @@ -0,0 +1,5 @@ +contract C { + function a(function(function(function(Nested)))) external pure {} +} +// ---- +// DeclarationError: (55-61): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol b/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol index 9f714aea..b66253e4 100644 --- a/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol +++ b/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol @@ -3,9 +3,9 @@ contract A { } } contract B { - constructor(address) public { + constructor(C) public { } - function b(address) public returns (A) { + function b(C) public returns (A) { return new A(); } } diff --git a/test/libsolidity/syntaxTests/parsing/tuples_decl_without_rhs.sol b/test/libsolidity/syntaxTests/parsing/tuples_decl_without_rhs.sol new file mode 100644 index 00000000..dba3e7ac --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/tuples_decl_without_rhs.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure { + (uint a, uint b, uint c); + } +} +// ---- +// ParserError: (76-77): Expected '=' but got ';' diff --git a/test/libsolidity/syntaxTests/scoping/function_state_variable_conflict.sol b/test/libsolidity/syntaxTests/scoping/function_state_variable_conflict.sol new file mode 100644 index 00000000..d717981b --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/function_state_variable_conflict.sol @@ -0,0 +1,6 @@ +contract C { + function f(uint) public pure {} + uint public f = 0; +} +// ---- +// DeclarationError: (53-70): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict.sol b/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict.sol new file mode 100644 index 00000000..0c732f7f --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict.sol @@ -0,0 +1,6 @@ +contract C { + uint public f = 0; + function f(uint) public pure {} +} +// ---- +// DeclarationError: (40-71): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict_former_crash.sol b/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict_former_crash.sol new file mode 100644 index 00000000..fb9180c6 --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict_former_crash.sol @@ -0,0 +1,14 @@ +// This used to crash with some compiler versions. +contract SomeContract { + + uint public balance = 0; + + function balance(uint number) public {} + + function doSomething() public { + balance(3); + } +} +// ---- +// DeclarationError: (106-145): Identifier already declared. +// TypeError: (185-195): Type is not callable diff --git a/test/libsolidity/syntaxTests/types/address_to_contract.sol b/test/libsolidity/syntaxTests/types/address_to_contract.sol new file mode 100644 index 00000000..629a3df0 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address_to_contract.sol @@ -0,0 +1,6 @@ +contract C { + function f() public pure returns (C c) { + c = C(address(2)); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/address_to_contract_implicitly.sol b/test/libsolidity/syntaxTests/types/address_to_contract_implicitly.sol new file mode 100644 index 00000000..efab7c27 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address_to_contract_implicitly.sol @@ -0,0 +1,7 @@ +contract C { + function f() public view { + C c = address(2); + } +} +// ---- +// TypeError: (46-62): Type address is not implicitly convertible to expected type contract C. diff --git a/test/libsolidity/syntaxTests/types/contract_to_address.sol b/test/libsolidity/syntaxTests/types/contract_to_address.sol new file mode 100644 index 00000000..ec2f8184 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/contract_to_address.sol @@ -0,0 +1,7 @@ +contract C { + function f() public view { + address a = address(this); + a; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/contract_to_address_implicitly.sol b/test/libsolidity/syntaxTests/types/contract_to_address_implicitly.sol new file mode 100644 index 00000000..8be9daac --- /dev/null +++ b/test/libsolidity/syntaxTests/types/contract_to_address_implicitly.sol @@ -0,0 +1,8 @@ +contract C { + function f() public view { + address a = this; + a; + } +} +// ---- +// TypeError: (46-62): Type contract C is not implicitly convertible to expected type address. diff --git a/test/libsolidity/syntaxTests/types/contract_to_base.sol b/test/libsolidity/syntaxTests/types/contract_to_base.sol new file mode 100644 index 00000000..b0a24e62 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/contract_to_base.sol @@ -0,0 +1,9 @@ +contract A {} +contract B is A {} +contract C { + function f() public { + A a = new B(); + a; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/contract_to_base_base.sol b/test/libsolidity/syntaxTests/types/contract_to_base_base.sol new file mode 100644 index 00000000..e99e5cdc --- /dev/null +++ b/test/libsolidity/syntaxTests/types/contract_to_base_base.sol @@ -0,0 +1,10 @@ +contract A {} +contract B is A {} +contract C is B {} +contract D { + function f() public { + A a = new C(); + a; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/contract_to_derived.sol b/test/libsolidity/syntaxTests/types/contract_to_derived.sol new file mode 100644 index 00000000..ac8df5d1 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/contract_to_derived.sol @@ -0,0 +1,9 @@ +contract B {} +contract A is B {} +contract C { + function f() public pure { + A a = A(new B()); + } +} +// ---- +// TypeError: (85-95): Explicit type conversion not allowed from "contract B" to "contract A". diff --git a/test/libsolidity/syntaxTests/types/contract_to_unrelated_contract.sol b/test/libsolidity/syntaxTests/types/contract_to_unrelated_contract.sol new file mode 100644 index 00000000..b0a4875f --- /dev/null +++ b/test/libsolidity/syntaxTests/types/contract_to_unrelated_contract.sol @@ -0,0 +1,9 @@ +contract A {} +contract B {} +contract C { + function f() public pure { + B b = B(new A()); + } +} +// ---- +// TypeError: (80-90): Explicit type conversion not allowed from "contract A" to "contract B". diff --git a/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_exhausted.sol b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_exhausted.sol new file mode 100644 index 00000000..c6669746 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_exhausted.sol @@ -0,0 +1,262 @@ +contract A {} +contract Main { + A constant B = C; + A constant C = D; + A constant D = E; + A constant E = F; + A constant F = G; + A constant G = H; + A constant H = I; + A constant I = J; + A constant J = K; + A constant K = L; + A constant L = M; + A constant M = N; + A constant N = O; + A constant O = P; + A constant P = Q; + A constant Q = R; + A constant R = S; + A constant S = T; + A constant T = U; + A constant U = V; + A constant V = W; + A constant W = X; + A constant X = Y; + A constant Y = Z; + A constant Z = BA; + A constant BA = BB; + A constant BB = BC; + A constant BC = BD; + A constant BD = BE; + A constant BE = BF; + A constant BF = BG; + A constant BG = BH; + A constant BH = BI; + A constant BI = BJ; + A constant BJ = BK; + A constant BK = BL; + A constant BL = BM; + A constant BM = BN; + A constant BN = BO; + A constant BO = BP; + A constant BP = BQ; + A constant BQ = BR; + A constant BR = BS; + A constant BS = BT; + A constant BT = BU; + A constant BU = BV; + A constant BV = BW; + A constant BW = BX; + A constant BX = BY; + A constant BY = BZ; + A constant BZ = CA; + A constant CA = CB; + A constant CB = CC; + A constant CC = CD; + A constant CD = CE; + A constant CE = CF; + A constant CF = CG; + A constant CG = CH; + A constant CH = CI; + A constant CI = CJ; + A constant CJ = CK; + A constant CK = CL; + A constant CL = CM; + A constant CM = CN; + A constant CN = CO; + A constant CO = CP; + A constant CP = CQ; + A constant CQ = CR; + A constant CR = CS; + A constant CS = CT; + A constant CT = CU; + A constant CU = CV; + A constant CV = CW; + A constant CW = CX; + A constant CX = CY; + A constant CY = CZ; + A constant CZ = DA; + A constant DA = DB; + A constant DB = DC; + A constant DC = DD; + A constant DD = DE; + A constant DE = DF; + A constant DF = DG; + A constant DG = DH; + A constant DH = DI; + A constant DI = DJ; + A constant DJ = DK; + A constant DK = DL; + A constant DL = DM; + A constant DM = DN; + A constant DN = DO; + A constant DO = DP; + A constant DP = DQ; + A constant DQ = DR; + A constant DR = DS; + A constant DS = DT; + A constant DT = DU; + A constant DU = DV; + A constant DV = DW; + A constant DW = DX; + A constant DX = DY; + A constant DY = DZ; + A constant DZ = EA; + A constant EA = EB; + A constant EB = EC; + A constant EC = ED; + A constant ED = EE; + A constant EE = EF; + A constant EF = EG; + A constant EG = EH; + A constant EH = EI; + A constant EI = EJ; + A constant EJ = EK; + A constant EK = EL; + A constant EL = EM; + A constant EM = EN; + A constant EN = EO; + A constant EO = EP; + A constant EP = EQ; + A constant EQ = ER; + A constant ER = ES; + A constant ES = ET; + A constant ET = EU; + A constant EU = EV; + A constant EV = EW; + A constant EW = EX; + A constant EX = EY; + A constant EY = EZ; + A constant EZ = FA; + A constant FA = FB; + A constant FB = FC; + A constant FC = FD; + A constant FD = FE; + A constant FE = FF; + A constant FF = FG; + A constant FG = FH; + A constant FH = FI; + A constant FI = FJ; + A constant FJ = FK; + A constant FK = FL; + A constant FL = FM; + A constant FM = FN; + A constant FN = FO; + A constant FO = FP; + A constant FP = FQ; + A constant FQ = FR; + A constant FR = FS; + A constant FS = FT; + A constant FT = FU; + A constant FU = FV; + A constant FV = FW; + A constant FW = FX; + A constant FX = FY; + A constant FY = FZ; + A constant FZ = GA; + A constant GA = GB; + A constant GB = GC; + A constant GC = GD; + A constant GD = GE; + A constant GE = GF; + A constant GF = GG; + A constant GG = GH; + A constant GH = GI; + A constant GI = GJ; + A constant GJ = GK; + A constant GK = GL; + A constant GL = GM; + A constant GM = GN; + A constant GN = GO; + A constant GO = GP; + A constant GP = GQ; + A constant GQ = GR; + A constant GR = GS; + A constant GS = GT; + A constant GT = GU; + A constant GU = GV; + A constant GV = GW; + A constant GW = GX; + A constant GX = GY; + A constant GY = GZ; + A constant GZ = HA; + A constant HA = HB; + A constant HB = HC; + A constant HC = HD; + A constant HD = HE; + A constant HE = HF; + A constant HF = HG; + A constant HG = HH; + A constant HH = HI; + A constant HI = HJ; + A constant HJ = HK; + A constant HK = HL; + A constant HL = HM; + A constant HM = HN; + A constant HN = HO; + A constant HO = HP; + A constant HP = HQ; + A constant HQ = HR; + A constant HR = HS; + A constant HS = HT; + A constant HT = HU; + A constant HU = HV; + A constant HV = HW; + A constant HW = HX; + A constant HX = HY; + A constant HY = HZ; + A constant HZ = IA; + A constant IA = IB; + A constant IB = IC; + A constant IC = ID; + A constant ID = IE; + A constant IE = IF; + A constant IF = IG; + A constant IG = IH; + A constant IH = II; + A constant II = IJ; + A constant IJ = IK; + A constant IK = IL; + A constant IL = IM; + A constant IM = IN; + A constant IN = IO; + A constant IO = IP; + A constant IP = IQ; + A constant IQ = IR; + A constant IR = IS; + A constant IS = IT; + A constant IT = IU; + A constant IU = IV; + A constant IV = IW; + A constant IW = IX; + A constant IX = IY; + A constant IY = IZ; + A constant IZ = JA; + A constant JA = JB; + A constant JB = JC; + A constant JC = JD; + A constant JD = JE; + A constant JE = JF; + A constant JF = JG; + A constant JG = JH; + A constant JH = JI; + A constant JI = JJ; + A constant JJ = JK; + A constant JK = JL; + A constant JL = JM; + A constant JM = JN; + A constant JN = JO; + A constant JO = JP; + A constant JP = JQ; + A constant JQ = JR; + A constant JR = JS; + A constant JS = JT; + A constant JT = JU; + A constant JU = JV; + A constant JV = JW; + A constant JW = JX; + A constant JX = A(0x00); +} +// ---- +// DeclarationError: (6105-6123): Variable definition exhausting cyclic dependency validator. diff --git a/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_good.sol b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_good.sol new file mode 100644 index 00000000..7f8c6189 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_good.sol @@ -0,0 +1,135 @@ +contract A {} +contract Main { + A constant B = C; + A constant C = D; + A constant D = E; + A constant E = F; + A constant F = G; + A constant G = H; + A constant H = I; + A constant I = J; + A constant J = K; + A constant K = L; + A constant L = M; + A constant M = N; + A constant N = O; + A constant O = P; + A constant P = Q; + A constant Q = R; + A constant R = S; + A constant S = T; + A constant T = U; + A constant U = V; + A constant V = W; + A constant W = X; + A constant X = Y; + A constant Y = Z; + A constant Z = BA; + A constant BA = BB; + A constant BB = BC; + A constant BC = BD; + A constant BD = BE; + A constant BE = BF; + A constant BF = BG; + A constant BG = BH; + A constant BH = BI; + A constant BI = BJ; + A constant BJ = BK; + A constant BK = BL; + A constant BL = BM; + A constant BM = BN; + A constant BN = BO; + A constant BO = BP; + A constant BP = BQ; + A constant BQ = BR; + A constant BR = BS; + A constant BS = BT; + A constant BT = BU; + A constant BU = BV; + A constant BV = BW; + A constant BW = BX; + A constant BX = BY; + A constant BY = BZ; + A constant BZ = CA; + A constant CA = CB; + A constant CB = CC; + A constant CC = CD; + A constant CD = CE; + A constant CE = CF; + A constant CF = CG; + A constant CG = CH; + A constant CH = CI; + A constant CI = CJ; + A constant CJ = CK; + A constant CK = CL; + A constant CL = CM; + A constant CM = CN; + A constant CN = CO; + A constant CO = CP; + A constant CP = CQ; + A constant CQ = CR; + A constant CR = CS; + A constant CS = CT; + A constant CT = CU; + A constant CU = CV; + A constant CV = CW; + A constant CW = CX; + A constant CX = CY; + A constant CY = CZ; + A constant CZ = DA; + A constant DA = DB; + A constant DB = DC; + A constant DC = DD; + A constant DD = DE; + A constant DE = DF; + A constant DF = DG; + A constant DG = DH; + A constant DH = DI; + A constant DI = DJ; + A constant DJ = DK; + A constant DK = DL; + A constant DL = DM; + A constant DM = DN; + A constant DN = DO; + A constant DO = DP; + A constant DP = DQ; + A constant DQ = DR; + A constant DR = DS; + A constant DS = DT; + A constant DT = DU; + A constant DU = DV; + A constant DV = DW; + A constant DW = DX; + A constant DX = DY; + A constant DY = DZ; + A constant DZ = EA; + A constant EA = EB; + A constant EB = EC; + A constant EC = ED; + A constant ED = EE; + A constant EE = EF; + A constant EF = EG; + A constant EG = EH; + A constant EH = EI; + A constant EI = EJ; + A constant EJ = EK; + A constant EK = EL; + A constant EL = EM; + A constant EM = EN; + A constant EN = EO; + A constant EO = EP; + A constant EP = EQ; + A constant EQ = ER; + A constant ER = ES; + A constant ES = ET; + A constant ET = EU; + A constant EU = EV; + A constant EV = EW; + A constant EW = EX; + A constant EX = EY; + A constant EY = EZ; + A constant EZ = FA; + A constant FA = FB; + A constant FB = FC; + A constant FC = A(0x00); +} diff --git a/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_exhausted.sol b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_exhausted.sol new file mode 100644 index 00000000..db0ff4af --- /dev/null +++ b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_exhausted.sol @@ -0,0 +1,260 @@ +contract Main { + struct B { C m; } + struct C { D m; } + struct D { E m; } + struct E { F m; } + struct F { G m; } + struct G { H m; } + struct H { I m; } + struct I { J m; } + struct J { K m; } + struct K { L m; } + struct L { M m; } + struct M { N m; } + struct N { O m; } + struct O { P m; } + struct P { Q m; } + struct Q { R m; } + struct R { S m; } + struct S { T m; } + struct T { U m; } + struct U { V m; } + struct V { W m; } + struct W { X m; } + struct X { Y m; } + struct Y { Z m; } + struct Z { BA m; } + struct BA { BB m; } + struct BB { BC m; } + struct BC { BD m; } + struct BD { BE m; } + struct BE { BF m; } + struct BF { BG m; } + struct BG { BH m; } + struct BH { BI m; } + struct BI { BJ m; } + struct BJ { BK m; } + struct BK { BL m; } + struct BL { BM m; } + struct BM { BN m; } + struct BN { BO m; } + struct BO { BP m; } + struct BP { BQ m; } + struct BQ { BR m; } + struct BR { BS m; } + struct BS { BT m; } + struct BT { BU m; } + struct BU { BV m; } + struct BV { BW m; } + struct BW { BX m; } + struct BX { BY m; } + struct BY { BZ m; } + struct BZ { CA m; } + struct CA { CB m; } + struct CB { CC m; } + struct CC { CD m; } + struct CD { CE m; } + struct CE { CF m; } + struct CF { CG m; } + struct CG { CH m; } + struct CH { CI m; } + struct CI { CJ m; } + struct CJ { CK m; } + struct CK { CL m; } + struct CL { CM m; } + struct CM { CN m; } + struct CN { CO m; } + struct CO { CP m; } + struct CP { CQ m; } + struct CQ { CR m; } + struct CR { CS m; } + struct CS { CT m; } + struct CT { CU m; } + struct CU { CV m; } + struct CV { CW m; } + struct CW { CX m; } + struct CX { CY m; } + struct CY { CZ m; } + struct CZ { DA m; } + struct DA { DB m; } + struct DB { DC m; } + struct DC { DD m; } + struct DD { DE m; } + struct DE { DF m; } + struct DF { DG m; } + struct DG { DH m; } + struct DH { DI m; } + struct DI { DJ m; } + struct DJ { DK m; } + struct DK { DL m; } + struct DL { DM m; } + struct DM { DN m; } + struct DN { DO m; } + struct DO { DP m; } + struct DP { DQ m; } + struct DQ { DR m; } + struct DR { DS m; } + struct DS { DT m; } + struct DT { DU m; } + struct DU { DV m; } + struct DV { DW m; } + struct DW { DX m; } + struct DX { DY m; } + struct DY { DZ m; } + struct DZ { EA m; } + struct EA { EB m; } + struct EB { EC m; } + struct EC { ED m; } + struct ED { EE m; } + struct EE { EF m; } + struct EF { EG m; } + struct EG { EH m; } + struct EH { EI m; } + struct EI { EJ m; } + struct EJ { EK m; } + struct EK { EL m; } + struct EL { EM m; } + struct EM { EN m; } + struct EN { EO m; } + struct EO { EP m; } + struct EP { EQ m; } + struct EQ { ER m; } + struct ER { ES m; } + struct ES { ET m; } + struct ET { EU m; } + struct EU { EV m; } + struct EV { EW m; } + struct EW { EX m; } + struct EX { EY m; } + struct EY { EZ m; } + struct EZ { FA m; } + struct FA { FB m; } + struct FB { FC m; } + struct FC { FD m; } + struct FD { FE m; } + struct FE { FF m; } + struct FF { FG m; } + struct FG { FH m; } + struct FH { FI m; } + struct FI { FJ m; } + struct FJ { FK m; } + struct FK { FL m; } + struct FL { FM m; } + struct FM { FN m; } + struct FN { FO m; } + struct FO { FP m; } + struct FP { FQ m; } + struct FQ { FR m; } + struct FR { FS m; } + struct FS { FT m; } + struct FT { FU m; } + struct FU { FV m; } + struct FV { FW m; } + struct FW { FX m; } + struct FX { FY m; } + struct FY { FZ m; } + struct FZ { GA m; } + struct GA { GB m; } + struct GB { GC m; } + struct GC { GD m; } + struct GD { GE m; } + struct GE { GF m; } + struct GF { GG m; } + struct GG { GH m; } + struct GH { GI m; } + struct GI { GJ m; } + struct GJ { GK m; } + struct GK { GL m; } + struct GL { GM m; } + struct GM { GN m; } + struct GN { GO m; } + struct GO { GP m; } + struct GP { GQ m; } + struct GQ { GR m; } + struct GR { GS m; } + struct GS { GT m; } + struct GT { GU m; } + struct GU { GV m; } + struct GV { GW m; } + struct GW { GX m; } + struct GX { GY m; } + struct GY { GZ m; } + struct GZ { HA m; } + struct HA { HB m; } + struct HB { HC m; } + struct HC { HD m; } + struct HD { HE m; } + struct HE { HF m; } + struct HF { HG m; } + struct HG { HH m; } + struct HH { HI m; } + struct HI { HJ m; } + struct HJ { HK m; } + struct HK { HL m; } + struct HL { HM m; } + struct HM { HN m; } + struct HN { HO m; } + struct HO { HP m; } + struct HP { HQ m; } + struct HQ { HR m; } + struct HR { HS m; } + struct HS { HT m; } + struct HT { HU m; } + struct HU { HV m; } + struct HV { HW m; } + struct HW { HX m; } + struct HX { HY m; } + struct HY { HZ m; } + struct HZ { IA m; } + struct IA { IB m; } + struct IB { IC m; } + struct IC { ID m; } + struct ID { IE m; } + struct IE { IF m; } + struct IF { IG m; } + struct IG { IH m; } + struct IH { II m; } + struct II { IJ m; } + struct IJ { IK m; } + struct IK { IL m; } + struct IL { IM m; } + struct IM { IN m; } + struct IN { IO m; } + struct IO { IP m; } + struct IP { IQ m; } + struct IQ { IR m; } + struct IR { IS m; } + struct IS { IT m; } + struct IT { IU m; } + struct IU { IV m; } + struct IV { IW m; } + struct IW { IX m; } + struct IX { IY m; } + struct IY { IZ m; } + struct IZ { JA m; } + struct JA { JB m; } + struct JB { JC m; } + struct JC { JD m; } + struct JD { JE m; } + struct JE { JF m; } + struct JF { JG m; } + struct JG { JH m; } + struct JH { JI m; } + struct JI { JJ m; } + struct JJ { JK m; } + struct JK { JL m; } + struct JL { JM m; } + struct JM { JN m; } + struct JN { JO m; } + struct JO { JP m; } + struct JP { JQ m; } + struct JQ { JR m; } + struct JR { JS m; } + struct JS { JT m; } + struct JT { JU m; } + struct JU { JV m; } + struct JV { JW m; } + struct JW { int i; } +} +// ---- +// DeclarationError: (6091-6111): Struct definition exhausting cyclic dependency validator. diff --git a/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_good.sol b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_good.sol new file mode 100644 index 00000000..0419bea6 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_good.sol @@ -0,0 +1,134 @@ +contract Main { + struct B { C m; } + struct C { D m; } + struct D { E m; } + struct E { F m; } + struct F { G m; } + struct G { H m; } + struct H { I m; } + struct I { J m; } + struct J { K m; } + struct K { L m; } + struct L { M m; } + struct M { N m; } + struct N { O m; } + struct O { P m; } + struct P { Q m; } + struct Q { R m; } + struct R { S m; } + struct S { T m; } + struct T { U m; } + struct U { V m; } + struct V { W m; } + struct W { X m; } + struct X { Y m; } + struct Y { Z m; } + struct Z { BA m; } + struct BA { BB m; } + struct BB { BC m; } + struct BC { BD m; } + struct BD { BE m; } + struct BE { BF m; } + struct BF { BG m; } + struct BG { BH m; } + struct BH { BI m; } + struct BI { BJ m; } + struct BJ { BK m; } + struct BK { BL m; } + struct BL { BM m; } + struct BM { BN m; } + struct BN { BO m; } + struct BO { BP m; } + struct BP { BQ m; } + struct BQ { BR m; } + struct BR { BS m; } + struct BS { BT m; } + struct BT { BU m; } + struct BU { BV m; } + struct BV { BW m; } + struct BW { BX m; } + struct BX { BY m; } + struct BY { BZ m; } + struct BZ { CA m; } + struct CA { CB m; } + struct CB { CC m; } + struct CC { CD m; } + struct CD { CE m; } + struct CE { CF m; } + struct CF { CG m; } + struct CG { CH m; } + struct CH { CI m; } + struct CI { CJ m; } + struct CJ { CK m; } + struct CK { CL m; } + struct CL { CM m; } + struct CM { CN m; } + struct CN { CO m; } + struct CO { CP m; } + struct CP { CQ m; } + struct CQ { CR m; } + struct CR { CS m; } + struct CS { CT m; } + struct CT { CU m; } + struct CU { CV m; } + struct CV { CW m; } + struct CW { CX m; } + struct CX { CY m; } + struct CY { CZ m; } + struct CZ { DA m; } + struct DA { DB m; } + struct DB { DC m; } + struct DC { DD m; } + struct DD { DE m; } + struct DE { DF m; } + struct DF { DG m; } + struct DG { DH m; } + struct DH { DI m; } + struct DI { DJ m; } + struct DJ { DK m; } + struct DK { DL m; } + struct DL { DM m; } + struct DM { DN m; } + struct DN { DO m; } + struct DO { DP m; } + struct DP { DQ m; } + struct DQ { DR m; } + struct DR { DS m; } + struct DS { DT m; } + struct DT { DU m; } + struct DU { DV m; } + struct DV { DW m; } + struct DW { DX m; } + struct DX { DY m; } + struct DY { DZ m; } + struct DZ { EA m; } + struct EA { EB m; } + struct EB { EC m; } + struct EC { ED m; } + struct ED { EE m; } + struct EE { EF m; } + struct EF { EG m; } + struct EG { EH m; } + struct EH { EI m; } + struct EI { EJ m; } + struct EJ { EK m; } + struct EK { EL m; } + struct EL { EM m; } + struct EM { EN m; } + struct EN { EO m; } + struct EO { EP m; } + struct EP { EQ m; } + struct EQ { ER m; } + struct ER { ES m; } + struct ES { ET m; } + struct ET { EU m; } + struct EU { EV m; } + struct EV { EW m; } + struct EW { EX m; } + struct EX { EY m; } + struct EY { EZ m; } + struct EZ { FA m; } + struct FA { FB m; } + struct FB { FC m; } + struct FC { int i; } +} diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_event.sol b/test/libsolidity/syntaxTests/types/empty_tuple_event.sol index 24327db0..898ee8ba 100644 --- a/test/libsolidity/syntaxTests/types/empty_tuple_event.sol +++ b/test/libsolidity/syntaxTests/types/empty_tuple_event.sol @@ -1,4 +1,3 @@ -pragma solidity ^0.4.3; contract C { event SomeEvent(); function a() public { @@ -6,4 +5,4 @@ contract C { } } // ---- -// ParserError: (95-99): Expected primary expression. +// ParserError: (71-75): Expected primary expression. diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_function.sol b/test/libsolidity/syntaxTests/types/empty_tuple_function.sol index ff31d440..a898f84a 100644 --- a/test/libsolidity/syntaxTests/types/empty_tuple_function.sol +++ b/test/libsolidity/syntaxTests/types/empty_tuple_function.sol @@ -1,4 +1,3 @@ -pragma solidity ^0.4.3; contract C { function f() private pure {} function a() public pure { @@ -8,5 +7,5 @@ contract C { } } // ---- -// TypeError: (162-165): Tuple component cannot be empty. -// TypeError: (181-184): Tuple component cannot be empty. +// TypeError: (138-141): Tuple component cannot be empty. +// TypeError: (157-160): Tuple component cannot be empty. diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol index 3d252f0b..63b039cd 100644 --- a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol +++ b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol @@ -1,4 +1,3 @@ -pragma solidity ^0.4.3; contract C { function f() private pure {} function a() public { @@ -8,6 +7,6 @@ contract C { } } // ---- -// TypeError: (146-149): Tuple component cannot be empty. -// TypeError: (151-154): Tuple component cannot be empty. -// TypeError: (145-155): Type tuple(tuple(),tuple()) is not implicitly convertible to expected type tuple(uint256,uint256). +// TypeError: (122-125): Tuple component cannot be empty. +// TypeError: (127-130): Tuple component cannot be empty. +// TypeError: (121-131): Type tuple(tuple(),tuple()) is not implicitly convertible to expected type tuple(uint256,uint256). diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol index f8b2ae7e..9bc21561 100644 --- a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol +++ b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol @@ -1,4 +1,3 @@ -pragma solidity ^0.4.3; contract C { function f() private pure {} function a() public { @@ -8,4 +7,4 @@ contract C { } } // ---- -// TypeError: (146-149): Array component cannot be empty. +// TypeError: (122-125): Array component cannot be empty. diff --git a/test/libsolidity/syntaxTests/types/unnamed_tuple_decl.sol b/test/libsolidity/syntaxTests/types/unnamed_tuple_decl.sol index 7ed92b58..36b3df9f 100644 --- a/test/libsolidity/syntaxTests/types/unnamed_tuple_decl.sol +++ b/test/libsolidity/syntaxTests/types/unnamed_tuple_decl.sol @@ -1,5 +1,3 @@ -pragma solidity ^0.4.20; - contract C { function f() internal pure {} function g() internal pure returns (uint) { return 1; } @@ -13,6 +11,6 @@ contract C { } // ---- -// SyntaxError: (249-261): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. -// SyntaxError: (271-283): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. -// SyntaxError: (293-306): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. +// SyntaxError: (223-235): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. +// SyntaxError: (245-257): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. +// SyntaxError: (267-280): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. diff --git a/test/libsolidity/syntaxTests/types/var_empty_decl_0.sol b/test/libsolidity/syntaxTests/types/var_empty_decl_0.sol new file mode 100644 index 00000000..51b949de --- /dev/null +++ b/test/libsolidity/syntaxTests/types/var_empty_decl_0.sol @@ -0,0 +1,9 @@ +contract C { + function f() public pure { + var (); + var (,); + } +} +// ---- +// SyntaxError: (52-58): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. +// SyntaxError: (68-75): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. diff --git a/test/libsolidity/syntaxTests/types/var_empty_decl_1.sol b/test/libsolidity/syntaxTests/types/var_empty_decl_1.sol new file mode 100644 index 00000000..20a004ff --- /dev/null +++ b/test/libsolidity/syntaxTests/types/var_empty_decl_1.sol @@ -0,0 +1,8 @@ +contract C { + function f() public pure { + var a; + a.NeverReachedByParser(); + } +} +// ---- +// TypeError: (52-57): Use of the "var" keyword is disallowed. diff --git a/test/libsolidity/syntaxTests/types/var_empty_decl_2.sol b/test/libsolidity/syntaxTests/types/var_empty_decl_2.sol new file mode 100644 index 00000000..de2abc9a --- /dev/null +++ b/test/libsolidity/syntaxTests/types/var_empty_decl_2.sol @@ -0,0 +1,9 @@ +contract C { + function f() public pure { + var (b, c); + b.WeMustNotReachHere(); + c.FailsToLookupToo(); + } +} +// ---- +// TypeError: (52-62): Use of the "var" keyword is disallowed. diff --git a/test/libsolidity/syntaxTests/types/var_empty_decl_3.sol b/test/libsolidity/syntaxTests/types/var_empty_decl_3.sol new file mode 100644 index 00000000..26ee824e --- /dev/null +++ b/test/libsolidity/syntaxTests/types/var_empty_decl_3.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure { + var (d, e,); + } +} +// ---- +// TypeError: (52-63): Use of the "var" keyword is disallowed. diff --git a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol deleted file mode 100644 index 418be561..00000000 --- a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol +++ /dev/null @@ -1,7 +0,0 @@ -contract C { - function k() public { - assembly { jump(2) } - } -} -// ---- -// Warning: (58-65): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead. diff --git a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol deleted file mode 100644 index c1729db7..00000000 --- a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol +++ /dev/null @@ -1,8 +0,0 @@ -contract C { - function k() public view { - assembly { jump(2) } - } -} -// ---- -// Warning: (63-70): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead. -// TypeError: (63-70): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. |