diff options
115 files changed, 638 insertions, 669 deletions
diff --git a/Changelog.md b/Changelog.md index b27254a8..f3c06d90 100644 --- a/Changelog.md +++ b/Changelog.md @@ -20,6 +20,7 @@ Breaking Changes: * General: Disallow raw ``callcode`` (was already deprecated in 0.4.12). It is still possible to use it via inline assembly. * General: Disallow ``var`` keyword. * General: Disallow ``sha3`` and ``suicide`` aliases. + * General: Disallow the ``throw`` statement. This was already the case in the experimental 0.5.0 mode. * General: Disallow the ``years`` unit denomination (was already deprecated in 0.4.24) * General: Introduce ``emit`` as a keyword instead of parsing it as identifier. * General: New keywords: ``calldata`` @@ -44,6 +45,7 @@ Breaking Changes: * Type Checker: Disallow uninitialized storage variables. This was already the case in the experimental 0.5.0 mode. * Type Checker: Only accept a single ``bytes`` type for ``.call()`` (and family), ``keccak256()``, ``sha256()`` and ``ripemd160()``. * Type Checker: Fallback function must be external. This was already the case in the experimental 0.5.0 mode. + * Type Checker: Interface functions must be declared external. This was already the case in the experimental 0.5.0 mode. * Remove obsolete ``std`` directory from the Solidity repository. This means accessing ``https://github.com/ethereum/soldity/blob/develop/std/*.sol`` (or ``https://github.com/ethereum/solidity/std/*.sol`` in Remix) will not be possible. * References Resolver: Turn missing storage locations into an error. This was already the case in the experimental 0.5.0 mode. * Syntax Checker: Named return values in function types are an error. diff --git a/cmake/EthCompilerSettings.cmake b/cmake/EthCompilerSettings.cmake index 468a8593..ff3a5edb 100644 --- a/cmake/EthCompilerSettings.cmake +++ b/cmake/EthCompilerSettings.cmake @@ -26,7 +26,7 @@ eth_add_cxx_compiler_flag_if_supported(-Wimplicit-fallthrough) if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")) # Use ISO C++11 standard language. - set(CMAKE_CXX_FLAGS -std=c++11) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # Enables all the warnings about constructions that some users consider questionable, # and that are easy to avoid. Also enable some extra warning flags that are not diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst index ab1650d8..5f6d7d50 100644 --- a/docs/abi-spec.rst +++ b/docs/abi-spec.rst @@ -193,9 +193,9 @@ Given the contract: pragma solidity ^0.4.16; contract Foo { - function bar(bytes3[2]) public pure {} + function bar(bytes3[2] memory) public pure {} function baz(uint32 x, bool y) public pure returns (bool r) { r = x > 32 || y; } - function sam(bytes, bool, uint[]) public pure {} + function sam(bytes memory, bool, uint[] memory) public pure {} } @@ -490,8 +490,8 @@ As an example, the code contract Test { struct S { uint a; uint[] b; T[] c; } struct T { uint x; uint y; } - function f(S s, T t, uint a) public { } - function g() public returns (S s, T t, uint a) {} + function f(S memory s, T memory t, uint a) public { } + function g() public returns (S memory s, T memory t, uint a) {} } would result in the JSON: diff --git a/docs/assembly.rst b/docs/assembly.rst index cf114c12..ec6ac876 100644 --- a/docs/assembly.rst +++ b/docs/assembly.rst @@ -54,7 +54,7 @@ idea is that assembly libraries will be used to enhance the language in such way pragma solidity ^0.4.0; library GetCode { - function at(address _addr) public view returns (bytes o_code) { + function at(address _addr) public view returns (bytes memory o_code) { assembly { // retrieve the size of the code, this needs assembly let size := extcodesize(_addr) @@ -83,7 +83,7 @@ you really know what you are doing. library VectorSum { // This function is less efficient because the optimizer currently fails to // remove the bounds checks in array access. - function sumSolidity(uint[] _data) public view returns (uint o_sum) { + function sumSolidity(uint[] memory _data) public view returns (uint o_sum) { for (uint i = 0; i < _data.length; ++i) o_sum += _data[i]; } @@ -91,7 +91,7 @@ you really know what you are doing. // We know that we only access the array in bounds, so we can avoid the check. // 0x20 needs to be added to an array because the first slot contains the // array length. - function sumAsm(uint[] _data) public view returns (uint o_sum) { + function sumAsm(uint[] memory _data) public view returns (uint o_sum) { for (uint i = 0; i < _data.length; ++i) { assembly { o_sum := add(o_sum, mload(add(add(_data, 0x20), mul(i, 0x20)))) @@ -100,7 +100,7 @@ you really know what you are doing. } // Same as above, but accomplish the entire code within inline assembly. - function sumPureAsm(uint[] _data) public view returns (uint o_sum) { + function sumPureAsm(uint[] memory _data) public view returns (uint o_sum) { assembly { // Load the length (first 32 bytes) let len := mload(_data) diff --git a/docs/contracts.rst b/docs/contracts.rst index fa6df6bf..033e9a45 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -1150,6 +1150,7 @@ Interfaces Interfaces are similar to abstract contracts, but they cannot have any functions implemented. There are further restrictions: - Cannot inherit other contracts or interfaces. +- All declared functions must be external. - Cannot define constructor. - Cannot define variables. - Cannot define structs. @@ -1167,7 +1168,7 @@ Interfaces are denoted by their own keyword: pragma solidity ^0.4.11; interface Token { - function transfer(address recipient, uint amount) public; + function transfer(address recipient, uint amount) external; } Contracts can inherit interfaces as they would inherit other contracts. @@ -1295,12 +1296,12 @@ custom types without the overhead of external function calls: uint[] limbs; } - function fromUint(uint x) internal pure returns (bigint r) { + function fromUint(uint x) internal pure returns (bigint memory r) { r.limbs = new uint[](1); r.limbs[0] = x; } - function add(bigint _a, bigint _b) internal pure returns (bigint r) { + function add(bigint memory _a, bigint memory _b) internal pure returns (bigint memory r) { r.limbs = new uint[](max(_a.limbs.length, _b.limbs.length)); uint carry = 0; for (uint i = 0; i < r.limbs.length; ++i) { @@ -1323,7 +1324,7 @@ custom types without the overhead of external function calls: } } - function limb(bigint _a, uint _limb) internal pure returns (uint) { + function limb(bigint memory _a, uint _limb) internal pure returns (uint) { return _limb < _a.limbs.length ? _a.limbs[_limb] : 0; } diff --git a/docs/frequently-asked-questions.rst b/docs/frequently-asked-questions.rst index 17e71747..36eaf534 100644 --- a/docs/frequently-asked-questions.rst +++ b/docs/frequently-asked-questions.rst @@ -85,7 +85,7 @@ Example:: pragma solidity ^0.4.16; contract C { - function f() public pure returns (uint8[5]) { + function f() public pure returns (uint8[5] memory) { string[4] memory adaArr = ["This", "is", "an", "array"]; return ([1, 2, 3, 4, 5]); } @@ -445,7 +445,7 @@ independent copies will be created:: h(x); } - function g(uint[20] y) internal pure { + function g(uint[20] memory y) internal pure { y[2] = 3; } @@ -455,10 +455,9 @@ independent copies will be created:: } The call to ``g(x)`` will not have an effect on ``x`` because it needs -to create an independent copy of the storage value in memory -(the default storage location is memory). On the other hand, -``h(x)`` successfully modifies ``x`` because only a reference -and not a copy is passed. +to create an independent copy of the storage value in memory. +On the other hand, ``h(x)`` successfully modifies ``x`` because only +a reference and not a copy is passed. Sometimes, when I try to change the length of an array with ex: ``arrayname.length = 7;`` I get a compiler error ``Value must be an lvalue``. Why? ================================================================================================================================================== diff --git a/docs/security-considerations.rst b/docs/security-considerations.rst index afdecb98..b997466b 100644 --- a/docs/security-considerations.rst +++ b/docs/security-considerations.rst @@ -203,7 +203,7 @@ Now someone tricks you into sending ether to the address of this attack wallet: pragma solidity >0.4.24; interface TxUserWallet { - function transferTo(address dest, uint amount) public; + function transferTo(address dest, uint amount) external; } contract TxAttackWallet { diff --git a/docs/solidity-by-example.rst b/docs/solidity-by-example.rst index b1985426..3934d29d 100644 --- a/docs/solidity-by-example.rst +++ b/docs/solidity-by-example.rst @@ -66,7 +66,7 @@ of votes. Proposal[] public proposals; /// Create a new ballot to choose one of `proposalNames`. - constructor(bytes32[] proposalNames) public { + constructor(bytes32[] memory proposalNames) public { chairperson = msg.sender; voters[chairperson].weight = 1; @@ -452,9 +452,9 @@ high or low invalid bids. /// correctly blinded invalid bids and for all bids except for /// the totally highest. function reveal( - uint[] _values, - bool[] _fake, - bytes32[] _secret + uint[] memory _values, + bool[] memory _fake, + bytes32[] memory _secret ) public onlyAfter(biddingEnd) @@ -1035,7 +1035,7 @@ The full contract /// if the timeout is reached without the recipient closing the channel, /// then the Ether is released back to the sender. - function clainTimeout() public { + function claimTimeout() public { require(now >= expiration); selfdestruct(sender); } diff --git a/docs/types.rst b/docs/types.rst index 16445a34..0fe36757 100644 --- a/docs/types.rst +++ b/docs/types.rst @@ -471,11 +471,11 @@ Another example that uses external function types:: } Request[] requests; event NewRequest(uint); - function query(bytes data, function(bytes memory) external callback) public { + function query(bytes memory data, function(bytes memory) external callback) public { requests.push(Request(data, callback)); emit NewRequest(requests.length - 1); } - function reply(uint requestID, bytes response) public { + function reply(uint requestID, bytes memory response) public { // Here goes the check that the reply comes from a trusted source requests[requestID].callback(response); } @@ -486,7 +486,7 @@ Another example that uses external function types:: function buySomething() { oracle.query("USD", this.oracleResponse); } - function oracleResponse(bytes response) public { + function oracleResponse(bytes memory response) public { require( msg.sender == address(oracle), "Only oracle can call this." @@ -540,7 +540,7 @@ memory-stored reference type do not create a copy. uint[] x; // the data location of x is storage // the data location of memoryArray is memory - function f(uint[] memoryArray) public { + function f(uint[] memory memoryArray) public { x = memoryArray; // works, copies the whole array to storage uint[] storage y = x; // works, assigns a pointer, data location of y is storage y[7]; // fine, returns the 8th element @@ -557,7 +557,7 @@ memory-stored reference type do not create a copy. } function g(uint[] storage storageArray) internal {} - function h(uint[] memoryArray) public {} + function h(uint[] memory memoryArray) public {} } Summary @@ -646,7 +646,7 @@ assigned to a variable right away. function f() public pure { g([uint(1), 2, 3]); } - function g(uint[3] _data) public pure { + function g(uint[3] memory _data) public pure { // ... } } @@ -713,7 +713,7 @@ Members bool[2][] m_pairsOfFlags; // newPairs is stored in memory - the default for function arguments - function setAllFlagPairs(bool[2][] newPairs) public { + function setAllFlagPairs(bool[2][] memory newPairs) public { // assignment to a storage array replaces the complete array m_pairsOfFlags = newPairs; } @@ -739,7 +739,7 @@ Members bytes m_byteData; - function byteArrays(bytes data) public { + function byteArrays(bytes memory data) public { // byte arrays ("bytes") are different as they are stored without padding, // but can be treated identical to "uint8[]" m_byteData = data; @@ -748,11 +748,11 @@ Members delete m_byteData[2]; } - function addFlag(bool[2] flag) public returns (uint) { + function addFlag(bool[2] memory flag) public returns (uint) { return m_pairsOfFlags.push(flag); } - function createMemoryArray(uint size) public pure returns (bytes) { + function createMemoryArray(uint size) public pure returns (bytes memory) { // Dynamic memory arrays are created using `new`: uint[2][] memory arrayOfPairs = new uint[2][](size); // Create a dynamic byte array: @@ -846,7 +846,7 @@ Mappings ======== Mapping types are declared as ``mapping(_KeyType => _ValueType)``. -Here ``_KeyType`` can be almost any type except for a mapping, a dynamically sized array, a contract, an enum and a struct. +Here ``_KeyType`` can be almost any type except for a mapping, a dynamically sized array, a contract, a function, an enum and a struct. ``_ValueType`` can actually be any type, including mappings. Mappings can be seen as `hash tables <https://en.wikipedia.org/wiki/Hash_table>`_ which are virtually initialized such that diff --git a/docs/units-and-global-variables.rst b/docs/units-and-global-variables.rst index b24b8b71..6eae2804 100644 --- a/docs/units-and-global-variables.rst +++ b/docs/units-and-global-variables.rst @@ -101,8 +101,7 @@ ABI Encoding Functions - ``abi.encode(...) returns (bytes)``: ABI-encodes the given arguments - ``abi.encodePacked(...) returns (bytes)``: Performs :ref:`packed encoding <abi_packed_mode>` of the given arguments -- ``abi.encodeWithSelector(bytes4 selector, ...) returns (bytes)``: ABI-encodes the given arguments - starting from the second and prepends the given four-byte selector +- ``abi.encodeWithSelector(bytes4 selector, ...) returns (bytes)``: ABI-encodes the given arguments starting from the second and prepends the given four-byte selector - ``abi.encodeWithSignature(string signature, ...) returns (bytes)``: Equivalent to ``abi.encodeWithSelector(bytes4(keccak256(bytes(signature)), ...)``` .. note:: diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp index e33aafed..fba18a45 100644 --- a/libsolidity/analysis/SyntaxChecker.cpp +++ b/libsolidity/analysis/SyntaxChecker.cpp @@ -175,18 +175,10 @@ bool SyntaxChecker::visit(Break const& _breakStatement) bool SyntaxChecker::visit(Throw const& _throwStatement) { - bool const v050 = m_sourceUnit->annotation().experimentalFeatures.count(ExperimentalFeature::V050); - - if (v050) - m_errorReporter.syntaxError( - _throwStatement.location(), - "\"throw\" is deprecated in favour of \"revert()\", \"require()\" and \"assert()\"." - ); - else - m_errorReporter.warning( - _throwStatement.location(), - "\"throw\" is deprecated in favour of \"revert()\", \"require()\" and \"assert()\"." - ); + m_errorReporter.syntaxError( + _throwStatement.location(), + "\"throw\" is deprecated in favour of \"revert()\", \"require()\" and \"assert()\"." + ); return true; } diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index cc373e03..92e5c978 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -671,18 +671,10 @@ bool TypeChecker::visit(FunctionDefinition const& _function) { if (_function.isImplemented()) m_errorReporter.typeError(_function.location(), "Functions in interfaces cannot have an implementation."); - if (_function.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050)) - { - if (_function.visibility() != FunctionDefinition::Visibility::External) - m_errorReporter.typeError(_function.location(), "Functions in interfaces must be declared external."); - } - else - { - if (_function.visibility() < FunctionDefinition::Visibility::Public) - m_errorReporter.typeError(_function.location(), "Functions in interfaces cannot be internal or private."); - else if (_function.visibility() != FunctionDefinition::Visibility::External) - m_errorReporter.warning(_function.location(), "Functions in interfaces should be declared external."); - } + + if (_function.visibility() != FunctionDefinition::Visibility::External) + m_errorReporter.typeError(_function.location(), "Functions in interfaces must be declared external."); + if (_function.isConstructor()) m_errorReporter.typeError(_function.location(), "Constructor cannot be defined in interfaces."); } @@ -1959,7 +1951,7 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) _memberAccess.location(), "Member \"" + memberName + "\" not found or not visible " "after argument-dependent lookup in " + exprType->toString() + - (memberName == "value" ? " - did you forget the \"payable\" modifier?" : "") + (memberName == "value" ? " - did you forget the \"payable\" modifier?" : ".") ); } else if (possibleMembers.size() > 1) @@ -1967,7 +1959,7 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) _memberAccess.location(), "Member \"" + memberName + "\" not unique " "after argument-dependent lookup in " + exprType->toString() + - (memberName == "value" ? " - did you forget the \"payable\" modifier?" : "") + (memberName == "value" ? " - did you forget the \"payable\" modifier?" : ".") ); auto& annotation = _memberAccess.annotation(); @@ -1979,7 +1971,7 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) m_errorReporter.typeError( _memberAccess.location(), "Function \"" + memberName + "\" cannot be called on an object of type " + - exprType->toString() + " (expected " + funType->selfType()->toString() + ")" + exprType->toString() + " (expected " + funType->selfType()->toString() + ")." ); if (exprType->category() == Type::Category::Struct) diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 4811f767..6a768a00 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -986,10 +986,15 @@ void CommandLineInterface::handleAst(string const& _argStr) map<ASTNode const*, eth::GasMeter::GasConsumption> gasCosts; // FIXME: shouldn't this be done for every contract? if (m_compiler->runtimeAssemblyItems(m_compiler->lastContractName())) - gasCosts = GasEstimator::breakToStatementLevel( + { + //NOTE: keep the local variable `ret` to prevent a Heisenbug that could happen on certain mac os platform. + //See: https://github.com/ethereum/solidity/issues/3718 for details. + auto ret = GasEstimator::breakToStatementLevel( GasEstimator(m_evmVersion).structuralEstimation(*m_compiler->runtimeAssemblyItems(m_compiler->lastContractName()), asts), asts ); + gasCosts = ret; + } bool legacyFormat = !m_args.count(g_argAstCompactJson); if (m_args.count(g_argOutputDir)) diff --git a/test/compilationTests/MultiSigWallet/MultiSigWallet.sol b/test/compilationTests/MultiSigWallet/MultiSigWallet.sol index c2a6c3ef..35f6208b 100644 --- a/test/compilationTests/MultiSigWallet/MultiSigWallet.sol +++ b/test/compilationTests/MultiSigWallet/MultiSigWallet.sol @@ -33,49 +33,49 @@ contract MultiSigWallet { modifier onlyWallet() { if (msg.sender != address(this)) - throw; + revert(); _; } modifier ownerDoesNotExist(address owner) { if (isOwner[owner]) - throw; + revert(); _; } modifier ownerExists(address owner) { if (!isOwner[owner]) - throw; + revert(); _; } modifier transactionExists(uint transactionId) { if (transactions[transactionId].destination == address(0)) - throw; + revert(); _; } modifier confirmed(uint transactionId, address owner) { if (!confirmations[transactionId][owner]) - throw; + revert(); _; } modifier notConfirmed(uint transactionId, address owner) { if (confirmations[transactionId][owner]) - throw; + revert(); _; } modifier notExecuted(uint transactionId) { if (transactions[transactionId].executed) - throw; + revert(); _; } modifier notNull(address _address) { if (_address == address(0)) - throw; + revert(); _; } @@ -84,7 +84,7 @@ contract MultiSigWallet { || _required > ownerCount || _required == 0 || ownerCount == 0) - throw; + revert(); _; } @@ -103,13 +103,13 @@ contract MultiSigWallet { /// @dev Contract constructor sets initial owners and required number of confirmations. /// @param _owners List of initial owners. /// @param _required Number of required confirmations. - constructor(address[] _owners, uint _required) + constructor(address[] memory _owners, uint _required) public validRequirement(_owners.length, _required) { for (uint i=0; i<_owners.length; i++) { if (isOwner[_owners[i]] || _owners[i] == address(0)) - throw; + revert(); isOwner[_owners[i]] = true; } owners = _owners; @@ -185,7 +185,7 @@ contract MultiSigWallet { /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return Returns transaction ID. - function submitTransaction(address destination, uint value, bytes data) + function submitTransaction(address destination, uint value, bytes memory data) public returns (uint transactionId) { @@ -261,7 +261,7 @@ contract MultiSigWallet { /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return Returns transaction ID. - function addTransaction(address destination, uint value, bytes data) + function addTransaction(address destination, uint value, bytes memory data) internal notNull(destination) returns (uint transactionId) @@ -313,7 +313,7 @@ contract MultiSigWallet { function getOwners() public view - returns (address[]) + returns (address[] memory) { return owners; } @@ -324,7 +324,7 @@ contract MultiSigWallet { function getConfirmations(uint transactionId) public view - returns (address[] _confirmations) + returns (address[] memory _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint count = 0; @@ -348,7 +348,7 @@ contract MultiSigWallet { function getTransactionIds(uint from, uint to, bool pending, bool executed) public view - returns (uint[] _transactionIds) + returns (uint[] memory _transactionIds) { uint[] memory transactionIdsTemp = new uint[](transactionCount); uint count = 0; diff --git a/test/compilationTests/MultiSigWallet/MultiSigWalletFactory.sol b/test/compilationTests/MultiSigWallet/MultiSigWalletFactory.sol index cb58ab1c..16219aa2 100644 --- a/test/compilationTests/MultiSigWallet/MultiSigWalletFactory.sol +++ b/test/compilationTests/MultiSigWallet/MultiSigWalletFactory.sol @@ -11,7 +11,7 @@ contract MultiSigWalletFactory is Factory { /// @param _owners List of initial owners. /// @param _required Number of required confirmations. /// @return Returns wallet address. - function create(address[] _owners, uint _required) + function create(address[] memory _owners, uint _required) public returns (address wallet) { diff --git a/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol b/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol index c1b1d7ea..69e94fd5 100644 --- a/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol +++ b/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol @@ -19,7 +19,7 @@ contract MultiSigWalletWithDailyLimit is MultiSigWallet { /// @param _owners List of initial owners. /// @param _required Number of required confirmations. /// @param _dailyLimit Amount in wei, which can be withdrawn without confirmations on a daily basis. - constructor(address[] _owners, uint _required, uint _dailyLimit) + constructor(address[] memory _owners, uint _required, uint _dailyLimit) public MultiSigWallet(_owners, _required) { diff --git a/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimitFactory.sol b/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimitFactory.sol index 8a2efa32..e4cfc031 100644 --- a/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimitFactory.sol +++ b/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimitFactory.sol @@ -12,7 +12,7 @@ contract MultiSigWalletWithDailyLimitFactory is Factory { /// @param _required Number of required confirmations. /// @param _dailyLimit Amount in wei, which can be withdrawn without confirmations on a daily basis. /// @return Returns wallet address. - function create(address[] _owners, uint _required, uint _dailyLimit) + function create(address[] memory _owners, uint _required, uint _dailyLimit) public returns (address wallet) { diff --git a/test/compilationTests/MultiSigWallet/TestToken.sol b/test/compilationTests/MultiSigWallet/TestToken.sol index df195c58..a100b449 100644 --- a/test/compilationTests/MultiSigWallet/TestToken.sol +++ b/test/compilationTests/MultiSigWallet/TestToken.sol @@ -27,7 +27,7 @@ contract TestToken { returns (bool success) { if (balances[msg.sender] < _value) { - throw; + revert(); } balances[msg.sender] -= _value; balances[_to] += _value; @@ -40,7 +40,7 @@ contract TestToken { returns (bool success) { if (balances[_from] < _value || allowed[_from][msg.sender] < _value) { - throw; + revert(); } balances[_to] += _value; balances[_from] -= _value; diff --git a/test/compilationTests/corion/ico.sol b/test/compilationTests/corion/ico.sol index abb6020b..2f60e0fe 100644 --- a/test/compilationTests/corion/ico.sol +++ b/test/compilationTests/corion/ico.sol @@ -50,7 +50,7 @@ contract ico is safeMath { uint256 public totalMint; uint256 public totalPremiumMint; - constructor(address foundation, address priceSet, uint256 exchangeRate, uint256 startBlockNum, address[] genesisAddr, uint256[] genesisValue) public { + constructor(address foundation, address priceSet, uint256 exchangeRate, uint256 startBlockNum, address[] memory genesisAddr, uint256[] memory genesisValue) public { /* Installation function. diff --git a/test/compilationTests/corion/moduleHandler.sol b/test/compilationTests/corion/moduleHandler.sol index fddd2a29..ce53114b 100644 --- a/test/compilationTests/corion/moduleHandler.sol +++ b/test/compilationTests/corion/moduleHandler.sol @@ -36,7 +36,7 @@ contract moduleHandler is multiOwner, announcementTypes { uint256 debugModeUntil = block.number + 1000000; - constructor(address[] newOwners) multiOwner(newOwners) public {} + constructor(address[] memory newOwners) multiOwner(newOwners) public {} function load(address foundation, bool forReplace, address Token, address Premium, address Publisher, address Schelling, address Provider) public { /* Loading modulest to ModuleHandler. @@ -60,7 +60,7 @@ contract moduleHandler is multiOwner, announcementTypes { addModule( modules_s(Schelling, keccak256('Schelling'), false, true), ! forReplace); addModule( modules_s(Provider, keccak256('Provider'), true, true), ! forReplace); } - function addModule(modules_s input, bool call) internal { + function addModule(modules_s memory input, bool call) internal { /* Inside function for registration of the modules in the database. If the call is false, won't happen any direct call. @@ -81,7 +81,7 @@ contract moduleHandler is multiOwner, announcementTypes { } modules[id] = input; } - function getModuleAddressByName(string name) public view returns( bool success, bool found, address addr ) { + function getModuleAddressByName(string memory name) public view returns( bool success, bool found, address addr ) { /* Search by name for module. The result is an Ethereum address. @@ -109,7 +109,7 @@ contract moduleHandler is multiOwner, announcementTypes { } return (true, false, 0); } - function getModuleIDByName(string name) public view returns( bool success, bool found, uint256 id ) { + function getModuleIDByName(string memory name) public view returns( bool success, bool found, uint256 id ) { /* Search by name for module. The result is an index array. @@ -177,7 +177,7 @@ contract moduleHandler is multiOwner, announcementTypes { require( abstractModule(modules[_id].addr).replaceModule(newModule) ); return true; } - + function newModule(string name, address addr, bool schellingEvent, bool transferEvent) external returns (bool success) { /* Adding new module to the database. Can be called only by the Publisher contract. diff --git a/test/compilationTests/corion/multiOwner.sol b/test/compilationTests/corion/multiOwner.sol index 337467db..ecc51ac3 100644 --- a/test/compilationTests/corion/multiOwner.sol +++ b/test/compilationTests/corion/multiOwner.sol @@ -12,7 +12,7 @@ contract multiOwner is safeMath { /* Constructor */ - constructor(address[] newOwners) public { + constructor(address[] memory newOwners) public { for ( uint256 a=0 ; a<newOwners.length ; a++ ) { _addOwner(newOwners[a]); } @@ -41,7 +41,7 @@ contract multiOwner is safeMath { function ownersForChange() public view returns (uint256 owners) { return ownerCount * 75 / 100; } - function calcDoHash(string job, bytes32 data) public pure returns (bytes32 hash) { + function calcDoHash(string memory job, bytes32 data) public pure returns (bytes32 hash) { return keccak256(abi.encodePacked(job, data)); } function validDoHash(bytes32 doHash) public view returns (bool valid) { diff --git a/test/compilationTests/corion/premium.sol b/test/compilationTests/corion/premium.sol index e1f12ed0..45fe7666 100644 --- a/test/compilationTests/corion/premium.sol +++ b/test/compilationTests/corion/premium.sol @@ -40,7 +40,7 @@ contract premium is module, safeMath { mapping(address => bool) public genesis; - constructor(bool forReplace, address moduleHandler, address dbAddress, address icoContractAddr, address[] genesisAddr, uint256[] genesisValue) public { + constructor(bool forReplace, address moduleHandler, address dbAddress, address icoContractAddr, address[] memory genesisAddr, uint256[] memory genesisValue) public { /* Setup function. If an ICOaddress is defined then the balance of the genesis addresses will be set as well. @@ -246,7 +246,7 @@ contract premium is module, safeMath { return true; } - function transferToContract(address from, address to, uint256 amount, bytes extraData) internal { + function transferToContract(address from, address to, uint256 amount, bytes memory extraData) internal { /* Inner function in order to transact a contract. diff --git a/test/compilationTests/corion/provider.sol b/test/compilationTests/corion/provider.sol index 35ade69f..7d1e04e3 100644 --- a/test/compilationTests/corion/provider.sol +++ b/test/compilationTests/corion/provider.sol @@ -299,7 +299,7 @@ contract provider is module, safeMath, announcementTypes { providers[addr].data[currHeight].currentRate = rate; emit EProviderDetailsChanged(addr, currHeight, website, country, info, rate, admin); } - function getProviderInfo(address addr, uint256 height) public view returns (string name, string website, string country, string info, uint256 create) { + function getProviderInfo(address addr, uint256 height) public view returns (string memory name, string memory website, string memory country, string memory info, uint256 create) { /* for the infos of the provider. In case the height is unknown then the system will use the last known height. @@ -514,7 +514,7 @@ contract provider is module, safeMath, announcementTypes { } else if ( clients[msg.sender].providerAddress != address(0x00) ) { clientReward = getClientReward(_limit); } else { - throw; + revert(); } if ( clientReward > 0 ) { require( moduleHandler(moduleHandlerAddress).transfer(address(this), _beneficiary, clientReward, false) ); diff --git a/test/compilationTests/corion/publisher.sol b/test/compilationTests/corion/publisher.sol index 44bc5964..575b99a8 100644 --- a/test/compilationTests/corion/publisher.sol +++ b/test/compilationTests/corion/publisher.sol @@ -70,7 +70,7 @@ contract publisher is announcementTypes, module, safeMath { super.registerModuleHandler(moduleHandler);
}
- function Announcements(uint256 id) public view returns (uint256 Type, uint256 Start, uint256 End, bool Closed, string Announcement, string Link, bool Opposited, string _str, uint256 _uint, address _addr) {
+ function Announcements(uint256 id) public view returns (uint256 Type, uint256 Start, uint256 End, bool Closed, string memory Announcement, string memory Link, bool Opposited, string memory _str, uint256 _uint, address _addr) {
/*
Announcement data query
diff --git a/test/compilationTests/corion/schelling.sol b/test/compilationTests/corion/schelling.sol index b8beaa3a..3905e300 100644 --- a/test/compilationTests/corion/schelling.sol +++ b/test/compilationTests/corion/schelling.sol @@ -174,7 +174,7 @@ contract schelling is module, announcementTypes, schellingVars { function setFunds(address addr, uint256 amount) internal { require( db.setFunds(addr, amount) ); } - function setVoter(address owner, _voter voter) internal { + function setVoter(address owner, _voter memory voter) internal { require( db.setVoter(owner, voter.roundID, voter.hash, @@ -182,13 +182,13 @@ contract schelling is module, announcementTypes, schellingVars { voter.voteResult, voter.rewards ) ); - } - function getVoter(address addr) internal view returns (_voter) { + } + function getVoter(address addr) internal view returns (_voter memory) { (bool a, uint256 b, bytes32 c, schellingVars.voterStatus d, bool e, uint256 f) = db.getVoter(addr); require( a ); return _voter(b, c, d, e, f); } - function setRound(uint256 id, _rounds round) internal { + function setRound(uint256 id, _rounds memory round) internal { require( db.setRound(id, round.totalAboveWeight, round.totalBelowWeight, @@ -197,8 +197,8 @@ contract schelling is module, announcementTypes, schellingVars { round.voted ) ); } - function pushRound(_rounds round) internal returns (uint256) { - (bool a, uint256 b) = db.pushRound( + function pushRound(_rounds memory round) internal returns (uint256) { + (bool a, uint256 b) = db.pushRound( round.totalAboveWeight, round.totalBelowWeight, round.reward, @@ -208,7 +208,7 @@ contract schelling is module, announcementTypes, schellingVars { require( a ); return b; } - function getRound(uint256 id) internal returns (_rounds) { + function getRound(uint256 id) internal returns (_rounds memory) { (bool a, uint256 b, uint256 c, uint256 d, uint256 e, bool f) = db.getRound(id); require( a ); return _rounds(b, c, d, e, f); @@ -389,7 +389,7 @@ contract schelling is module, announcementTypes, schellingVars { } delete voter.status; delete voter.roundID; - } else { throw; } + } else { revert(); } setVoter(msg.sender, voter); setFunds(msg.sender, funds); @@ -529,7 +529,7 @@ contract schelling is module, announcementTypes, schellingVars { return belowW; } } - function isWinner(_rounds round, bool aboveVote) internal returns (bool) { + function isWinner(_rounds memory round, bool aboveVote) internal returns (bool) { /* Inside function for calculating the result of the game. diff --git a/test/compilationTests/corion/token.sol b/test/compilationTests/corion/token.sol index 8ca18083..6c8f6f24 100644 --- a/test/compilationTests/corion/token.sol +++ b/test/compilationTests/corion/token.sol @@ -48,7 +48,7 @@ contract token is safeMath, module, announcementTypes { mapping(address => bool) public genesis; - constructor(bool forReplace, address moduleHandler, address dbAddr, address icoContractAddr, address exchangeContractAddress, address[] genesisAddr, uint256[] genesisValue) public payable { + constructor(bool forReplace, address moduleHandler, address dbAddr, address icoContractAddr, address exchangeContractAddress, address[] memory genesisAddr, uint256[] memory genesisValue) public payable { /* Installation function @@ -288,7 +288,7 @@ contract token is safeMath, module, announcementTypes { return true; } - function _transferToContract(address from, address to, uint256 amount, bytes extraData) internal { + function _transferToContract(address from, address to, uint256 amount, bytes memory extraData) internal { /* Internal function to start transactions to a contract diff --git a/test/compilationTests/gnosis/Events/Event.sol b/test/compilationTests/gnosis/Events/Event.sol index 177f61df..5b1a550c 100644 --- a/test/compilationTests/gnosis/Events/Event.sol +++ b/test/compilationTests/gnosis/Events/Event.sol @@ -101,7 +101,7 @@ contract Event { function getOutcomeTokens() public view - returns (OutcomeToken[]) + returns (OutcomeToken[] memory) { return outcomeTokens; } @@ -111,7 +111,7 @@ contract Event { function getOutcomeTokenDistribution(address owner) public view - returns (uint[] outcomeTokenDistribution) + returns (uint[] memory outcomeTokenDistribution) { outcomeTokenDistribution = new uint[](outcomeTokens.length); for (uint8 i = 0; i < outcomeTokenDistribution.length; i++) diff --git a/test/compilationTests/gnosis/MarketMakers/LMSRMarketMaker.sol b/test/compilationTests/gnosis/MarketMakers/LMSRMarketMaker.sol index cf4fcd7d..4ad285eb 100644 --- a/test/compilationTests/gnosis/MarketMakers/LMSRMarketMaker.sol +++ b/test/compilationTests/gnosis/MarketMakers/LMSRMarketMaker.sol @@ -108,7 +108,7 @@ contract LMSRMarketMaker is MarketMaker { /// @param netOutcomeTokensSold Net outcome tokens sold by market /// @param funding Initial funding for market /// @return Cost level - function calcCostLevel(int logN, int[] netOutcomeTokensSold, uint funding) + function calcCostLevel(int logN, int[] memory netOutcomeTokensSold, uint funding) private view returns(int costLevel) @@ -129,7 +129,7 @@ contract LMSRMarketMaker is MarketMaker { /// @param funding Initial funding for market /// @param outcomeIndex Index of exponential term to extract (for use by marginal price function) /// @return A result structure composed of the sum, the offset used, and the summand associated with the supplied index - function sumExpOffset(int logN, int[] netOutcomeTokensSold, uint funding, uint8 outcomeIndex) + function sumExpOffset(int logN, int[] memory netOutcomeTokensSold, uint funding, uint8 outcomeIndex) private view returns (uint sum, int offset, uint outcomeExpTerm) @@ -171,7 +171,7 @@ contract LMSRMarketMaker is MarketMaker { function getNetOutcomeTokensSold(Market market) private view - returns (int[] quantities) + returns (int[] memory quantities) { quantities = new int[](market.eventContract().getOutcomeCount()); for (uint8 i = 0; i < quantities.length; i++) diff --git a/test/compilationTests/gnosis/Oracles/CentralizedOracle.sol b/test/compilationTests/gnosis/Oracles/CentralizedOracle.sol index de182a61..e175dfdb 100644 --- a/test/compilationTests/gnosis/Oracles/CentralizedOracle.sol +++ b/test/compilationTests/gnosis/Oracles/CentralizedOracle.sol @@ -34,7 +34,7 @@ contract CentralizedOracle is Oracle { */ /// @dev Constructor sets owner address and IPFS hash /// @param _ipfsHash Hash identifying off chain event description - constructor(address _owner, bytes _ipfsHash) + constructor(address _owner, bytes memory _ipfsHash) public { // Description hash cannot be null diff --git a/test/compilationTests/gnosis/Oracles/CentralizedOracleFactory.sol b/test/compilationTests/gnosis/Oracles/CentralizedOracleFactory.sol index ca4e37d2..be632070 100644 --- a/test/compilationTests/gnosis/Oracles/CentralizedOracleFactory.sol +++ b/test/compilationTests/gnosis/Oracles/CentralizedOracleFactory.sol @@ -17,7 +17,7 @@ contract CentralizedOracleFactory { /// @dev Creates a new centralized oracle contract /// @param ipfsHash Hash identifying off chain event description /// @return Oracle contract - function createCentralizedOracle(bytes ipfsHash) + function createCentralizedOracle(bytes memory ipfsHash) public returns (CentralizedOracle centralizedOracle) { diff --git a/test/compilationTests/gnosis/Oracles/MajorityOracle.sol b/test/compilationTests/gnosis/Oracles/MajorityOracle.sol index d8097370..4dc1760d 100644 --- a/test/compilationTests/gnosis/Oracles/MajorityOracle.sol +++ b/test/compilationTests/gnosis/Oracles/MajorityOracle.sol @@ -16,7 +16,7 @@ contract MajorityOracle is Oracle { */ /// @dev Allows to create an oracle for a majority vote based on other oracles /// @param _oracles List of oracles taking part in the majority vote - constructor(Oracle[] _oracles) + constructor(Oracle[] memory _oracles) public { // At least 2 oracles should be defined diff --git a/test/compilationTests/gnosis/Oracles/MajorityOracleFactory.sol b/test/compilationTests/gnosis/Oracles/MajorityOracleFactory.sol index 3c02fef4..dbbccc4c 100644 --- a/test/compilationTests/gnosis/Oracles/MajorityOracleFactory.sol +++ b/test/compilationTests/gnosis/Oracles/MajorityOracleFactory.sol @@ -17,7 +17,7 @@ contract MajorityOracleFactory { /// @dev Creates a new majority oracle contract /// @param oracles List of oracles taking part in the majority vote /// @return Oracle contract - function createMajorityOracle(Oracle[] oracles) + function createMajorityOracle(Oracle[] memory oracles) public returns (MajorityOracle majorityOracle) { diff --git a/test/compilationTests/gnosis/Utils/Math.sol b/test/compilationTests/gnosis/Utils/Math.sol index 93456c33..47edcba4 100644 --- a/test/compilationTests/gnosis/Utils/Math.sol +++ b/test/compilationTests/gnosis/Utils/Math.sol @@ -176,7 +176,7 @@ library Math { /// @dev Returns maximum of an array /// @param nums Numbers to look through /// @return Maximum number - function max(int[] nums) + function max(int[] memory nums) public pure returns (int max) diff --git a/test/compilationTests/milestonetracker/MilestoneTracker.sol b/test/compilationTests/milestonetracker/MilestoneTracker.sol index bc182f9d..856fb1a5 100644 --- a/test/compilationTests/milestonetracker/MilestoneTracker.sol +++ b/test/compilationTests/milestonetracker/MilestoneTracker.sol @@ -83,14 +83,14 @@ contract MilestoneTracker { /// @dev The following modifiers only allow specific roles to call functions /// with these modifiers - modifier onlyRecipient { if (msg.sender != recipient) throw; _; } - modifier onlyArbitrator { if (msg.sender != arbitrator) throw; _; } - modifier onlyDonor { if (msg.sender != donor) throw; _; } + modifier onlyRecipient { if (msg.sender != recipient) revert(); _; } + modifier onlyArbitrator { if (msg.sender != arbitrator) revert(); _; } + modifier onlyDonor { if (msg.sender != donor) revert(); _; } /// @dev The following modifiers prevent functions from being called if the /// campaign has been canceled or if new milestones are being proposed - modifier campaignNotCanceled { if (campaignCanceled) throw; _; } - modifier notChanging { if (changingMilestones) throw; _; } + modifier campaignNotCanceled { if (campaignCanceled) revert(); _; } + modifier notChanging { if (changingMilestones) revert(); _; } // @dev Events to make the payment movements easy to find on the blockchain event NewMilestoneListProposed(); @@ -175,7 +175,7 @@ contract MilestoneTracker { /// uint reviewTime /// address paymentSource, /// bytes payData, - function proposeMilestones(bytes _newMilestones + function proposeMilestones(bytes memory _newMilestones ) public onlyRecipient campaignNotCanceled { proposedMilestones = _newMilestones; changingMilestones = true; @@ -204,8 +204,8 @@ contract MilestoneTracker { uint i; - if (!changingMilestones) throw; - if (keccak256(proposedMilestones) != _hashProposals) throw; + if (!changingMilestones) revert(); + if (keccak256(proposedMilestones) != _hashProposals) revert(); // Cancel all the unfinished milestones for (i=0; i<milestones.length; i++) { @@ -218,7 +218,7 @@ contract MilestoneTracker { RLP.RLPItem memory itmProposals = mProposedMilestones.toRLPItem(true); - if (!itmProposals.isList()) throw; + if (!itmProposals.isList()) revert(); RLP.Iterator memory itrProposals = itmProposals.iterator(); @@ -229,7 +229,7 @@ contract MilestoneTracker { Milestone storage milestone = milestones[milestones.length ++]; - if (!itmProposal.isList()) throw; + if (!itmProposal.isList()) revert(); RLP.Iterator memory itrProposal = itmProposal.iterator(); @@ -258,14 +258,14 @@ contract MilestoneTracker { function markMilestoneComplete(uint _idMilestone) public campaignNotCanceled notChanging { - if (_idMilestone >= milestones.length) throw; + if (_idMilestone >= milestones.length) revert(); Milestone storage milestone = milestones[_idMilestone]; if ( (msg.sender != milestone.milestoneLeadLink) &&(msg.sender != recipient)) - throw; - if (milestone.status != MilestoneStatus.AcceptedAndInProgress) throw; - if (now < milestone.minCompletionDate) throw; - if (now > milestone.maxCompletionDate) throw; + revert(); + if (milestone.status != MilestoneStatus.AcceptedAndInProgress) revert(); + if (now < milestone.minCompletionDate) revert(); + if (now > milestone.maxCompletionDate) revert(); milestone.status = MilestoneStatus.Completed; milestone.doneTime = now; emit ProposalStatusChanged(_idMilestone, milestone.status); @@ -276,10 +276,10 @@ contract MilestoneTracker { function approveCompletedMilestone(uint _idMilestone) public campaignNotCanceled notChanging { - if (_idMilestone >= milestones.length) throw; + if (_idMilestone >= milestones.length) revert(); Milestone storage milestone = milestones[_idMilestone]; if ((msg.sender != milestone.reviewer) || - (milestone.status != MilestoneStatus.Completed)) throw; + (milestone.status != MilestoneStatus.Completed)) revert(); authorizePayment(_idMilestone); } @@ -291,10 +291,10 @@ contract MilestoneTracker { function rejectMilestone(uint _idMilestone) public campaignNotCanceled notChanging { - if (_idMilestone >= milestones.length) throw; + if (_idMilestone >= milestones.length) revert(); Milestone storage milestone = milestones[_idMilestone]; if ((msg.sender != milestone.reviewer) || - (milestone.status != MilestoneStatus.Completed)) throw; + (milestone.status != MilestoneStatus.Completed)) revert(); milestone.status = MilestoneStatus.AcceptedAndInProgress; emit ProposalStatusChanged(_idMilestone, milestone.status); @@ -306,14 +306,14 @@ contract MilestoneTracker { /// @param _idMilestone ID of the milestone to be paid out function requestMilestonePayment(uint _idMilestone ) public campaignNotCanceled notChanging { - if (_idMilestone >= milestones.length) throw; + if (_idMilestone >= milestones.length) revert(); Milestone storage milestone = milestones[_idMilestone]; if ( (msg.sender != milestone.milestoneLeadLink) &&(msg.sender != recipient)) - throw; + revert(); if ((milestone.status != MilestoneStatus.Completed) || (now < milestone.doneTime + milestone.reviewTime)) - throw; + revert(); authorizePayment(_idMilestone); } @@ -323,11 +323,11 @@ contract MilestoneTracker { function cancelMilestone(uint _idMilestone) public onlyRecipient campaignNotCanceled notChanging { - if (_idMilestone >= milestones.length) throw; + if (_idMilestone >= milestones.length) revert(); Milestone storage milestone = milestones[_idMilestone]; if ((milestone.status != MilestoneStatus.AcceptedAndInProgress) && (milestone.status != MilestoneStatus.Completed)) - throw; + revert(); milestone.status = MilestoneStatus.Canceled; emit ProposalStatusChanged(_idMilestone, milestone.status); @@ -338,11 +338,11 @@ contract MilestoneTracker { /// @param _idMilestone ID of the milestone to be paid out function arbitrateApproveMilestone(uint _idMilestone ) public onlyArbitrator campaignNotCanceled notChanging { - if (_idMilestone >= milestones.length) throw; + if (_idMilestone >= milestones.length) revert(); Milestone storage milestone = milestones[_idMilestone]; if ((milestone.status != MilestoneStatus.AcceptedAndInProgress) && (milestone.status != MilestoneStatus.Completed)) - throw; + revert(); authorizePayment(_idMilestone); } @@ -355,13 +355,13 @@ contract MilestoneTracker { // @dev This internal function is executed when the milestone is paid out function authorizePayment(uint _idMilestone) internal { - if (_idMilestone >= milestones.length) throw; + if (_idMilestone >= milestones.length) revert(); Milestone storage milestone = milestones[_idMilestone]; // Recheck again to not pay twice - if (milestone.status == MilestoneStatus.AuthorizedForPayment) throw; + if (milestone.status == MilestoneStatus.AuthorizedForPayment) revert(); milestone.status = MilestoneStatus.AuthorizedForPayment; if (!milestone.paymentSource.call.value(0)(milestone.payData)) - throw; + revert(); emit ProposalStatusChanged(_idMilestone, milestone.status); } } diff --git a/test/compilationTests/milestonetracker/RLP.sol b/test/compilationTests/milestonetracker/RLP.sol index e96bb332..e261bf23 100644 --- a/test/compilationTests/milestonetracker/RLP.sol +++ b/test/compilationTests/milestonetracker/RLP.sol @@ -39,13 +39,13 @@ library RLP { self._unsafe_nextPtr = ptr + itemLength; } else - throw; + revert(); } function next(Iterator memory self, bool strict) internal view returns (RLPItem memory subItem) { subItem = next(self); if(strict && !_validate(subItem)) - throw; + revert(); return; } @@ -80,11 +80,11 @@ library RLP { if(strict) { uint len = self.length; if(_payloadOffset(item) > len) - throw; + revert(); if(_itemLength(item._unsafe_memPtr) != len) - throw; + revert(); if(!_validate(item)) - throw; + revert(); } return item; } @@ -160,7 +160,7 @@ library RLP { /// @return An 'Iterator' over the item. function iterator(RLPItem memory self) internal view returns (Iterator memory it) { if (!isList(self)) - throw; + revert(); uint ptr = self._unsafe_memPtr + _payloadOffset(self); it._unsafe_item = self; it._unsafe_nextPtr = ptr; @@ -183,7 +183,7 @@ library RLP { /// @return The decoded string. function toData(RLPItem memory self) internal returns (bytes memory bts) { if(!isData(self)) - throw; + revert(); (uint rStartPos, uint len) = _decode(self); bts = new bytes(len); _copyToBytes(rStartPos, bts, len); @@ -195,7 +195,7 @@ library RLP { /// @return Array of RLPItems. function toList(RLPItem memory self) internal view returns (RLPItem[] memory list) { if(!isList(self)) - throw; + revert(); uint numItems = items(self); list = new RLPItem[](numItems); Iterator memory it = iterator(self); @@ -212,7 +212,7 @@ library RLP { /// @return The decoded string. function toAscii(RLPItem memory self) internal returns (string memory str) { if(!isData(self)) - throw; + revert(); (uint rStartPos, uint len) = _decode(self); bytes memory bts = new bytes(len); _copyToBytes(rStartPos, bts, len); @@ -225,10 +225,10 @@ library RLP { /// @return The decoded string. function toUint(RLPItem memory self) internal view returns (uint data) { if(!isData(self)) - throw; + revert(); (uint rStartPos, uint len) = _decode(self); if (len > 32 || len == 0) - throw; + revert(); assembly { data := div(mload(rStartPos), exp(256, sub(32, len))) } @@ -240,16 +240,16 @@ library RLP { /// @return The decoded string. function toBool(RLPItem memory self) internal view returns (bool data) { if(!isData(self)) - throw; + revert(); (uint rStartPos, uint len) = _decode(self); if (len != 1) - throw; + revert(); uint temp; assembly { temp := byte(0, mload(rStartPos)) } if (temp > 1) - throw; + revert(); return temp == 1 ? true : false; } @@ -259,10 +259,10 @@ library RLP { /// @return The decoded string. function toByte(RLPItem memory self) internal view returns (byte data) { if(!isData(self)) - throw; + revert(); (uint rStartPos, uint len) = _decode(self); if (len != 1) - throw; + revert(); uint8 temp; assembly { temp := byte(0, mload(rStartPos)) @@ -292,10 +292,10 @@ library RLP { /// @return The decoded string. function toAddress(RLPItem memory self) internal view returns (address data) { if(!isData(self)) - throw; + revert(); (uint rStartPos, uint len) = _decode(self); if (len != 20) - throw; + revert(); assembly { data := div(mload(rStartPos), exp(256, 12)) } @@ -350,7 +350,7 @@ library RLP { // Get start position and length of the data. function _decode(RLPItem memory self) private view returns (uint memPtr, uint len) { if(!isData(self)) - throw; + revert(); uint b0; uint start = self._unsafe_memPtr; assembly { diff --git a/test/compilationTests/stringutils/strings.sol b/test/compilationTests/stringutils/strings.sol index fc46ec5a..390fb5d9 100644 --- a/test/compilationTests/stringutils/strings.sol +++ b/test/compilationTests/stringutils/strings.sol @@ -63,7 +63,7 @@ library strings { * @param self The string to make a slice from. * @return A newly allocated slice containing the entire string. */ - function toSlice(string self) internal returns (slice) { + function toSlice(string memory self) internal returns (slice memory) { uint ptr; assembly { ptr := add(self, 0x20) @@ -109,7 +109,7 @@ library strings { * @return A new slice containing the value of the input argument up to the * first null. */ - function toSliceB32(bytes32 self) internal returns (slice ret) { + function toSliceB32(bytes32 self) internal returns (slice memory ret) { // Allocate space for `self` in memory, copy it there, and point ret at it assembly { let ptr := mload(0x40) @@ -125,7 +125,7 @@ library strings { * @param self The slice to copy. * @return A new slice containing the same data as `self`. */ - function copy(slice self) internal returns (slice) { + function copy(slice memory self) internal returns (slice memory) { return slice(self._len, self._ptr); } @@ -134,7 +134,7 @@ library strings { * @param self The slice to copy. * @return A newly allocated string containing the slice's text. */ - function toString(slice self) internal returns (string) { + function toString(slice memory self) internal returns (string memory) { string memory ret = new string(self._len); uint retptr; assembly { retptr := add(ret, 32) } @@ -151,7 +151,7 @@ library strings { * @param self The slice to operate on. * @return The length of the slice in runes. */ - function len(slice self) internal returns (uint) { + function len(slice memory self) internal returns (uint) { // Starting at ptr-31 means the LSB will be the byte we care about uint ptr = self._ptr - 31; uint end = ptr + self._len; @@ -181,7 +181,7 @@ library strings { * @param self The slice to operate on. * @return True if the slice is empty, False otherwise. */ - function empty(slice self) internal returns (bool) { + function empty(slice memory self) internal returns (bool) { return self._len == 0; } @@ -194,7 +194,7 @@ library strings { * @param other The second slice to compare. * @return The result of the comparison. */ - function compare(slice self, slice other) internal returns (int) { + function compare(slice memory self, slice memory other) internal returns (int) { uint shortest = self._len; if (other._len < self._len) shortest = other._len; @@ -227,7 +227,7 @@ library strings { * @param self The second slice to compare. * @return True if the slices are equal, false otherwise. */ - function equals(slice self, slice other) internal returns (bool) { + function equals(slice memory self, slice memory other) internal returns (bool) { return compare(self, other) == 0; } @@ -238,7 +238,7 @@ library strings { * @param rune The slice that will contain the first rune. * @return `rune`. */ - function nextRune(slice self, slice rune) internal returns (slice) { + function nextRune(slice memory self, slice memory rune) internal returns (slice memory) { rune._ptr = self._ptr; if (self._len == 0) { @@ -280,7 +280,7 @@ library strings { * @param self The slice to operate on. * @return A slice containing only the first rune from `self`. */ - function nextRune(slice self) internal returns (slice ret) { + function nextRune(slice memory self) internal returns (slice memory ret) { nextRune(self, ret); } @@ -289,7 +289,7 @@ library strings { * @param self The slice to operate on. * @return The number of the first codepoint in the slice. */ - function ord(slice self) internal returns (uint ret) { + function ord(slice memory self) internal returns (uint ret) { if (self._len == 0) { return 0; } @@ -338,7 +338,7 @@ library strings { * @param self The slice to hash. * @return The hash of the slice. */ - function keccak(slice self) internal returns (bytes32 ret) { + function keccak(slice memory self) internal returns (bytes32 ret) { assembly { ret := keccak256(mload(add(self, 32)), mload(self)) } @@ -350,7 +350,7 @@ library strings { * @param needle The slice to search for. * @return True if the slice starts with the provided text, false otherwise. */ - function startsWith(slice self, slice needle) internal returns (bool) { + function startsWith(slice memory self, slice memory needle) internal returns (bool) { if (self._len < needle._len) { return false; } @@ -376,7 +376,7 @@ library strings { * @param needle The slice to search for. * @return `self` */ - function beyond(slice self, slice needle) internal returns (slice) { + function beyond(slice memory self, slice memory needle) internal returns (slice memory) { if (self._len < needle._len) { return self; } @@ -405,7 +405,7 @@ library strings { * @param needle The slice to search for. * @return True if the slice starts with the provided text, false otherwise. */ - function endsWith(slice self, slice needle) internal returns (bool) { + function endsWith(slice memory self, slice memory needle) internal returns (bool) { if (self._len < needle._len) { return false; } @@ -433,7 +433,7 @@ library strings { * @param needle The slice to search for. * @return `self` */ - function until(slice self, slice needle) internal returns (slice) { + function until(slice memory self, slice memory needle) internal returns (slice memory) { if (self._len < needle._len) { return self; } @@ -542,7 +542,7 @@ library strings { * @param needle The text to search for. * @return `self`. */ - function find(slice self, slice needle) internal returns (slice) { + function find(slice memory self, slice memory needle) internal returns (slice memory) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); self._len -= ptr - self._ptr; self._ptr = ptr; @@ -557,7 +557,7 @@ library strings { * @param needle The text to search for. * @return `self`. */ - function rfind(slice self, slice needle) internal returns (slice) { + function rfind(slice memory self, slice memory needle) internal returns (slice memory) { uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); self._len = ptr - self._ptr; return self; @@ -573,7 +573,7 @@ library strings { * @param token An output parameter to which the first token is written. * @return `token`. */ - function split(slice self, slice needle, slice token) internal returns (slice) { + function split(slice memory self, slice memory needle, slice memory token) internal returns (slice memory) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); token._ptr = self._ptr; token._len = ptr - self._ptr; @@ -596,7 +596,7 @@ library strings { * @param needle The text to search for in `self`. * @return The part of `self` up to the first occurrence of `delim`. */ - function split(slice self, slice needle) internal returns (slice token) { + function split(slice memory self, slice memory needle) internal returns (slice memory token) { split(self, needle, token); } @@ -610,7 +610,7 @@ library strings { * @param token An output parameter to which the first token is written. * @return `token`. */ - function rsplit(slice self, slice needle, slice token) internal returns (slice) { + function rsplit(slice memory self, slice memory needle, slice memory token) internal returns (slice memory) { uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); token._ptr = ptr; token._len = self._len - (ptr - self._ptr); @@ -632,7 +632,7 @@ library strings { * @param needle The text to search for in `self`. * @return The part of `self` after the last occurrence of `delim`. */ - function rsplit(slice self, slice needle) internal returns (slice token) { + function rsplit(slice memory self, slice memory needle) internal returns (slice memory token) { rsplit(self, needle, token); } @@ -642,7 +642,7 @@ library strings { * @param needle The text to search for in `self`. * @return The number of occurrences of `needle` found in `self`. */ - function count(slice self, slice needle) internal returns (uint count) { + function count(slice memory self, slice memory needle) internal returns (uint count) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len; while (ptr <= self._ptr + self._len) { count++; @@ -656,7 +656,7 @@ library strings { * @param needle The text to search for in `self`. * @return True if `needle` is found in `self`, false otherwise. */ - function contains(slice self, slice needle) internal returns (bool) { + function contains(slice memory self, slice memory needle) internal returns (bool) { return rfindPtr(self._len, self._ptr, needle._len, needle._ptr) != self._ptr; } @@ -667,7 +667,7 @@ library strings { * @param other The second slice to concatenate. * @return The concatenation of the two strings. */ - function concat(slice self, slice other) internal returns (string) { + function concat(slice memory self, slice memory other) internal returns (string memory) { string memory ret = new string(self._len + other._len); uint retptr; assembly { retptr := add(ret, 32) } @@ -684,7 +684,7 @@ library strings { * @return A newly allocated string containing all the slices in `parts`, * joined with `self`. */ - function join(slice self, slice[] parts) internal returns (string) { + function join(slice memory self, slice[] memory parts) internal returns (string memory) { if (parts.length == 0) return ""; diff --git a/test/compilationTests/zeppelin/Bounty.sol b/test/compilationTests/zeppelin/Bounty.sol index a5e75cd3..55e64071 100644 --- a/test/compilationTests/zeppelin/Bounty.sol +++ b/test/compilationTests/zeppelin/Bounty.sol @@ -20,7 +20,7 @@ contract Bounty is PullPayment, Destructible { */ function() external payable { if (claimed) { - throw; + revert(); } } @@ -49,11 +49,11 @@ contract Bounty is PullPayment, Destructible { function claim(Target target) public { address researcher = researchers[target]; if (researcher == address(0)) { - throw; + revert(); } // Check Target contract invariants if (target.checkInvariant()) { - throw; + revert(); } asyncSend(researcher, address(this).balance); claimed = true; diff --git a/test/compilationTests/zeppelin/DayLimit.sol b/test/compilationTests/zeppelin/DayLimit.sol index 5a2937b5..bc576c89 100644 --- a/test/compilationTests/zeppelin/DayLimit.sol +++ b/test/compilationTests/zeppelin/DayLimit.sol @@ -68,7 +68,7 @@ contract DayLimit { */ modifier limitedDaily(uint256 _value) { if (!underLimit(_value)) { - throw; + revert(); } _; } diff --git a/test/compilationTests/zeppelin/LimitBalance.sol b/test/compilationTests/zeppelin/LimitBalance.sol index 9682ff1c..8bf4b253 100644 --- a/test/compilationTests/zeppelin/LimitBalance.sol +++ b/test/compilationTests/zeppelin/LimitBalance.sol @@ -24,7 +24,7 @@ contract LimitBalance { */ modifier limitedPayable() { if (address(this).balance > limit) { - throw; + revert(); } _; diff --git a/test/compilationTests/zeppelin/MultisigWallet.sol b/test/compilationTests/zeppelin/MultisigWallet.sol index e8e8d05d..3793428d 100644 --- a/test/compilationTests/zeppelin/MultisigWallet.sol +++ b/test/compilationTests/zeppelin/MultisigWallet.sol @@ -25,7 +25,7 @@ contract MultisigWallet is Multisig, Shareable, DayLimit { * @param _owners A list of owners. * @param _required The amount required for a transaction to be approved. */ - constructor(address[] _owners, uint256 _required, uint256 _daylimit) + constructor(address[] memory _owners, uint256 _required, uint256 _daylimit) Shareable(_owners, _required) DayLimit(_daylimit) public { } @@ -61,7 +61,7 @@ contract MultisigWallet is Multisig, Shareable, DayLimit { emit SingleTransact(msg.sender, _value, _to, _data); // yes - just execute the call. if (!_to.call.value(_value)(_data)) { - throw; + revert(); } return 0; } @@ -83,7 +83,7 @@ contract MultisigWallet is Multisig, Shareable, DayLimit { function confirm(bytes32 _h) onlymanyowners(_h) public returns (bool) { if (txs[_h].to != address(0)) { if (!txs[_h].to.call.value(txs[_h].value)(txs[_h].data)) { - throw; + revert(); } emit MultiTransact(msg.sender, _h, txs[_h].value, txs[_h].to, txs[_h].data); delete txs[_h]; diff --git a/test/compilationTests/zeppelin/ReentrancyGuard.sol b/test/compilationTests/zeppelin/ReentrancyGuard.sol index 60c7927b..7805ec07 100644 --- a/test/compilationTests/zeppelin/ReentrancyGuard.sol +++ b/test/compilationTests/zeppelin/ReentrancyGuard.sol @@ -27,7 +27,7 @@ contract ReentrancyGuard { _; rentrancy_lock = false; } else { - throw; + revert(); } } diff --git a/test/compilationTests/zeppelin/lifecycle/Pausable.sol b/test/compilationTests/zeppelin/lifecycle/Pausable.sol index 4ffd281a..0c48f2f6 100644 --- a/test/compilationTests/zeppelin/lifecycle/Pausable.sol +++ b/test/compilationTests/zeppelin/lifecycle/Pausable.sol @@ -19,7 +19,7 @@ contract Pausable is Ownable { * @dev modifier to allow actions only when the contract IS paused */ modifier whenNotPaused() { - if (paused) throw; + if (paused) revert(); _; } @@ -27,7 +27,7 @@ contract Pausable is Ownable { * @dev modifier to allow actions only when the contract IS NOT paused */ modifier whenPaused { - if (!paused) throw; + if (!paused) revert(); _; } diff --git a/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol b/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol index 0b19eb71..51f6b68e 100644 --- a/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol +++ b/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol @@ -21,7 +21,7 @@ contract TokenDestructible is Ownable { * @notice The called token contracts could try to re-enter this contract. Only supply token contracts you trust. */ - function destroy(address[] tokens) public onlyOwner { + function destroy(address[] memory tokens) public onlyOwner { // Transfer tokens to owner for(uint256 i = 0; i < tokens.length; i++) { diff --git a/test/compilationTests/zeppelin/ownership/Claimable.sol b/test/compilationTests/zeppelin/ownership/Claimable.sol index 72390411..d7b48a29 100644 --- a/test/compilationTests/zeppelin/ownership/Claimable.sol +++ b/test/compilationTests/zeppelin/ownership/Claimable.sol @@ -17,7 +17,7 @@ contract Claimable is Ownable { */ modifier onlyPendingOwner() { if (msg.sender != pendingOwner) { - throw; + revert(); } _; } diff --git a/test/compilationTests/zeppelin/ownership/Contactable.sol b/test/compilationTests/zeppelin/ownership/Contactable.sol index 11b0e1dd..5f781e13 100644 --- a/test/compilationTests/zeppelin/ownership/Contactable.sol +++ b/test/compilationTests/zeppelin/ownership/Contactable.sol @@ -15,7 +15,7 @@ contract Contactable is Ownable{ * @dev Allows the owner to set a string with their contact information. * @param info The contact information to attach to the contract. */ - function setContactInformation(string info) public onlyOwner{ + function setContactInformation(string memory info) public onlyOwner{ contactInformation = info; } } diff --git a/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol b/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol index f019d2f1..540a2ce0 100644 --- a/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol +++ b/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol @@ -22,7 +22,7 @@ contract DelayedClaimable is Claimable { */ function setLimits(uint256 _start, uint256 _end) public onlyOwner { if (_start > _end) - throw; + revert(); end = _end; start = _start; } @@ -34,7 +34,7 @@ contract DelayedClaimable is Claimable { */ function claimOwnership() public onlyPendingOwner { if ((block.number > end) || (block.number < start)) - throw; + revert(); owner = pendingOwner; pendingOwner = address(0x0); end = 0; diff --git a/test/compilationTests/zeppelin/ownership/HasNoEther.sol b/test/compilationTests/zeppelin/ownership/HasNoEther.sol index 9f294679..75d90841 100644 --- a/test/compilationTests/zeppelin/ownership/HasNoEther.sol +++ b/test/compilationTests/zeppelin/ownership/HasNoEther.sol @@ -23,7 +23,7 @@ contract HasNoEther is Ownable { */ constructor() public payable { if(msg.value > 0) { - throw; + revert(); } } @@ -38,7 +38,7 @@ contract HasNoEther is Ownable { */ function reclaimEther() external onlyOwner { if(!owner.send(address(this).balance)) { - throw; + revert(); } } } diff --git a/test/compilationTests/zeppelin/ownership/HasNoTokens.sol b/test/compilationTests/zeppelin/ownership/HasNoTokens.sol index d1dc4b3e..df4284f1 100644 --- a/test/compilationTests/zeppelin/ownership/HasNoTokens.sol +++ b/test/compilationTests/zeppelin/ownership/HasNoTokens.sol @@ -19,7 +19,7 @@ contract HasNoTokens is Ownable { * @param data_ Bytes The data passed from the caller. */ function tokenFallback(address from_, uint256 value_, bytes data_) external { - throw; + revert(); } /** diff --git a/test/compilationTests/zeppelin/ownership/Ownable.sol b/test/compilationTests/zeppelin/ownership/Ownable.sol index 7417b2bd..a862cb74 100644 --- a/test/compilationTests/zeppelin/ownership/Ownable.sol +++ b/test/compilationTests/zeppelin/ownership/Ownable.sol @@ -24,7 +24,7 @@ contract Ownable { */ modifier onlyOwner() { if (msg.sender != owner) { - throw; + revert(); } _; } diff --git a/test/compilationTests/zeppelin/ownership/Shareable.sol b/test/compilationTests/zeppelin/ownership/Shareable.sol index d44f63b8..0c8d16a5 100644 --- a/test/compilationTests/zeppelin/ownership/Shareable.sol +++ b/test/compilationTests/zeppelin/ownership/Shareable.sol @@ -37,7 +37,7 @@ contract Shareable { // simple single-sig function modifier. modifier onlyOwner { if (!isOwner(msg.sender)) { - throw; + revert(); } _; } @@ -59,7 +59,7 @@ contract Shareable { * @param _owners A list of owners. * @param _required The amount required for a transaction to be approved. */ - constructor(address[] _owners, uint256 _required) public { + constructor(address[] memory _owners, uint256 _required) public { owners[1] = msg.sender; ownerIndex[msg.sender] = 1; for (uint256 i = 0; i < _owners.length; ++i) { @@ -68,7 +68,7 @@ contract Shareable { } required = _required; if (required > owners.length) { - throw; + revert(); } } @@ -139,7 +139,7 @@ contract Shareable { uint256 index = ownerIndex[msg.sender]; // make sure they're an owner if (index == 0) { - throw; + revert(); } PendingState memory pending = pendings[_operation]; diff --git a/test/compilationTests/zeppelin/payment/PullPayment.sol b/test/compilationTests/zeppelin/payment/PullPayment.sol index 2f3e1b51..bac1d019 100644 --- a/test/compilationTests/zeppelin/payment/PullPayment.sol +++ b/test/compilationTests/zeppelin/payment/PullPayment.sol @@ -33,18 +33,18 @@ contract PullPayment { uint256 payment = payments[payee]; if (payment == 0) { - throw; + revert(); } if (address(this).balance < payment) { - throw; + revert(); } totalPayments = totalPayments.sub(payment); payments[payee] = 0; if (!payee.send(payment)) { - throw; + revert(); } } } diff --git a/test/compilationTests/zeppelin/token/LimitedTransferToken.sol b/test/compilationTests/zeppelin/token/LimitedTransferToken.sol index 052c28e6..3ce928f6 100644 --- a/test/compilationTests/zeppelin/token/LimitedTransferToken.sol +++ b/test/compilationTests/zeppelin/token/LimitedTransferToken.sol @@ -23,7 +23,7 @@ contract LimitedTransferToken is ERC20 { * @dev Checks whether it can transfer or otherwise throws. */ modifier canTransfer(address _sender, uint256 _value) { - if (_value > transferableTokens(_sender, uint64(now))) throw; + if (_value > transferableTokens(_sender, uint64(now))) revert(); _; } diff --git a/test/compilationTests/zeppelin/token/MintableToken.sol b/test/compilationTests/zeppelin/token/MintableToken.sol index f99964d0..24b8c807 100644 --- a/test/compilationTests/zeppelin/token/MintableToken.sol +++ b/test/compilationTests/zeppelin/token/MintableToken.sol @@ -21,7 +21,7 @@ contract MintableToken is StandardToken, Ownable { modifier canMint() { - if(mintingFinished) throw; + if(mintingFinished) revert(); _; } diff --git a/test/compilationTests/zeppelin/token/StandardToken.sol b/test/compilationTests/zeppelin/token/StandardToken.sol index 94b12e57..56f4a5f3 100644 --- a/test/compilationTests/zeppelin/token/StandardToken.sol +++ b/test/compilationTests/zeppelin/token/StandardToken.sol @@ -27,7 +27,7 @@ contract StandardToken is ERC20, BasicToken { uint256 _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met - // if (_value > _allowance) throw; + // if (_value > _allowance) revert(); balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); @@ -46,7 +46,7 @@ contract StandardToken is ERC20, BasicToken { // allowance to zero by calling `approve(_spender, 0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 - if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) throw; + if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) revert(); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); diff --git a/test/compilationTests/zeppelin/token/VestedToken.sol b/test/compilationTests/zeppelin/token/VestedToken.sol index 48818c3f..ca13b638 100644 --- a/test/compilationTests/zeppelin/token/VestedToken.sol +++ b/test/compilationTests/zeppelin/token/VestedToken.sol @@ -46,10 +46,10 @@ contract VestedToken is StandardToken, LimitedTransferToken { // Check for date inconsistencies that may cause unexpected behavior if (_cliff < _start || _vesting < _cliff) { - throw; + revert(); } - if (tokenGrantsCount(_to) > MAX_GRANTS_PER_ADDRESS) throw; // To prevent a user being spammed and have his balance locked (out of gas attack when calculating vesting). + if (tokenGrantsCount(_to) > MAX_GRANTS_PER_ADDRESS) revert(); // To prevent a user being spammed and have his balance locked (out of gas attack when calculating vesting). uint256 count = grants[_to].push( TokenGrant( @@ -77,11 +77,11 @@ contract VestedToken is StandardToken, LimitedTransferToken { TokenGrant storage grant = grants[_holder][_grantId]; if (!grant.revokable) { // Check if grant was revokable - throw; + revert(); } if (grant.granter != msg.sender) { // Only granter can revoke it - throw; + revert(); } address receiver = grant.burnsOnRevoke ? 0xdead : msg.sender; @@ -212,7 +212,7 @@ contract VestedToken is StandardToken, LimitedTransferToken { * @param time The time to be checked * @return An uint256 representing the amount of vested tokens of a specific grant at a specific time. */ - function vestedTokens(TokenGrant grant, uint64 time) private view returns (uint256) { + function vestedTokens(TokenGrant memory grant, uint64 time) private view returns (uint256) { return calculateVestedTokens( grant.value, uint256(time), @@ -229,7 +229,7 @@ contract VestedToken is StandardToken, LimitedTransferToken { * @return An uint256 representing the amount of non vested tokens of a specific grant on the * passed time frame. */ - function nonVestedTokens(TokenGrant grant, uint64 time) private view returns (uint256) { + function nonVestedTokens(TokenGrant memory grant, uint64 time) private view returns (uint256) { return grant.value.sub(vestedTokens(grant, time)); } diff --git a/test/contracts/AuctionRegistrar.cpp b/test/contracts/AuctionRegistrar.cpp index 0fc093e7..4ff55b75 100644 --- a/test/contracts/AuctionRegistrar.cpp +++ b/test/contracts/AuctionRegistrar.cpp @@ -43,20 +43,20 @@ static char const* registrarCode = R"DELIMITER( pragma solidity ^0.4.0; contract NameRegister { - function addr(string _name) view returns (address o_owner); - function name(address _owner) view returns (string o_name); + function addr(string memory _name) public view returns (address o_owner); + function name(address _owner) public view returns (string memory o_name); } contract Registrar is NameRegister { event Changed(string indexed name); event PrimaryChanged(string indexed name, address indexed addr); - function owner(string _name) view returns (address o_owner); - function addr(string _name) view returns (address o_address); - function subRegistrar(string _name) view returns (address o_subRegistrar); - function content(string _name) view returns (bytes32 o_content); + function owner(string memory _name) public view returns (address o_owner); + function addr(string memory _name) public view returns (address o_address); + function subRegistrar(string memory _name) public view returns (address o_subRegistrar); + function content(string memory _name) public view returns (bytes32 o_content); - function name(address _owner) view returns (string o_name); + function name(address _owner) public view returns (string memory o_name); } contract AuctionSystem { @@ -64,9 +64,9 @@ contract AuctionSystem { event NewBid(string indexed _name, address _bidder, uint _value); /// Function that is called once an auction ends. - function onAuctionEnd(string _name) internal; + function onAuctionEnd(string memory _name) internal; - function bid(string _name, address _bidder, uint _value) internal { + function bid(string memory _name, address _bidder, uint _value) internal { Auction storage auction = m_auctions[_name]; if (auction.endDate > 0 && now > auction.endDate) { @@ -112,11 +112,11 @@ contract GlobalRegistrar is Registrar, AuctionSystem { uint constant c_renewalInterval = 365 days; uint constant c_freeBytes = 12; - function Registrar() { + function Registrar() public { // TODO: Populate with hall-of-fame. } - function onAuctionEnd(string _name) internal { + function onAuctionEnd(string memory _name) internal { Auction storage auction = m_auctions[_name]; Record storage record = m_toRecord[_name]; address previousOwner = record.owner; @@ -125,43 +125,43 @@ contract GlobalRegistrar is Registrar, AuctionSystem { emit Changed(_name); if (previousOwner != 0x0000000000000000000000000000000000000000) { if (!record.owner.send(auction.sumOfBids - auction.highestBid / 100)) - throw; + revert(); } else { if (!auction.highestBidder.send(auction.highestBid - auction.secondHighestBid)) - throw; + revert(); } } function reserve(string _name) external payable { if (bytes(_name).length == 0) - throw; + revert(); bool needAuction = requiresAuction(_name); if (needAuction) { if (now < m_toRecord[_name].renewalDate) - throw; + revert(); bid(_name, msg.sender, msg.value); } else { Record storage record = m_toRecord[_name]; if (record.owner != 0x0000000000000000000000000000000000000000) - throw; + revert(); m_toRecord[_name].owner = msg.sender; emit Changed(_name); } } - function requiresAuction(string _name) internal returns (bool) { + function requiresAuction(string memory _name) internal returns (bool) { return bytes(_name).length < c_freeBytes; } - modifier onlyrecordowner(string _name) { if (m_toRecord[_name].owner == msg.sender) _; } + modifier onlyrecordowner(string memory _name) { if (m_toRecord[_name].owner == msg.sender) _; } - function transfer(string _name, address _newOwner) onlyrecordowner(_name) { + function transfer(string memory _name, address _newOwner) onlyrecordowner(_name) public { m_toRecord[_name].owner = _newOwner; emit Changed(_name); } - function disown(string _name) onlyrecordowner(_name) { + function disown(string memory _name) onlyrecordowner(_name) public { if (stringsEqual(m_toName[m_toRecord[_name].primary], _name)) { emit PrimaryChanged(_name, m_toRecord[_name].primary); @@ -171,7 +171,7 @@ contract GlobalRegistrar is Registrar, AuctionSystem { emit Changed(_name); } - function setAddress(string _name, address _a, bool _primary) onlyrecordowner(_name) { + function setAddress(string memory _name, address _a, bool _primary) onlyrecordowner(_name) public { m_toRecord[_name].primary = _a; if (_primary) { @@ -180,11 +180,11 @@ contract GlobalRegistrar is Registrar, AuctionSystem { } emit Changed(_name); } - function setSubRegistrar(string _name, address _registrar) onlyrecordowner(_name) { + function setSubRegistrar(string memory _name, address _registrar) onlyrecordowner(_name) public { m_toRecord[_name].subRegistrar = _registrar; emit Changed(_name); } - function setContent(string _name, bytes32 _content) onlyrecordowner(_name) { + function setContent(string memory _name, bytes32 _content) onlyrecordowner(_name) public { m_toRecord[_name].content = _content; emit Changed(_name); } @@ -201,11 +201,11 @@ contract GlobalRegistrar is Registrar, AuctionSystem { return true; } - function owner(string _name) view returns (address) { return m_toRecord[_name].owner; } - function addr(string _name) view returns (address) { return m_toRecord[_name].primary; } - function subRegistrar(string _name) view returns (address) { return m_toRecord[_name].subRegistrar; } - function content(string _name) view returns (bytes32) { return m_toRecord[_name].content; } - function name(address _addr) view returns (string o_name) { return m_toName[_addr]; } + function owner(string memory _name) public view returns (address) { return m_toRecord[_name].owner; } + function addr(string memory _name) public view returns (address) { return m_toRecord[_name].primary; } + function subRegistrar(string memory _name) public view returns (address) { return m_toRecord[_name].subRegistrar; } + function content(string memory _name) public view returns (bytes32) { return m_toRecord[_name].content; } + function name(address _addr) public view returns (string memory o_name) { return m_toName[_addr]; } mapping (address => string) m_toName; mapping (string => Record) m_toRecord; diff --git a/test/contracts/FixedFeeRegistrar.cpp b/test/contracts/FixedFeeRegistrar.cpp index aebdb053..78db4761 100644 --- a/test/contracts/FixedFeeRegistrar.cpp +++ b/test/contracts/FixedFeeRegistrar.cpp @@ -58,10 +58,10 @@ pragma solidity ^0.4.0; contract Registrar { event Changed(string indexed name); - function owner(string _name) view returns (address o_owner); - function addr(string _name) view returns (address o_address); - function subRegistrar(string _name) view returns (address o_subRegistrar); - function content(string _name) view returns (bytes32 o_content); + function owner(string memory _name) public view returns (address o_owner); + function addr(string memory _name) public view returns (address o_address); + function subRegistrar(string memory _name) public view returns (address o_subRegistrar); + function content(string memory _name) public view returns (bytes32 o_content); } contract FixedFeeRegistrar is Registrar { @@ -72,52 +72,52 @@ contract FixedFeeRegistrar is Registrar { address owner; } - modifier onlyrecordowner(string _name) { if (m_record(_name).owner == msg.sender) _; } + modifier onlyrecordowner(string memory _name) { if (m_record(_name).owner == msg.sender) _; } - function reserve(string _name) payable { + function reserve(string memory _name) public payable { Record storage rec = m_record(_name); if (rec.owner == 0x0000000000000000000000000000000000000000 && msg.value >= c_fee) { rec.owner = msg.sender; emit Changed(_name); } } - function disown(string _name, address _refund) onlyrecordowner(_name) { + function disown(string memory _name, address _refund) onlyrecordowner(_name) public { delete m_recordData[uint(keccak256(bytes(_name))) / 8]; if (!_refund.send(c_fee)) - throw; + revert(); emit Changed(_name); } - function transfer(string _name, address _newOwner) onlyrecordowner(_name) { + function transfer(string memory _name, address _newOwner) onlyrecordowner(_name) public { m_record(_name).owner = _newOwner; emit Changed(_name); } - function setAddr(string _name, address _a) onlyrecordowner(_name) { + function setAddr(string memory _name, address _a) onlyrecordowner(_name) public { m_record(_name).addr = _a; emit Changed(_name); } - function setSubRegistrar(string _name, address _registrar) onlyrecordowner(_name) { + function setSubRegistrar(string memory _name, address _registrar) onlyrecordowner(_name) public { m_record(_name).subRegistrar = _registrar; emit Changed(_name); } - function setContent(string _name, bytes32 _content) onlyrecordowner(_name) { + function setContent(string memory _name, bytes32 _content) onlyrecordowner(_name) public { m_record(_name).content = _content; emit Changed(_name); } - function record(string _name) view returns (address o_addr, address o_subRegistrar, bytes32 o_content, address o_owner) { + function record(string memory _name) public view returns (address o_addr, address o_subRegistrar, bytes32 o_content, address o_owner) { Record storage rec = m_record(_name); o_addr = rec.addr; o_subRegistrar = rec.subRegistrar; o_content = rec.content; o_owner = rec.owner; } - function addr(string _name) view returns (address) { return m_record(_name).addr; } - function subRegistrar(string _name) view returns (address) { return m_record(_name).subRegistrar; } - function content(string _name) view returns (bytes32) { return m_record(_name).content; } - function owner(string _name) view returns (address) { return m_record(_name).owner; } + function addr(string memory _name) public view returns (address) { return m_record(_name).addr; } + function subRegistrar(string memory _name) public view returns (address) { return m_record(_name).subRegistrar; } + function content(string memory _name) public view returns (bytes32) { return m_record(_name).content; } + function owner(string memory _name) public view returns (address) { return m_record(_name).owner; } Record[2**253] m_recordData; - function m_record(string _name) view internal returns (Record storage o_record) { + function m_record(string memory _name) view internal returns (Record storage o_record) { return m_recordData[uint(keccak256(bytes(_name))) / 8]; } uint constant c_fee = 69 ether; diff --git a/test/contracts/Wallet.cpp b/test/contracts/Wallet.cpp index 45fe5bbd..dc949063 100644 --- a/test/contracts/Wallet.cpp +++ b/test/contracts/Wallet.cpp @@ -101,7 +101,7 @@ contract multiowned { // constructor is given number of sigs required to do protected "onlymanyowners" transactions // as well as the selection of addresses capable of confirming them. - constructor(address[] _owners, uint _required) { + constructor(address[] memory _owners, uint _required) public { m_numOwners = _owners.length + 1; m_owners[1] = uint(msg.sender); m_ownerIndex[uint(msg.sender)] = 1; @@ -173,11 +173,11 @@ contract multiowned { emit RequirementChanged(_newRequired); } - function isOwner(address _addr) returns (bool) { + function isOwner(address _addr) public returns (bool) { return m_ownerIndex[uint(_addr)] > 0; } - function hasConfirmed(bytes32 _operation, address _owner) view returns (bool) { + function hasConfirmed(bytes32 _operation, address _owner) public view returns (bool) { PendingState storage pending = m_pending[_operation]; uint ownerIndex = m_ownerIndex[uint(_owner)]; @@ -288,7 +288,7 @@ contract daylimit is multiowned { // METHODS // constructor - stores initial daily limit and records the present day's index. - constructor(uint _limit) { + constructor(uint _limit) public { m_dailyLimit = _limit; m_lastDay = today(); } @@ -348,7 +348,7 @@ contract multisig { // TODO: document function changeOwner(address _from, address _to) external; function execute(address _to, uint _value, bytes _data) external returns (bytes32); - function confirm(bytes32 _h) returns (bool); + function confirm(bytes32 _h) public returns (bool); } // usage: @@ -369,7 +369,7 @@ contract Wallet is multisig, multiowned, daylimit { // constructor - just pass on the owner array to the multiowned and // the limit to daylimit - constructor(address[] _owners, uint _required, uint _daylimit) payable + constructor(address[] memory _owners, uint _required, uint _daylimit) public payable multiowned(_owners, _required) daylimit(_daylimit) { } @@ -409,7 +409,7 @@ contract Wallet is multisig, multiowned, daylimit { // confirm a transaction through just the hash. we use the previous transactions map, m_txs, in order // to determine the body of the transaction from the hash provided. - function confirm(bytes32 _h) onlymanyowners(_h) returns (bool) { + function confirm(bytes32 _h) onlymanyowners(_h) public returns (bool) { if (m_txs[_h].to != 0x0000000000000000000000000000000000000000) { m_txs[_h].to.call.value(m_txs[_h].value)(m_txs[_h].data); emit MultiTransact(msg.sender, _h, m_txs[_h].value, m_txs[_h].to, m_txs[_h].data); diff --git a/test/libsolidity/ABIDecoderTests.cpp b/test/libsolidity/ABIDecoderTests.cpp index 6504f6bc..28f982c4 100644 --- a/test/libsolidity/ABIDecoderTests.cpp +++ b/test/libsolidity/ABIDecoderTests.cpp @@ -128,7 +128,7 @@ BOOST_AUTO_TEST_CASE(fixed_arrays) { string sourceCode = R"( contract C { - function f(uint16[3] a, uint16[2][3] b, uint i, uint j, uint k) + function f(uint16[3] memory a, uint16[2][3] memory b, uint i, uint j, uint k) public pure returns (uint, uint) { return (a[i], b[j][k]); } @@ -154,7 +154,7 @@ BOOST_AUTO_TEST_CASE(dynamic_arrays) { string sourceCode = R"( contract C { - function f(uint a, uint16[] b, uint c) + function f(uint a, uint16[] memory b, uint c) public pure returns (uint, uint, uint) { return (b.length, b[a], c); } @@ -178,11 +178,11 @@ BOOST_AUTO_TEST_CASE(dynamic_nested_arrays) { string sourceCode = R"( contract C { - function f(uint a, uint16[][] b, uint[2][][3] c, uint d) + function f(uint a, uint16[][] memory b, uint[2][][3] memory c, uint d) public pure returns (uint, uint, uint, uint, uint, uint, uint) { return (a, b.length, b[1].length, b[1][1], c[1].length, c[1][1][1], d); } - function test() view returns (uint, uint, uint, uint, uint, uint, uint) { + function test() public view returns (uint, uint, uint, uint, uint, uint, uint) { uint16[][] memory b = new uint16[][](3); b[0] = new uint16[](2); b[0][0] = 0x55; @@ -229,7 +229,7 @@ BOOST_AUTO_TEST_CASE(byte_arrays) { string sourceCode = R"( contract C { - function f(uint a, bytes b, uint c) + function f(uint a, bytes memory b, uint c) public pure returns (uint, uint, byte, uint) { return (a, b.length, b[3], c); } @@ -285,7 +285,7 @@ BOOST_AUTO_TEST_CASE(decode_from_memory_simple) contract C { uint public _a; uint[] public _b; - constructor(uint a, uint[] b) public { + constructor(uint a, uint[] memory b) public { _a = a; _b = b; } @@ -344,13 +344,13 @@ BOOST_AUTO_TEST_CASE(decode_function_type_array) string sourceCode = R"( contract D { function () external returns (uint)[] public _a; - constructor(function () external returns (uint)[] a) public { + constructor(function () external returns (uint)[] memory a) public { _a = a; } } contract E { function () external returns (uint)[3] public _a; - constructor(function () external returns (uint)[3] a) public { + constructor(function () external returns (uint)[3] memory a) public { _a = a; } } @@ -364,10 +364,10 @@ BOOST_AUTO_TEST_CASE(decode_function_type_array) function f3() public returns (uint) { return 3; } - function g(function () external returns (uint)[] _f, uint i) public returns (uint) { + function g(function () external returns (uint)[] memory _f, uint i) public returns (uint) { return _f[i](); } - function h(function () external returns (uint)[3] _f, uint i) public returns (uint) { + function h(function () external returns (uint)[3] memory _f, uint i) public returns (uint) { return _f[i](); } // uses "decode from memory" @@ -412,7 +412,7 @@ BOOST_AUTO_TEST_CASE(decode_from_memory_complex) uint public _a; uint[] public _b; bytes[2] public _c; - constructor(uint a, uint[] b, bytes[2] c) public { + constructor(uint a, uint[] memory b, bytes[2] memory c) public { _a = a; _b = b; _c = c; @@ -459,7 +459,7 @@ BOOST_AUTO_TEST_CASE(short_input_array) { string sourceCode = R"( contract C { - function f(uint[] a) public pure returns (uint) { return 7; } + function f(uint[] memory a) public pure returns (uint) { return 7; } } )"; BOTH_ENCODERS( @@ -476,7 +476,7 @@ BOOST_AUTO_TEST_CASE(short_dynamic_input_array) { string sourceCode = R"( contract C { - function f(bytes[1] a) public pure returns (uint) { return 7; } + function f(bytes[1] memory a) public pure returns (uint) { return 7; } } )"; NEW_ENCODER( @@ -489,8 +489,8 @@ BOOST_AUTO_TEST_CASE(short_input_bytes) { string sourceCode = R"( contract C { - function e(bytes a) public pure returns (uint) { return 7; } - function f(bytes[] a) public pure returns (uint) { return 7; } + function e(bytes memory a) public pure returns (uint) { return 7; } + function f(bytes[] memory a) public pure returns (uint) { return 7; } } )"; NEW_ENCODER( @@ -511,9 +511,9 @@ BOOST_AUTO_TEST_CASE(cleanup_int_inside_arrays) string sourceCode = R"( contract C { enum E { A, B } - function f(uint16[] a) public pure returns (uint r) { assembly { r := mload(add(a, 0x20)) } } - function g(int16[] a) public pure returns (uint r) { assembly { r := mload(add(a, 0x20)) } } - function h(E[] a) public pure returns (uint r) { assembly { r := mload(add(a, 0x20)) } } + function f(uint16[] memory a) public pure returns (uint r) { assembly { r := mload(add(a, 0x20)) } } + function g(int16[] memory a) public pure returns (uint r) { assembly { r := mload(add(a, 0x20)) } } + function h(E[] memory a) public pure returns (uint r) { assembly { r := mload(add(a, 0x20)) } } } )"; NEW_ENCODER( @@ -569,7 +569,7 @@ BOOST_AUTO_TEST_CASE(struct_simple) string sourceCode = R"( contract C { struct S { uint a; uint8 b; uint8 c; bytes2 d; } - function f(S s) public pure returns (uint a, uint b, uint c, uint d) { + function f(S memory s) public pure returns (uint a, uint b, uint c, uint d) { a = s.a; b = s.b; c = s.c; @@ -588,7 +588,7 @@ BOOST_AUTO_TEST_CASE(struct_cleanup) string sourceCode = R"( contract C { struct S { int16 a; uint8 b; bytes2 c; } - function f(S s) public pure returns (uint a, uint b, uint c) { + function f(S memory s) public pure returns (uint a, uint b, uint c) { assembly { a := mload(s) b := mload(add(s, 0x20)) @@ -611,7 +611,7 @@ BOOST_AUTO_TEST_CASE(struct_short) string sourceCode = R"( contract C { struct S { int a; uint b; bytes16 c; } - function f(S s) public pure returns (S q) { + function f(S memory s) public pure returns (S memory q) { q = s; } } @@ -638,7 +638,7 @@ BOOST_AUTO_TEST_CASE(struct_function) string sourceCode = R"( contract C { struct S { function () external returns (uint) f; uint b; } - function f(S s) public returns (uint, uint) { + function f(S memory s) public returns (uint, uint) { return (s.f(), s.b); } function test() public returns (uint, uint) { @@ -658,7 +658,7 @@ BOOST_AUTO_TEST_CASE(mediocre_struct) string sourceCode = R"( contract C { struct S { C c; } - function f(uint a, S[2] s1, uint b) public returns (uint r1, C r2, uint r3) { + function f(uint a, S[2] memory s1, uint b) public returns (uint r1, C r2, uint r3) { r1 = a; r2 = s1[0].c; r3 = b; @@ -679,7 +679,7 @@ BOOST_AUTO_TEST_CASE(mediocre2_struct) string sourceCode = R"( contract C { struct S { C c; uint[] x; } - function f(uint a, S[2] s1, uint b) public returns (uint r1, C r2, uint r3) { + function f(uint a, S[2] memory s1, uint b) public returns (uint r1, C r2, uint r3) { r1 = a; r2 = s1[0].c; r3 = b; @@ -707,7 +707,7 @@ BOOST_AUTO_TEST_CASE(complex_struct) enum E {A, B, C} struct T { uint x; E e; uint8 y; } struct S { C c; T[] t;} - function f(uint a, S[2] s1, S[] s2, uint b) public returns + function f(uint a, S[2] memory s1, S[] memory s2, uint b) public returns (uint r1, C r2, uint r3, uint r4, C r5, uint r6, E r7, uint8 r8) { r1 = a; r2 = s1[0].c; @@ -767,10 +767,10 @@ BOOST_AUTO_TEST_CASE(return_dynamic_types_cross_call_simple) string sourceCode = R"( contract C { - function dyn() public returns (bytes) { + function dyn() public returns (bytes memory) { return "1234567890123456789012345678901234567890"; } - function f() public returns (bytes) { + function f() public returns (bytes memory) { return this.dyn(); } } @@ -788,7 +788,7 @@ BOOST_AUTO_TEST_CASE(return_dynamic_types_cross_call_advanced) string sourceCode = R"( contract C { - function dyn() public returns (bytes a, uint b, bytes20[] c, uint d) { + function dyn() public returns (bytes memory a, uint b, bytes20[] memory c, uint d) { a = "1234567890123456789012345678901234567890"; b = uint(-1); c = new bytes20[](4); @@ -796,7 +796,7 @@ BOOST_AUTO_TEST_CASE(return_dynamic_types_cross_call_advanced) c[3] = bytes20(6789); d = 0x1234; } - function f() public returns (bytes, uint, bytes20[], uint) { + function f() public returns (bytes memory, uint, bytes20[] memory, uint) { return this.dyn(); } } @@ -815,7 +815,7 @@ BOOST_AUTO_TEST_CASE(return_dynamic_types_cross_call_out_of_range) { string sourceCode = R"( contract C { - function dyn(uint x) public returns (bytes a) { + function dyn(uint x) public returns (bytes memory a) { assembly { mstore(0, 0x20) mstore(0x20, 0x21) diff --git a/test/libsolidity/ABIEncoderTests.cpp b/test/libsolidity/ABIEncoderTests.cpp index 9b6250d8..b1eda425 100644 --- a/test/libsolidity/ABIEncoderTests.cpp +++ b/test/libsolidity/ABIEncoderTests.cpp @@ -417,7 +417,7 @@ BOOST_AUTO_TEST_CASE(structs) struct T { uint64[2] x; } S s; event e(uint16, S); - function f() public returns (uint, S) { + function f() public returns (uint, S memory) { uint16 x = 7; s.a = 8; s.b = 9; @@ -454,7 +454,7 @@ BOOST_AUTO_TEST_CASE(structs2) enum E {A, B, C} struct T { uint x; E e; uint8 y; } struct S { C c; T[] t;} - function f() public returns (uint a, S[2] s1, S[] s2, uint b) { + function f() public returns (uint a, S[2] memory s1, S[] memory s2, uint b) { a = 7; b = 8; s1[0].c = this; diff --git a/test/libsolidity/GasMeter.cpp b/test/libsolidity/GasMeter.cpp index a404c072..84e30033 100644 --- a/test/libsolidity/GasMeter.cpp +++ b/test/libsolidity/GasMeter.cpp @@ -119,7 +119,7 @@ BOOST_AUTO_TEST_CASE(non_overlapping_filtered_costs) char const* sourceCode = R"( contract test { bytes x; - function f(uint a) returns (uint b) { + function f(uint a) public returns (uint b) { x.length = a; for (; a < 200; ++a) { x[a] = 9; @@ -152,7 +152,7 @@ BOOST_AUTO_TEST_CASE(simple_contract) char const* sourceCode = R"( contract test { bytes32 public shaValue; - function f(uint a) { + function f(uint a) public { shaValue = keccak256(abi.encodePacked(a)); } } @@ -165,7 +165,7 @@ BOOST_AUTO_TEST_CASE(store_keccak256) char const* sourceCode = R"( contract test { bytes32 public shaValue; - constructor(uint a) { + constructor(uint a) public { shaValue = keccak256(abi.encodePacked(a)); } } @@ -179,7 +179,7 @@ BOOST_AUTO_TEST_CASE(updating_store) contract test { uint data; uint data2; - constructor() { + constructor() public { data = 1; data = 2; data2 = 0; @@ -195,7 +195,7 @@ BOOST_AUTO_TEST_CASE(branches) contract test { uint data; uint data2; - function f(uint x) { + function f(uint x) public { if (x > 7) data2 = 1; else @@ -213,7 +213,7 @@ BOOST_AUTO_TEST_CASE(function_calls) contract test { uint data; uint data2; - function f(uint x) { + function f(uint x) public { if (x > 7) data2 = g(x**8) + 1; else @@ -234,13 +234,13 @@ BOOST_AUTO_TEST_CASE(multiple_external_functions) contract test { uint data; uint data2; - function f(uint x) { + function f(uint x) public { if (x > 7) data2 = g(x**8) + 1; else data = 1; } - function g(uint x) returns (uint) { + function g(uint x) public returns (uint) { return data2; } } @@ -254,10 +254,10 @@ BOOST_AUTO_TEST_CASE(exponent_size) { char const* sourceCode = R"( contract A { - function g(uint x) returns (uint) { + function g(uint x) public returns (uint) { return x ** 0x100; } - function h(uint x) returns (uint) { + function h(uint x) public returns (uint) { return x ** 0x10000; } } @@ -271,7 +271,7 @@ BOOST_AUTO_TEST_CASE(balance_gas) { char const* sourceCode = R"( contract A { - function lookup_balance(address a) returns (uint) { + function lookup_balance(address a) public returns (uint) { return a.balance; } } @@ -284,7 +284,7 @@ BOOST_AUTO_TEST_CASE(extcodesize_gas) { char const* sourceCode = R"( contract A { - function f() returns (uint _s) { + function f() public returns (uint _s) { assembly { _s := extcodesize(0x30) } @@ -316,7 +316,7 @@ BOOST_AUTO_TEST_CASE(complex_control_flow) // we previously considered. This of course reduces accuracy. char const* sourceCode = R"( contract log { - function ln(int128 x) pure returns (int128 result) { + function ln(int128 x) public pure returns (int128 result) { int128 t = x / 256; int128 y = 5545177; x = t; diff --git a/test/libsolidity/Imports.cpp b/test/libsolidity/Imports.cpp index 4b700ceb..df31ac40 100644 --- a/test/libsolidity/Imports.cpp +++ b/test/libsolidity/Imports.cpp @@ -138,7 +138,7 @@ BOOST_AUTO_TEST_CASE(complex_import) CompilerStack c; c.addSource("a", "contract A {} contract B {} contract C { struct S { uint a; } } pragma solidity >=0.0;"); c.addSource("b", "import \"a\" as x; import {B as b, C as c, C} from \"a\"; " - "contract D is b { function f(c.S var1, x.C.S var2, C.S var3) internal {} } pragma solidity >=0.0;"); + "contract D is b { function f(c.S memory var1, x.C.S memory var2, C.S memory var3) internal {} } pragma solidity >=0.0;"); c.setEVMVersion(dev::test::Options::get().evmVersion()); BOOST_CHECK(c.compile()); } diff --git a/test/libsolidity/Metadata.cpp b/test/libsolidity/Metadata.cpp index 808bd1e1..007ee2b6 100644 --- a/test/libsolidity/Metadata.cpp +++ b/test/libsolidity/Metadata.cpp @@ -41,7 +41,7 @@ BOOST_AUTO_TEST_CASE(metadata_stamp) pragma solidity >=0.0; pragma experimental __testOnlyAnalysis; contract test { - function g(function(uint) external returns (uint) x) {} + function g(function(uint) external returns (uint) x) public {} } )"; CompilerStack compilerStack; @@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(metadata_stamp_experimental) pragma solidity >=0.0; pragma experimental __test; contract test { - function g(function(uint) external returns (uint) x) {} + function g(function(uint) external returns (uint) x) public {} } )"; CompilerStack compilerStack; @@ -97,14 +97,14 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources) char const* sourceCode = R"( pragma solidity >=0.0; contract A { - function g(function(uint) external returns (uint) x) {} + function g(function(uint) external returns (uint) x) public {} } )"; compilerStack.addSource("A", std::string(sourceCode)); sourceCode = R"( pragma solidity >=0.0; contract B { - function g(function(uint) external returns (uint) x) {} + function g(function(uint) external returns (uint) x) public {} } )"; compilerStack.addSource("B", std::string(sourceCode)); @@ -127,7 +127,7 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources_imports) char const* sourceCode = R"( pragma solidity >=0.0; contract A { - function g(function(uint) external returns (uint) x) {} + function g(function(uint) external returns (uint) x) public {} } )"; compilerStack.addSource("A", std::string(sourceCode)); @@ -135,7 +135,7 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources_imports) pragma solidity >=0.0; import "./A"; contract B is A { - function g(function(uint) external returns (uint) x) {} + function g(function(uint) external returns (uint) x) public {} } )"; compilerStack.addSource("B", std::string(sourceCode)); @@ -143,7 +143,7 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources_imports) pragma solidity >=0.0; import "./B"; contract C is B { - function g(function(uint) external returns (uint) x) {} + function g(function(uint) external returns (uint) x) public {} } )"; compilerStack.addSource("C", std::string(sourceCode)); diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp index 57f414db..497ee867 100644 --- a/test/libsolidity/SMTChecker.cpp +++ b/test/libsolidity/SMTChecker.cpp @@ -91,7 +91,7 @@ BOOST_AUTO_TEST_CASE(warn_on_struct) pragma experimental ABIEncoderV2; contract C { struct A { uint a; uint b; } - function f() public pure returns (A) { + function f() public pure returns (A memory) { return A({ a: 1, b: 2 }); } } diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp index 736b0b33..14413ca0 100644 --- a/test/libsolidity/SolidityABIJSON.cpp +++ b/test/libsolidity/SolidityABIJSON.cpp @@ -256,7 +256,7 @@ BOOST_AUTO_TEST_CASE(view_function) char const* sourceCode = R"( contract test { function foo(uint a, uint b) public returns (uint d) { return a + b; } - function boo(uint32 a) view returns(uint b) { return a * 4; } + function boo(uint32 a) public view returns(uint b) { return a * 4; } } )"; @@ -311,7 +311,7 @@ BOOST_AUTO_TEST_CASE(pure_function) char const* sourceCode = R"( contract test { function foo(uint a, uint b) public returns (uint d) { return a + b; } - function boo(uint32 a) pure returns(uint b) { return a * 4; } + function boo(uint32 a) public pure returns (uint b) { return a * 4; } } )"; @@ -616,7 +616,7 @@ BOOST_AUTO_TEST_CASE(constructor_abi) { char const* sourceCode = R"( contract test { - constructor(uint param1, test param2, bool param3) {} + constructor(uint param1, test param2, bool param3) public {} } )"; @@ -648,7 +648,7 @@ BOOST_AUTO_TEST_CASE(payable_constructor_abi) { char const* sourceCode = R"( contract test { - constructor(uint param1, test param2, bool param3) payable {} + constructor(uint param1, test param2, bool param3) public payable {} } )"; @@ -682,7 +682,7 @@ BOOST_AUTO_TEST_CASE(return_param_in_abi) char const* sourceCode = R"( contract test { enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } - constructor(ActionChoices param) {} + constructor(ActionChoices param) public {} function ret() public returns (ActionChoices) { ActionChoices action = ActionChoices.GoLeft; return action; @@ -756,7 +756,7 @@ BOOST_AUTO_TEST_CASE(library_function) char const* sourceCode = R"( library test { struct StructType { uint a; } - function f(StructType storage b, uint[] storage c, test d) public returns (uint[] e, StructType storage f) {} + function f(StructType storage b, uint[] storage c, test d) public returns (uint[] memory e, StructType storage f) {} } )"; @@ -807,8 +807,8 @@ BOOST_AUTO_TEST_CASE(payable_function) { char const* sourceCode = R"( contract test { - function f() {} - function g() payable {} + function f() public {} + function g() public payable {} } )"; @@ -861,7 +861,7 @@ BOOST_AUTO_TEST_CASE(function_type) { char const* sourceCode = R"( contract test { - function g(function(uint) external returns (uint) x) {} + function g(function(uint) external returns (uint) x) public {} } )"; @@ -891,7 +891,7 @@ BOOST_AUTO_TEST_CASE(return_structs) contract C { struct S { uint a; T[] sub; } struct T { uint[2] x; } - function f() public returns (uint x, S s) { + function f() public returns (uint x, S memory s) { } } )"; @@ -940,7 +940,7 @@ BOOST_AUTO_TEST_CASE(return_structs_with_contracts) pragma experimental ABIEncoderV2; contract C { struct S { C[] x; C y; } - function f() public returns (S s, C c) { + function f() public returns (S memory s, C c) { } } )"; @@ -1041,8 +1041,8 @@ BOOST_AUTO_TEST_CASE(structs_in_libraries) library L { struct S { uint a; T[] sub; bytes b; } struct T { uint[2] x; } - function f(L.S storage s) {} - function g(L.S s) {} + function f(L.S storage s) public {} + function g(L.S memory s) public {} } )"; char const* interface = R"( diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index bee83007..0fe21c4a 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -53,9 +53,9 @@ BOOST_AUTO_TEST_CASE(transaction_status) { char const* sourceCode = R"( contract test { - function f() { } - function g() { revert(); } - function h() { assert(false); } + function f() public { } + function g() public { revert(); } + function h() public { assert(false); } } )"; compileAndRun(sourceCode); @@ -1253,7 +1253,7 @@ BOOST_AUTO_TEST_CASE(state_smoke_test) if (which == 0) return value1; else return value2; } - function set(uint8 which, uint256 value) { + function set(uint8 which, uint256 value) public { if (which == 0) value1 = value; else value2 = value; } @@ -1315,7 +1315,7 @@ BOOST_AUTO_TEST_CASE(simple_mapping) function get(uint8 k) public returns (uint8 v) { return table[k]; } - function set(uint8 k, uint8 v) { + function set(uint8 k, uint8 v) public { table[k] = v; } } @@ -1349,7 +1349,7 @@ BOOST_AUTO_TEST_CASE(mapping_state) function getVoteCount(address addr) public returns (uint retVoteCount) { return voteCount[addr]; } - function grantVoteRight(address addr) { + function grantVoteRight(address addr) public { canVote[addr] = true; } function vote(address voter, address vote) public returns (bool success) { @@ -1562,7 +1562,7 @@ BOOST_AUTO_TEST_CASE(deleteStruct) uint nestedValue; mapping (uint => bool) nestedMapping; } - constructor(){ + constructor() public { toDelete = 5; str.topValue = 1; str.topMapping[0] = 1; @@ -2085,7 +2085,7 @@ BOOST_AUTO_TEST_CASE(transfer_ether) addr.transfer(amount); return this.balance; } - function b(address addr, uint amount) { + function b(address addr, uint amount) public { addr.transfer(amount); } } @@ -2095,7 +2095,7 @@ BOOST_AUTO_TEST_CASE(transfer_ether) contract C { function () external payable { - throw; + revert(); } } )"; @@ -2477,7 +2477,7 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls) function getHelper() public returns (address haddress) { return address(h); } - function setHelper(address haddress) { + function setHelper(address haddress) public { h = Helper(haddress); } } @@ -2508,7 +2508,7 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_with_complex_parameters) function getHelper() public returns (address haddress) { return address(h); } - function setHelper(address haddress) { + function setHelper(address haddress) public { h = Helper(haddress); } } @@ -2540,7 +2540,7 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_accessing_this) function getHelper() public returns (address addr) { return address(h); } - function setHelper(address addr) { + function setHelper(address addr) public { h = Helper(addr); } } @@ -2572,7 +2572,7 @@ BOOST_AUTO_TEST_CASE(calls_to_this) function getHelper() public returns (address addr) { return address(h); } - function setHelper(address addr) { + function setHelper(address addr) public { h = Helper(addr); } } @@ -2607,7 +2607,7 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_with_local_vars) function getHelper() public returns (address haddress) { return address(h); } - function setHelper(address haddress) { + function setHelper(address haddress) public { h = Helper(haddress); } } @@ -2638,7 +2638,7 @@ BOOST_AUTO_TEST_CASE(fixed_bytes_in_calls) function getHelper() public returns (address addr) { return address(h); } - function setHelper(address addr) { + function setHelper(address addr) public { h = Helper(addr); } } @@ -2706,7 +2706,7 @@ BOOST_AUTO_TEST_CASE(constructor_with_long_arguments) string public a; string public b; - constructor(string _a, string _b) public { + constructor(string memory _a, string memory _b) public { a = _a; b = _b; } @@ -2734,7 +2734,7 @@ BOOST_AUTO_TEST_CASE(constructor_static_array_argument) uint public a; uint[3] public b; - constructor(uint _a, uint[3] _b) public { + constructor(uint _a, uint[3] memory _b) public { a = _a; b = _b; } @@ -2754,7 +2754,7 @@ BOOST_AUTO_TEST_CASE(constant_var_as_array_length) uint constant LEN = 3; uint[LEN] public a; - constructor(uint[LEN] _a) public { + constructor(uint[LEN] memory _a) public { a = _a; } } @@ -2847,7 +2847,7 @@ BOOST_AUTO_TEST_CASE(value_complex) contract test { helper h; constructor() public payable { h = new helper(); } - function sendAmount(uint amount) payable returns (uint256 bal) { + function sendAmount(uint amount) public payable returns (uint256 bal) { uint someStackElement = 20; return h.getBalance.value(amount).gas(1000).value(amount + 3)(); } @@ -2883,7 +2883,7 @@ BOOST_AUTO_TEST_CASE(value_for_constructor) contract Helper { bytes3 name; bool flag; - constructor(bytes3 x, bool f) payable { + constructor(bytes3 x, bool f) public payable { name = x; flag = f; } @@ -2892,7 +2892,7 @@ BOOST_AUTO_TEST_CASE(value_for_constructor) } contract Main { Helper h; - constructor() payable { + constructor() public payable { h = (new Helper).value(10)("abc", true); } function getFlag() public returns (bool ret) { return h.getFlag(); } @@ -2953,10 +2953,10 @@ BOOST_AUTO_TEST_CASE(single_copy_with_multiple_inheritance) char const* sourceCode = R"( contract Base { uint data; - function setData(uint i) { data = i; } + function setData(uint i) public { data = i; } function getViaBase() public returns (uint i) { return data; } } - contract A is Base { function setViaA(uint i) { setData(i); } } + contract A is Base { function setViaA(uint i) public { setData(i); } } contract B is Base { function getViaB() public returns (uint i) { return getViaBase(); } } contract Derived is Base, B, A { } )"; @@ -3165,7 +3165,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_for_constructor) char const* sourceCode = R"( contract A { uint data; - constructor() mod1 { data |= 2; } + constructor() mod1 public { data |= 2; } modifier mod1 { data |= 1; _; } function getData() public returns (uint r) { return data; } } @@ -3375,7 +3375,7 @@ BOOST_AUTO_TEST_CASE(event) char const* sourceCode = R"( contract ClientReceipt { event Deposit(address indexed _from, bytes32 indexed _id, uint _value); - function deposit(bytes32 _id, bool _manually) payable { + function deposit(bytes32 _id, bool _manually) public payable { if (_manually) { bytes32 s = 0x19dacbf83c5de6658e14cbf7bcae5c15eca2eedecf1c66fbca928e4d351bea0f; log3(bytes32(msg.value), s, bytes32(uint256(msg.sender)), _id); @@ -3406,7 +3406,7 @@ BOOST_AUTO_TEST_CASE(event_emit) char const* sourceCode = R"( contract ClientReceipt { event Deposit(address indexed _from, bytes32 indexed _id, uint _value); - function deposit(bytes32 _id) payable { + function deposit(bytes32 _id) public payable { emit Deposit(msg.sender, _id, msg.value); } } @@ -3584,7 +3584,7 @@ BOOST_AUTO_TEST_CASE(event_anonymous_with_topics) char const* sourceCode = R"( contract ClientReceipt { event Deposit(address indexed _from, bytes32 indexed _id, uint indexed _value, uint indexed _value2, bytes32 data) anonymous; - function deposit(bytes32 _id) payable { + function deposit(bytes32 _id) public payable { emit Deposit(msg.sender, _id, msg.value, 2, "abc"); } } @@ -3608,7 +3608,7 @@ BOOST_AUTO_TEST_CASE(event_lots_of_data) char const* sourceCode = R"( contract ClientReceipt { event Deposit(address _from, bytes32 _id, uint _value, bool _flag); - function deposit(bytes32 _id) payable { + function deposit(bytes32 _id) public payable { emit Deposit(msg.sender, _id, msg.value, true); } } @@ -3910,7 +3910,7 @@ BOOST_AUTO_TEST_CASE(generic_call) char const* sourceCode = R"**( contract receiver { uint public received; - function receive(uint256 x) payable { received = x; } + function receive(uint256 x) public payable { received = x; } } contract sender { constructor() public payable {} @@ -3936,15 +3936,15 @@ BOOST_AUTO_TEST_CASE(generic_delegatecall) uint public received; address public sender; uint public value; - constructor() payable {} - function receive(uint256 x) payable { received = x; sender = msg.sender; value = msg.value; } + constructor() public payable {} + function receive(uint256 x) public payable { received = x; sender = msg.sender; value = msg.value; } } contract Sender { uint public received; address public sender; uint public value; - constructor() payable {} - function doSend(address rec) payable + constructor() public payable {} + function doSend(address rec) public payable { bytes4 signature = bytes4(bytes32(keccak256("receive(uint256)"))); if (rec.delegatecall(abi.encodeWithSelector(signature, 23))) {} @@ -4130,7 +4130,7 @@ BOOST_AUTO_TEST_CASE(copying_bytes_multiassign) char const* sourceCode = R"( contract receiver { uint public received; - function receive(uint x) { received += x + 1; } + function receive(uint x) public { received += x + 1; } function() external { received = 0x80; } } contract sender { @@ -4349,7 +4349,7 @@ BOOST_AUTO_TEST_CASE(using_enums) char const* sourceCode = R"( contract test { enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } - constructor() + constructor() public { choices = ActionChoices.GoStraight; } @@ -4369,7 +4369,7 @@ BOOST_AUTO_TEST_CASE(enum_explicit_overflow) char const* sourceCode = R"( contract test { enum ActionChoices { GoLeft, GoRight, GoStraight } - constructor() + constructor() public { } function getChoiceExp(uint x) public returns (uint d) @@ -4514,7 +4514,7 @@ BOOST_AUTO_TEST_CASE(inline_member_init) { char const* sourceCode = R"( contract test { - constructor(){ + constructor() public { m_b = 6; m_c = 8; } @@ -4536,12 +4536,12 @@ BOOST_AUTO_TEST_CASE(inline_member_init_inheritence) { char const* sourceCode = R"( contract Base { - constructor(){} + constructor() public {} uint m_base = 5; function getBMember() public returns (uint i) { return m_base; } } contract Derived is Base { - constructor(){} + constructor() public {} uint m_derived = 6; function getDMember() public returns (uint i) { return m_derived; } } @@ -4588,8 +4588,8 @@ BOOST_AUTO_TEST_CASE(bytes_in_arguments) char const* sourceCode = R"( contract c { uint result; - function f(uint a, uint b) { result += a + b; } - function g(uint a) { result *= a; } + function f(uint a, uint b) public { result += a + b; } + function g(uint a) public { result *= a; } function test(uint a, bytes data1, bytes data2, uint b) external returns (uint r_a, uint r, uint r_b, uint l) { r_a = a; this.call(data1); @@ -4621,9 +4621,9 @@ BOOST_AUTO_TEST_CASE(fixed_arrays_in_storage) struct Data { uint x; uint y; } Data[2**10] data; uint[2**10 + 3] ids; - function setIDStatic(uint id) { ids[2] = id; } - function setID(uint index, uint id) { ids[index] = id; } - function setData(uint index, uint x, uint y) { data[index].x = x; data[index].y = y; } + function setIDStatic(uint id) public { ids[2] = id; } + function setID(uint index, uint id) public { ids[index] = id; } + function setData(uint index, uint x, uint y) public { data[index].x = x; data[index].y = y; } function getID(uint index) public returns (uint) { return ids[index]; } function getData(uint index) public returns (uint x, uint y) { x = data[index].x; y = data[index].y; } function getLengths() public returns (uint l1, uint l2) { l1 = data.length; l2 = ids.length; } @@ -4648,13 +4648,13 @@ BOOST_AUTO_TEST_CASE(dynamic_arrays_in_storage) struct Data { uint x; uint y; } Data[] data; uint[] ids; - function setIDStatic(uint id) { ids[2] = id; } - function setID(uint index, uint id) { ids[index] = id; } - function setData(uint index, uint x, uint y) { data[index].x = x; data[index].y = y; } + function setIDStatic(uint id) public { ids[2] = id; } + function setID(uint index, uint id) public { ids[index] = id; } + function setData(uint index, uint x, uint y) public { data[index].x = x; data[index].y = y; } function getID(uint index) public returns (uint) { return ids[index]; } function getData(uint index) public returns (uint x, uint y) { x = data[index].x; y = data[index].y; } function getLengths() public returns (uint l1, uint l2) { l1 = data.length; l2 = ids.length; } - function setLengths(uint l1, uint l2) { data.length = l1; ids.length = l2; } + function setLengths(uint l1, uint l2) public { data.length = l1; ids.length = l2; } } )"; compileAndRun(sourceCode); @@ -4811,7 +4811,7 @@ BOOST_AUTO_TEST_CASE(array_copy_storage_storage_dyn_dyn) contract c { uint[] data1; uint[] data2; - function setData1(uint length, uint index, uint value) { + function setData1(uint length, uint index, uint value) public { data1.length = length; if (index < length) data1[index] = value; } function copyStorageStorage() public { data2 = data1; } @@ -5022,22 +5022,22 @@ BOOST_AUTO_TEST_CASE(array_copy_storage_abi) uint16[] y; uint24[] z; uint24[][] w; - function test1() public returns (uint8[]) { + function test1() public returns (uint8[] memory) { for (uint i = 0; i < 101; ++i) x.push(uint8(i)); return x; } - function test2() public returns (uint16[]) { + function test2() public returns (uint16[] memory) { for (uint i = 0; i < 101; ++i) y.push(uint16(i)); return y; } - function test3() public returns (uint24[]) { + function test3() public returns (uint24[] memory) { for (uint i = 0; i < 101; ++i) z.push(uint24(i)); return z; } - function test4() public returns (uint24[][]) { + function test4() public returns (uint24[][] memory) { w.length = 5; for (uint i = 0; i < 5; ++i) for (uint j = 0; j < 101; ++j) @@ -5070,7 +5070,7 @@ BOOST_AUTO_TEST_CASE(array_copy_storage_abi_signed) char const* sourceCode = R"( contract c { int16[] x; - function test() public returns (int16[]) { + function test() public returns (int16[] memory) { x.push(int16(-1)); x.push(int16(-1)); x.push(int16(8)); @@ -5448,7 +5448,7 @@ BOOST_AUTO_TEST_CASE(byte_array_pop_masking_long) char const* sourceCode = R"( contract c { bytes data; - function test() public returns (bytes) { + function test() public returns (bytes memory) { for (uint i = 0; i < 34; i++) data.push(3); data.pop(); @@ -5470,7 +5470,7 @@ BOOST_AUTO_TEST_CASE(byte_array_pop_copy_long) char const* sourceCode = R"( contract c { bytes data; - function test() public returns (bytes) { + function test() public returns (bytes memory) { for (uint i = 0; i < 33; i++) data.push(3); for (uint j = 0; j < 4; j++) @@ -5737,14 +5737,14 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base) { char const* sourceCode = R"( contract Base { - constructor(uint i) + constructor(uint i) public { m_i = i; } uint public m_i; } contract Derived is Base { - constructor(uint i) Base(i) + constructor(uint i) Base(i) public {} } contract Final is Derived(4) { @@ -5782,14 +5782,14 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base_base_with_gap) { char const* sourceCode = R"( contract Base { - constructor(uint i) + constructor(uint i) public { m_i = i; } uint public m_i; } contract Base1 is Base { - constructor(uint k) {} + constructor(uint k) public {} } contract Derived is Base, Base1 { constructor(uint i) Base(i) Base1(7) public {} @@ -6368,7 +6368,7 @@ BOOST_AUTO_TEST_CASE(struct_assign_reference_to_struct) testStruct data1; testStruct data2; testStruct data3; - constructor() + constructor() public { data1.m_value = 2; } @@ -6400,7 +6400,7 @@ BOOST_AUTO_TEST_CASE(struct_delete_member) uint m_value; } testStruct data1; - constructor() + constructor() public { data1.m_value = 2; } @@ -6427,7 +6427,7 @@ BOOST_AUTO_TEST_CASE(struct_delete_struct_in_mapping) } mapping (uint => testStruct) campaigns; - constructor() + constructor() public { campaigns[0].m_value = 2; } @@ -6470,14 +6470,14 @@ BOOST_AUTO_TEST_CASE(evm_exceptions_in_constructor_call_fail) { char const* sourceCode = R"( contract A { - constructor() + constructor() public { this.call("123"); } } contract B { uint public test = 1; - function testIt() + function testIt() public { A a = new A(); ++test; @@ -6496,7 +6496,7 @@ BOOST_AUTO_TEST_CASE(evm_exceptions_in_constructor_out_of_baund) contract A { uint public test = 1; uint[3] arr; - constructor() + constructor() public { uint index = 5; test = arr[index]; @@ -6601,10 +6601,10 @@ BOOST_AUTO_TEST_CASE(return_string) function set(string _s) external { s = _s; } - function get1() public returns (string r) { + function get1() public returns (string memory r) { return s; } - function get2() public returns (string r) { + function get2() public returns (string memory r) { r = s; } } @@ -6629,7 +6629,7 @@ BOOST_AUTO_TEST_CASE(return_multiple_strings_of_various_sizes) s2 = _s2; return x; } - function get() public returns (string r1, string r2) { + function get() public returns (string memory r1, string memory r2) { r1 = s1; r2 = s2; } @@ -6702,12 +6702,12 @@ BOOST_AUTO_TEST_CASE(bytes_in_function_calls) contract Main { string public s1; string public s2; - function set(string _s1, uint x, string _s2) public returns (uint) { + function set(string memory _s1, uint x, string memory _s2) public returns (uint) { s1 = _s1; s2 = _s2; return x; } - function setIndirectFromMemory(string _s1, uint x, string _s2) public returns (uint) { + function setIndirectFromMemory(string memory _s1, uint x, string memory _s2) public returns (uint) { return this.set(_s1, x, _s2); } function setIndirectFromCalldata(string _s1, uint x, string _s2) external returns (uint) { @@ -6747,11 +6747,11 @@ BOOST_AUTO_TEST_CASE(return_bytes_internal) char const* sourceCode = R"( contract Main { bytes s1; - function doSet(bytes _s1) public returns (bytes _r1) { + function doSet(bytes memory _s1) public returns (bytes memory _r1) { s1 = _s1; _r1 = s1; } - function set(bytes _s1) external returns (uint _r, bytes _r1) { + function set(bytes _s1) external returns (uint _r, bytes memory _r1) { _r1 = doSet(_s1); _r = _r1.length; } @@ -6775,15 +6775,15 @@ BOOST_AUTO_TEST_CASE(bytes_index_access_memory) { char const* sourceCode = R"( contract Main { - function f(bytes _s1, uint i1, uint i2, uint i3) public returns (byte c1, byte c2, byte c3) { + function f(bytes memory _s1, uint i1, uint i2, uint i3) public returns (byte c1, byte c2, byte c3) { c1 = _s1[i1]; c2 = intern(_s1, i2); c3 = internIndirect(_s1)[i3]; } - function intern(bytes _s1, uint i) public returns (byte c) { + function intern(bytes memory _s1, uint i) public returns (byte c) { return _s1[i]; } - function internIndirect(bytes _s1) public returns (bytes) { + function internIndirect(bytes memory _s1) public returns (bytes memory) { return _s1; } } @@ -6804,7 +6804,7 @@ BOOST_AUTO_TEST_CASE(bytes_in_constructors_unpacker) contract Test { uint public m_x; bytes public m_s; - constructor(uint x, bytes s) public { + constructor(uint x, bytes memory s) public { m_x = x; m_s = s; } @@ -6825,7 +6825,7 @@ BOOST_AUTO_TEST_CASE(bytes_in_constructors_packer) contract Base { uint public m_x; bytes m_s; - constructor(uint x, bytes s) public { + constructor(uint x, bytes memory s) public { m_x = x; m_s = s; } @@ -6834,13 +6834,13 @@ BOOST_AUTO_TEST_CASE(bytes_in_constructors_packer) } } contract Main is Base { - constructor(bytes s, uint x) Base(x, f(s)) public {} - function f(bytes s) public returns (bytes) { + constructor(bytes memory s, uint x) Base(x, f(s)) public {} + function f(bytes memory s) public returns (bytes memory) { return s; } } contract Creator { - function f(uint x, bytes s) public returns (uint r, byte ch) { + function f(uint x, bytes memory s) public returns (uint r, byte ch) { Main c = new Main(s, x); r = c.m_x(); ch = c.part(x); @@ -6864,7 +6864,7 @@ BOOST_AUTO_TEST_CASE(arrays_in_constructors) contract Base { uint public m_x; address[] m_s; - constructor(uint x, address[] s) public { + constructor(uint x, address[] memory s) public { m_x = x; m_s = s; } @@ -6873,13 +6873,13 @@ BOOST_AUTO_TEST_CASE(arrays_in_constructors) } } contract Main is Base { - constructor(address[] s, uint x) Base(x, f(s)) public {} - function f(address[] s) public returns (address[]) { + constructor(address[] memory s, uint x) Base(x, f(s)) public {} + function f(address[] memory s) public returns (address[] memory) { return s; } } contract Creator { - function f(uint x, address[] s) public returns (uint r, address ch) { + function f(uint x, address[] memory s) public returns (uint r, address ch) { Main c = new Main(s, x); r = c.m_x(); ch = c.part(x); @@ -6903,7 +6903,7 @@ BOOST_AUTO_TEST_CASE(fixed_arrays_in_constructors) contract Creator { uint public r; address public ch; - constructor(address[3] s, uint x) public { + constructor(address[3] memory s, uint x) public { r = x; ch = s[2]; } @@ -6919,11 +6919,11 @@ BOOST_AUTO_TEST_CASE(arrays_from_and_to_storage) char const* sourceCode = R"( contract Test { uint24[] public data; - function set(uint24[] _data) public returns (uint) { + function set(uint24[] memory _data) public returns (uint) { data = _data; return data.length; } - function get() public returns (uint24[]) { + function get() public returns (uint24[] memory) { return data; } } @@ -6946,11 +6946,11 @@ BOOST_AUTO_TEST_CASE(arrays_complex_from_and_to_storage) char const* sourceCode = R"( contract Test { uint24[3][] public data; - function set(uint24[3][] _data) public returns (uint) { + function set(uint24[3][] memory _data) public returns (uint) { data = _data; return data.length; } - function get() public returns (uint24[3][]) { + function get() public returns (uint24[3][] memory) { return data; } } @@ -6972,7 +6972,7 @@ BOOST_AUTO_TEST_CASE(arrays_complex_memory_index_access) { char const* sourceCode = R"( contract Test { - function set(uint24[3][] _data, uint a, uint b) public returns (uint l, uint e) { + function set(uint24[3][] memory _data, uint a, uint b) public returns (uint l, uint e) { l = _data.length; e = _data[a][b]; } @@ -6995,7 +6995,7 @@ BOOST_AUTO_TEST_CASE(bytes_memory_index_access) { char const* sourceCode = R"( contract Test { - function set(bytes _data, uint i) public returns (uint l, byte c) { + function set(bytes memory _data, uint i) public returns (uint l, byte c) { l = _data.length; c = _data[i]; } @@ -7038,7 +7038,7 @@ BOOST_AUTO_TEST_CASE(storage_array_ref) contract Store is BinarySearch { uint[] data; - function add(uint v) { + function add(uint v) public { data.length++; data[data.length - 1] = v; } @@ -7071,13 +7071,13 @@ BOOST_AUTO_TEST_CASE(memory_types_initialisation) char const* sourceCode = R"( contract Test { mapping(uint=>uint) data; - function stat() public returns (uint[5]) + function stat() public returns (uint[5] memory) { data[2] = 3; // make sure to use some memory } - function dyn() public returns (uint[]) { stat(); } - function nested() public returns (uint[3][]) { stat(); } - function nestedStat() public returns (uint[3][7]) { stat(); } + function dyn() public returns (uint[] memory) { stat(); } + function nested() public returns (uint[3][] memory) { stat(); } + function nestedStat() public returns (uint[3][7] memory) { stat(); } } )"; compileAndRun(sourceCode, 0, "Test"); @@ -7092,7 +7092,7 @@ BOOST_AUTO_TEST_CASE(memory_arrays_delete) { char const* sourceCode = R"( contract Test { - function del() public returns (uint24[3][4]) { + function del() public returns (uint24[3][4] memory) { uint24[3][4] memory x; for (uint24 i = 0; i < x.length; i ++) for (uint24 j = 0; j < x[i].length; j ++) @@ -7121,11 +7121,11 @@ BOOST_AUTO_TEST_CASE(memory_arrays_index_access_write) { char const* sourceCode = R"( contract Test { - function set(uint24[3][4] x) { + function set(uint24[3][4] memory x) public { x[2][2] = 1; x[3][2] = 7; } - function f() public returns (uint24[3][4]){ + function f() public returns (uint24[3][4] memory){ uint24[3][4] memory data; set(data); return data; @@ -7145,12 +7145,12 @@ BOOST_AUTO_TEST_CASE(memory_arrays_dynamic_index_access_write) char const* sourceCode = R"( contract Test { uint24[3][][4] data; - function set(uint24[3][][4] x) internal returns (uint24[3][][4]) { + function set(uint24[3][][4] memory x) internal returns (uint24[3][][4] memory) { x[1][2][2] = 1; x[1][3][2] = 7; return x; } - function f() public returns (uint24[3][]) { + function f() public returns (uint24[3][] memory) { data[1].length = 4; return set(data)[1]; } @@ -7220,12 +7220,12 @@ BOOST_AUTO_TEST_CASE(memory_structs_as_function_args) y = extract(data, 1); z = extract(data, 2); } - function extract(S s, uint which) internal returns (uint x) { + function extract(S memory s, uint which) internal returns (uint x) { if (which == 0) return s.x; else if (which == 1) return s.y; else return s.z; } - function combine(uint8 x, uint16 y, uint z) internal returns (S s) { + function combine(uint8 x, uint16 y, uint z) internal returns (S memory s) { s.x = x; s.y = y; s.z = z; @@ -7250,13 +7250,13 @@ BOOST_AUTO_TEST_CASE(memory_structs_nested) y = extract(d, 2); z = extract(d, 3); } - function extract(X s, uint which) internal returns (uint x) { + function extract(X memory s, uint which) internal returns (uint x) { if (which == 0) return s.x; else if (which == 1) return s.s.x; else if (which == 2) return s.s.y; else return s.s.z; } - function combine(uint8 a, uint8 x, uint16 y, uint z) internal returns (X s) { + function combine(uint8 a, uint8 x, uint16 y, uint z) internal returns (X memory s) { s.x = a; s.s.x = x; s.s.y = y; @@ -7328,7 +7328,7 @@ BOOST_AUTO_TEST_CASE(struct_constructor_nested) s2[1] = 9; s = S(1, s2, X(4, 5)); } - function get() public returns (uint s1, uint[3] s2, uint x1, uint x2) + function get() public returns (uint s1, uint[3] memory s2, uint x1, uint x2) { s1 = s.s1; s2 = s.s2; @@ -7367,7 +7367,7 @@ BOOST_AUTO_TEST_CASE(literal_strings) string public medium; string public short; string public empty; - function f() public returns (string) { + function f() public returns (string memory) { long = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; medium = "01234567890123456789012345678901234567890123456789012345678901234567890123456789"; short = "123"; @@ -7434,7 +7434,7 @@ BOOST_AUTO_TEST_CASE(string_bytes_conversion) contract Test { string s; bytes b; - function f(string _s, uint n) public returns (byte) { + function f(string memory _s, uint n) public returns (byte) { b = bytes(_s); s = string(b); return bytes(s)[n]; @@ -7458,8 +7458,8 @@ BOOST_AUTO_TEST_CASE(string_as_mapping_key) char const* sourceCode = R"( contract Test { mapping(string => uint) data; - function set(string _s, uint _v) { data[_s] = _v; } - function get(string _s) public returns (uint) { return data[_s]; } + function set(string memory _s, uint _v) public { data[_s] = _v; } + function get(string memory _s) public returns (uint) { return data[_s]; } } )"; compileAndRun(sourceCode, 0, "Test"); @@ -7636,8 +7636,8 @@ BOOST_AUTO_TEST_CASE(constant_string_literal) bytes32 bb = b; } function getB() public returns (bytes32) { return b; } - function getX() public returns (string) { return x; } - function getX2() public returns (string r) { r = x; } + function getX() public returns (string memory) { return x; } + function getX2() public returns (string memory r) { r = x; } function unused() public returns (uint) { "unusedunusedunusedunusedunusedunusedunusedunusedunusedunusedunusedunused"; return 2; @@ -7691,7 +7691,7 @@ BOOST_AUTO_TEST_CASE(library_function_external) char const* sourceCode = R"( library Lib { function m(bytes b) external pure returns (byte) { return b[2]; } } contract Test { - function f(bytes b) public pure returns (byte) { + function f(bytes memory b) public pure returns (byte) { return Lib.m(b); } } @@ -7741,7 +7741,7 @@ BOOST_AUTO_TEST_CASE(simple_throw) if (x > 10) return x + 10; else - throw; + revert(); return 2; } } @@ -7764,7 +7764,7 @@ BOOST_AUTO_TEST_CASE(strings_in_struct) string last; } - constructor(){ + constructor() public { bug = Buggy(10, 20, 30, "asdfghjkl"); } function getFirst() public returns (uint) @@ -7779,7 +7779,7 @@ BOOST_AUTO_TEST_CASE(strings_in_struct) { return bug.third; } - function getLast() public returns (string) + function getLast() public returns (string memory) { return bug.last; } @@ -7797,7 +7797,7 @@ BOOST_AUTO_TEST_CASE(fixed_arrays_as_return_type) { char const* sourceCode = R"( contract A { - function f(uint16 input) public pure returns (uint16[5] arr) + function f(uint16 input) public pure returns (uint16[5] memory arr) { arr[0] = input; arr[1] = ++input; @@ -7807,7 +7807,7 @@ BOOST_AUTO_TEST_CASE(fixed_arrays_as_return_type) } } contract B { - function f() public returns (uint16[5] res, uint16[5] res2) + function f() public returns (uint16[5] memory res, uint16[5] memory res2) { A a = new A(); res = a.f(2); @@ -7856,7 +7856,7 @@ BOOST_AUTO_TEST_CASE(using_library_structs) char const* sourceCode = R"( library Lib { struct Data { uint a; uint[] b; } - function set(Data storage _s) + function set(Data storage _s) public { _s.a = 7; _s.b.length = 20; @@ -8039,7 +8039,7 @@ BOOST_AUTO_TEST_CASE(calldata_offset) { address[] _arr; string public last = "nd"; - constructor(address[] guardians) + constructor(address[] memory guardians) public { _arr = guardians; } @@ -8190,13 +8190,13 @@ BOOST_AUTO_TEST_CASE(string_tuples) { char const* sourceCode = R"( contract C { - function f() public returns (string, uint) { + function f() public returns (string memory, uint) { return ("abc", 8); } - function g() public returns (string, string) { + function g() public returns (string memory, string memory) { return (h(), "def"); } - function h() public returns (string) { + function h() public returns (string memory) { return ("abc"); } } @@ -8243,13 +8243,13 @@ BOOST_AUTO_TEST_CASE(destructuring_assignment) bytes data; uint[] y; uint[] arrayData; - function returnsArray() public returns (uint[]) { + function returnsArray() public returns (uint[] memory) { arrayData.length = 9; arrayData[2] = 5; arrayData[7] = 4; return arrayData; } - function f(bytes s) public returns (uint) { + function f(bytes memory s) public returns (uint) { uint loc; uint[] memory memArray; (loc, x, y, data, arrayData[3]) = (8, 4, returnsArray(), s, 2); @@ -8396,7 +8396,7 @@ BOOST_AUTO_TEST_CASE(memory_overwrite) { char const* sourceCode = R"( contract C { - function f() public returns (bytes x) { + function f() public returns (bytes memory x) { x = "12345"; x[3] = 0x61; x[0] = 0x62; @@ -8628,7 +8628,7 @@ BOOST_AUTO_TEST_CASE(inline_array_storage_to_memory_conversion_strings) char const* sourceCode = R"( contract C { string s = "doh"; - function f() public returns (string, string) { + function f() public returns (string memory, string memory) { string memory t = "ray"; string[3] memory x = [s, t, "mi"]; return (x[1], x[2]); @@ -8643,7 +8643,7 @@ BOOST_AUTO_TEST_CASE(inline_array_strings_from_document) { char const* sourceCode = R"( contract C { - function f(uint i) public returns (string) { + function f(uint i) public returns (string memory) { string[4] memory x = ["This", "is", "an", "array"]; return (x[i]); } @@ -8690,7 +8690,7 @@ BOOST_AUTO_TEST_CASE(inline_array_index_access_strings) char const* sourceCode = R"( contract C { string public tester; - function f() public returns (string) { + function f() public returns (string memory) { return (["abc", "def", "g"][0]); } function test() public { @@ -8708,7 +8708,7 @@ BOOST_AUTO_TEST_CASE(inline_array_return) char const* sourceCode = R"( contract C { uint8[] tester; - function f() public returns (uint8[5]) { + function f() public returns (uint8[5] memory) { return ([1,2,3,4,5]); } function test() public returns (uint8, uint8, uint8, uint8, uint8) { @@ -8740,7 +8740,7 @@ BOOST_AUTO_TEST_CASE(inline_long_string_return) { char const* sourceCode = R"( contract C { - function f() public returns (string) { + function f() public returns (string memory) { return (["somethingShort", "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"][1]); } } @@ -8817,7 +8817,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_memory_access) { char const* sourceCode = R"( contract C { - function test() public returns (bytes) { + function test() public returns (bytes memory) { bytes memory x = new bytes(5); for (uint i = 0; i < x.length; ++i) x[i] = byte(uint8(i + 1)); @@ -8941,8 +8941,8 @@ BOOST_AUTO_TEST_CASE(inline_assembly_function_access) char const* sourceCode = R"( contract C { uint public x; - function g(uint y) { x = 2 * y; assembly { stop } } - function f(uint _x) { + function g(uint y) public { x = 2 * y; assembly { stop } } + function f(uint _x) public { assembly { _x jump(g) @@ -9176,7 +9176,7 @@ BOOST_AUTO_TEST_CASE(index_access_with_type_conversion) // Test for a bug where higher order bits cleanup was not done for array index access. char const* sourceCode = R"( contract C { - function f(uint x) public returns (uint[256] r){ + function f(uint x) public returns (uint[256] memory r){ r[uint8(x)] = 2; } } @@ -9216,7 +9216,7 @@ BOOST_AUTO_TEST_CASE(internal_library_function) // and retain the same memory context (i.e. are pulled into the caller's code) char const* sourceCode = R"( library L { - function f(uint[] _data) internal { + function f(uint[] memory _data) internal { _data[3] = 2; } } @@ -9241,10 +9241,10 @@ BOOST_AUTO_TEST_CASE(internal_library_function_calling_private) // also has to be pulled into the caller's code) char const* sourceCode = R"( library L { - function g(uint[] _data) private { + function g(uint[] memory _data) private { _data[3] = 2; } - function f(uint[] _data) internal { + function f(uint[] memory _data) internal { g(_data); } } @@ -9267,7 +9267,7 @@ BOOST_AUTO_TEST_CASE(internal_library_function_bound) char const* sourceCode = R"( library L { struct S { uint[] data; } - function f(S _s) internal { + function f(S memory _s) internal { _s.data[3] = 2; } } @@ -9292,7 +9292,7 @@ BOOST_AUTO_TEST_CASE(internal_library_function_return_var_size) char const* sourceCode = R"( library L { struct S { uint[] data; } - function f(S _s) internal returns (uint[]) { + function f(S memory _s) internal returns (uint[] memory) { _s.data[3] = 2; return _s.data; } @@ -9373,7 +9373,7 @@ BOOST_AUTO_TEST_CASE(skip_dynamic_types) // The EVM cannot provide access to dynamically-sized return values, so we have to skip them. char const* sourceCode = R"( contract C { - function f() public returns (uint, uint[], uint) { + function f() public returns (uint, uint[] memory, uint) { return (7, new uint[](2), 8); } function g() public returns (uint, uint) { @@ -9416,7 +9416,7 @@ BOOST_AUTO_TEST_CASE(skip_dynamic_types_for_structs) BOOST_AUTO_TEST_CASE(failed_create) { char const* sourceCode = R"( - contract D { constructor() payable {} } + contract D { constructor() public payable {} } contract C { uint public x; constructor() public payable {} @@ -9512,7 +9512,7 @@ BOOST_AUTO_TEST_CASE(break_in_modifier) break; } } - function f() run { + function f() run public { uint k = x; uint t = k + 1; x = t; @@ -9584,7 +9584,7 @@ BOOST_AUTO_TEST_CASE(stacked_return_with_modifiers) break; } } - function f() run { + function f() run public { uint k = x; uint t = k + 1; x = t; @@ -9603,7 +9603,7 @@ BOOST_AUTO_TEST_CASE(mutex) contract mutexed { bool locked; modifier protected { - if (locked) throw; + if (locked) revert(); locked = true; _; locked = false; @@ -9611,20 +9611,20 @@ BOOST_AUTO_TEST_CASE(mutex) } contract Fund is mutexed { uint shares; - constructor() payable { shares = msg.value; } - function withdraw(uint amount) protected returns (uint) { + constructor() public payable { shares = msg.value; } + function withdraw(uint amount) public protected returns (uint) { // NOTE: It is very bad practice to write this function this way. // Please refer to the documentation of how to do this properly. - if (amount > shares) throw; - if (!msg.sender.call.value(amount)("")) throw; + if (amount > shares) revert(); + if (!msg.sender.call.value(amount)("")) revert(); shares -= amount; return shares; } function withdrawUnprotected(uint amount) public returns (uint) { // NOTE: It is very bad practice to write this function this way. // Please refer to the documentation of how to do this properly. - if (amount > shares) throw; - if (!msg.sender.call.value(amount)("")) throw; + if (amount > shares) revert(); + if (!msg.sender.call.value(amount)("")) revert(); shares -= amount; return shares; } @@ -9633,7 +9633,7 @@ BOOST_AUTO_TEST_CASE(mutex) Fund public fund; uint callDepth; bool protected; - function setProtected(bool _protected) { protected = _protected; } + function setProtected(bool _protected) public { protected = _protected; } constructor(Fund _fund) public { fund = _fund; } function attack() public returns (uint) { callDepth = 0; @@ -9730,7 +9730,7 @@ BOOST_AUTO_TEST_CASE(failing_ecrecover_invalid_input_asm) BOOST_AUTO_TEST_CASE(calling_nonexisting_contract_throws) { char const* sourceCode = R"YY( - contract D { function g(); } + contract D { function g() public; } contract C { D d = D(0x1212); function f() public returns (uint) { @@ -9757,7 +9757,7 @@ BOOST_AUTO_TEST_CASE(payable_constructor) { char const* sourceCode = R"( contract C { - constructor() payable { } + constructor() public payable { } } )"; compileAndRun(sourceCode, 27, "C"); @@ -9792,7 +9792,7 @@ BOOST_AUTO_TEST_CASE(payable_function_calls_library) function f() public returns (uint) { return 7; } } contract C { - function f() payable public returns (uint) { + function f() public payable returns (uint) { return L.f(); } } @@ -9852,7 +9852,7 @@ BOOST_AUTO_TEST_CASE(mem_resize_is_not_paid_at_call) // Tests that this also survives the optimizer. char const* sourceCode = R"( contract C { - function f() public returns (uint[200]) {} + function f() public returns (uint[200] memory) {} } contract D { function f(C c) public returns (uint) { c.f(); return 7; } @@ -10015,7 +10015,7 @@ BOOST_AUTO_TEST_CASE(store_function) contract C { function (function (uint) external returns (uint)) internal returns (uint) ev; function (uint) external returns (uint) x; - function store(function(uint) external returns (uint) y) { + function store(function(uint) external returns (uint) y) public { x = y; } function eval(function(uint) external returns (uint) y) public returns (uint) { @@ -10157,7 +10157,7 @@ BOOST_AUTO_TEST_CASE(function_type_library_internal) } } contract C { - function f(uint[] x) public returns (uint) { + function f(uint[] memory x) public returns (uint) { return Utils.reduce(x, Utils.sum, 0); } } @@ -10386,8 +10386,8 @@ BOOST_AUTO_TEST_CASE(function_array_cross_calls) { char const* sourceCode = R"( contract D { - function f(function() external returns (function() external returns (uint))[] x) - public returns (function() external returns (uint)[3] r) + function f(function() external returns (function() external returns (uint))[] memory x) + public returns (function() external returns (uint)[3] memory r) { r[0] = x[0](); r[1] = x[1](); @@ -11159,7 +11159,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_in_modifiers) a := 2 } if (a != 2) - throw; + revert(); _; } function f() m public returns (bool) { @@ -11344,7 +11344,7 @@ BOOST_AUTO_TEST_CASE(revert_with_cause) } contract C { D d = new D(); - function forward(address target, bytes data) internal returns (bool success, bytes retval) { + function forward(address target, bytes memory data) internal returns (bool success, bytes memory retval) { uint retsize; assembly { success := call(not(0), target, 0, add(data, 0x20), mload(data), 0, 0) @@ -11355,19 +11355,19 @@ BOOST_AUTO_TEST_CASE(revert_with_cause) returndatacopy(add(retval, 0x20), 0, returndatasize()) } } - function f() public returns (bool, bytes) { + function f() public returns (bool, bytes memory) { return forward(address(d), msg.data); } - function g() public returns (bool, bytes) { + function g() public returns (bool, bytes memory) { return forward(address(d), msg.data); } - function h() public returns (bool, bytes) { + function h() public returns (bool, bytes memory) { return forward(address(d), msg.data); } - function i() public returns (bool, bytes) { + function i() public returns (bool, bytes memory) { return forward(address(d), msg.data); } - function j() public returns (bool, bytes) { + function j() public returns (bool, bytes memory) { return forward(address(d), msg.data); } } @@ -11399,7 +11399,7 @@ BOOST_AUTO_TEST_CASE(require_with_message) bool flagCopy = flag; require(flagCopy == false, internalFun()); } - function internalFun() public returns (string) { + function internalFun() public returns (string memory) { flag = true; return "only on second run"; } @@ -11416,7 +11416,7 @@ BOOST_AUTO_TEST_CASE(require_with_message) } contract C { D d = new D(); - function forward(address target, bytes data) internal returns (bool success, bytes retval) { + function forward(address target, bytes memory data) internal returns (bool success, bytes memory retval) { uint retsize; assembly { success := call(not(0), target, 0, add(data, 0x20), mload(data), 0, 0) @@ -11427,19 +11427,19 @@ BOOST_AUTO_TEST_CASE(require_with_message) returndatacopy(add(retval, 0x20), 0, returndatasize()) } } - function f(uint x) public returns (bool, bytes) { + function f(uint x) public returns (bool, bytes memory) { return forward(address(d), msg.data); } - function g() public returns (bool, bytes) { + function g() public returns (bool, bytes memory) { return forward(address(d), msg.data); } - function h() public returns (bool, bytes) { + function h() public returns (bool, bytes memory) { return forward(address(d), msg.data); } - function i() public returns (bool, bytes) { + function i() public returns (bool, bytes memory) { return forward(address(d), msg.data); } - function j() public returns (bool, bytes) { + function j() public returns (bool, bytes memory) { return forward(address(d), msg.data); } } @@ -11469,7 +11469,7 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages) } contract C { D d = new D(); - function forward(address target, bytes data) internal returns (bool success, bytes retval) { + function forward(address target, bytes memory data) internal returns (bool success, bytes memory retval) { uint retsize; assembly { success := call(not(0), target, 0, add(data, 0x20), mload(data), 0, 0) @@ -11480,10 +11480,10 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages) returndatacopy(add(retval, 0x20), 0, returndatasize()) } } - function f() public returns (bool, bytes) { + function f() public returns (bool, bytes memory) { return forward(address(d), msg.data); } - function g() public returns (bool, bytes) { + function g() public returns (bool, bytes memory) { return forward(address(d), msg.data); } } @@ -11508,7 +11508,7 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages_through_transfer) } contract C { D d = new D(); - function forward(address target, bytes data) internal returns (bool success, bytes retval) { + function forward(address target, bytes memory data) internal returns (bool success, bytes memory retval) { uint retsize; assembly { success := call(not(0), target, 0, add(data, 0x20), mload(data), 0, 0) @@ -11519,7 +11519,7 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages_through_transfer) returndatacopy(add(retval, 0x20), 0, returndatasize()) } } - function f() public returns (bool, bytes) { + function f() public returns (bool, bytes memory) { return forward(address(d), msg.data); } } @@ -11545,7 +11545,7 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages_through_create) } contract C { D d = new D(); - function forward(address target, bytes data) internal returns (bool success, bytes retval) { + function forward(address target, bytes memory data) internal returns (bool success, bytes memory retval) { uint retsize; assembly { success := call(not(0), target, 0, add(data, 0x20), mload(data), 0, 0) @@ -11556,7 +11556,7 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages_through_create) returndatacopy(add(retval, 0x20), 0, returndatasize()) } } - function f() public returns (bool, bytes) { + function f() public returns (bool, bytes memory) { return forward(address(d), msg.data); } } @@ -11580,9 +11580,9 @@ BOOST_AUTO_TEST_CASE(negative_stack_height) bool Aboolc; bool exists; } - function nredit(uint startindex) public pure returns(uint[500] CIDs, uint[500] dates, uint[500] RIDs, bool[500] Cboolas, uint[500] amounts){} - function return500InvoicesByDates(uint begindate, uint enddate, uint startindex) public view returns(uint[500] AIDs, bool[500] Aboolas, uint[500] dates, bytes32[3][500] Abytesas, bytes32[3][500] bytesbs, bytes32[2][500] bytescs, uint[500] amounts, bool[500] Aboolbs, bool[500] Aboolcs){} - function return500PaymentsByDates(uint begindate, uint enddate, uint startindex) public view returns(uint[500] BIDs, uint[500] dates, uint[500] RIDs, bool[500] Bboolas, bytes32[3][500] bytesbs,bytes32[2][500] bytescs, uint[500] amounts, bool[500] Bboolbs){} + function nredit(uint startindex) public pure returns(uint[500] memory CIDs, uint[500] memory dates, uint[500] memory RIDs, bool[500] memory Cboolas, uint[500] memory amounts){} + function return500InvoicesByDates(uint begindate, uint enddate, uint startindex) public view returns(uint[500] memory AIDs, bool[500] memory Aboolas, uint[500] memory dates, bytes32[3][500] memory Abytesas, bytes32[3][500] memory bytesbs, bytes32[2][500] memory bytescs, uint[500] memory amounts, bool[500] memory Aboolbs, bool[500] memory Aboolcs){} + function return500PaymentsByDates(uint begindate, uint enddate, uint startindex) public view returns(uint[500] memory BIDs, uint[500] memory dates, uint[500] memory RIDs, bool[500] memory Bboolas, bytes32[3][500] memory bytesbs,bytes32[2][500] memory bytescs, uint[500] memory amounts, bool[500] memory Bboolbs){} } )"; compileAndRun(sourceCode, 0, "C"); @@ -11594,7 +11594,7 @@ BOOST_AUTO_TEST_CASE(literal_empty_string) contract C { bytes32 public x; uint public a; - function f(bytes32 _x, uint _a) { + function f(bytes32 _x, uint _a) public { x = _x; a = _a; } @@ -11649,7 +11649,7 @@ BOOST_AUTO_TEST_CASE(interface_contract) char const* sourceCode = R"( interface I { event A(); - function f() public returns (bool); + function f() external returns (bool); function() external payable; } @@ -11837,13 +11837,13 @@ BOOST_AUTO_TEST_CASE(constant_string) bytes constant a = "\x03\x01\x02"; bytes constant b = hex"030102"; string constant c = "hello"; - function f() public returns (bytes) { + function f() public returns (bytes memory) { return a; } - function g() public returns (bytes) { + function g() public returns (bytes memory) { return b; } - function h() public returns (bytes) { + function h() public returns (bytes memory) { return bytes(c); } } @@ -11894,12 +11894,12 @@ BOOST_AUTO_TEST_CASE(snark) } /// @return the generator of G1 - function P1() internal returns (G1Point) { + function P1() internal returns (G1Point memory) { return G1Point(1, 2); } /// @return the generator of G2 - function P2() internal returns (G2Point) { + function P2() internal returns (G2Point memory) { return G2Point( [11559732032986387107991004021392285783925812861821192530917403151452391805634, 10857046999023057135944570762232829481370756359578518086990519993285655852781], @@ -11909,7 +11909,7 @@ BOOST_AUTO_TEST_CASE(snark) } /// @return the negation of p, i.e. p.add(p.negate()) should be zero. - function negate(G1Point p) internal returns (G1Point) { + function negate(G1Point memory p) internal returns (G1Point memory) { // The prime q in the base field F_q for G1 uint q = 21888242871839275222246405745257275088696311157297823662689037894645226208583; if (p.X == 0 && p.Y == 0) @@ -11918,7 +11918,7 @@ BOOST_AUTO_TEST_CASE(snark) } /// @return the sum of two points of G1 - function add(G1Point p1, G1Point p2) internal returns (G1Point r) { + function add(G1Point memory p1, G1Point memory p2) internal returns (G1Point memory r) { uint[4] memory input; input[0] = p1.X; input[1] = p1.Y; @@ -11935,7 +11935,7 @@ BOOST_AUTO_TEST_CASE(snark) /// @return the product of a point on G1 and a scalar, i.e. /// p == p.mul(1) and p.add(p) == p.mul(2) for all points p. - function mul(G1Point p, uint s) internal returns (G1Point r) { + function mul(G1Point memory p, uint s) internal returns (G1Point memory r) { uint[3] memory input; input[0] = p.X; input[1] = p.Y; @@ -11953,7 +11953,7 @@ BOOST_AUTO_TEST_CASE(snark) /// e(p1[0], p2[0]) * .... * e(p1[n], p2[n]) == 1 /// For example pairing([P1(), P1().negate()], [P2(), P2()]) should /// return true. - function pairing(G1Point[] p1, G2Point[] p2) internal returns (bool) { + function pairing(G1Point[] memory p1, G2Point[] memory p2) internal returns (bool) { require(p1.length == p2.length); uint elements = p1.length; uint inputSize = p1.length * 6; @@ -11977,7 +11977,7 @@ BOOST_AUTO_TEST_CASE(snark) require(success); return out[0] != 0; } - function pairingProd2(G1Point a1, G2Point a2, G1Point b1, G2Point b2) internal returns (bool) { + function pairingProd2(G1Point memory a1, G2Point memory a2, G1Point memory b1, G2Point memory b2) internal returns (bool) { G1Point[] memory p1 = new G1Point[](2); G2Point[] memory p2 = new G2Point[](2); p1[0] = a1; @@ -11987,9 +11987,9 @@ BOOST_AUTO_TEST_CASE(snark) return pairing(p1, p2); } function pairingProd3( - G1Point a1, G2Point a2, - G1Point b1, G2Point b2, - G1Point c1, G2Point c2 + G1Point memory a1, G2Point memory a2, + G1Point memory b1, G2Point memory b2, + G1Point memory c1, G2Point memory c2 ) internal returns (bool) { G1Point[] memory p1 = new G1Point[](3); G2Point[] memory p2 = new G2Point[](3); @@ -12002,10 +12002,10 @@ BOOST_AUTO_TEST_CASE(snark) return pairing(p1, p2); } function pairingProd4( - G1Point a1, G2Point a2, - G1Point b1, G2Point b2, - G1Point c1, G2Point c2, - G1Point d1, G2Point d2 + G1Point memory a1, G2Point memory a2, + G1Point memory b1, G2Point memory b2, + G1Point memory c1, G2Point memory c2, + G1Point memory d1, G2Point memory d2 ) internal returns (bool) { G1Point[] memory p1 = new G1Point[](4); G2Point[] memory p2 = new G2Point[](4); @@ -12094,7 +12094,7 @@ BOOST_AUTO_TEST_CASE(snark) return false; return true; } - function verifyingKey() internal returns (VerifyingKey vk) { + function verifyingKey() internal returns (VerifyingKey memory vk) { vk.A = Pairing.G2Point([0x209dd15ebff5d46c4bd888e51a93cf99a7329636c63514396b4a452003a35bf7, 0x04bf11ca01483bfa8b34b43561848d28905960114c8ac04049af4b6315a41678], [0x2bb8324af6cfc93537a2ad1a445cfd0ca2a71acd7ac41fadbf933c2a51be344d, 0x120a2a4cf30c1bf9845f20c6fe39e07ea2cce61f0c9bb048165fe5e4de877550]); vk.B = Pairing.G1Point(0x2eca0c7238bf16e83e7a1e6c5d49540685ff51380f309842a98561558019fc02, 0x03d3260361bb8451de5ff5ecd17f010ff22f5c31cdf184e9020b06fa5997db84); vk.C = Pairing.G2Point([0x2e89718ad33c8bed92e210e81d1853435399a271913a6520736a4729cf0d51eb, 0x01a9e2ffa2e92599b68e44de5bcf354fa2642bd4f26b259daa6f7ce3ed57aeb3], [0x14a9a87b789a58af499b314e13c3d65bede56c07ea2d418d6874857b70763713, 0x178fb49a2d6cd347dc58973ff49613a20757d0fcc22079f9abd10c3baee24590]); @@ -12114,7 +12114,7 @@ BOOST_AUTO_TEST_CASE(snark) vk.IC[8] = Pairing.G1Point(0x0a6de0e2240aa253f46ce0da883b61976e3588146e01c9d8976548c145fe6e4a, 0x04fbaa3a4aed4bb77f30ebb07a3ec1c7d77a7f2edd75636babfeff97b1ea686e); vk.IC[9] = Pairing.G1Point(0x111e2e2a5f8828f80ddad08f9f74db56dac1cc16c1cb278036f79a84cf7a116f, 0x1d7d62e192b219b9808faa906c5ced871788f6339e8d91b83ac1343e20a16b30); } - function verify(uint[] input, Proof proof) internal returns (uint) { + function verify(uint[] memory input, Proof memory proof) internal returns (uint) { VerifyingKey memory vk = verifyingKey(); require(input.length + 1 == vk.IC.length); // Compute the linear combination vk_x @@ -12184,17 +12184,17 @@ BOOST_AUTO_TEST_CASE(abi_encode) { char const* sourceCode = R"( contract C { - function f0() public returns (bytes) { + function f0() public returns (bytes memory) { return abi.encode(); } - function f1() public returns (bytes) { + function f1() public returns (bytes memory) { return abi.encode(1, 2); } - function f2() public returns (bytes) { + function f2() public returns (bytes memory) { string memory x = "abc"; return abi.encode(1, x, 2); } - function f3() public returns (bytes r) { + function f3() public returns (bytes memory r) { // test that memory is properly allocated string memory x = "abc"; r = abi.encode(1, x, 2); @@ -12203,7 +12203,7 @@ BOOST_AUTO_TEST_CASE(abi_encode) y[0] = "e"; require(y[0] == "e"); } - function f4() public returns (bytes) { + function f4() public returns (bytes memory) { bytes4 x = "abcd"; return abi.encode(bytes2(x)); } @@ -12223,17 +12223,17 @@ BOOST_AUTO_TEST_CASE(abi_encode_v2) pragma experimental ABIEncoderV2; contract C { struct S { uint a; uint[] b; } - function f0() public pure returns (bytes) { + function f0() public pure returns (bytes memory) { return abi.encode(); } - function f1() public pure returns (bytes) { + function f1() public pure returns (bytes memory) { return abi.encode(1, 2); } - function f2() public pure returns (bytes) { + function f2() public pure returns (bytes memory) { string memory x = "abc"; return abi.encode(1, x, 2); } - function f3() public pure returns (bytes r) { + function f3() public pure returns (bytes memory r) { // test that memory is properly allocated string memory x = "abc"; r = abi.encode(1, x, 2); @@ -12243,7 +12243,7 @@ BOOST_AUTO_TEST_CASE(abi_encode_v2) require(y[0] == "e"); } S s; - function f4() public returns (bytes r) { + function f4() public returns (bytes memory r) { string memory x = "abc"; s.a = 7; s.b.push(2); @@ -12269,17 +12269,17 @@ BOOST_AUTO_TEST_CASE(abi_encodePacked) { char const* sourceCode = R"( contract C { - function f0() public pure returns (bytes) { + function f0() public pure returns (bytes memory) { return abi.encodePacked(); } - function f1() public pure returns (bytes) { + function f1() public pure returns (bytes memory) { return abi.encodePacked(uint8(1), uint8(2)); } - function f2() public pure returns (bytes) { + function f2() public pure returns (bytes memory) { string memory x = "abc"; return abi.encodePacked(uint8(1), x, uint8(2)); } - function f3() public pure returns (bytes r) { + function f3() public pure returns (bytes memory r) { // test that memory is properly allocated string memory x = "abc"; r = abi.encodePacked(uint8(1), x, uint8(2)); @@ -12301,17 +12301,17 @@ BOOST_AUTO_TEST_CASE(abi_encode_with_selector) { char const* sourceCode = R"( contract C { - function f0() public pure returns (bytes) { + function f0() public pure returns (bytes memory) { return abi.encodeWithSelector(0x12345678); } - function f1() public pure returns (bytes) { + function f1() public pure returns (bytes memory) { return abi.encodeWithSelector(0x12345678, "abc"); } - function f2() public pure returns (bytes) { + function f2() public pure returns (bytes memory) { bytes4 x = 0x12345678; return abi.encodeWithSelector(x, "abc"); } - function f3() public pure returns (bytes) { + function f3() public pure returns (bytes memory) { bytes4 x = 0x12345678; return abi.encodeWithSelector(x, uint(-1)); } @@ -12333,22 +12333,22 @@ BOOST_AUTO_TEST_CASE(abi_encode_with_selectorv2) char const* sourceCode = R"( pragma experimental ABIEncoderV2; contract C { - function f0() public pure returns (bytes) { + function f0() public pure returns (bytes memory) { return abi.encodeWithSelector(0x12345678); } - function f1() public pure returns (bytes) { + function f1() public pure returns (bytes memory) { return abi.encodeWithSelector(0x12345678, "abc"); } - function f2() public pure returns (bytes) { + function f2() public pure returns (bytes memory) { bytes4 x = 0x12345678; return abi.encodeWithSelector(x, "abc"); } - function f3() public pure returns (bytes) { + function f3() public pure returns (bytes memory) { bytes4 x = 0x12345678; return abi.encodeWithSelector(x, uint(-1)); } struct S { uint a; string b; uint16 c; } - function f4() public pure returns (bytes) { + function f4() public pure returns (bytes memory) { bytes4 x = 0x12345678; S memory s; s.a = 0x1234567; @@ -12379,19 +12379,19 @@ BOOST_AUTO_TEST_CASE(abi_encode_with_signature) { char const* sourceCode = R"T( contract C { - function f0() public pure returns (bytes) { + function f0() public pure returns (bytes memory) { return abi.encodeWithSignature("f(uint256)"); } - function f1() public pure returns (bytes) { + function f1() public pure returns (bytes memory) { string memory x = "f(uint256)"; return abi.encodeWithSignature(x, "abc"); } string xstor; - function f1s() public returns (bytes) { + function f1s() public returns (bytes memory) { xstor = "f(uint256)"; return abi.encodeWithSignature(xstor, "abc"); } - function f2() public pure returns (bytes r, uint[] ar) { + function f2() public pure returns (bytes memory r, uint[] memory ar) { string memory x = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."; uint[] memory y = new uint[](4); y[0] = uint(-1); @@ -12423,19 +12423,19 @@ BOOST_AUTO_TEST_CASE(abi_encode_with_signaturev2) char const* sourceCode = R"T( pragma experimental ABIEncoderV2; contract C { - function f0() public pure returns (bytes) { + function f0() public pure returns (bytes memory) { return abi.encodeWithSignature("f(uint256)"); } - function f1() public pure returns (bytes) { + function f1() public pure returns (bytes memory) { string memory x = "f(uint256)"; return abi.encodeWithSignature(x, "abc"); } string xstor; - function f1s() public returns (bytes) { + function f1s() public returns (bytes memory) { xstor = "f(uint256)"; return abi.encodeWithSignature(xstor, "abc"); } - function f2() public pure returns (bytes r, uint[] ar) { + function f2() public pure returns (bytes memory r, uint[] memory ar) { string memory x = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."; uint[] memory y = new uint[](4); y[0] = uint(-1); @@ -12448,7 +12448,7 @@ BOOST_AUTO_TEST_CASE(abi_encode_with_signaturev2) ar = new uint[](2); } struct S { uint a; string b; uint16 c; } - function f4() public pure returns (bytes) { + function f4() public pure returns (bytes memory) { bytes4 x = 0x12345678; S memory s; s.a = 0x1234567; @@ -12482,7 +12482,7 @@ BOOST_AUTO_TEST_CASE(abi_encode_call) char const* sourceCode = R"T( contract C { bool x; - function c(uint a, uint[] b) public { + function c(uint a, uint[] memory b) public { require(a == 5); require(b.length == 2); require(b[0] == 6); @@ -12730,7 +12730,7 @@ BOOST_AUTO_TEST_CASE(senders_balance) } contract D { C c = new C(); - constructor() payable { } + constructor() public payable { } function f() public view returns (uint) { return c.f(); } diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 6ae9d8f9..d025e65a 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -350,7 +350,7 @@ BOOST_AUTO_TEST_CASE(dynamic_return_types_not_possible) { char const* sourceCode = R"( contract C { - function f(uint) public returns (string); + function f(uint) public returns (string memory); function g() public { string memory x = this.f(2); // we can assign to x but it is not usable. diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp index 764550eb..3e2dce26 100644 --- a/test/libsolidity/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -370,7 +370,7 @@ BOOST_AUTO_TEST_CASE(sequence_number_for_calls) // to storage), so the sequence number should be incremented. char const* sourceCode = R"( contract test { - function f(string a, string b) public returns (bool) { return sha256(bytes(a)) == sha256(bytes(b)); } + function f(string memory a, string memory b) public returns (bool) { return sha256(bytes(a)) == sha256(bytes(b)); } } )"; compileBothVersions(sourceCode); @@ -394,12 +394,12 @@ BOOST_AUTO_TEST_CASE(computing_constants) g(); return 1; } - function g() { + function g() public { m_b = 0x817416927846239487123469187231298734162934871263941234127518276; m_c = 0x817416927846239487123469187231298734162934871263941234127518276; h(); } - function h() { + function h() public { m_d = 0xff05694900000000000000000000000000000000000000000000000000000000; } function get() public returns (uint ra, uint rb, uint rc, uint rd) { @@ -600,7 +600,7 @@ BOOST_AUTO_TEST_CASE(init_empty_dynamic_arrays) // not use any memory. char const* sourceCode = R"( contract Test { - function f() pure returns (uint r) { + function f() public pure returns (uint r) { uint[][] memory x = new uint[][](20000); return x.length; } @@ -619,7 +619,7 @@ BOOST_AUTO_TEST_CASE(optimise_multi_stores) struct S { uint16 a; uint16 b; uint16[3] c; uint[] dyn; } uint padding; S[] s; - function f() public returns (uint16, uint16, uint16[3], uint) { + function f() public returns (uint16, uint16, uint16[3] memory, uint) { uint16[3] memory c; c[0] = 7; c[1] = 8; diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp index bfb0d739..16921a24 100644 --- a/test/libsolidity/StandardCompiler.cpp +++ b/test/libsolidity/StandardCompiler.cpp @@ -466,7 +466,7 @@ BOOST_AUTO_TEST_CASE(output_selection_dependent_contract) }, "sources": { "fileA": { - "content": "contract B { } contract A { function f() { new B(); } }" + "content": "contract B { } contract A { function f() public { new B(); } }" } } } @@ -495,7 +495,7 @@ BOOST_AUTO_TEST_CASE(output_selection_dependent_contract_with_import) }, "sources": { "fileA": { - "content": "import \"fileB\"; contract A { function f() { new B(); } }" + "content": "import \"fileB\"; contract A { function f() public { new B(); } }" }, "fileB": { "content": "contract B { }" @@ -712,7 +712,7 @@ BOOST_AUTO_TEST_CASE(library_linking) "content": "library L { function g() public returns (uint) { return 1; } }" }, "library2.sol": { - "content": "library L2 { function g() { } }" + "content": "library L2 { function g() public { } }" } } } diff --git a/test/libsolidity/syntaxTests/array/no_array_pop.sol b/test/libsolidity/syntaxTests/array/no_array_pop.sol index 44e54ad2..79a68ef1 100644 --- a/test/libsolidity/syntaxTests/array/no_array_pop.sol +++ b/test/libsolidity/syntaxTests/array/no_array_pop.sol @@ -5,4 +5,4 @@ contract C { } } // ---- -// TypeError: (63-71): Member "pop" not found or not visible after argument-dependent lookup in uint256 +// TypeError: (63-71): Member "pop" not found or not visible after argument-dependent lookup in uint256. diff --git a/test/libsolidity/syntaxTests/array/static_storage_array_pop.sol b/test/libsolidity/syntaxTests/array/static_storage_array_pop.sol index 0af171ad..8414f43d 100644 --- a/test/libsolidity/syntaxTests/array/static_storage_array_pop.sol +++ b/test/libsolidity/syntaxTests/array/static_storage_array_pop.sol @@ -5,4 +5,4 @@ contract C { } } // ---- -// TypeError: (66-74): Member "pop" not found or not visible after argument-dependent lookup in uint256[3] storage ref +// TypeError: (66-74): Member "pop" not found or not visible after argument-dependent lookup in uint256[3] storage ref. diff --git a/test/libsolidity/syntaxTests/array/string_pop.sol b/test/libsolidity/syntaxTests/array/string_pop.sol index 2a46d0c3..700fda16 100644 --- a/test/libsolidity/syntaxTests/array/string_pop.sol +++ b/test/libsolidity/syntaxTests/array/string_pop.sol @@ -5,4 +5,4 @@ contract C { } } // ---- -// TypeError: (65-73): Member "pop" not found or not visible after argument-dependent lookup in string storage ref +// TypeError: (65-73): Member "pop" not found or not visible after argument-dependent lookup in string storage ref. diff --git a/test/libsolidity/syntaxTests/array/uninitialized_storage_var.sol b/test/libsolidity/syntaxTests/array/uninitialized_storage_var.sol index 363d8147..f3be9071 100644 --- a/test/libsolidity/syntaxTests/array/uninitialized_storage_var.sol +++ b/test/libsolidity/syntaxTests/array/uninitialized_storage_var.sol @@ -1,9 +1,9 @@ contract C { - function f() { + function f() public { uint[] storage x; uint[10] storage y; } } // ---- -// DeclarationError: (31-47): Uninitialized storage pointer. -// DeclarationError: (51-69): Uninitialized storage pointer. +// DeclarationError: (38-54): Uninitialized storage pointer. +// DeclarationError: (58-76): Uninitialized storage pointer. diff --git a/test/libsolidity/syntaxTests/constructor/interface_constructor_new.sol b/test/libsolidity/syntaxTests/constructor/interface_constructor_new.sol index 2cab1851..87585a62 100644 --- a/test/libsolidity/syntaxTests/constructor/interface_constructor_new.sol +++ b/test/libsolidity/syntaxTests/constructor/interface_constructor_new.sol @@ -2,6 +2,6 @@ interface I { constructor() public; } // ---- -// Warning: (15-36): Functions in interfaces should be declared external. +// TypeError: (15-36): Functions in interfaces must be declared external. // TypeError: (15-36): Constructor cannot be defined in interfaces. // TypeError: (15-36): Constructor must be implemented if declared. diff --git a/test/libsolidity/syntaxTests/constructor/interface_constructor_old.sol b/test/libsolidity/syntaxTests/constructor/interface_constructor_old.sol index 313d4345..2c029f4d 100644 --- a/test/libsolidity/syntaxTests/constructor/interface_constructor_old.sol +++ b/test/libsolidity/syntaxTests/constructor/interface_constructor_old.sol @@ -3,6 +3,6 @@ interface I { } // ---- // Warning: (15-35): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. -// Warning: (15-35): Functions in interfaces should be declared external. +// TypeError: (15-35): Functions in interfaces must be declared external. // TypeError: (15-35): Constructor cannot be defined in interfaces. // TypeError: (15-35): Constructor must be implemented if declared. diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/throw_fine.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/throw_fine.sol deleted file mode 100644 index 4cecc27c..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/throw_fine.sol +++ /dev/null @@ -1,9 +0,0 @@ -contract C { - struct S { bool f; } - S s; - function f() internal pure returns (S storage) { - throw; - } -} -// ---- -// Warning: (108-113): "throw" is deprecated in favour of "revert()", "require()" and "assert()". diff --git a/test/libsolidity/syntaxTests/memberLookup/failed_function_lookup_in_library.sol b/test/libsolidity/syntaxTests/memberLookup/failed_function_lookup_in_library.sol index df0cba3f..d8f2eadd 100644 --- a/test/libsolidity/syntaxTests/memberLookup/failed_function_lookup_in_library.sol +++ b/test/libsolidity/syntaxTests/memberLookup/failed_function_lookup_in_library.sol @@ -6,4 +6,4 @@ contract C { function g() public { L.f(1, 2, 3); } } // ---- -// TypeError: (115-118): Member "f" not found or not visible after argument-dependent lookup in type(library L) +// TypeError: (115-118): Member "f" not found or not visible after argument-dependent lookup in type(library L). diff --git a/test/libsolidity/syntaxTests/missing_state_variable.sol b/test/libsolidity/syntaxTests/missing_state_variable.sol index 02082a45..8b97220c 100644 --- a/test/libsolidity/syntaxTests/missing_state_variable.sol +++ b/test/libsolidity/syntaxTests/missing_state_variable.sol @@ -4,4 +4,4 @@ contract Scope { } } // ---- -// TypeError: (101-115): Member "stateVar" not found or not visible after argument-dependent lookup in type(contract Scope) +// TypeError: (101-115): Member "stateVar" not found or not visible after argument-dependent lookup in type(contract Scope). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/065_super_excludes_current_contract.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/065_super_excludes_current_contract.sol index 6fa92a6a..544df1a5 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/065_super_excludes_current_contract.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/065_super_excludes_current_contract.sol @@ -8,4 +8,4 @@ contract B is A { } } // ---- -// TypeError: (95-102): Member "f" not found or not visible after argument-dependent lookup in contract super B +// TypeError: (95-102): Member "f" not found or not visible after argument-dependent lookup in contract super B. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/072_state_variable_member_of_wrong_class1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/072_state_variable_member_of_wrong_class1.sol index 949761b6..dd73ac47 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/072_state_variable_member_of_wrong_class1.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/072_state_variable_member_of_wrong_class1.sol @@ -8,4 +8,4 @@ contract Child is Parent2 { function foo() public returns (uint256) { return Parent2.m_aMember1; } } // ---- -// TypeError: (200-218): Member "m_aMember1" not found or not visible after argument-dependent lookup in type(contract Parent2) +// TypeError: (200-218): Member "m_aMember1" not found or not visible after argument-dependent lookup in type(contract Parent2). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/073_state_variable_member_of_wrong_class2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/073_state_variable_member_of_wrong_class2.sol index 9a0ee8a3..f2de6e72 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/073_state_variable_member_of_wrong_class2.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/073_state_variable_member_of_wrong_class2.sol @@ -9,4 +9,4 @@ contract Child is Parent2 { uint256 public m_aMember3; } // ---- -// TypeError: (200-216): Member "m_aMember2" not found or not visible after argument-dependent lookup in type(contract Child) +// TypeError: (200-216): Member "m_aMember2" not found or not visible after argument-dependent lookup in type(contract Child). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/097_access_to_internal_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/097_access_to_internal_function.sol index e13e1531..60d7b758 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/097_access_to_internal_function.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/097_access_to_internal_function.sol @@ -5,4 +5,4 @@ contract d { function g() public { c(0).f(); } } // ---- -// TypeError: (83-89): Member "f" not found or not visible after argument-dependent lookup in contract c +// TypeError: (83-89): Member "f" not found or not visible after argument-dependent lookup in contract c. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/098_access_to_default_state_variable_visibility.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/098_access_to_default_state_variable_visibility.sol index ab7546c6..8c9d0c0f 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/098_access_to_default_state_variable_visibility.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/098_access_to_default_state_variable_visibility.sol @@ -5,4 +5,4 @@ contract d { function g() public { c(0).a(); } } // ---- -// TypeError: (66-72): Member "a" not found or not visible after argument-dependent lookup in contract c +// TypeError: (66-72): Member "a" not found or not visible after argument-dependent lookup in contract c. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/126_enum_invalid_member_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/126_enum_invalid_member_access.sol index 079bf0c8..e58ed160 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/126_enum_invalid_member_access.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/126_enum_invalid_member_access.sol @@ -6,4 +6,4 @@ contract test { ActionChoices choices; } // ---- -// TypeError: (121-159): Member "RunAroundWavingYourHands" not found or not visible after argument-dependent lookup in type(enum test.ActionChoices) +// TypeError: (121-159): Member "RunAroundWavingYourHands" not found or not visible after argument-dependent lookup in type(enum test.ActionChoices). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/136_private_visibility_via_explicit_base_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/136_private_visibility_via_explicit_base_access.sol index fc89c033..2f94ef92 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/136_private_visibility_via_explicit_base_access.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/136_private_visibility_via_explicit_base_access.sol @@ -5,4 +5,4 @@ contract derived is base { function g() public { base.f(); } } // ---- -// TypeError: (99-105): Member "f" not found or not visible after argument-dependent lookup in type(contract base) +// TypeError: (99-105): Member "f" not found or not visible after argument-dependent lookup in type(contract base). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/145_external_base_visibility.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/145_external_base_visibility.sol index 2d1baa20..cf680462 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/145_external_base_visibility.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/145_external_base_visibility.sol @@ -5,4 +5,4 @@ contract derived is base { function g() public { base.f(); } } // ---- -// TypeError: (100-106): Member "f" not found or not visible after argument-dependent lookup in type(contract base) +// TypeError: (100-106): Member "f" not found or not visible after argument-dependent lookup in type(contract base). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/189_string_length.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/189_string_length.sol index 9e714d68..845b9156 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/189_string_length.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/189_string_length.sol @@ -3,4 +3,4 @@ contract C { function f() public { uint a = s.length; } } // ---- -// TypeError: (62-70): Member "length" not found or not visible after argument-dependent lookup in string storage ref +// TypeError: (62-70): Member "length" not found or not visible after argument-dependent lookup in string storage ref. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/258_using_for_mismatch.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/258_using_for_mismatch.sol index 84e42072..c60ee651 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/258_using_for_mismatch.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/258_using_for_mismatch.sol @@ -6,4 +6,4 @@ contract C { } } // ---- -// TypeError: (177-185): Member "double" not found or not visible after argument-dependent lookup in uint256 +// TypeError: (177-185): Member "double" not found or not visible after argument-dependent lookup in uint256. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/259_using_for_not_used.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/259_using_for_not_used.sol index fae918b7..b11cefba 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/259_using_for_not_used.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/259_using_for_not_used.sol @@ -8,4 +8,4 @@ contract C { } } // ---- -// TypeError: (305-313): Member "double" not found or not visible after argument-dependent lookup in uint16 +// TypeError: (305-313): Member "double" not found or not visible after argument-dependent lookup in uint16. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/261_using_for_arbitrary_mismatch.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/261_using_for_arbitrary_mismatch.sol index ced4705f..b2b55350 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/261_using_for_arbitrary_mismatch.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/261_using_for_arbitrary_mismatch.sol @@ -7,4 +7,4 @@ contract C { } } // ---- -// TypeError: (227-235): Member "double" not found or not visible after argument-dependent lookup in uint256 +// TypeError: (227-235): Member "double" not found or not visible after argument-dependent lookup in uint256. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/301_library_instances_cannot_be_used.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/301_library_instances_cannot_be_used.sol index 82e4a0d1..dcf11a6e 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/301_library_instances_cannot_be_used.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/301_library_instances_cannot_be_used.sol @@ -6,4 +6,4 @@ contract test { } } // ---- -// TypeError: (100-103): Member "l" not found or not visible after argument-dependent lookup in library L +// TypeError: (100-103): Member "l" not found or not visible after argument-dependent lookup in library L. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/367_using_directive_for_missing_selftype.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/367_using_directive_for_missing_selftype.sol index 415acb3c..3d9bc3fc 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/367_using_directive_for_missing_selftype.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/367_using_directive_for_missing_selftype.sol @@ -11,4 +11,4 @@ contract A { } } // ---- -// TypeError: (137-140): Member "b" not found or not visible after argument-dependent lookup in bytes memory +// TypeError: (137-140): Member "b" not found or not visible after argument-dependent lookup in bytes memory. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/416_interface_function_bodies.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/416_interface_function_bodies.sol index 24b26c04..fee2525e 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/416_interface_function_bodies.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/416_interface_function_bodies.sol @@ -1,7 +1,6 @@ interface I { - function f() public { + function f() external pure { } } // ---- -// TypeError: (18-45): Functions in interfaces cannot have an implementation. -// Warning: (18-45): Functions in interfaces should be declared external. +// TypeError: (18-52): Functions in interfaces cannot have an implementation. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/421_interface_function_parameters.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/421_interface_function_parameters.sol index 05e2dcfd..9722e936 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/421_interface_function_parameters.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/421_interface_function_parameters.sol @@ -1,5 +1,4 @@ interface I { - function f(uint a) public returns (bool); + function f(uint a) external returns (bool); } // ---- -// Warning: (18-59): Functions in interfaces should be declared external. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/426_throw_is_deprecated.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/426_throw_is_deprecated.sol index 510c0d01..24f36c5b 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/426_throw_is_deprecated.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/426_throw_is_deprecated.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// Warning: (52-57): "throw" is deprecated in favour of "revert()", "require()" and "assert()". +// SyntaxError: (52-57): "throw" is deprecated in favour of "revert()", "require()" and "assert()". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/427_throw_is_deprecated_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/427_throw_is_deprecated_v050.sol deleted file mode 100644 index 170d47d9..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/427_throw_is_deprecated_v050.sol +++ /dev/null @@ -1,8 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function f() pure public { - throw; - } -} -// ---- -// SyntaxError: (82-87): "throw" is deprecated in favour of "revert()", "require()" and "assert()". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/484_function_types_selector_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/484_function_types_selector_1.sol index 9ed2b70f..41ef95c5 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/484_function_types_selector_1.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/484_function_types_selector_1.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// TypeError: (76-86): Member "selector" not found or not visible after argument-dependent lookup in function () view returns (bytes4) +// TypeError: (76-86): Member "selector" not found or not visible after argument-dependent lookup in function () view returns (bytes4). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/485_function_types_selector_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/485_function_types_selector_2.sol index 0876a4f7..d02b098d 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/485_function_types_selector_2.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/485_function_types_selector_2.sol @@ -6,4 +6,4 @@ contract C { } } // ---- -// TypeError: (115-125): Member "selector" not found or not visible after argument-dependent lookup in function () pure +// TypeError: (115-125): Member "selector" not found or not visible after argument-dependent lookup in function () pure. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/486_function_types_selector_3.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/486_function_types_selector_3.sol index d0ccc724..d39fcc28 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/486_function_types_selector_3.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/486_function_types_selector_3.sol @@ -5,4 +5,4 @@ contract C { } } // ---- -// TypeError: (99-109): Member "selector" not found or not visible after argument-dependent lookup in function () +// TypeError: (99-109): Member "selector" not found or not visible after argument-dependent lookup in function (). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/493_builtin_keccak256_reject_gas.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/493_builtin_keccak256_reject_gas.sol index b99431f9..e4113906 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/493_builtin_keccak256_reject_gas.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/493_builtin_keccak256_reject_gas.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// TypeError: (47-60): Member "gas" not found or not visible after argument-dependent lookup in function (bytes memory) pure returns (bytes32) +// TypeError: (47-60): Member "gas" not found or not visible after argument-dependent lookup in function (bytes memory) pure returns (bytes32). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/494_builtin_sha256_reject_gas.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/494_builtin_sha256_reject_gas.sol index 23c90acb..20031ea9 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/494_builtin_sha256_reject_gas.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/494_builtin_sha256_reject_gas.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// TypeError: (47-57): Member "gas" not found or not visible after argument-dependent lookup in function (bytes memory) pure returns (bytes32) +// TypeError: (47-57): Member "gas" not found or not visible after argument-dependent lookup in function (bytes memory) pure returns (bytes32). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/495_builtin_ripemd160_reject_gas.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/495_builtin_ripemd160_reject_gas.sol index 5884e212..3d37e988 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/495_builtin_ripemd160_reject_gas.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/495_builtin_ripemd160_reject_gas.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// TypeError: (47-60): Member "gas" not found or not visible after argument-dependent lookup in function (bytes memory) pure returns (bytes20) +// TypeError: (47-60): Member "gas" not found or not visible after argument-dependent lookup in function (bytes memory) pure returns (bytes20). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/496_builtin_ecrecover_reject_gas.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/496_builtin_ecrecover_reject_gas.sol index 0a874f5d..82b6c89d 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/496_builtin_ecrecover_reject_gas.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/496_builtin_ecrecover_reject_gas.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// TypeError: (47-60): Member "gas" not found or not visible after argument-dependent lookup in function (bytes32,uint8,bytes32,bytes32) pure returns (address) +// TypeError: (47-60): Member "gas" not found or not visible after argument-dependent lookup in function (bytes32,uint8,bytes32,bytes32) pure returns (address). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/553_no_address_members_on_contract_balance_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/553_no_address_members_on_contract_balance_v050.sol index 7c4ad16a..1cd3e9b0 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/553_no_address_members_on_contract_balance_v050.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/553_no_address_members_on_contract_balance_v050.sol @@ -5,4 +5,4 @@ contract C { } } // ---- -// TypeError: (77-89): Member "balance" not found or not visible after argument-dependent lookup in contract C +// TypeError: (77-89): Member "balance" not found or not visible after argument-dependent lookup in contract C. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/554_no_address_members_on_contract_transfer_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/554_no_address_members_on_contract_transfer_v050.sol index 74bdabd2..8c3c1c23 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/554_no_address_members_on_contract_transfer_v050.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/554_no_address_members_on_contract_transfer_v050.sol @@ -5,4 +5,4 @@ contract C { } } // ---- -// TypeError: (77-90): Member "transfer" not found or not visible after argument-dependent lookup in contract C +// TypeError: (77-90): Member "transfer" not found or not visible after argument-dependent lookup in contract C. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/555_no_address_members_on_contract_send_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/555_no_address_members_on_contract_send_v050.sol index 0852e47e..b7868a91 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/555_no_address_members_on_contract_send_v050.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/555_no_address_members_on_contract_send_v050.sol @@ -5,4 +5,4 @@ contract C { } } // ---- -// TypeError: (77-86): Member "send" not found or not visible after argument-dependent lookup in contract C +// TypeError: (77-86): Member "send" not found or not visible after argument-dependent lookup in contract C. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/556_no_address_members_on_contract_call_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/556_no_address_members_on_contract_call_v050.sol index b9a226ad..66fcda20 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/556_no_address_members_on_contract_call_v050.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/556_no_address_members_on_contract_call_v050.sol @@ -5,4 +5,4 @@ contract C { } } // ---- -// TypeError: (77-86): Member "call" not found or not visible after argument-dependent lookup in contract C +// TypeError: (77-86): Member "call" not found or not visible after argument-dependent lookup in contract C. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/557_no_address_members_on_contract_callcode_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/557_no_address_members_on_contract_callcode_v050.sol index 95198a94..001083bf 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/557_no_address_members_on_contract_callcode_v050.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/557_no_address_members_on_contract_callcode_v050.sol @@ -5,4 +5,4 @@ contract C { } } // ---- -// TypeError: (77-90): Member "callcode" not found or not visible after argument-dependent lookup in contract C +// TypeError: (77-90): Member "callcode" not found or not visible after argument-dependent lookup in contract C. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/558_no_address_members_on_contract_delegatecall_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/558_no_address_members_on_contract_delegatecall_v050.sol index b7a7053e..cb6d0735 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/558_no_address_members_on_contract_delegatecall_v050.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/558_no_address_members_on_contract_delegatecall_v050.sol @@ -5,4 +5,4 @@ contract C { } } // ---- -// TypeError: (77-94): Member "delegatecall" not found or not visible after argument-dependent lookup in contract C +// TypeError: (77-94): Member "delegatecall" not found or not visible after argument-dependent lookup in contract C. diff --git a/test/libsolidity/syntaxTests/parsing/interface_basic.sol b/test/libsolidity/syntaxTests/parsing/interface_basic.sol index 2363eaa8..0742c24f 100644 --- a/test/libsolidity/syntaxTests/parsing/interface_basic.sol +++ b/test/libsolidity/syntaxTests/parsing/interface_basic.sol @@ -1,5 +1,4 @@ interface Interface { - function f() public; + function f() external; } // ---- -// Warning: (23-43): Functions in interfaces should be declared external. diff --git a/test/libsolidity/syntaxTests/parsing/trailing_dot1.sol b/test/libsolidity/syntaxTests/parsing/trailing_dot1.sol index 7f26242c..d91c385a 100644 --- a/test/libsolidity/syntaxTests/parsing/trailing_dot1.sol +++ b/test/libsolidity/syntaxTests/parsing/trailing_dot1.sol @@ -4,4 +4,4 @@ contract test { uint256 c = 4.e-2; } // ---- -// TypeError: (70-73): Member "e" not found or not visible after argument-dependent lookup in int_const 4 +// TypeError: (70-73): Member "e" not found or not visible after argument-dependent lookup in int_const 4. diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_default.sol b/test/libsolidity/syntaxTests/visibility/interface/function_default.sol index 72ce3b40..161d66e1 100644 --- a/test/libsolidity/syntaxTests/visibility/interface/function_default.sol +++ b/test/libsolidity/syntaxTests/visibility/interface/function_default.sol @@ -2,5 +2,4 @@ interface I { function f(); } // ---- -// Warning: (15-28): Functions in interfaces should be declared external. -// Warning: (15-28): No visibility specified. Defaulting to "public". In interfaces it defaults to external. +// TypeError: (15-28): Functions in interfaces must be declared external. diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_internal.sol b/test/libsolidity/syntaxTests/visibility/interface/function_internal.sol index ac62e69b..06c1547a 100644 --- a/test/libsolidity/syntaxTests/visibility/interface/function_internal.sol +++ b/test/libsolidity/syntaxTests/visibility/interface/function_internal.sol @@ -2,4 +2,4 @@ interface I { function f() internal; } // ---- -// TypeError: (15-37): Functions in interfaces cannot be internal or private. +// TypeError: (15-37): Functions in interfaces must be declared external. diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_private.sol b/test/libsolidity/syntaxTests/visibility/interface/function_private.sol index 881e647e..98198c3d 100644 --- a/test/libsolidity/syntaxTests/visibility/interface/function_private.sol +++ b/test/libsolidity/syntaxTests/visibility/interface/function_private.sol @@ -2,4 +2,4 @@ interface I { function f() private; } // ---- -// TypeError: (15-36): Functions in interfaces cannot be internal or private. +// TypeError: (15-36): Functions in interfaces must be declared external. diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_public.sol b/test/libsolidity/syntaxTests/visibility/interface/function_public.sol index 891d9fdf..a8cea199 100644 --- a/test/libsolidity/syntaxTests/visibility/interface/function_public.sol +++ b/test/libsolidity/syntaxTests/visibility/interface/function_public.sol @@ -2,4 +2,4 @@ interface I { function f() public; } // ---- -// Warning: (15-35): Functions in interfaces should be declared external. +// TypeError: (15-35): Functions in interfaces must be declared external. |