diff options
Diffstat (limited to 'test/libsolidity')
123 files changed, 791 insertions, 218 deletions
diff --git a/test/libsolidity/AnalysisFramework.cpp b/test/libsolidity/AnalysisFramework.cpp index bd24115c..abeecd32 100644 --- a/test/libsolidity/AnalysisFramework.cpp +++ b/test/libsolidity/AnalysisFramework.cpp @@ -52,7 +52,7 @@ AnalysisFramework::parseAnalyseAndReturnError( m_compiler.setEVMVersion(dev::test::Options::get().evmVersion()); if (!m_compiler.parse()) { - BOOST_ERROR("Parsing contract failed in analysis test suite:" + formatErrors()); + BOOST_FAIL("Parsing contract failed in analysis test suite:" + formatErrors()); } m_compiler.analyze(); @@ -127,8 +127,7 @@ string AnalysisFramework::formatError(Error const& _error) const { return SourceReferenceFormatter::formatExceptionInformation( _error, - (_error.type() == Error::Type::Warning) ? "Warning" : "Error", - [&](std::string const& _sourceName) -> Scanner const& { return m_compiler.scanner(_sourceName); } + (_error.type() == Error::Type::Warning) ? "Warning" : "Error" ); } diff --git a/test/libsolidity/Assembly.cpp b/test/libsolidity/Assembly.cpp index aa10147c..baa9bff1 100644 --- a/test/libsolidity/Assembly.cpp +++ b/test/libsolidity/Assembly.cpp @@ -165,19 +165,19 @@ BOOST_AUTO_TEST_CASE(location_test) auto codegenCharStream = make_shared<CharStream>("", "--CODEGEN--"); vector<SourceLocation> locations = - vector<SourceLocation>(hasShifts ? 21 : 22, SourceLocation(2, 82, sourceCode)) + - vector<SourceLocation>(2, SourceLocation(20, 79, sourceCode)) + - vector<SourceLocation>(1, SourceLocation(8, 17, codegenCharStream)) + - vector<SourceLocation>(3, SourceLocation(5, 7, codegenCharStream)) + - vector<SourceLocation>(1, SourceLocation(30, 31, codegenCharStream)) + - vector<SourceLocation>(1, SourceLocation(27, 28, codegenCharStream)) + - vector<SourceLocation>(1, SourceLocation(20, 32, codegenCharStream)) + - vector<SourceLocation>(1, SourceLocation(5, 7, codegenCharStream)) + - vector<SourceLocation>(24, SourceLocation(20, 79, sourceCode)) + - vector<SourceLocation>(1, SourceLocation(49, 58, sourceCode)) + - vector<SourceLocation>(1, SourceLocation(72, 74, sourceCode)) + - vector<SourceLocation>(2, SourceLocation(65, 74, sourceCode)) + - vector<SourceLocation>(2, SourceLocation(20, 79, sourceCode)); + vector<SourceLocation>(4, SourceLocation{2, 82, sourceCode}) + + vector<SourceLocation>(1, SourceLocation{8, 17, codegenCharStream}) + + vector<SourceLocation>(3, SourceLocation{5, 7, codegenCharStream}) + + vector<SourceLocation>(1, SourceLocation{30, 31, codegenCharStream}) + + vector<SourceLocation>(1, SourceLocation{27, 28, codegenCharStream}) + + vector<SourceLocation>(1, SourceLocation{20, 32, codegenCharStream}) + + vector<SourceLocation>(1, SourceLocation{5, 7, codegenCharStream}) + + vector<SourceLocation>(hasShifts ? 19 : 20, SourceLocation{2, 82, sourceCode}) + + vector<SourceLocation>(24, SourceLocation{20, 79, sourceCode}) + + vector<SourceLocation>(1, SourceLocation{49, 58, sourceCode}) + + vector<SourceLocation>(1, SourceLocation{72, 74, sourceCode}) + + vector<SourceLocation>(2, SourceLocation{65, 74, sourceCode}) + + vector<SourceLocation>(2, SourceLocation{20, 79, sourceCode}); checkAssemblyLocations(items, locations); } diff --git a/test/libsolidity/GasCosts.cpp b/test/libsolidity/GasCosts.cpp new file mode 100644 index 00000000..c7da3ca0 --- /dev/null +++ b/test/libsolidity/GasCosts.cpp @@ -0,0 +1,132 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see <http://www.gnu.org/licenses/>. +*/ +/** + * Tests that check that the cost of certain operations stay within range. + */ + +#include <test/libsolidity/SolidityExecutionFramework.h> + +#include <cmath> + +using namespace std; +using namespace langutil; +using namespace dev::eth; +using namespace dev::solidity; +using namespace dev::test; + +namespace dev +{ +namespace solidity +{ +namespace test +{ + +#define CHECK_GAS(_gasNoOpt, _gasOpt, _tolerance) \ + do \ + { \ + u256 gasOpt{_gasOpt}; \ + u256 gasNoOpt{_gasNoOpt}; \ + u256 tolerance{_tolerance}; \ + u256 gas = m_optimize ? gasOpt : gasNoOpt; \ + u256 diff = gas < m_gasUsed ? m_gasUsed - gas : gas - m_gasUsed; \ + BOOST_CHECK_MESSAGE( \ + diff <= tolerance, \ + "Gas used: " + \ + m_gasUsed.str() + \ + " - expected: " + \ + gas.str() + \ + " (tolerance: " + \ + tolerance.str() + \ + ")" \ + ); \ + } while(0) + +BOOST_FIXTURE_TEST_SUITE(GasCostTests, SolidityExecutionFramework) + +BOOST_AUTO_TEST_CASE(string_storage) +{ + char const* sourceCode = R"( + contract C { + function f() pure public { + require(false, "Not Authorized. This function can only be called by the custodian or owner of this contract"); + } + } + )"; + compileAndRun(sourceCode); + + if (Options::get().evmVersion() <= EVMVersion::byzantium()) + CHECK_GAS(134435, 130591, 100); + else + CHECK_GAS(127225, 124873, 100); + if (Options::get().evmVersion() >= EVMVersion::byzantium()) + { + callContractFunction("f()"); + if (Options::get().evmVersion() == EVMVersion::byzantium()) + CHECK_GAS(21551, 21526, 20); + else + CHECK_GAS(21546, 21526, 20); + } +} + +BOOST_AUTO_TEST_CASE(single_callvaluecheck) +{ + string sourceCode = R"( + // All functions nonpayable, we can check callvalue at the beginning + contract Nonpayable { + address a; + function f(address b) public { + a = b; + } + function f1(address b) public pure returns (uint c) { + return uint(b) + 2; + } + function f2(address b) public pure returns (uint) { + return uint(b) + 8; + } + function f3(address, uint c) pure public returns (uint) { + return c - 5; + } + } + // At least on payable function, we cannot do the optimization. + contract Payable { + address a; + function f(address b) public { + a = b; + } + function f1(address b) public pure returns (uint c) { + return uint(b) + 2; + } + function f2(address b) public pure returns (uint) { + return uint(b) + 8; + } + function f3(address, uint c) payable public returns (uint) { + return c - 5; + } + } + )"; + compileAndRun(sourceCode); + size_t bytecodeSizeNonpayable = m_compiler.object("Nonpayable").bytecode.size(); + size_t bytecodeSizePayable = m_compiler.object("Payable").bytecode.size(); + + BOOST_CHECK_EQUAL(bytecodeSizePayable - bytecodeSizeNonpayable, 26); +} + +BOOST_AUTO_TEST_SUITE_END() + +} +} +} diff --git a/test/libsolidity/GasMeter.cpp b/test/libsolidity/GasMeter.cpp index 601948bc..d765d440 100644 --- a/test/libsolidity/GasMeter.cpp +++ b/test/libsolidity/GasMeter.cpp @@ -44,7 +44,6 @@ namespace test class GasMeterTestFramework: public SolidityExecutionFramework { public: - GasMeterTestFramework() { } void compile(string const& _sourceCode) { m_compiler.reset(false); @@ -62,7 +61,7 @@ public: ); } - void testCreationTimeGas(string const& _sourceCode) + void testCreationTimeGas(string const& _sourceCode, u256 const& _tolerance = u256(0)) { compileAndRun(_sourceCode); auto state = make_shared<KnownState>(); @@ -75,12 +74,13 @@ public: gas += gasForTransaction(m_compiler.object(m_compiler.lastContractName()).bytecode, true); BOOST_REQUIRE(!gas.isInfinite); - BOOST_CHECK_EQUAL(gas.value, m_gasUsed); + BOOST_CHECK_LE(m_gasUsed, gas.value); + BOOST_CHECK_LE(gas.value - _tolerance, m_gasUsed); } /// Compares the gas computed by PathGasMeter for the given signature (but unknown arguments) /// against the actual gas usage computed by the VM on the given set of argument variants. - void testRunTimeGas(string const& _sig, vector<bytes> _argumentVariants) + void testRunTimeGas(string const& _sig, vector<bytes> _argumentVariants, u256 const& _tolerance = u256(0)) { u256 gasUsed = 0; GasMeter::GasConsumption gas; @@ -98,7 +98,8 @@ public: _sig ); BOOST_REQUIRE(!gas.isInfinite); - BOOST_CHECK_EQUAL(gas.value, m_gasUsed); + BOOST_CHECK_LE(m_gasUsed, gas.value); + BOOST_CHECK_LE(gas.value - _tolerance, m_gasUsed); } static GasMeter::GasConsumption gasForTransaction(bytes const& _data, bool _isCreation) @@ -138,8 +139,7 @@ BOOST_AUTO_TEST_CASE(non_overlapping_filtered_costs) if (first->first->location().intersects(second->first->location())) { BOOST_CHECK_MESSAGE(false, "Source locations should not overlap!"); - auto scannerFromSource = [&](string const& _sourceName) -> Scanner const& { return m_compiler.scanner(_sourceName); }; - SourceReferenceFormatter formatter(cout, scannerFromSource); + SourceReferenceFormatter formatter(cout); formatter.printSourceLocation(&first->first->location()); formatter.printSourceLocation(&second->first->location()); @@ -187,7 +187,7 @@ BOOST_AUTO_TEST_CASE(updating_store) } } )"; - testCreationTimeGas(sourceCode); + testCreationTimeGas(sourceCode, m_evmVersion < EVMVersion::constantinople() ? u256(0) : u256(9600)); } BOOST_AUTO_TEST_CASE(branches) diff --git a/test/libsolidity/InlineAssembly.cpp b/test/libsolidity/InlineAssembly.cpp index 11d4c59f..b6986041 100644 --- a/test/libsolidity/InlineAssembly.cpp +++ b/test/libsolidity/InlineAssembly.cpp @@ -433,8 +433,7 @@ BOOST_AUTO_TEST_CASE(variable_access_cross_functions) BOOST_AUTO_TEST_CASE(invalid_tuple_assignment) { - /// The push(42) is added here to silence the unbalanced stack error, so that there's only one error reported. - CHECK_PARSE_ERROR("{ 42 let x, y := 1 }", DeclarationError, "Variable count mismatch."); + CHECK_PARSE_ERROR("{ let x, y := 1 }", DeclarationError, "Variable count mismatch: 2 variables and 1 values"); } BOOST_AUTO_TEST_CASE(instruction_too_few_arguments) diff --git a/test/libsolidity/LibSolc.cpp b/test/libsolidity/LibSolc.cpp index 09c08700..ec97f22f 100644 --- a/test/libsolidity/LibSolc.cpp +++ b/test/libsolidity/LibSolc.cpp @@ -81,7 +81,9 @@ BOOST_AUTO_TEST_CASE(standard_compilation) // Only tests some assumptions. The StandardCompiler is tested properly in another suite. BOOST_CHECK(result.isMember("sources")); - BOOST_CHECK(result.isMember("contracts")); + // This used to test that it is a member, but we did not actually request any output, + // so there should not be a contract member. + BOOST_CHECK(!result.isMember("contracts")); } BOOST_AUTO_TEST_SUITE_END() diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp index a8a67bca..63f2b3a6 100644 --- a/test/libsolidity/SolidityABIJSON.cpp +++ b/test/libsolidity/SolidityABIJSON.cpp @@ -38,8 +38,6 @@ namespace test class JSONInterfaceChecker { public: - JSONInterfaceChecker(): m_compilerStack() {} - void checkInterface(std::string const& _code, std::string const& _contractName, std::string const& _expectedInterfaceString) { m_compilerStack.reset(false); diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index c6135a72..8d219d16 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -3039,7 +3039,8 @@ BOOST_AUTO_TEST_CASE(gaslimit) } )"; compileAndRun(sourceCode); - ABI_CHECK(callContractFunction("f()"), encodeArgs(gasLimit())); + auto result = callContractFunction("f()"); + ABI_CHECK(result, encodeArgs(gasLimit())); } BOOST_AUTO_TEST_CASE(gasprice) @@ -12245,7 +12246,7 @@ BOOST_AUTO_TEST_CASE(include_creation_bytecode_only_once) compileAndRun(sourceCode); BOOST_CHECK_LE( double(m_compiler.object("Double").bytecode.size()), - 1.1 * double(m_compiler.object("Single").bytecode.size()) + 1.2 * double(m_compiler.object("Single").bytecode.size()) ); } diff --git a/test/libsolidity/SolidityExecutionFramework.h b/test/libsolidity/SolidityExecutionFramework.h index cedbf51a..73377eb9 100644 --- a/test/libsolidity/SolidityExecutionFramework.h +++ b/test/libsolidity/SolidityExecutionFramework.h @@ -72,8 +72,7 @@ public: m_compiler.setOptimiserSettings(m_optimize, m_optimizeRuns); if (!m_compiler.compile()) { - auto scannerFromSourceName = [&](std::string const& _sourceName) -> langutil::Scanner const& { return m_compiler.scanner(_sourceName); }; - langutil::SourceReferenceFormatter formatter(std::cerr, scannerFromSourceName); + langutil::SourceReferenceFormatter formatter(std::cerr); for (auto const& error: m_compiler.errors()) formatter.printExceptionInformation( diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index 8bce26c1..f5c4dc5e 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -366,7 +366,7 @@ BOOST_AUTO_TEST_CASE(unary_operators) { char const* sourceCode = R"( contract test { - function f(int y) { !(~+- y == 2); } + function f(int y) { !(~- y == 2); } } )"; bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}}); diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 75726027..774f67fe 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -376,18 +376,6 @@ BOOST_AUTO_TEST_CASE(warn_nonpresent_pragma) BOOST_CHECK(searchErrorMessage(*sourceAndError.second.front(), "Source file does not specify required compiler version!")); } -BOOST_AUTO_TEST_CASE(unsatisfied_version) -{ - char const* text = R"( - pragma solidity ^99.99.0; - )"; - auto sourceAndError = parseAnalyseAndReturnError(text, false, false, false); - BOOST_REQUIRE(!sourceAndError.second.empty()); - BOOST_REQUIRE(!!sourceAndError.first); - BOOST_CHECK(sourceAndError.second.front()->type() == Error::Type::SyntaxError); - BOOST_CHECK(searchErrorMessage(*sourceAndError.second.front(), "Source file requires different compiler version")); -} - BOOST_AUTO_TEST_CASE(returndatasize_as_variable) { char const* text = R"( diff --git a/test/libsolidity/SolidityNatspecJSON.cpp b/test/libsolidity/SolidityNatspecJSON.cpp index d930f697..000a7938 100644 --- a/test/libsolidity/SolidityNatspecJSON.cpp +++ b/test/libsolidity/SolidityNatspecJSON.cpp @@ -39,8 +39,6 @@ namespace test class DocumentationChecker { public: - DocumentationChecker(): m_compilerStack() {} - void checkNatspec( std::string const& _code, std::string const& _contractName, diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp index f925d36e..b5ce6f2a 100644 --- a/test/libsolidity/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -45,8 +45,6 @@ namespace test class OptimizerTestFramework: public SolidityExecutionFramework { public: - OptimizerTestFramework() { } - bytes const& compileAndRunWithOptimizer( std::string const& _sourceCode, u256 const& _value = 0, diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp index d86d3d39..a33c6134 100644 --- a/test/libsolidity/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -113,6 +113,23 @@ while(0) BOOST_AUTO_TEST_SUITE(SolidityParser) +BOOST_AUTO_TEST_CASE(unsatisfied_version) +{ + char const* text = R"( + pragma solidity ^99.99.0; + )"; + CHECK_PARSE_ERROR(text, "Source file requires different compiler version"); +} + +BOOST_AUTO_TEST_CASE(unsatisfied_version_followed_by_invalid_syntax) +{ + char const* text = R"( + pragma solidity ^99.99.0; + this is surely invalid + )"; + CHECK_PARSE_ERROR(text, "Source file requires different compiler version"); +} + BOOST_AUTO_TEST_CASE(function_natspec_documentation) { char const* text = R"( diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp index 1570a9d2..118d8210 100644 --- a/test/libsolidity/StandardCompiler.cpp +++ b/test/libsolidity/StandardCompiler.cpp @@ -333,11 +333,11 @@ BOOST_AUTO_TEST_CASE(basic_compilation) " /* \"fileA\":0:14 contract A { } */\n mstore(0x40, 0x80)\n " "callvalue\n /* \"--CODEGEN--\":8:17 */\n dup1\n " "/* \"--CODEGEN--\":5:7 */\n iszero\n tag_1\n jumpi\n " - "/* \"--CODEGEN--\":30:31 */\n 0x0\n /* \"--CODEGEN--\":27:28 */\n " + "/* \"--CODEGEN--\":30:31 */\n 0x00\n /* \"--CODEGEN--\":27:28 */\n " "dup1\n /* \"--CODEGEN--\":20:32 */\n revert\n /* \"--CODEGEN--\":5:7 */\n" "tag_1:\n /* \"fileA\":0:14 contract A { } */\n pop\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, 0x80)\n 0x0\n " + "dataOffset(sub_0)\n 0x00\n codecopy\n 0x00\n return\nstop\n\nsub_0: assembly {\n " + "/* \"fileA\":0:14 contract A { } */\n mstore(0x40, 0x80)\n 0x00\n " "dup1\n revert\n\n auxdata: 0xa165627a7a72305820" ) == 0); BOOST_CHECK(contract["evm"]["gasEstimates"].isObject()); diff --git a/test/libsolidity/smtCheckerTests/functions/functions_identity_as_tuple.sol b/test/libsolidity/smtCheckerTests/functions/functions_identity_as_tuple.sol index 3793f411..2ecff63e 100644 --- a/test/libsolidity/smtCheckerTests/functions/functions_identity_as_tuple.sol +++ b/test/libsolidity/smtCheckerTests/functions/functions_identity_as_tuple.sol @@ -12,3 +12,4 @@ contract C } // ---- +// Warning: (153-156): Assertion checker does not yet implement tuples and inline arrays. diff --git a/test/libsolidity/smtCheckerTests/functions/functions_identity_as_tuple_fail.sol b/test/libsolidity/smtCheckerTests/functions/functions_identity_as_tuple_fail.sol index e3c80594..a9bde9e4 100644 --- a/test/libsolidity/smtCheckerTests/functions/functions_identity_as_tuple_fail.sol +++ b/test/libsolidity/smtCheckerTests/functions/functions_identity_as_tuple_fail.sol @@ -12,4 +12,5 @@ contract C } // ---- +// Warning: (153-156): Assertion checker does not yet implement tuples and inline arrays. // Warning: (163-176): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/loops/do_while_1_fail.sol b/test/libsolidity/smtCheckerTests/loops/do_while_1_fail.sol new file mode 100644 index 00000000..df6eaaa7 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/loops/do_while_1_fail.sol @@ -0,0 +1,17 @@ +pragma experimental SMTChecker; + +contract C +{ + function f(uint x) public pure { + require(x < 100); + do { + // Overflows due to resetting x. + x = x + 1; + } while (x < 10); + assert(x < 14); + } +} +// ---- +// Warning: (150-155): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning: (146-155): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning: (179-193): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/loops/do_while_1_false_positives.sol b/test/libsolidity/smtCheckerTests/loops/do_while_1_false_positives.sol new file mode 100644 index 00000000..49a1e0a5 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/loops/do_while_1_false_positives.sol @@ -0,0 +1,19 @@ +pragma experimental SMTChecker; + +contract C +{ + function f(uint x) public pure { + require(x < 100); + do { + // Overflows due to resetting x. + x = x + 1; + } while (x < 1000); + // The assertion is true but we can't infer so + // because x is touched in the loop. + assert(x > 0); + } +} +// ---- +// Warning: (150-155): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning: (146-155): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning: (269-282): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/loops/for_1_fail.sol b/test/libsolidity/smtCheckerTests/loops/for_1_fail.sol new file mode 100644 index 00000000..2be01c2d --- /dev/null +++ b/test/libsolidity/smtCheckerTests/loops/for_1_fail.sol @@ -0,0 +1,17 @@ +pragma experimental SMTChecker; + +contract C +{ + function f(uint x) public pure { + require(x < 100); + for(uint i = 0; i < 10; ++i) { + // Overflows due to resetting x. + x = x + 1; + } + assert(x < 14); + } +} +// ---- +// Warning: (176-181): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning: (172-181): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning: (189-203): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/loops/for_1_false_positive.sol b/test/libsolidity/smtCheckerTests/loops/for_1_false_positive.sol new file mode 100644 index 00000000..c8232ab6 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/loops/for_1_false_positive.sol @@ -0,0 +1,18 @@ +pragma experimental SMTChecker; + +contract C +{ + function f(uint x) public pure { + require(x < 100); + for(uint i = 0; i < 10; ++i) { + // Overflows due to resetting x. + x = x + 1; + } + // The assertion is true but x is touched and reset. + assert(x > 0); + } +} +// ---- +// Warning: (176-181): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning: (172-181): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning: (244-257): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/loops/for_loop_5.sol b/test/libsolidity/smtCheckerTests/loops/for_loop_5.sol index 2c84960f..eb62d36e 100644 --- a/test/libsolidity/smtCheckerTests/loops/for_loop_5.sol +++ b/test/libsolidity/smtCheckerTests/loops/for_loop_5.sol @@ -9,4 +9,4 @@ contract C { } } // ---- -// Warning: (167-181): Assertion violation happens here\nNote that some information is erased after the execution of loops.\nYou can re-introduce information using require(). +// Warning: (167-181): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/loops/for_loop_6.sol b/test/libsolidity/smtCheckerTests/loops/for_loop_6.sol index 90c4c328..b0c3cae4 100644 --- a/test/libsolidity/smtCheckerTests/loops/for_loop_6.sol +++ b/test/libsolidity/smtCheckerTests/loops/for_loop_6.sol @@ -5,8 +5,9 @@ contract C { for (y = 2; x < 10; ) { y = 3; } - assert(y == 2); + // False positive due to resetting y. + assert(y < 4); } } // ---- -// Warning: (167-181): Assertion violation happens here\nNote that some information is erased after the execution of loops.\nYou can re-introduce information using require(). +// Warning: (213-226): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/loops/for_loop_trivial_condition_1.sol b/test/libsolidity/smtCheckerTests/loops/for_loop_trivial_condition_1.sol new file mode 100644 index 00000000..21e6c91e --- /dev/null +++ b/test/libsolidity/smtCheckerTests/loops/for_loop_trivial_condition_1.sol @@ -0,0 +1,10 @@ +pragma experimental SMTChecker; +contract C { + function f(uint x) public pure { + require(x == 2); + for (; x == 2;) {} + assert(x == 2); + } +} +// ---- +// Warning: (122-128): For loop condition is always true. diff --git a/test/libsolidity/smtCheckerTests/loops/for_loop_trivial_condition_2.sol b/test/libsolidity/smtCheckerTests/loops/for_loop_trivial_condition_2.sol new file mode 100644 index 00000000..6184c441 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/loops/for_loop_trivial_condition_2.sol @@ -0,0 +1,13 @@ +pragma experimental SMTChecker; +contract C { + function f(uint x) public pure { + require(x == 2); + uint y; + for (; x == 2;) { + y = 7; + } + assert(x == 2); + } +} +// ---- +// Warning: (138-144): For loop condition is always true. diff --git a/test/libsolidity/smtCheckerTests/loops/for_loop_trivial_condition_3.sol b/test/libsolidity/smtCheckerTests/loops/for_loop_trivial_condition_3.sol new file mode 100644 index 00000000..eec59ded --- /dev/null +++ b/test/libsolidity/smtCheckerTests/loops/for_loop_trivial_condition_3.sol @@ -0,0 +1,18 @@ +pragma experimental SMTChecker; +contract C { + function f(uint x) public pure { + require(x == 2); + uint y; + // The loop condition is always true, + // but since x is touched in the body + // we can't infer that. + for (; x == 2;) { + x = 2; + } + // False positive due to resetting x. + assert(x == 2); + } +} +// ---- +// Warning: (115-121): Unused local variable. +// Warning: (356-370): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/loops/for_loop_unreachable_1.sol b/test/libsolidity/smtCheckerTests/loops/for_loop_unreachable_1.sol new file mode 100644 index 00000000..f367d8d9 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/loops/for_loop_unreachable_1.sol @@ -0,0 +1,10 @@ +pragma experimental SMTChecker; +contract C { + function f(uint x) public pure { + require(x == 2); + for (; x > 2;) {} + assert(x == 2); + } +} +// ---- +// Warning: (122-127): For loop condition is always false. diff --git a/test/libsolidity/smtCheckerTests/loops/while_1.sol b/test/libsolidity/smtCheckerTests/loops/while_1.sol new file mode 100644 index 00000000..871ed929 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/loops/while_1.sol @@ -0,0 +1,17 @@ +pragma experimental SMTChecker; + +contract C +{ + function f(uint x, bool b) public pure { + require(x < 100); + while (x < 10) { + if (b) + x = x + 1; + else + x = 0; + } + assert(x > 0); + } +} +// ---- +// Warning: (177-190): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/loops/while_1_fail.sol b/test/libsolidity/smtCheckerTests/loops/while_1_fail.sol new file mode 100644 index 00000000..6964f7c8 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/loops/while_1_fail.sol @@ -0,0 +1,14 @@ +pragma experimental SMTChecker; + +contract C +{ + function f(uint x) public pure { + require(x < 100); + while (x < 10) { + x = x + 1; + } + assert(x < 14); + } +} +// ---- +// Warning: (139-153): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/loops/while_2_fail.sol b/test/libsolidity/smtCheckerTests/loops/while_2_fail.sol new file mode 100644 index 00000000..4c52287d --- /dev/null +++ b/test/libsolidity/smtCheckerTests/loops/while_2_fail.sol @@ -0,0 +1,15 @@ +pragma experimental SMTChecker; +contract C { + function f(uint x) public pure { + x = 2; + while (x > 1) { + if (x > 10) + x = 2; + else + x = 10; + } + assert(x == 2); + } +} +// ---- +// Warning: (158-172): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/loops/while_loop_simple_1.sol b/test/libsolidity/smtCheckerTests/loops/while_loop_simple_1.sol index 074be86f..9b5d04c3 100644 --- a/test/libsolidity/smtCheckerTests/loops/while_loop_simple_1.sol +++ b/test/libsolidity/smtCheckerTests/loops/while_loop_simple_1.sol @@ -4,10 +4,10 @@ contract C { function f(uint x) public pure { x = 2; while (x > 1) { - x = 2; + x = 1; } assert(x == 2); } } // ---- -// Warning: (194-208): Assertion violation happens here\nNote that some information is erased after the execution of loops.\nYou can re-introduce information using require(). +// Warning: (194-208): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/loops/while_loop_simple_3.sol b/test/libsolidity/smtCheckerTests/loops/while_loop_simple_3.sol index a37df888..f3634edb 100644 --- a/test/libsolidity/smtCheckerTests/loops/while_loop_simple_3.sol +++ b/test/libsolidity/smtCheckerTests/loops/while_loop_simple_3.sol @@ -8,4 +8,4 @@ contract C { } } // ---- -// Warning: (187-201): Assertion violation happens here\nNote that some information is erased after the execution of loops.\nYou can re-introduce information using require(). +// Warning: (187-201): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/loops/while_loop_simple_4.sol b/test/libsolidity/smtCheckerTests/loops/while_loop_simple_4.sol index f71da865..5a3aee9e 100644 --- a/test/libsolidity/smtCheckerTests/loops/while_loop_simple_4.sol +++ b/test/libsolidity/smtCheckerTests/loops/while_loop_simple_4.sol @@ -8,4 +8,4 @@ contract C { } } // ---- -// Warning: (199-213): Assertion violation happens here\nNote that some information is erased after the execution of loops.\nYou can re-introduce information using require(). +// Warning: (199-213): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/loops/while_loop_simple_5.sol b/test/libsolidity/smtCheckerTests/loops/while_loop_simple_5.sol index 41559c99..6c81e36f 100644 --- a/test/libsolidity/smtCheckerTests/loops/while_loop_simple_5.sol +++ b/test/libsolidity/smtCheckerTests/loops/while_loop_simple_5.sol @@ -9,4 +9,4 @@ contract C { } } // ---- -// Warning: (216-230): Assertion violation happens here\nNote that some information is erased after the execution of loops.\nYou can re-introduce information using require(). +// Warning: (216-230): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/overflow/simple_overflow.sol b/test/libsolidity/smtCheckerTests/overflow/simple_overflow.sol index 894ff1a4..ec819b80 100644 --- a/test/libsolidity/smtCheckerTests/overflow/simple_overflow.sol +++ b/test/libsolidity/smtCheckerTests/overflow/simple_overflow.sol @@ -3,4 +3,4 @@ contract C { function f(uint a, uint b) public pure returns (uint) { return a + b; } } // ---- -// Warning: (112-117): Overflow (resulting value larger than 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) happens here +// Warning: (112-117): Overflow (resulting value larger than 2**256 - 1) happens here diff --git a/test/libsolidity/smtCheckerTests/special/many.sol b/test/libsolidity/smtCheckerTests/special/many.sol index 40e5d987..ae60b1e5 100644 --- a/test/libsolidity/smtCheckerTests/special/many.sol +++ b/test/libsolidity/smtCheckerTests/special/many.sol @@ -20,6 +20,6 @@ contract C // Warning: (165-204): Assertion violation happens here // Warning: (208-240): Assertion violation happens here // Warning: (244-275): Assertion violation happens here -// Warning: (311-316): Overflow (resulting value larger than 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) happens here +// Warning: (311-316): Overflow (resulting value larger than 2**256 - 1) happens here // Warning: (336-352): Assertion violation happens here // Warning: (356-379): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/special/msg_data.sol b/test/libsolidity/smtCheckerTests/special/msg_data.sol index 7e748f09..b667f971 100644 --- a/test/libsolidity/smtCheckerTests/special/msg_data.sol +++ b/test/libsolidity/smtCheckerTests/special/msg_data.sol @@ -8,7 +8,6 @@ contract C } // ---- // Warning: (86-101): Assertion checker does not yet support this expression. -// Warning: (86-94): Assertion checker does not yet support this special variable. -// Warning: (86-94): Assertion checker does not yet implement this type. +// Warning: (86-94): Assertion checker does not yet support this global variable. // Warning: (86-101): Internal error: Expression undefined for SMT solver. // Warning: (79-106): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/types/bytes_1.sol b/test/libsolidity/smtCheckerTests/types/bytes_1.sol new file mode 100644 index 00000000..fb957421 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/types/bytes_1.sol @@ -0,0 +1,16 @@ +pragma experimental SMTChecker; + +contract C +{ + function f(bytes memory b) public pure returns (bytes memory) { + bytes memory c = b; + return b; + } +} +// ---- +// Warning: (113-127): Unused local variable. +// Warning: (113-127): Assertion checker does not yet support the type of this variable. +// Warning: (58-72): Assertion checker does not yet support the type of this variable. +// Warning: (95-107): Assertion checker does not yet support the type of this variable. +// Warning: (130-131): Internal error: Expression undefined for SMT solver. +// Warning: (130-131): Assertion checker does not yet implement this type. diff --git a/test/libsolidity/smtCheckerTests/types/mapping_1.sol b/test/libsolidity/smtCheckerTests/types/mapping_1.sol new file mode 100644 index 00000000..4d71ff38 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/types/mapping_1.sol @@ -0,0 +1,10 @@ +pragma experimental SMTChecker; + +contract C +{ + mapping (uint => uint) map; + function f(uint x) public { + map[2] = x; + assert(x == map[2]); + } +} diff --git a/test/libsolidity/smtCheckerTests/types/mapping_1_fail.sol b/test/libsolidity/smtCheckerTests/types/mapping_1_fail.sol new file mode 100644 index 00000000..83c963ad --- /dev/null +++ b/test/libsolidity/smtCheckerTests/types/mapping_1_fail.sol @@ -0,0 +1,13 @@ +pragma experimental SMTChecker; + +contract C +{ + mapping (uint => uint) map; + function f(uint x) public { + map[2] = x; + map[2] = 3; + assert(x != map[2]); + } +} +// ---- +// Warning: (134-153): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/types/mapping_2.sol b/test/libsolidity/smtCheckerTests/types/mapping_2.sol new file mode 100644 index 00000000..06d618bd --- /dev/null +++ b/test/libsolidity/smtCheckerTests/types/mapping_2.sol @@ -0,0 +1,11 @@ +pragma experimental SMTChecker; + +contract C +{ + mapping (uint => bool) map; + function f(bool x) public view { + assert(x != map[2]); + } +} +// ---- +// Warning: (111-130): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/types/mapping_2d_1.sol b/test/libsolidity/smtCheckerTests/types/mapping_2d_1.sol new file mode 100644 index 00000000..b6474903 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/types/mapping_2d_1.sol @@ -0,0 +1,14 @@ +pragma experimental SMTChecker; + +contract C +{ + mapping (uint => mapping (uint => uint)) map; + function f(uint x) public { + x = 42; + map[13][14] = 42; + assert(x == map[13][14]); + } +} +// ---- +// Warning: (134-145): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays. +// Warning: (154-178): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/types/mapping_2d_1_fail.sol b/test/libsolidity/smtCheckerTests/types/mapping_2d_1_fail.sol new file mode 100644 index 00000000..dd4d568e --- /dev/null +++ b/test/libsolidity/smtCheckerTests/types/mapping_2d_1_fail.sol @@ -0,0 +1,14 @@ +pragma experimental SMTChecker; + +contract C +{ + mapping (uint => mapping (uint => uint)) map; + function f(uint x) public { + x = 41; + map[13][14] = 42; + assert(x == map[13][14]); + } +} +// ---- +// Warning: (134-145): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays. +// Warning: (154-178): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/types/mapping_3.sol b/test/libsolidity/smtCheckerTests/types/mapping_3.sol new file mode 100644 index 00000000..985ed3a3 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/types/mapping_3.sol @@ -0,0 +1,12 @@ +pragma experimental SMTChecker; + +contract C +{ + mapping (uint => uint) map; + function f() public { + map[1] = 111; + uint x = map[2]; + map[1] = 112; + assert(map[2] == x); + } +} diff --git a/test/libsolidity/smtCheckerTests/types/mapping_3d_1.sol b/test/libsolidity/smtCheckerTests/types/mapping_3d_1.sol new file mode 100644 index 00000000..6c5f439a --- /dev/null +++ b/test/libsolidity/smtCheckerTests/types/mapping_3d_1.sol @@ -0,0 +1,14 @@ +pragma experimental SMTChecker; + +contract C +{ + mapping (uint => mapping (uint => mapping (uint => uint))) map; + function f(uint x) public { + x = 42; + map[13][14][15] = 42; + assert(x == map[13][14][15]); + } +} +// ---- +// Warning: (152-167): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays. +// Warning: (176-204): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/types/mapping_3d_1_fail.sol b/test/libsolidity/smtCheckerTests/types/mapping_3d_1_fail.sol new file mode 100644 index 00000000..dfd4ddaf --- /dev/null +++ b/test/libsolidity/smtCheckerTests/types/mapping_3d_1_fail.sol @@ -0,0 +1,14 @@ +pragma experimental SMTChecker; + +contract C +{ + mapping (uint => mapping (uint => mapping (uint => uint))) map; + function f(uint x) public { + x = 41; + map[13][14][15] = 42; + assert(x == map[13][14][15]); + } +} +// ---- +// Warning: (152-167): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays. +// Warning: (176-204): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/types/mapping_4.sol b/test/libsolidity/smtCheckerTests/types/mapping_4.sol new file mode 100644 index 00000000..d0204211 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/types/mapping_4.sol @@ -0,0 +1,12 @@ +pragma experimental SMTChecker; + +contract C +{ + mapping (bool => bool) map; + function f(bool x) public view { + require(x); + assert(x != map[x]); + } +} +// ---- +// Warning: (125-144): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/types/mapping_5.sol b/test/libsolidity/smtCheckerTests/types/mapping_5.sol new file mode 100644 index 00000000..4acea501 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/types/mapping_5.sol @@ -0,0 +1,11 @@ +pragma experimental SMTChecker; + +contract C +{ + mapping (address => uint) map; + function f(address a, uint x) public view { + assert(x != map[a]); + } +} +// ---- +// Warning: (125-144): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/types/mapping_aliasing_1.sol b/test/libsolidity/smtCheckerTests/types/mapping_aliasing_1.sol new file mode 100644 index 00000000..39d096f5 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/types/mapping_aliasing_1.sol @@ -0,0 +1,18 @@ +pragma experimental SMTChecker; + +contract C +{ + mapping (uint => uint) a; + mapping (uint => uint) b; + + function f() public { + require(a[1] == b[1]); + a[1] = 2; + mapping (uint => uint) storage c = a; + assert(c[1] == 2); + // False negative! Needs aliasing. + assert(a[1] == b[1]); + } +} +// ---- +// Warning: (261-281): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/types/mapping_as_local_var_1.sol b/test/libsolidity/smtCheckerTests/types/mapping_as_local_var_1.sol new file mode 100644 index 00000000..e005fbef --- /dev/null +++ b/test/libsolidity/smtCheckerTests/types/mapping_as_local_var_1.sol @@ -0,0 +1,21 @@ +pragma experimental SMTChecker; + +contract c { + mapping(uint => uint) x; + mapping(uint => uint) y; + function f(bool cond) public { + mapping(uint => uint) storage a = cond ? x : y; + x[2] = 1; + y[2] = 2; + a[2] = 3; + // False positive since aliasing is not yet supported. + if (cond) + assert(a[2] == x[2] && a[2] != y[2]); + else + assert(a[2] == y[2] && a[2] != x[2]); + } +} +// ---- +// Warning: (166-178): Internal error: Expression undefined for SMT solver. +// Warning: (288-324): Assertion violation happens here +// Warning: (336-372): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/types/mapping_as_parameter_1.sol b/test/libsolidity/smtCheckerTests/types/mapping_as_parameter_1.sol new file mode 100644 index 00000000..9aeed32b --- /dev/null +++ b/test/libsolidity/smtCheckerTests/types/mapping_as_parameter_1.sol @@ -0,0 +1,15 @@ +pragma experimental SMTChecker; + +contract c { + mapping(uint => uint) x; + function f(mapping(uint => uint) storage map, uint index, uint value) internal { + map[index] = value; + } + function g(uint a, uint b) public { + f(x, a, b); + // False positive since aliasing is not yet supported. + assert(x[a] == b); + } +} +// ---- +// Warning: (289-306): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/types/mapping_equal_keys_1.sol b/test/libsolidity/smtCheckerTests/types/mapping_equal_keys_1.sol new file mode 100644 index 00000000..188bc59a --- /dev/null +++ b/test/libsolidity/smtCheckerTests/types/mapping_equal_keys_1.sol @@ -0,0 +1,10 @@ +pragma experimental SMTChecker; + +contract C +{ + mapping (uint => uint) map; + function f(uint x, uint y) public view { + require(x == y); + assert(map[x] == map[y]); + } +} diff --git a/test/libsolidity/smtCheckerTests/types/mapping_equal_keys_2.sol b/test/libsolidity/smtCheckerTests/types/mapping_equal_keys_2.sol new file mode 100644 index 00000000..93b249df --- /dev/null +++ b/test/libsolidity/smtCheckerTests/types/mapping_equal_keys_2.sol @@ -0,0 +1,12 @@ +pragma experimental SMTChecker; + +contract C +{ + mapping (uint => uint) map; + function f(uint x, uint y) public view { + assert(x == y); + assert(map[x] == map[y]); + } +} +// ---- +// Warning: (119-133): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/types/mapping_unsupported_key_type_1.sol b/test/libsolidity/smtCheckerTests/types/mapping_unsupported_key_type_1.sol new file mode 100644 index 00000000..f4e3a65f --- /dev/null +++ b/test/libsolidity/smtCheckerTests/types/mapping_unsupported_key_type_1.sol @@ -0,0 +1,17 @@ +pragma experimental SMTChecker; + +contract C +{ + mapping (string => uint) map; + function f(string memory s, uint x) public { + map[s] = x; + assert(x == map[s]); + } +} +// ---- +// Warning: (89-104): Assertion checker does not yet support the type of this variable. +// Warning: (129-130): Internal error: Expression undefined for SMT solver. +// Warning: (129-130): Assertion checker does not yet implement this type. +// Warning: (155-156): Internal error: Expression undefined for SMT solver. +// Warning: (155-156): Assertion checker does not yet implement this type. +// Warning: (139-158): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTestsJSON/multi.json b/test/libsolidity/smtCheckerTestsJSON/multi.json index 2ed5150d..df45fbf4 100644 --- a/test/libsolidity/smtCheckerTestsJSON/multi.json +++ b/test/libsolidity/smtCheckerTestsJSON/multi.json @@ -1,11 +1,11 @@ { - "auxiliaryInput": - { - "smtlib2responses": - { - "0x0426cd198d1e7123a28ffac2b759a666b86508ad046babf5166500dd6d8ed308": "unsat\n(error \"line 31 column 26: model is not available\")", - "0xa51ca41ae407f5a727f27101cbc079834743cc8955f9f585582034ca634953f6": "sat\n((|EVALEXPR_0| 1))", - "0xe9477f683ff20aa57fcb08682150f86c5917e1d4c0686b278ab9b73446d0682c": "sat\n((|EVALEXPR_0| 0))" - } - } + "auxiliaryInput": + { + "smtlib2responses": + { + "0x47826ec8b83cfec30171b34f944aed6c33ecd12f02b9ad522ca45317c9bd5f45": "sat\n((|EVALEXPR_0| 1))", + "0x734c058efe9d6ec224de3cf2bdfa6c936a1c9c159c040c128d631145b2fed195": "unsat\n", + "0xa0c072acdbe5181dd56cbad8960cb5bb0b9e97fd598cfd895467bd73bbcca028": "sat\n((|EVALEXPR_0| 0))" + } + } } diff --git a/test/libsolidity/smtCheckerTestsJSON/simple.json b/test/libsolidity/smtCheckerTestsJSON/simple.json index fd976b63..b82d93b8 100644 --- a/test/libsolidity/smtCheckerTestsJSON/simple.json +++ b/test/libsolidity/smtCheckerTestsJSON/simple.json @@ -1,9 +1,9 @@ { - "auxiliaryInput": - { - "smtlib2responses": - { - "0xe9477f683ff20aa57fcb08682150f86c5917e1d4c0686b278ab9b73446d0682c": "sat\n((|EVALEXPR_0| 0))" - } - } + "auxiliaryInput": + { + "smtlib2responses": + { + "0xa0c072acdbe5181dd56cbad8960cb5bb0b9e97fd598cfd895467bd73bbcca028": "sat\n((|EVALEXPR_0| 0))\n" + } + } } diff --git a/test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_err.sol b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_err.sol index 35420b6d..dbd3db08 100644 --- a/test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_err.sol +++ b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_err.sol @@ -2,4 +2,4 @@ contract C { function f() internal pure returns (mapping(uint=>uint) storage r) { } } // ---- -// TypeError: (53-82): 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: (53-82): This variable is of storage pointer type and can be returned without prior assignment. diff --git a/test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_err.sol b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_err.sol index 52a8b3d7..476e799b 100644 --- a/test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_err.sol +++ b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_err.sol @@ -2,4 +2,4 @@ contract C { function f() internal pure returns (mapping(uint=>uint) storage) {} } // ---- -// TypeError: (53-80): 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: (53-80): This variable is of storage pointer type and can be returned without prior assignment. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_err.sol index cad9b8e8..a6df889d 100644 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_err.sol +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_err.sol @@ -7,4 +7,4 @@ contract C { } } // ---- -// TypeError: (87-96): 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: (87-96): This variable is of storage pointer type and can be returned without prior assignment. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_fine.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_fine.sol deleted file mode 100644 index 0d3db856..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_fine.sol +++ /dev/null @@ -1,26 +0,0 @@ -contract C { - struct S { bool f; } - S s; - function f() internal returns (S storage c) { - assembly { - sstore(c_slot, sload(s_slot)) - } - } - function g(bool flag) internal returns (S storage c) { - // control flow in assembly will not be analyzed for now, - // so this will not issue an error - assembly { - if flag { - sstore(c_slot, sload(s_slot)) - } - } - } - function h() internal returns (S storage c) { - // any reference from assembly will be sufficient for now, - // so this will not issue an error - assembly { - sstore(s_slot, sload(c_slot)) - } - } -} -// ---- diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_err.sol index eb574c96..b868d61d 100644 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_err.sol +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_err.sol @@ -45,8 +45,8 @@ contract C { } } // ---- -// 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. +// TypeError: (87-98): This variable is of storage pointer type and can be returned without prior assignment. +// TypeError: (223-234): This variable is of storage pointer type and can be returned without prior assignment. +// TypeError: (440-451): This variable is of storage pointer type and can be returned without prior assignment. +// TypeError: (654-665): This variable is of storage pointer type and can be returned without prior assignment. +// TypeError: (871-882): This variable is of storage pointer type and can be returned without prior assignment. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_err.sol index 9aa580a4..d2dec9c1 100644 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_err.sol +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_err.sol @@ -12,5 +12,5 @@ contract C { } } // ---- -// 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. +// TypeError: (87-98): This variable is of storage pointer type and can be returned without prior assignment. +// TypeError: (182-193): This variable is of storage pointer type and can be returned without prior assignment. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_err.sol index f3e55318..12ec31e4 100644 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_err.sol +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_err.sol @@ -14,5 +14,5 @@ contract C { } } // ---- -// 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. +// TypeError: (96-107): This variable is of storage pointer type and can be returned without prior assignment. +// TypeError: (186-197): This variable is of storage pointer type and can be returned without prior assignment. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_err.sol index 42342979..ee1e08fd 100644 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_err.sol +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_err.sol @@ -18,5 +18,5 @@ contract C { } } // ---- -// TypeError: (249-258): 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-376): 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: (249-258): This variable is of storage pointer type and can be returned without prior assignment. +// TypeError: (367-376): This variable is of storage pointer type and can be returned without prior assignment. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_err.sol index d0ad8245..e3579628 100644 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_err.sol +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_err.sol @@ -13,6 +13,6 @@ contract C { } } // ---- -// 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. +// TypeError: (87-98): This variable is of storage pointer type and can be returned without prior assignment. +// TypeError: (176-187): This variable is of storage pointer type and can be returned without prior assignment. +// TypeError: (264-275): This variable is of storage pointer type and can be returned without prior assignment. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_err.sol index 6d10287b..d5ad73c5 100644 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_err.sol +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_err.sol @@ -9,5 +9,5 @@ contract C { } } // ---- -// 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. +// TypeError: (96-107): This variable is of storage pointer type and can be returned without prior assignment. +// TypeError: (200-211): This variable is of storage pointer type and can be returned without prior assignment. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_err.sol index e7b4fae7..aabb76dd 100644 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_err.sol +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_err.sol @@ -8,4 +8,4 @@ contract C { } } // ---- -// 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: (87-98): This variable is of storage pointer type and can be returned without prior assignment. diff --git a/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/always_revert.sol b/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/always_revert.sol new file mode 100644 index 00000000..96767402 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/always_revert.sol @@ -0,0 +1,8 @@ +contract C { + function f() internal view returns(uint[] storage a) + { + uint b = a[0]; + revert(); + b; + } +}
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/assembly.sol b/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/assembly.sol new file mode 100644 index 00000000..bfcbbef5 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/assembly.sol @@ -0,0 +1,9 @@ +contract C { + uint[] r; + function f() internal view returns (uint[] storage s) { + assembly { pop(s_slot) } + s = r; + } +} +// ---- +// TypeError: (92-126): This variable is of storage pointer type and can be accessed without prior assignment. diff --git a/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/functionType.sol b/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/functionType.sol new file mode 100644 index 00000000..1d683eff --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/functionType.sol @@ -0,0 +1,8 @@ +contract C { + // Make sure function parameters and return values are not considered + // for uninitialized return detection in the control flow analysis. + function f(function(uint[] storage) internal returns (uint[] storage)) internal pure + returns (function(uint[] storage) internal returns (uint[] storage)) + { + } +} diff --git a/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/modifier_order_fail.sol b/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/modifier_order_fail.sol new file mode 100644 index 00000000..90d228fa --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/modifier_order_fail.sol @@ -0,0 +1,8 @@ +contract C { + modifier m1(uint[] storage a) { _; } + modifier m2(uint[] storage a) { _; } + uint[] s; + function f() m1(b) m2(b = s) internal view returns (uint[] storage b) {} +} +// ---- +// TypeError: (129-130): This variable is of storage pointer type and can be accessed without prior assignment. diff --git a/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/modifier_order_fine.sol b/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/modifier_order_fine.sol new file mode 100644 index 00000000..af133929 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/modifier_order_fine.sol @@ -0,0 +1,6 @@ +contract C { + modifier m1(uint[] storage a) { _; } + modifier m2(uint[] storage a) { _; } + uint[] s; + function f() m1(b = s) m2(b) internal view returns (uint[] storage b) {} +}
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/modifier_post_access.sol b/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/modifier_post_access.sol new file mode 100644 index 00000000..b9f08615 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/modifier_post_access.sol @@ -0,0 +1,13 @@ +contract C { + uint[] s; + modifier mod(uint[] storage b) { + _; + b[0] = 0; + } + function f() mod(a) internal returns (uint[] storage a) + { + a = s; + } +} +// ---- +// TypeError: (120-121): This variable is of storage pointer type and can be accessed without prior assignment. diff --git a/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/modifier_pre_access.sol b/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/modifier_pre_access.sol new file mode 100644 index 00000000..81618aec --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/modifier_pre_access.sol @@ -0,0 +1,13 @@ +contract C { + uint[] s; + modifier mod(uint[] storage b) { + b[0] = 0; + _; + } + function f() mod(a) internal returns (uint[] storage a) + { + a = s; + } +} +// ---- +// TypeError: (120-121): This variable is of storage pointer type and can be accessed without prior assignment. diff --git a/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/smoke.sol b/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/smoke.sol new file mode 100644 index 00000000..41ced51d --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/smoke.sol @@ -0,0 +1,10 @@ +contract C { + uint[] s; + function f() internal returns (uint[] storage a) + { + a[0] = 0; + a = s; + } +} +// ---- +// TypeError: (94-95): This variable is of storage pointer type and can be accessed without prior assignment. diff --git a/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/struct.sol b/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/struct.sol new file mode 100644 index 00000000..b4f2be5d --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/struct.sol @@ -0,0 +1,11 @@ +contract C { + struct S { uint a; } + S s; + function f() internal returns (S storage r) + { + r.a = 0; + r = s; + } +} +// ---- +// TypeError: (109-110): This variable is of storage pointer type and can be accessed without prior assignment. diff --git a/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/unreachable.sol b/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/unreachable.sol new file mode 100644 index 00000000..b941ad34 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/unreachable.sol @@ -0,0 +1,10 @@ +contract C { + uint[] s; + function f() internal returns (uint[] storage a) + { + revert(); + a[0] = 0; + a = s; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/dataLocations/libraries/library_function_with_data_location_fine.sol b/test/libsolidity/syntaxTests/dataLocations/libraries/library_function_with_data_location_fine.sol index 7a276f95..95d4e02a 100644 --- a/test/libsolidity/syntaxTests/dataLocations/libraries/library_function_with_data_location_fine.sol +++ b/test/libsolidity/syntaxTests/dataLocations/libraries/library_function_with_data_location_fine.sol @@ -8,3 +8,9 @@ library L { function i(uint[] calldata, uint[] storage) external pure returns (S storage x) {return x; } } // ---- +// TypeError: (197-198): This variable is of storage pointer type and can be accessed without prior assignment. +// TypeError: (203-204): This variable is of storage pointer type and can be accessed without prior assignment. +// TypeError: (359-360): This variable is of storage pointer type and can be accessed without prior assignment. +// TypeError: (365-366): This variable is of storage pointer type and can be accessed without prior assignment. +// TypeError: (460-461): This variable is of storage pointer type and can be accessed without prior assignment. +// TypeError: (557-558): This variable is of storage pointer type and can be accessed without prior assignment. diff --git a/test/libsolidity/syntaxTests/functionTypes/valid_function_type_variables.sol b/test/libsolidity/syntaxTests/functionTypes/valid_function_type_variables.sol index e7d2c9a9..65198706 100644 --- a/test/libsolidity/syntaxTests/functionTypes/valid_function_type_variables.sol +++ b/test/libsolidity/syntaxTests/functionTypes/valid_function_type_variables.sol @@ -18,9 +18,3 @@ contract test { function(uint) pure internal h = fh; } // ---- -// Warning: (20-47): Function state mutability can be restricted to pure -// Warning: (52-81): Function state mutability can be restricted to pure -// Warning: (86-115): Function state mutability can be restricted to pure -// Warning: (120-149): Function state mutability can be restricted to pure -// Warning: (154-183): Function state mutability can be restricted to pure -// Warning: (188-217): Function state mutability can be restricted to pure 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 ac1f541e..2d36bedd 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol @@ -10,7 +10,5 @@ contract C { } } // ---- -// TypeError: (87-88): Expected 1 arguments but got 0. -// 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. -// SyntaxError: (108-115): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. +// TypeError: (87-88): Function expects 1 arguments but got 0. +// TypeError: (108-109): Function expects 1 arguments but got 2. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/004_reference_to_later_declaration.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/004_reference_to_later_declaration.sol index e112e16c..a554d3ab 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/004_reference_to_later_declaration.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/004_reference_to_later_declaration.sol @@ -3,4 +3,3 @@ contract test { function f() public {} } // ---- -// Warning: (53-75): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/009_type_checking_function_call.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/009_type_checking_function_call.sol index abe2beac..3872b1c3 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/009_type_checking_function_call.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/009_type_checking_function_call.sol @@ -3,4 +3,3 @@ contract test { function g(uint256, bool) public returns (uint256) { } } // ---- -// Warning: (88-142): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/049_function_external_call_allowed_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/049_function_external_call_allowed_conversion.sol index ec72adeb..bda0b946 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/049_function_external_call_allowed_conversion.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/049_function_external_call_allowed_conversion.sol @@ -7,5 +7,3 @@ contract Test { function g (C c) external {} } // ---- -// Warning: (125-128): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (113-141): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/051_function_internal_allowed_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/051_function_internal_allowed_conversion.sol index aedc7b0b..5a9616ac 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/051_function_internal_allowed_conversion.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/051_function_internal_allowed_conversion.sol @@ -9,5 +9,3 @@ contract Test { } } // ---- -// Warning: (68-71): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (56-82): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/055_inheritance_diamond_basic.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/055_inheritance_diamond_basic.sol index c07e59e2..2e235ee0 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/055_inheritance_diamond_basic.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/055_inheritance_diamond_basic.sol @@ -5,5 +5,3 @@ contract derived is root, inter2, inter1 { function g() public { f(); rootFunction(); } } // ---- -// Warning: (16-49): Function state mutability can be restricted to pure -// Warning: (129-151): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/057_legal_override_direct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/057_legal_override_direct.sol index 062507ee..bf6459cb 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/057_legal_override_direct.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/057_legal_override_direct.sol @@ -1,6 +1,3 @@ contract B { function f() public {} } contract C is B { function f(uint i) public {} } // ---- -// Warning: (67-73): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (13-35): Function state mutability can be restricted to pure -// Warning: (56-84): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/058_legal_override_indirect.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/058_legal_override_indirect.sol index f59da472..461bbbf2 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/058_legal_override_indirect.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/058_legal_override_indirect.sol @@ -2,6 +2,3 @@ contract A { function f(uint a) public {} } contract B { function f() public {} } contract C is A, B { } // ---- -// Warning: (24-30): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (13-41): Function state mutability can be restricted to pure -// Warning: (57-79): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/060_complex_inheritance.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/060_complex_inheritance.sol index c7e42238..ce3b622b 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/060_complex_inheritance.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/060_complex_inheritance.sol @@ -3,4 +3,3 @@ contract B { function f() public {} function g() public returns (uint8) {} } contract C is A, B { } // ---- // Warning: (35-42): Unused local variable. -// Warning: (95-133): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/061_missing_base_constructor_arguments.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/061_missing_base_constructor_arguments.sol index 8ebb46aa..31be70ca 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/061_missing_base_constructor_arguments.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/061_missing_base_constructor_arguments.sol @@ -1,4 +1,3 @@ contract A { constructor(uint a) public { } } contract B is A { } // ---- -// Warning: (25-31): Unused function parameter. Remove or comment out the variable name to silence this warning. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/062_base_constructor_arguments_override.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/062_base_constructor_arguments_override.sol index 8ebb46aa..31be70ca 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/062_base_constructor_arguments_override.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/062_base_constructor_arguments_override.sol @@ -1,4 +1,3 @@ contract A { constructor(uint a) public { } } contract B is A { } // ---- -// Warning: (25-31): Unused function parameter. Remove or comment out the variable name to silence this warning. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/096_access_to_default_function_visibility.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/096_access_to_default_function_visibility.sol index 9251df73..4f89e69e 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/096_access_to_default_function_visibility.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/096_access_to_default_function_visibility.sol @@ -5,4 +5,3 @@ contract d { function g() public { c(0).f(); } } // ---- -// Warning: (17-39): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/104_empty_name_input_parameter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/104_empty_name_input_parameter.sol index 824543ef..af392402 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/104_empty_name_input_parameter.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/104_empty_name_input_parameter.sol @@ -2,4 +2,3 @@ contract test { function f(uint) public { } } // ---- -// Warning: (20-47): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/106_empty_name_return_parameter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/106_empty_name_return_parameter.sol index a2ffc6e1..b524cd97 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/106_empty_name_return_parameter.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/106_empty_name_return_parameter.sol @@ -2,4 +2,3 @@ contract test { function f() public returns (bool) { } } // ---- -// Warning: (20-58): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/201_integer_signed_exp_signed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/201_integer_signed_exp_signed.sol index 93e5f065..9d2951b8 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/201_integer_signed_exp_signed.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/201_integer_signed_exp_signed.sol @@ -1,3 +1,9 @@ -contract test { function() external { int x = -3; int y = -4; x ** y; } } +contract test { + function f() public { int x = 3; int y = 4; x ** y; } + function g() public { int16 x = 3; uint8 y = 4; x ** y; } + function h() public { uint8 x = 3; int16 y = 4; x ** y; } +} // ---- -// TypeError: (62-68): Operator ** not compatible with types int256 and int256 +// TypeError: (64-70): Operator ** not compatible with types int256 and int256. Exponentiation is not allowed for signed integer types. +// TypeError: (126-132): Operator ** not compatible with types int16 and uint8. Exponentiation is not allowed for signed integer types. +// TypeError: (188-194): Operator ** not compatible with types uint8 and int16. Exponentiation is not allowed for signed integer types. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/216_function_argument_storage_to_mem.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/216_function_argument_storage_to_mem.sol index c5175a41..0f4388d0 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/216_function_argument_storage_to_mem.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/216_function_argument_storage_to_mem.sol @@ -6,5 +6,3 @@ contract C { } } // ---- -// Warning: (91-106): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (80-122): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/256_using_for_overload.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/256_using_for_overload.sol index 155281f5..f033b85b 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/256_using_for_overload.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/256_using_for_overload.sol @@ -11,4 +11,3 @@ contract C { } } // ---- -// Warning: (128-189): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/260_library_memory_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/260_library_memory_struct.sol index 20d8afa5..ee5bcda9 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/260_library_memory_struct.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/260_library_memory_struct.sol @@ -5,4 +5,3 @@ library c { } // ---- // Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. -// Warning: (75-116): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/288_conditional_with_all_types.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/288_conditional_with_all_types.sol index e9ab08ba..a92c07f3 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/288_conditional_with_all_types.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/288_conditional_with_all_types.sol @@ -85,7 +85,5 @@ contract C { } // ---- // Warning: (1005-1019): This declaration shadows an existing declaration. -// Warning: (90-116): Function state mutability can be restricted to pure -// Warning: (121-147): Function state mutability can be restricted to pure // Warning: (257-642): Function state mutability can be restricted to pure // Warning: (647-1227): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/313_fixed_type_size_capabilities.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/313_fixed_type_size_capabilities.sol index 441cf81e..295cf4ea 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/313_fixed_type_size_capabilities.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/313_fixed_type_size_capabilities.sol @@ -10,4 +10,5 @@ contract test { } } // ---- -// Warning: (20-707): Function state mutability can be restricted to pure +// TypeError: (153-250): Type rational_const 9208...(70 digits omitted)...7637 / 1000...(71 digits omitted)...0000 is not implicitly convertible to expected type ufixed256x77, but it can be explicitly converted. +// TypeError: (470-566): Type rational_const -933...(70 digits omitted)...0123 / 1000...(70 digits omitted)...0000 is not implicitly convertible to expected type fixed256x76, but it can be explicitly converted. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/345_unused_return_value.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/345_unused_return_value.sol index 7f640505..109e8dfb 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/345_unused_return_value.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/345_unused_return_value.sol @@ -5,4 +5,3 @@ contract test { } } // ---- -// Warning: (20-57): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/376_inline_assembly_in_modifier.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/376_inline_assembly_in_modifier.sol index 0032f99e..87a7b28d 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/376_inline_assembly_in_modifier.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/376_inline_assembly_in_modifier.sol @@ -10,4 +10,3 @@ contract test { } } // ---- -// Warning: (122-151): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/403_return_structs.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/403_return_structs.sol index 2575954e..b4088068 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/403_return_structs.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/403_return_structs.sol @@ -7,4 +7,3 @@ contract C { } // ---- // Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. -// Warning: (112-164): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/437_warn_unused_function_parameter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/437_warn_unused_function_parameter.sol index 8a36eaad..4227cbb9 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/437_warn_unused_function_parameter.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/437_warn_unused_function_parameter.sol @@ -3,4 +3,3 @@ contract C { } } // ---- -// Warning: (28-34): Unused function parameter. Remove or comment out the variable name to silence this warning. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/439_warn_unused_return_parameter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/439_warn_unused_return_parameter.sol index b1422c4f..b4c9be35 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/439_warn_unused_return_parameter.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/439_warn_unused_return_parameter.sol @@ -3,4 +3,3 @@ contract C { } } // ---- -// Warning: (51-57): Unused function parameter. Remove or comment out the variable name to silence this warning. diff --git a/test/libsolidity/syntaxTests/parsing/empty_function.sol b/test/libsolidity/syntaxTests/parsing/empty_function.sol index 320a0bcc..3f42e4e3 100644 --- a/test/libsolidity/syntaxTests/parsing/empty_function.sol +++ b/test/libsolidity/syntaxTests/parsing/empty_function.sol @@ -3,7 +3,3 @@ contract test { function functionName(bytes20 arg1, address addr) public view returns (int id) { } } // ---- -// Warning: (58-70): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (72-84): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (107-113): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (36-118): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/external_function.sol b/test/libsolidity/syntaxTests/parsing/external_function.sol index 3aa3ceec..0315b200 100644 --- a/test/libsolidity/syntaxTests/parsing/external_function.sol +++ b/test/libsolidity/syntaxTests/parsing/external_function.sol @@ -2,4 +2,3 @@ contract c { function x() external {} } // ---- -// Warning: (17-41): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol b/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol index 94e1e60a..231be9c2 100644 --- a/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol +++ b/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol @@ -4,6 +4,3 @@ contract test { function functionName(bytes32 input) public returns (bytes32 out) {} } // ---- -// Warning: (97-110): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (128-139): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (75-143): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol b/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol index 11e77f25..42d8717a 100644 --- a/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol +++ b/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol @@ -3,7 +3,3 @@ contract test { function (uint, uint) internal returns (uint) f1 = f; } // ---- -// Warning: (31-37): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (39-45): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (63-69): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (20-73): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol b/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol index 3defb5ea..000c2011 100644 --- a/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol +++ b/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol @@ -5,9 +5,5 @@ contract test { } } // ---- -// Warning: (31-37): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (39-45): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (63-69): Unused function parameter. Remove or comment out the variable name to silence this warning. // Warning: (108-156): Unused local variable. -// Warning: (20-73): Function state mutability can be restricted to pure // Warning: (78-167): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/library_simple.sol b/test/libsolidity/syntaxTests/parsing/library_simple.sol index 006ff307..c892e3ed 100644 --- a/test/libsolidity/syntaxTests/parsing/library_simple.sol +++ b/test/libsolidity/syntaxTests/parsing/library_simple.sol @@ -2,4 +2,3 @@ library Lib { function f() public { } } // ---- -// Warning: (18-41): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol b/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol index cf986efe..6fa007c7 100644 --- a/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol +++ b/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol @@ -4,4 +4,3 @@ contract c { function f() public mod1(7) mod2 { } } // ---- -// Warning: (135-171): Function state mutability can be restricted to view diff --git a/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol b/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol index 85d9e6a8..ba090c53 100644 --- a/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol +++ b/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol @@ -10,15 +10,3 @@ contract test { function functionName4(bytes32 input) public returns (bytes32 out) {} } // ---- -// Warning: (97-110): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (128-139): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (203-216): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (234-245): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (304-317): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (335-346): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (410-423): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (441-452): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (74-143): Function state mutability can be restricted to pure -// Warning: (180-249): Function state mutability can be restricted to pure -// Warning: (281-350): Function state mutability can be restricted to pure -// Warning: (387-456): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/no_function_params.sol b/test/libsolidity/syntaxTests/parsing/no_function_params.sol index 5a024bdb..1f7c85a3 100644 --- a/test/libsolidity/syntaxTests/parsing/no_function_params.sol +++ b/test/libsolidity/syntaxTests/parsing/no_function_params.sol @@ -3,4 +3,3 @@ contract test { function functionName() public {} } // ---- -// Warning: (36-69): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/single_function_param.sol b/test/libsolidity/syntaxTests/parsing/single_function_param.sol index 955f20f0..8dbac272 100644 --- a/test/libsolidity/syntaxTests/parsing/single_function_param.sol +++ b/test/libsolidity/syntaxTests/parsing/single_function_param.sol @@ -3,6 +3,3 @@ contract test { function functionName(bytes32 input) public returns (bytes32 out) {} } // ---- -// Warning: (58-71): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (89-100): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (36-104): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/unary_plus_expression.sol b/test/libsolidity/syntaxTests/parsing/unary_plus_expression.sol index 5646c43b..f2542d90 100644 --- a/test/libsolidity/syntaxTests/parsing/unary_plus_expression.sol +++ b/test/libsolidity/syntaxTests/parsing/unary_plus_expression.sol @@ -6,3 +6,4 @@ contract test { } // ---- // SyntaxError: (70-72): Use of unary + is disallowed. +// TypeError: (70-72): Unary operator + cannot be applied to type uint256 diff --git a/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol b/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol index db890b37..24071388 100644 --- a/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol +++ b/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol @@ -9,6 +9,3 @@ contract c { } // ---- // Warning: (58-71): This declaration shadows an existing declaration. -// Warning: (89-111): Function state mutability can be restricted to pure -// Warning: (116-144): Function state mutability can be restricted to pure -// Warning: (149-182): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/types/address/address_binary_operators.sol b/test/libsolidity/syntaxTests/types/address/address_binary_operators.sol new file mode 100644 index 00000000..f721f4a9 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/address_binary_operators.sol @@ -0,0 +1,15 @@ +contract C { + address a; + function f() public pure returns(bool) { + a = address(0) + address(0); + a = address(0) - address(0); + a = address(0) * address(0); + a = address(0) / address(0); + return address(0) == address(0); + } +} +// ---- +// TypeError: (85-108): Operator + not compatible with types address payable and address payable. Arithmetic operations on addresses are not supported. Convert to integer first before using them. +// TypeError: (122-145): Operator - not compatible with types address payable and address payable. Arithmetic operations on addresses are not supported. Convert to integer first before using them. +// TypeError: (159-182): Operator * not compatible with types address payable and address payable. Arithmetic operations on addresses are not supported. Convert to integer first before using them. +// TypeError: (196-219): Operator / not compatible with types address payable and address payable. Arithmetic operations on addresses are not supported. Convert to integer first before using them. diff --git a/test/libsolidity/syntaxTests/types/rational_number_div_limit.sol b/test/libsolidity/syntaxTests/types/rational_number_div_limit.sol index 1b0b5f94..31226781 100644 --- a/test/libsolidity/syntaxTests/types/rational_number_div_limit.sol +++ b/test/libsolidity/syntaxTests/types/rational_number_div_limit.sol @@ -5,5 +5,5 @@ contract c { } } // ---- -// TypeError: (71-92): Operator / not compatible with types rational_const 1 / 5221...(1225 digits omitted)...5168 and int_const 5221...(1225 digits omitted)...5168 +// TypeError: (71-92): Operator / not compatible with types rational_const 1 / 5221...(1225 digits omitted)...5168 and int_const 5221...(1225 digits omitted)...5168. Precision of rational constants is limited to 4096 bits. // TypeError: (71-92): Type rational_const 1 / 5221...(1225 digits omitted)...5168 is not implicitly convertible to expected type int256. Try converting to type ufixed8x80 or use an explicit conversion. diff --git a/test/libsolidity/syntaxTests/types/rational_number_exp_limit_fail.sol b/test/libsolidity/syntaxTests/types/rational_number_exp_limit_fail.sol index 058db2e9..80b23eff 100644 --- a/test/libsolidity/syntaxTests/types/rational_number_exp_limit_fail.sol +++ b/test/libsolidity/syntaxTests/types/rational_number_exp_limit_fail.sol @@ -19,23 +19,23 @@ contract c { } } // ---- -// TypeError: (71-102): Operator ** not compatible with types int_const 1797...(301 digits omitted)...7216 and int_const 4 +// TypeError: (71-102): Operator ** not compatible with types int_const 1797...(301 digits omitted)...7216 and int_const 4. Precision of rational constants is limited to 4096 bits. // TypeError: (71-102): Type int_const 1797...(301 digits omitted)...7216 is not implicitly convertible to expected type int256. -// TypeError: (116-148): Operator ** not compatible with types int_const 1797...(301 digits omitted)...7216 and int_const 4 -// TypeError: (116-153): Operator ** not compatible with types int_const 1797...(301 digits omitted)...7216 and int_const 4 +// TypeError: (116-148): Operator ** not compatible with types int_const 1797...(301 digits omitted)...7216 and int_const 4. Precision of rational constants is limited to 4096 bits. +// TypeError: (116-153): Operator ** not compatible with types int_const 1797...(301 digits omitted)...7216 and int_const 4. Precision of rational constants is limited to 4096 bits. // TypeError: (116-153): Type int_const 1797...(301 digits omitted)...7216 is not implicitly convertible to expected type int256. // TypeError: (167-203): Operator ** not compatible with types int_const 4 and int_const -179...(302 digits omitted)...7216 // TypeError: (217-228): Operator ** not compatible with types int_const 2 and int_const 1000...(1226 digits omitted)...0000 // TypeError: (242-254): Operator ** not compatible with types int_const -2 and int_const 1000...(1226 digits omitted)...0000 // TypeError: (268-280): Operator ** not compatible with types int_const 2 and int_const -100...(1227 digits omitted)...0000 // TypeError: (294-307): Operator ** not compatible with types int_const -2 and int_const -100...(1227 digits omitted)...0000 -// TypeError: (321-332): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const 2 +// TypeError: (321-332): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const 2. Precision of rational constants is limited to 4096 bits. // TypeError: (321-332): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. -// TypeError: (346-358): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const 2 +// TypeError: (346-358): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const 2. Precision of rational constants is limited to 4096 bits. // TypeError: (346-358): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. -// TypeError: (372-384): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const -2 +// TypeError: (372-384): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const -2. Precision of rational constants is limited to 4096 bits. // TypeError: (372-384): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. -// TypeError: (398-411): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const -2 +// TypeError: (398-411): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const -2. Precision of rational constants is limited to 4096 bits. // TypeError: (398-411): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. // TypeError: (425-441): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const 1000...(1226 digits omitted)...0000 // TypeError: (425-441): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. diff --git a/test/libsolidity/syntaxTests/types/rational_number_literal_to_fixed_implicit.sol b/test/libsolidity/syntaxTests/types/rational_number_literal_to_fixed_implicit.sol new file mode 100644 index 00000000..ca50e03b --- /dev/null +++ b/test/libsolidity/syntaxTests/types/rational_number_literal_to_fixed_implicit.sol @@ -0,0 +1,15 @@ +contract C { + function literalToUFixed() public pure { + ufixed8x2 a = 0.10; + ufixed8x2 b = 0.00; + ufixed8x2 c = 2.55; + a; b; c; + } + function literalToFixed() public pure { + fixed8x1 a = 0.1; + fixed8x1 b = 12.7; + fixed8x1 c = -12.8; + a; b; c; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/rational_number_mul_limit.sol b/test/libsolidity/syntaxTests/types/rational_number_mul_limit.sol index bbed94b5..d725b43a 100644 --- a/test/libsolidity/syntaxTests/types/rational_number_mul_limit.sol +++ b/test/libsolidity/syntaxTests/types/rational_number_mul_limit.sol @@ -5,5 +5,5 @@ contract c { } } // ---- -// TypeError: (71-90): Operator * not compatible with types int_const 5221...(1225 digits omitted)...5168 and int_const 5221...(1225 digits omitted)...5168 +// TypeError: (71-90): Operator * not compatible with types int_const 5221...(1225 digits omitted)...5168 and int_const 5221...(1225 digits omitted)...5168. Precision of rational constants is limited to 4096 bits. // TypeError: (71-90): Type int_const 5221...(1225 digits omitted)...5168 is not implicitly convertible to expected type int256. diff --git a/test/libsolidity/syntaxTests/types/too_small_negative_numbers.sol b/test/libsolidity/syntaxTests/types/too_small_negative_numbers.sol index 66bd9a8e..f86ffcdd 100644 --- a/test/libsolidity/syntaxTests/types/too_small_negative_numbers.sol +++ b/test/libsolidity/syntaxTests/types/too_small_negative_numbers.sol @@ -2,3 +2,4 @@ contract C { fixed8x80 a = -1e-100; } // ---- +// TypeError: (29-36): Type rational_const -1 / 1000...(93 digits omitted)...0000 is not implicitly convertible to expected type fixed8x80, but it can be explicitly converted. diff --git a/test/libsolidity/syntaxTests/viewPureChecker/suggest_pure.sol b/test/libsolidity/syntaxTests/viewPureChecker/suggest_pure.sol index 87719eb3..5ec6d06f 100644 --- a/test/libsolidity/syntaxTests/viewPureChecker/suggest_pure.sol +++ b/test/libsolidity/syntaxTests/viewPureChecker/suggest_pure.sol @@ -2,4 +2,3 @@ contract C { function g() view public { } } // ---- -// Warning: (17-45): Function state mutability can be restricted to pure |