diff options
235 files changed, 1194 insertions, 1314 deletions
diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..ab452ecf --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +# out-of-tree builds usually go here. This helps improving performance of uploading +# the build context to the docker image build server +/build + +# in-tree builds +/deps diff --git a/Changelog.md b/Changelog.md index 1e9b2787..b1f742bf 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,10 @@ ### 0.5.0 (unreleased) +How to update your code: + * Change every ``.call()`` to a ``.call("")`` and every ``.call(signature, a, b, c)`` to use ``.call(abi.encodeWithSignature(signature, a, b, c))`` (the last one only works for value types). + * Change every ``keccak256(a, b, c)`` to ``keccak256(abi.encodePacked(a, b, c))``. + + Breaking Changes: * ABI Encoder: Properly pad data from calldata (``msg.data`` and external function parameters). Use ``abi.encodePacked`` for unpadded encoding. * Code Generator: Signed right shift uses proper arithmetic shift, i.e. rounding towards negative infinity. Warning: this may silently change the semantics of existing code! @@ -22,6 +27,7 @@ Breaking Changes: * Parser: Disallow trailing dots that are not followed by a number. * Type Checker: Disallow arithmetic operations for boolean variables. * Type Checker: Disallow conversions between ``bytesX`` and ``uintY`` of different size. + * Type Checker: Only accept a single ``bytes`` type for ``.call()`` (and family), ``keccak256()``, ``sha256()`` and ``ripemd160()``. * 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. * Syntax Checker: Named return values in function types are an error. diff --git a/docs/_static/theme_overrides.css b/docs/_static/theme_overrides.css new file mode 100644 index 00000000..d750f4f1 --- /dev/null +++ b/docs/_static/theme_overrides.css @@ -0,0 +1,13 @@ +/* override table width restrictions */ +@media screen and (min-width: 767px) { + + .wy-table-responsive table td { + /* !important prevents the common CSS stylesheets from overriding + this as on sphinx_rtd_theme they are loaded after this stylesheet */ + white-space: normal !important; + } + + .wy-table-responsive { + overflow: visible !important; + } +} diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst index 2fb207c7..e4f8ed4f 100644 --- a/docs/abi-spec.rst +++ b/docs/abi-spec.rst @@ -443,7 +443,7 @@ For example, function Test() public { b = 0x12345678901234567890123456789012; } event Event(uint indexed a, bytes32 b); event Event2(uint indexed a, bytes32 b); - function foo(uint a) public { Event(a, b); } + function foo(uint a) public { emit Event(a, b); } bytes32 b; } @@ -559,7 +559,7 @@ would result in the JSON: Non-standard Packed Mode ======================== -Solidity supports a non-standard packed mode where: +Through ``abi.encodePacked()``, Solidity supports a non-standard packed mode where: - no :ref:`function selector <abi_function_selector>` is encoded, - types shorter than 32 bytes are neither zero padded nor sign extended and @@ -577,3 +577,9 @@ More specifically, each statically-sized type takes as many bytes as its range h and dynamically-sized types like ``string``, ``bytes`` or ``uint[]`` are encoded without their length field. This means that the encoding is ambiguous as soon as there are two dynamically-sized elements. + +Note that constants will be packed using the minimum number of bytes required to store them. +This means that, for example, ``abi.encodePacked(0) == abi.encodePacked(uint8(0)) == hex"00"`` and +``abi.encodePacked(0x12345678) == abi.encodePacked(uint32(0x12345678)) == hex"12345678"``. + +If padding is needed, explicit type conversions can be used: ``abi.encodePacked(uint16(0x12)) == hex"0012"``.
\ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index fdb67367..fcf46c11 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -141,7 +141,16 @@ html_theme = 'sphinx_rtd_theme' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = [] +html_static_path = ['_static'] + +# A dictionary of values to pass into the template engine’s context for +# all pages. Single values can also be put in +# this dictionary using the -A command-line option of sphinx-build. +html_context = { + 'css_files': [ + '_static/theme_overrides.css', # override wide tables in sphinx_rtd_theme + ], + } # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied diff --git a/docs/contracts.rst b/docs/contracts.rst index 5e7eab80..845fd973 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -113,7 +113,7 @@ This means that cyclic creation dependencies are impossible. { // Check some arbitrary condition. address tokenAddress = msg.sender; - return (keccak256(newOwner) & 0xff) == (bytes20(tokenAddress) & 0xff); + return (keccak256(abi.encodePacked(newOwner)) & 0xff) == (bytes20(tokenAddress) & 0xff); } } @@ -377,7 +377,7 @@ inheritable properties of contracts and may be overridden by derived contracts. /// The `return 7` statement assigns 7 to the return value but still /// executes the statement `locked = false` in the modifier. function f() public noReentrancy returns (uint) { - require(msg.sender.call()); + require(msg.sender.call("")); return 7; } } @@ -543,7 +543,7 @@ Fallback Function ================= A contract can have exactly one unnamed function. This function cannot have -arguments and cannot return anything. +arguments, cannot return anything and has to have ``external`` visibility. It is executed on a call to the contract if none of the other functions match the given function identifier (or if no data was supplied at all). @@ -591,7 +591,7 @@ Like any function, the fallback function can execute complex operations as long // Sending Ether to this contract will cause an exception, // because the fallback function does not have the `payable` // modifier. - function() public { x = 1; } + function() external { x = 1; } uint x; } @@ -599,12 +599,12 @@ Like any function, the fallback function can execute complex operations as long // This contract keeps all Ether sent to it with no way // to get it back. contract Sink { - function() public payable { } + function() external payable { } } contract Caller { function callTest(Test test) public { - test.call(0xabcdef01); // hash does not exist + test.call(abi.encodeWithSignature("nonExistingFunction()")); // results in test.x becoming == 1. // The following will not compile, but even @@ -1402,24 +1402,25 @@ Using For ********* The directive ``using A for B;`` can be used to attach library -functions (from the library ``A``) to any type (``B``). +functions (from the library ``A``) to any type (``B``). These functions will receive the object they are called on -as their first parameter (like the ``self`` variable in -Python). +as their first parameter (like the ``self`` variable in Python). The effect of ``using A for *;`` is that the functions from -the library ``A`` are attached to any type. +the library ``A`` are attached to *any* type. -In both situations, all functions, even those where the -type of the first parameter does not match the type of -the object, are attached. The type is checked at the +In both situations, *all* functions in the library are attached, +even those where the type of the first parameter does not +match the type of the object. The type is checked at the point the function is called and function overload resolution is performed. -The ``using A for B;`` directive is active for the current -scope, which is limited to a contract for now but will -be lifted to the global scope later, so that by including -a module, its data types including library functions are +The ``using A for B;`` directive is active only within the current +contract, including within all of its functions, and has no effect +outside of the contract in which it is used. The directive +may only be used inside a contract, not inside any of its functions. + +By including a library, its data types including library functions are available without having to add further code. Let us rewrite the set example from the diff --git a/docs/contributing.rst b/docs/contributing.rst index eabf40b7..481aab1e 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -184,7 +184,8 @@ does not fail if e.g. the code contains an error. This way, internal problems in can be found by fuzzing tools. We mainly use `AFL <http://lcamtuf.coredump.cx/afl/>`_ for fuzzing. You need to download and -build AFL manually. Next, build Solidity (or just the ``solfuzzer`` binary) with AFL as your compiler: +install AFL packages from your repos (afl, afl-clang) or build them manually. +Next, build Solidity (or just the ``solfuzzer`` binary) with AFL as your compiler: :: @@ -194,6 +195,47 @@ build AFL manually. Next, build Solidity (or just the ``solfuzzer`` binary) with cmake .. -DCMAKE_C_COMPILER=path/to/afl-gcc -DCMAKE_CXX_COMPILER=path/to/afl-g++ make solfuzzer +At this stage you should be able to see a message similar to the following: + +:: + + Scanning dependencies of target solfuzzer + [ 98%] Building CXX object test/tools/CMakeFiles/solfuzzer.dir/fuzzer.cpp.o + afl-cc 2.52b by <lcamtuf@google.com> + afl-as 2.52b by <lcamtuf@google.com> + [+] Instrumented 1949 locations (64-bit, non-hardened mode, ratio 100%). + [100%] Linking CXX executable solfuzzer + +If the instrumentation messages did not appear, try switching the cmake flags pointing to AFL's clang binaries: + +:: + # if previously failed + make clean + cmake .. -DCMAKE_C_COMPILER=path/to/afl-clang -DCMAKE_CXX_COMPILER=path/to/afl-clang++ + make solfuzzer + +Othwerise, upon execution the fuzzer will halt with an error saying binary is not instrumented: + +:: + + afl-fuzz 2.52b by <lcamtuf@google.com> + ... (truncated messages) + [*] Validating target binary... + + [-] Looks like the target binary is not instrumented! The fuzzer depends on + compile-time instrumentation to isolate interesting test cases while + mutating the input data. For more information, and for tips on how to + instrument binaries, please see /usr/share/doc/afl-doc/docs/README. + + When source code is not available, you may be able to leverage QEMU + mode support. Consult the README for tips on how to enable this. + (It is also possible to use afl-fuzz as a traditional, "dumb" fuzzer. + For that, you can use the -n option - but expect much worse results.) + + [-] PROGRAM ABORT : No instrumentation detected + Location : check_binary(), afl-fuzz.c:6920 + + Next, you need some example source files. This will make it much easer for the fuzzer to find errors. You can either copy some files from the syntax tests or extract test files from the documentation or the other tests: diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst index 108d4c96..30ece7e1 100644 --- a/docs/miscellaneous.rst +++ b/docs/miscellaneous.rst @@ -79,6 +79,7 @@ Solidity always places new objects at the free memory pointer and memory is neve .. warning:: There are some operations in Solidity that need a temporary memory area larger than 64 bytes and therefore will not fit into the scratch space. They will be placed where the free memory points to, but given their short lifecycle, the pointer is not updated. The memory may or may not be zeroed out. Because of this, one shouldn't expect the free memory to be zeroed out. + While it may seem like a good idea to use ``msize`` to arrive at a definitely zeroed out memory area, using such a pointer non-temporarily without updating the free memory pointer can have adverse results. .. index: calldata layout @@ -321,7 +322,7 @@ Global Variables - ``abi.encodePacked(...) returns (bytes)``: Performes :ref:`packed encoding <abi_packed_mode>` of the given arguments - ``abi.encodeWithSelector(bytes4 selector, ...) returns (bytes)``: :ref:`ABI <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(signature), ...)``` +- ``abi.encodeWithSignature(string signature, ...) returns (bytes)``: Equivalent to ``abi.encodeWithSelector(bytes4(keccak256(bytes(signature)), ...)``` - ``block.blockhash(uint blockNumber) returns (bytes32)``: hash of the given block - only works for 256 most recent, excluding current, blocks - deprecated in version 0.4.22 and replaced by ``blockhash(uint blockNumber)``. - ``block.coinbase`` (``address``): current block miner's address - ``block.difficulty`` (``uint``): current block difficulty @@ -342,10 +343,10 @@ Global Variables - ``revert()``: abort execution and revert state changes - ``revert(string message)``: abort execution and revert state changes providing an explanatory string - ``blockhash(uint blockNumber) returns (bytes32)``: hash of the given block - only works for 256 most recent blocks -- ``keccak256(...) returns (bytes32)``: compute the Ethereum-SHA-3 (Keccak-256) hash of the :ref:`(tightly packed) arguments <abi_packed_mode>` -- ``sha3(...) returns (bytes32)``: an alias to ``keccak256`` -- ``sha256(...) returns (bytes32)``: compute the SHA-256 hash of the :ref:`(tightly packed) arguments <abi_packed_mode>` -- ``ripemd160(...) returns (bytes20)``: compute the RIPEMD-160 hash of the :ref:`(tightly packed) arguments <abi_packed_mode>` +- ``keccak256(bytes memory) returns (bytes32)``: compute the Ethereum-SHA-3 (Keccak-256) hash of the input +- ``sha3(bytes memory) returns (bytes32)``: an alias to ``keccak256`` +- ``sha256(bytes memory) returns (bytes32)``: compute the SHA-256 hash of the input +- ``ripemd160(bytes memory) returns (bytes20)``: compute the RIPEMD-160 hash of the input - ``ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address)``: recover address associated with the public key from elliptic curve signature, return zero on error - ``addmod(uint x, uint y, uint k) returns (uint)``: compute ``(x + y) % k`` where the addition is performed with arbitrary precision and does not wrap around at ``2**256``. Assert that ``k != 0`` starting from version 0.5.0. - ``mulmod(uint x, uint y, uint k) returns (uint)``: compute ``(x * y) % k`` where the multiplication is performed with arbitrary precision and does not wrap around at ``2**256``. Assert that ``k != 0`` starting from version 0.5.0. diff --git a/docs/security-considerations.rst b/docs/security-considerations.rst index 4133edb1..ec67773d 100644 --- a/docs/security-considerations.rst +++ b/docs/security-considerations.rst @@ -86,7 +86,7 @@ as it uses ``call`` which forwards all remaining gas by default: mapping(address => uint) shares; /// Withdraw your share. function withdraw() public { - if (msg.sender.call.value(shares[msg.sender])()) + if (msg.sender.call.value(shares[msg.sender])("")) shares[msg.sender] = 0; } } @@ -140,7 +140,7 @@ Sending and Receiving Ether (for example in the "details" section in Remix). - There is a way to forward more gas to the receiving contract using - ``addr.call.value(x)()``. This is essentially the same as ``addr.transfer(x)``, + ``addr.call.value(x)("")``. This is essentially the same as ``addr.transfer(x)``, only that it forwards all remaining gas and opens up the ability for the recipient to perform more expensive actions (and it only returns a failure code and does not automatically propagate the error). This might include calling back @@ -213,7 +213,7 @@ Now someone tricks you into sending ether to the address of this attack wallet: owner = msg.sender; } - function() public { + function() external { TxUserWallet(msg.sender).transferTo(owner, msg.sender.balance); } } diff --git a/docs/solidity-by-example.rst b/docs/solidity-by-example.rst index 2b3d4b48..fcdd1862 100644 --- a/docs/solidity-by-example.rst +++ b/docs/solidity-by-example.rst @@ -428,8 +428,8 @@ high or low invalid bids. revealEnd = biddingEnd + _revealTime; } - /// Place a blinded bid with `_blindedBid` = keccak256(value, - /// fake, secret). + /// Place a blinded bid with `_blindedBid` = + /// keccak256(abi.encodePacked(value, fake, secret)). /// The sent ether is only refunded if the bid is correctly /// revealed in the revealing phase. The bid is valid if the /// ether sent together with the bid is at least "value" and @@ -470,7 +470,7 @@ high or low invalid bids. Bid storage bid = bids[msg.sender][i]; (uint value, bool fake, bytes32 secret) = (_values[i], _fake[i], _secret[i]); - if (bid.blindedBid != keccak256(value, fake, secret)) { + if (bid.blindedBid != keccak256(abi.encodePacked(value, fake, secret))) { // Bid was not actually revealed. // Do not refund deposit. continue; @@ -496,7 +496,7 @@ high or low invalid bids. if (value <= highestBid) { return false; } - if (highestBidder != 0) { + if (highestBidder != address(0)) { // Refund the previously highest bidder. pendingReturns[highestBidder] += highestBid; } diff --git a/docs/style-guide.rst b/docs/style-guide.rst index 6b28f2ab..792110e1 100644 --- a/docs/style-guide.rst +++ b/docs/style-guide.rst @@ -278,7 +278,7 @@ Yes:: ... } - function() public { + function() external { ... } @@ -308,6 +308,10 @@ No:: // External functions // ... + function() external { + ... + } + // Private functions // ... @@ -318,10 +322,6 @@ No:: ... } - function() public { - ... - } - // Internal functions // ... } @@ -374,13 +374,13 @@ Don't include a whitespace in the fallback function: Yes:: - function() public { + function() external { ... } No:: - function () public { + function () external { ... } diff --git a/docs/types.rst b/docs/types.rst index 009896d5..528807d9 100644 --- a/docs/types.rst +++ b/docs/types.rst @@ -143,27 +143,37 @@ Send is the low-level counterpart of ``transfer``. If the execution fails, the c * ``call``, ``callcode`` and ``delegatecall`` Furthermore, to interface with contracts that do not adhere to the ABI, -the function ``call`` is provided which takes an arbitrary number of arguments of any type. These arguments are padded to 32 bytes and concatenated. One exception is the case where the first argument is encoded to exactly four bytes. In this case, it is not padded to allow the use of function signatures here. +or to get more direct control over the encoding, +the function ``call`` is provided which takes a single byte array as input. +The functions ``abi.encode``, ``abi.encodePacked``, ``abi.encodeWithSelector`` +and ``abi.encodeWithSignature`` can be used to encode structured data. -:: +.. warning:: + All these functions are low-level functions and should be used with care. + Specifically, any unknown contract might be malicious and if you call it, you + hand over control to that contract which could in turn call back into + your contract, so be prepared for changes to your state variables + when the call returns. The regular way to interact with other contracts + is to call a function on a contract object (``x.f()``). - address nameReg = 0x72ba7d8e73fe8eb666ea66babc8116a41bfb10e2; - nameReg.call("register", "MyName"); - nameReg.call(bytes4(keccak256("fun(uint256)")), a); +:: note:: + Previous versions of Solidity allowed these functions to receive + arbitrary arguments and would also handle a first argument of type + ``bytes4`` differently. These edge cases were removed in version 0.5.0. -``call`` returns a boolean indicating whether the invoked function terminated (``true``) or caused an EVM exception (``false``). It is not possible to access the actual data returned (for this we would need to know the encoding and size in advance). +``call`` returns a boolean indicating whether the invoked function terminated (``true``) or caused an EVM exception (``false``). It is not possible to access the actual data returned with plain Solidity. However, using inline assembly it is possible to make a raw ``call`` and access the actual data returned with the ``returndatacopy`` instruction. It is possible to adjust the supplied gas with the ``.gas()`` modifier:: - namReg.call.gas(1000000)("register", "MyName"); + namReg.call.gas(1000000)(abi.encodeWithSignature("register(string)", "MyName")); Similarly, the supplied Ether value can be controlled too:: - nameReg.call.value(1 ether)("register", "MyName"); + nameReg.call.value(1 ether)(abi.encodeWithSignature("register(string)", "MyName")); Lastly, these modifiers can be combined. Their order does not matter:: - nameReg.call.gas(1000000).value(1 ether)("register", "MyName"); + nameReg.call.gas(1000000).value(1 ether)(abi.encodeWithSignature("register(string)", "MyName")); .. note:: It is not yet possible to use the gas or value modifiers on overloaded functions. @@ -184,13 +194,6 @@ The ``.gas()`` option is available on all three methods, while the ``.value()`` .. note:: The use of ``callcode`` is discouraged and will be removed in the future. -.. warning:: - All these functions are low-level functions and should be used with care. - Specifically, any unknown contract might be malicious and if you call it, you - hand over control to that contract which could in turn call back into - your contract, so be prepared for changes to your state variables - when the call returns. - .. index:: byte array, bytes32 diff --git a/docs/units-and-global-variables.rst b/docs/units-and-global-variables.rst index 3b0be438..455231cd 100644 --- a/docs/units-and-global-variables.rst +++ b/docs/units-and-global-variables.rst @@ -100,16 +100,16 @@ ABI Encoding Functions ---------------------- - ``abi.encode(...) returns (bytes)``: ABI-encodes the given arguments -- ``abi.encodePacked(...) returns (bytes)``: Performes packed encoding of the given arguments +- ``abi.encodePacked(...) returns (bytes)``: Performes :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.encodeWithSignature(string signature, ...) returns (bytes)``: Equivalent to ``abi.encodeWithSelector(bytes4(keccak256(signature), ...)``` +- ``abi.encodeWithSignature(string signature, ...) returns (bytes)``: Equivalent to ``abi.encodeWithSelector(bytes4(keccak256(bytes(signature)), ...)``` .. note:: These encoding functions can be used to craft data for function calls without actually - calling a function. Furthermore, ``keccak256(abi.encodePacked(a, b))`` is a more - explicit way to compute ``keccak256(a, b)``, which will be deprecated in future - versions. + calling a function. Furthermore, ``keccak256(abi.encodePacked(a, b))`` is a way + to compute the hash of structured data (although be aware that it is possible to + craft a "hash collision" using different inputs types). See the documentation about the :ref:`ABI <ABI>` and the :ref:`tightly packed encoding <abi_packed_mode>` for details about the encoding. @@ -139,34 +139,18 @@ Mathematical and Cryptographic Functions compute ``(x + y) % k`` where the addition is performed with arbitrary precision and does not wrap around at ``2**256``. Assert that ``k != 0`` starting from version 0.5.0. ``mulmod(uint x, uint y, uint k) returns (uint)``: compute ``(x * y) % k`` where the multiplication is performed with arbitrary precision and does not wrap around at ``2**256``. Assert that ``k != 0`` starting from version 0.5.0. -``keccak256(...) returns (bytes32)``: - compute the Ethereum-SHA-3 (Keccak-256) hash of the :ref:`(tightly packed) arguments <abi_packed_mode>` -``sha256(...) returns (bytes32)``: - compute the SHA-256 hash of the :ref:`(tightly packed) arguments <abi_packed_mode>` -``sha3(...) returns (bytes32)``: +``keccak256(bytes memory) returns (bytes32)``: + compute the Ethereum-SHA-3 (Keccak-256) hash of the input +``sha256(bytes memory) returns (bytes32)``: + compute the SHA-256 hash of the input +``sha3(bytes memory) returns (bytes32)``: alias to ``keccak256`` -``ripemd160(...) returns (bytes20)``: - compute RIPEMD-160 hash of the :ref:`(tightly packed) arguments <abi_packed_mode>` +``ripemd160(bytes memory) returns (bytes20)``: + compute RIPEMD-160 hash of the input ``ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address)``: recover the address associated with the public key from elliptic curve signature or return zero on error (`example usage <https://ethereum.stackexchange.com/q/1777/222>`_) -In the above, "tightly packed" means that the arguments are concatenated without padding. -This means that the following are all identical:: - - keccak256("ab", "c") - keccak256("abc") - keccak256(0x616263) - keccak256(6382179) - keccak256(97, 98, 99) - -If padding is needed, explicit type conversions can be used: ``keccak256("\x00\x12")`` is the -same as ``keccak256(uint16(0x12))``. - -Note that constants will be packed using the minimum number of bytes required to store them. -This means that, for example, ``keccak256(0) == keccak256(uint8(0))`` and -``keccak256(0x12345678) == keccak256(uint32(0x12345678))``. - It might be that you run into Out-of-Gas for ``sha256``, ``ripemd160`` or ``ecrecover`` on a *private blockchain*. The reason for this is that those are implemented as so-called precompiled contracts and these contracts only really exist after they received the first message (although their contract code is hardcoded). Messages to non-existing contracts are more expensive and thus the execution runs into an Out-of-Gas error. A workaround for this problem is to first send e.g. 1 Wei to each of the contracts before you use them in your actual contracts. This is not an issue on the official or test net. .. index:: balance, send, transfer, call, callcode, delegatecall @@ -181,12 +165,12 @@ Address Related send given amount of Wei to :ref:`address`, throws on failure, forwards 2300 gas stipend, not adjustable ``<address>.send(uint256 amount) returns (bool)``: send given amount of Wei to :ref:`address`, returns ``false`` on failure, forwards 2300 gas stipend, not adjustable -``<address>.call(...) returns (bool)``: - issue low-level ``CALL``, returns ``false`` on failure, forwards all available gas, adjustable -``<address>.callcode(...) returns (bool)``: - issue low-level ``CALLCODE``, returns ``false`` on failure, forwards all available gas, adjustable -``<address>.delegatecall(...) returns (bool)``: - issue low-level ``DELEGATECALL``, returns ``false`` on failure, forwards all available gas, adjustable +``<address>.call(bytes memory) returns (bool)``: + issue low-level ``CALL`` with the given payload, returns ``false`` on failure, forwards all available gas, adjustable +``<address>.callcode(bytes memory) returns (bool)``: + issue low-level ``CALLCODE`` with the given payload, returns ``false`` on failure, forwards all available gas, adjustable +``<address>.delegatecall(bytes memory) returns (bool)``: + issue low-level ``DELEGATECALL`` with the given payload, returns ``false`` on failure, forwards all available gas, adjustable For more information, see the section on :ref:`address`. diff --git a/libjulia/Exceptions.h b/libjulia/Exceptions.h index 20ab6520..48624a56 100644 --- a/libjulia/Exceptions.h +++ b/libjulia/Exceptions.h @@ -15,7 +15,7 @@ along with solidity. If not, see <http://www.gnu.org/licenses/>. */ /** - * Exceptions in Julia. + * Exceptions in Yul. */ #pragma once @@ -28,8 +28,8 @@ namespace dev namespace julia { -struct IuliaException: virtual Exception {}; -struct OptimizerException: virtual IuliaException {}; +struct YulException: virtual Exception {}; +struct OptimizerException: virtual YulException {}; } } diff --git a/libjulia/backends/evm/AbstractAssembly.h b/libjulia/backends/evm/AbstractAssembly.h index 8e90a912..46fa7796 100644 --- a/libjulia/backends/evm/AbstractAssembly.h +++ b/libjulia/backends/evm/AbstractAssembly.h @@ -42,7 +42,7 @@ namespace julia { /// -/// Assembly class that abstracts both the libevmasm assembly and the new julia evm assembly. +/// Assembly class that abstracts both the libevmasm assembly and the new Yul assembly. /// class AbstractAssembly { diff --git a/libjulia/backends/evm/EVMCodeTransform.cpp b/libjulia/backends/evm/EVMCodeTransform.cpp index 2a97429b..ba2d7f75 100644 --- a/libjulia/backends/evm/EVMCodeTransform.cpp +++ b/libjulia/backends/evm/EVMCodeTransform.cpp @@ -15,7 +15,7 @@ along with solidity. If not, see <http://www.gnu.org/licenses/>. */ /** - * Common code generator for translating Julia / inline assembly to EVM and EVM1.5. + * Common code generator for translating Yul / inline assembly to EVM and EVM1.5. */ #include <libjulia/backends/evm/EVMCodeTransform.h> @@ -331,7 +331,7 @@ void CodeTransform::operator()(FunctionDefinition const& _function) CodeTransform( m_assembly, m_info, - m_julia, + m_yul, m_evm15, m_identifierAccess, m_useNamedLabelsForFunctions, diff --git a/libjulia/backends/evm/EVMCodeTransform.h b/libjulia/backends/evm/EVMCodeTransform.h index f8eec0b7..ed0785d3 100644 --- a/libjulia/backends/evm/EVMCodeTransform.h +++ b/libjulia/backends/evm/EVMCodeTransform.h @@ -15,7 +15,7 @@ along with solidity. If not, see <http://www.gnu.org/licenses/>. */ /** - * Common code generator for translating Julia / inline assembly to EVM and EVM1.5. + * Common code generator for translating Yul / inline assembly to EVM and EVM1.5. */ #include <libjulia/backends/evm/EVMAssembly.h> @@ -49,14 +49,14 @@ public: CodeTransform( julia::AbstractAssembly& _assembly, solidity::assembly::AsmAnalysisInfo& _analysisInfo, - bool _julia = false, + bool _yul = false, bool _evm15 = false, ExternalIdentifierAccess const& _identifierAccess = ExternalIdentifierAccess(), bool _useNamedLabelsForFunctions = false ): CodeTransform( _assembly, _analysisInfo, - _julia, + _yul, _evm15, _identifierAccess, _useNamedLabelsForFunctions, @@ -78,7 +78,7 @@ protected: CodeTransform( julia::AbstractAssembly& _assembly, solidity::assembly::AsmAnalysisInfo& _analysisInfo, - bool _julia, + bool _yul, bool _evm15, ExternalIdentifierAccess const& _identifierAccess, bool _useNamedLabelsForFunctions, @@ -87,7 +87,7 @@ protected: ): m_assembly(_assembly), m_info(_analysisInfo), - m_julia(_julia), + m_yul(_yul), m_evm15(_evm15), m_useNamedLabelsForFunctions(_useNamedLabelsForFunctions), m_identifierAccess(_identifierAccess), @@ -142,7 +142,7 @@ private: julia::AbstractAssembly& m_assembly; solidity::assembly::AsmAnalysisInfo& m_info; solidity::assembly::Scope* m_scope = nullptr; - bool m_julia = false; + bool m_yul = false; bool m_evm15 = false; bool m_useNamedLabelsForFunctions = false; ExternalIdentifierAccess m_identifierAccess; diff --git a/libjulia/optimiser/ASTCopier.h b/libjulia/optimiser/ASTCopier.h index 8681f2e0..cb2925e3 100644 --- a/libjulia/optimiser/ASTCopier.h +++ b/libjulia/optimiser/ASTCopier.h @@ -62,7 +62,7 @@ public: }; /** - * Creates a copy of a iulia AST potentially replacing identifier names. + * Creates a copy of a Yul AST potentially replacing identifier names. * Base class to be extended. */ class ASTCopier: public ExpressionCopier, public StatementCopier diff --git a/libjulia/optimiser/Disambiguator.h b/libjulia/optimiser/Disambiguator.h index 6fc8a615..4ef43736 100644 --- a/libjulia/optimiser/Disambiguator.h +++ b/libjulia/optimiser/Disambiguator.h @@ -38,7 +38,7 @@ namespace julia { /** - * Creates a copy of a iulia AST replacing all identifiers by unique names. + * Creates a copy of a Yul AST replacing all identifiers by unique names. */ class Disambiguator: public ASTCopier { diff --git a/libjulia/optimiser/README.md b/libjulia/optimiser/README.md index 1b000294..b1ce8931 100644 --- a/libjulia/optimiser/README.md +++ b/libjulia/optimiser/README.md @@ -1,6 +1,6 @@ -## IULIA Optimiser +## Yul Optimiser -The iulia optimiser consists of several stages and components that all transform +The Yul optimiser consists of several stages and components that all transform the AST in a semantically equivalent way. The goal is to end up either with code that is shorter or at least only marginally longer but will allow further optimisation steps. @@ -81,7 +81,7 @@ a loop or conditional, the first one is not inside), the first assignment is rem ## Expression Simplifier -This step can only be applied for the EVM-flavoured dialect of iulia. It applies +This step can only be applied for the EVM-flavoured dialect of Yul. It applies simple rules like ``x + 0 == x`` to simplify expressions. ## Ineffective Statement Remover diff --git a/libjulia/optimiser/UnusedPruner.cpp b/libjulia/optimiser/UnusedPruner.cpp index 54e8fd6e..af503712 100644 --- a/libjulia/optimiser/UnusedPruner.cpp +++ b/libjulia/optimiser/UnusedPruner.cpp @@ -59,7 +59,7 @@ void UnusedPruner::operator()(Block& _block) // Multi-variable declarations are special. We can only remove it // if all vairables are unused and the right-hand-side is either // movable or it return a single value. In the latter case, we - // replace `let a := f()` by `pop(f())` (in pure IULIA, this will be + // replace `let a := f()` by `pop(f())` (in pure Yul, this will be // `drop(f())`). if (boost::algorithm::none_of( varDecl.variables, @@ -74,7 +74,7 @@ void UnusedPruner::operator()(Block& _block) statement = Block{std::move(varDecl.location), {}}; } else if (varDecl.variables.size() == 1) - // In pure IULIA, this should be replaced by a function call to `drop` + // In pure Yul, this should be replaced by a function call to `drop` // instead of `pop`. statement = ExpressionStatement{varDecl.location, FunctionalInstruction{ varDecl.location, diff --git a/libsolidity/analysis/GlobalContext.cpp b/libsolidity/analysis/GlobalContext.cpp index 756bb540..7b4bc3aa 100644 --- a/libsolidity/analysis/GlobalContext.cpp +++ b/libsolidity/analysis/GlobalContext.cpp @@ -42,7 +42,7 @@ m_magicVariables(vector<shared_ptr<MagicVariableDeclaration const>>{ make_shared<MagicVariableDeclaration>("blockhash", make_shared<FunctionType>(strings{"uint256"}, strings{"bytes32"}, FunctionType::Kind::BlockHash, false, StateMutability::View)), make_shared<MagicVariableDeclaration>("ecrecover", make_shared<FunctionType>(strings{"bytes32", "uint8", "bytes32", "bytes32"}, strings{"address"}, FunctionType::Kind::ECRecover, false, StateMutability::Pure)), make_shared<MagicVariableDeclaration>("gasleft", make_shared<FunctionType>(strings(), strings{"uint256"}, FunctionType::Kind::GasLeft, false, StateMutability::View)), - make_shared<MagicVariableDeclaration>("keccak256", make_shared<FunctionType>(strings(), strings{"bytes32"}, FunctionType::Kind::SHA3, true, StateMutability::Pure)), + make_shared<MagicVariableDeclaration>("keccak256", make_shared<FunctionType>(strings{"bytes memory"}, strings{"bytes32"}, FunctionType::Kind::SHA3, false, StateMutability::Pure)), make_shared<MagicVariableDeclaration>("log0", make_shared<FunctionType>(strings{"bytes32"}, strings{}, FunctionType::Kind::Log0)), make_shared<MagicVariableDeclaration>("log1", make_shared<FunctionType>(strings{"bytes32", "bytes32"}, strings{}, FunctionType::Kind::Log1)), make_shared<MagicVariableDeclaration>("log2", make_shared<FunctionType>(strings{"bytes32", "bytes32", "bytes32"}, strings{}, FunctionType::Kind::Log2)), @@ -55,10 +55,10 @@ m_magicVariables(vector<shared_ptr<MagicVariableDeclaration const>>{ make_shared<MagicVariableDeclaration>("require", make_shared<FunctionType>(strings{"bool", "string memory"}, strings{}, FunctionType::Kind::Require, false, StateMutability::Pure)), make_shared<MagicVariableDeclaration>("revert", make_shared<FunctionType>(strings(), strings(), FunctionType::Kind::Revert, false, StateMutability::Pure)), make_shared<MagicVariableDeclaration>("revert", make_shared<FunctionType>(strings{"string memory"}, strings(), FunctionType::Kind::Revert, false, StateMutability::Pure)), - make_shared<MagicVariableDeclaration>("ripemd160", make_shared<FunctionType>(strings(), strings{"bytes20"}, FunctionType::Kind::RIPEMD160, true, StateMutability::Pure)), + make_shared<MagicVariableDeclaration>("ripemd160", make_shared<FunctionType>(strings{"bytes memory"}, strings{"bytes20"}, FunctionType::Kind::RIPEMD160, false, StateMutability::Pure)), make_shared<MagicVariableDeclaration>("selfdestruct", make_shared<FunctionType>(strings{"address"}, strings{}, FunctionType::Kind::Selfdestruct)), - make_shared<MagicVariableDeclaration>("sha256", make_shared<FunctionType>(strings(), strings{"bytes32"}, FunctionType::Kind::SHA256, true, StateMutability::Pure)), - make_shared<MagicVariableDeclaration>("sha3", make_shared<FunctionType>(strings(), strings{"bytes32"}, FunctionType::Kind::SHA3, true, StateMutability::Pure)), + make_shared<MagicVariableDeclaration>("sha256", make_shared<FunctionType>(strings{"bytes memory"}, strings{"bytes32"}, FunctionType::Kind::SHA256, false, StateMutability::Pure)), + make_shared<MagicVariableDeclaration>("sha3", make_shared<FunctionType>(strings{"bytes memory"}, strings{"bytes32"}, FunctionType::Kind::SHA3, false, StateMutability::Pure)), make_shared<MagicVariableDeclaration>("suicide", make_shared<FunctionType>(strings{"address"}, strings{}, FunctionType::Kind::Selfdestruct)), make_shared<MagicVariableDeclaration>("tx", make_shared<MagicType>(MagicType::Kind::Transaction)) }) diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index e89ce27a..b9e3f8d0 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -1712,12 +1712,7 @@ bool TypeChecker::visit(FunctionCall const& _functionCall) m_errorReporter.typeError(_functionCall.location(), "\"suicide\" has been deprecated in favour of \"selfdestruct\""); } if (!m_insideEmitStatement && functionType->kind() == FunctionType::Kind::Event) - { - if (m_scope->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050)) - m_errorReporter.typeError(_functionCall.location(), "Event invocations have to be prefixed by \"emit\"."); - else - m_errorReporter.warning(_functionCall.location(), "Invoking events without \"emit\" prefix is deprecated."); - } + m_errorReporter.typeError(_functionCall.location(), "Event invocations have to be prefixed by \"emit\"."); TypePointers parameterTypes = functionType->parameterTypes(); @@ -1750,35 +1745,6 @@ bool TypeChecker::visit(FunctionCall const& _functionCall) } } - if (functionType->takesSinglePackedBytesParameter()) - { - if ( - (arguments.size() > 1) || - (arguments.size() == 1 && !type(*arguments.front())->isImplicitlyConvertibleTo(ArrayType(DataLocation::Memory))) - ) - { - string msg = - "This function only accepts a single \"bytes\" argument. Please use " - "\"abi.encodePacked(...)\" or a similar function to encode the data."; - if (v050) - m_errorReporter.typeError(_functionCall.location(), msg); - else - m_errorReporter.warning(_functionCall.location(), msg); - } - - if (arguments.size() == 1 && !type(*arguments.front())->isImplicitlyConvertibleTo(ArrayType(DataLocation::Memory))) - { - string msg = - "The provided argument of type " + - type(*arguments.front())->toString() + - " is not implicitly convertible to expected type bytes memory."; - if (v050) - m_errorReporter.typeError(_functionCall.location(), msg); - else - m_errorReporter.warning(_functionCall.location(), msg); - } - } - if (functionType->takesArbitraryParameters() && arguments.size() < parameterTypes.size()) { solAssert(_functionCall.annotation().kind == FunctionCallKind::FunctionCall, ""); @@ -1810,6 +1776,26 @@ bool TypeChecker::visit(FunctionCall const& _functionCall) for (auto const& member: membersRemovedForStructConstructor) msg += " " + member; } + else if ( + functionType->kind() == FunctionType::Kind::BareCall || + functionType->kind() == FunctionType::Kind::BareCallCode || + functionType->kind() == FunctionType::Kind::BareDelegateCall + ) + { + if (arguments.empty()) + msg += " This function requires a single bytes argument. Use \"\" as argument to provide empty calldata."; + else + msg += " This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it."; + } + else if ( + functionType->kind() == FunctionType::Kind::SHA3 || + functionType->kind() == FunctionType::Kind::SHA256 || + functionType->kind() == FunctionType::Kind::RIPEMD160 + ) + msg += + " This function requires a single bytes argument." + " Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour" + " or abi.encode(...) to use ABI encoding."; m_errorReporter.typeError(_functionCall.location(), msg); } else if (isPositionalCall) @@ -1846,15 +1832,31 @@ bool TypeChecker::visit(FunctionCall const& _functionCall) } } else if (!type(*arguments[i])->isImplicitlyConvertibleTo(*parameterTypes[i])) - m_errorReporter.typeError( - arguments[i]->location(), + { + string msg = "Invalid type for argument in function call. " "Invalid implicit conversion from " + type(*arguments[i])->toString() + " to " + parameterTypes[i]->toString() + - " requested." - ); + " requested."; + if ( + functionType->kind() == FunctionType::Kind::BareCall || + functionType->kind() == FunctionType::Kind::BareCallCode || + functionType->kind() == FunctionType::Kind::BareDelegateCall + ) + msg += " This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it."; + else if ( + functionType->kind() == FunctionType::Kind::SHA3 || + functionType->kind() == FunctionType::Kind::SHA256 || + functionType->kind() == FunctionType::Kind::RIPEMD160 + ) + msg += + " This function requires a single bytes argument." + " Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour" + " or abi.encode(...) to use ABI encoding."; + m_errorReporter.typeError(arguments[i]->location(), msg); + } } } else @@ -2287,14 +2289,28 @@ void TypeChecker::endVisit(Literal const& _literal) if (_literal.looksLikeAddress()) { - if (_literal.passesAddressChecksum()) - _literal.annotation().type = make_shared<IntegerType>(160, IntegerType::Modifier::Address); - else - m_errorReporter.warning( + // Assign type here if it even looks like an address. This prevents double error in 050 mode for invalid address + _literal.annotation().type = make_shared<IntegerType>(160, IntegerType::Modifier::Address); + + string msg; + if (_literal.value().length() != 42) // "0x" + 40 hex digits + // looksLikeAddress enforces that it is a hex literal starting with "0x" + msg = + "This looks like an address but is not exactly 40 hex digits. It is " + + to_string(_literal.value().length() - 2) + + " hex digits."; + else if (!_literal.passesAddressChecksum()) + { + msg = "This looks like an address but has an invalid checksum."; + if (!_literal.getChecksummedAddress().empty()) + msg += " Correct checksummed address: \"" + _literal.getChecksummedAddress() + "\"."; + } + + if (!msg.empty()) + m_errorReporter.syntaxError( _literal.location(), - "This looks like an address but has an invalid checksum. " - "If this is not used as an address, please prepend '00'. " + - (!_literal.getChecksummedAddress().empty() ? "Correct checksummed address: '" + _literal.getChecksummedAddress() + "'. " : "") + + msg + + " If this is not used as an address, please prepend '00'. " + "For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals" ); } diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index c4d97c64..1c4eb76e 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -599,9 +599,9 @@ MemberList::MemberMap IntegerType::nativeMembers(ContractDefinition const*) cons if (isAddress()) return { {"balance", make_shared<IntegerType>(256)}, - {"call", make_shared<FunctionType>(strings(), strings{"bool"}, FunctionType::Kind::BareCall, true, StateMutability::Payable)}, - {"callcode", make_shared<FunctionType>(strings(), strings{"bool"}, FunctionType::Kind::BareCallCode, true, StateMutability::Payable)}, - {"delegatecall", make_shared<FunctionType>(strings(), strings{"bool"}, FunctionType::Kind::BareDelegateCall, true)}, + {"call", make_shared<FunctionType>(strings{"bytes memory"}, strings{"bool"}, FunctionType::Kind::BareCall, false, StateMutability::Payable)}, + {"callcode", make_shared<FunctionType>(strings{"bytes memory"}, strings{"bool"}, FunctionType::Kind::BareCallCode, false, StateMutability::Payable)}, + {"delegatecall", make_shared<FunctionType>(strings{"bytes memory"}, strings{"bool"}, FunctionType::Kind::BareDelegateCall, false)}, {"send", make_shared<FunctionType>(strings{"uint"}, strings{"bool"}, FunctionType::Kind::Send)}, {"transfer", make_shared<FunctionType>(strings{"uint"}, strings(), FunctionType::Kind::Transfer)} }; @@ -856,43 +856,49 @@ tuple<bool, rational> RationalNumberType::isValidLiteral(Literal const& _literal bool RationalNumberType::isImplicitlyConvertibleTo(Type const& _convertTo) const { - if (_convertTo.category() == Category::Integer) + switch (_convertTo.category()) + { + case Category::Integer: { - if (m_value == rational(0)) - return true; if (isFractional()) return false; IntegerType const& targetType = dynamic_cast<IntegerType const&>(_convertTo); + if (targetType.isAddress()) + return false; + if (m_value == rational(0)) + return true; unsigned forSignBit = (targetType.isSigned() ? 1 : 0); if (m_value > rational(0)) { if (m_value.numerator() <= (u256(-1) >> (256 - targetType.numBits() + forSignBit))) return true; + return false; + } + if (targetType.isSigned()) + { + if (-m_value.numerator() <= (u256(1) << (targetType.numBits() - forSignBit))) + return true; } - else if (targetType.isSigned() && -m_value.numerator() <= (u256(1) << (targetType.numBits() - forSignBit))) - return true; return false; } - else if (_convertTo.category() == Category::FixedPoint) + case Category::FixedPoint: { if (auto fixed = fixedPointType()) return fixed->isImplicitlyConvertibleTo(_convertTo); - else - return false; + return false; } - else if (_convertTo.category() == Category::FixedBytes) + case Category::FixedBytes: { FixedBytesType const& fixedBytes = dynamic_cast<FixedBytesType const&>(_convertTo); - if (!isFractional()) - { - if (integerType()) - return fixedBytes.numBytes() * 8 >= integerType()->numBits(); - return false; - } - else + if (isFractional()) return false; + if (integerType()) + return fixedBytes.numBytes() * 8 >= integerType()->numBits(); + return false; + } + default: + return false; } - return false; } bool RationalNumberType::isExplicitlyConvertibleTo(Type const& _convertTo) const @@ -2999,6 +3005,25 @@ ASTPointer<ASTString> FunctionType::documentation() const return ASTPointer<ASTString>(); } +bool FunctionType::padArguments() const +{ + // No padding only for hash functions, low-level calls and the packed encoding function. + switch (m_kind) + { + case Kind::BareCall: + case Kind::BareCallCode: + case Kind::BareDelegateCall: + case Kind::SHA256: + case Kind::RIPEMD160: + case Kind::SHA3: + case Kind::ABIEncodePacked: + return false; + default: + return true; + } + return true; +} + string MappingType::richIdentifier() const { return "t_mapping" + identifierList(m_keyType, m_valueType); diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index b2f34dee..4415fb4b 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -1058,18 +1058,21 @@ public: ASTPointer<ASTString> documentation() const; /// true iff arguments are to be padded to multiples of 32 bytes for external calls - bool padArguments() const { return !(m_kind == Kind::SHA3 || m_kind == Kind::SHA256 || m_kind == Kind::RIPEMD160 || m_kind == Kind::ABIEncodePacked); } + /// The only functions that do not pad are hash functions, the low-level call functions + /// and abi.encodePacked. + bool padArguments() const; bool takesArbitraryParameters() const { return m_arbitraryParameters; } /// true iff the function takes a single bytes parameter and it is passed on without padding. - /// @todo until 0.5.0, this is just a "recommendation". bool takesSinglePackedBytesParameter() const { - // @todo add the call kinds here with 0.5.0 and perhaps also log0. switch (m_kind) { case FunctionType::Kind::SHA3: case FunctionType::Kind::SHA256: case FunctionType::Kind::RIPEMD160: + case FunctionType::Kind::BareCall: + case FunctionType::Kind::BareCallCode: + case FunctionType::Kind::BareDelegateCall: return true; default: return false; diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 0470c3ec..ecbd0243 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -699,16 +699,24 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) } case FunctionType::Kind::SHA3: { - TypePointers argumentTypes; - for (auto const& arg: arguments) + solAssert(arguments.size() == 1, ""); + solAssert(!function.padArguments(), ""); + TypePointer const& argType = arguments.front()->annotation().type; + solAssert(argType, ""); + arguments.front()->accept(*this); + // Optimization: If type is bytes or string, then do not encode, + // but directly compute keccak256 on memory. + if (*argType == ArrayType(DataLocation::Memory) || *argType == ArrayType(DataLocation::Memory, true)) { - arg->accept(*this); - argumentTypes.push_back(arg->annotation().type); + ArrayUtils(m_context).retrieveLength(ArrayType(DataLocation::Memory)); + m_context << Instruction::SWAP1 << u256(0x20) << Instruction::ADD; + } + else + { + utils().fetchFreeMemoryPointer(); + utils().packedEncode({argType}, TypePointers()); + utils().toSizeAfterFreeMemoryPointer(); } - utils().fetchFreeMemoryPointer(); - solAssert(!function.padArguments(), ""); - utils().packedEncode(argumentTypes, TypePointers()); - utils().toSizeAfterFreeMemoryPointer(); m_context << Instruction::KECCAK256; break; } @@ -1802,13 +1810,14 @@ void ExpressionCompiler::appendExternalFunctionCall( if (_functionType.bound()) utils().moveToStackTop(gasValueSize, _functionType.selfType()->sizeOnStack()); + bool const v050 = m_context.experimentalFeatureActive(ExperimentalFeature::V050); auto funKind = _functionType.kind(); bool returnSuccessCondition = funKind == FunctionType::Kind::BareCall || funKind == FunctionType::Kind::BareCallCode || funKind == FunctionType::Kind::BareDelegateCall; bool isCallCode = funKind == FunctionType::Kind::BareCallCode || funKind == FunctionType::Kind::CallCode; bool isDelegateCall = funKind == FunctionType::Kind::BareDelegateCall || funKind == FunctionType::Kind::DelegateCall; bool useStaticCall = _functionType.stateMutability() <= StateMutability::View && - m_context.experimentalFeatureActive(ExperimentalFeature::V050) && + v050 && m_context.evmVersion().hasStaticCall(); bool haveReturndatacopy = m_context.evmVersion().supportsReturndata(); @@ -1836,38 +1845,12 @@ void ExpressionCompiler::appendExternalFunctionCall( // Evaluate arguments. TypePointers argumentTypes; TypePointers parameterTypes = _functionType.parameterTypes(); - bool manualFunctionId = false; - if ( - (funKind == FunctionType::Kind::BareCall || funKind == FunctionType::Kind::BareCallCode || funKind == FunctionType::Kind::BareDelegateCall) && - !_arguments.empty() - ) - { - solAssert(_arguments.front()->annotation().type->mobileType(), ""); - manualFunctionId = - _arguments.front()->annotation().type->mobileType()->calldataEncodedSize(false) == - CompilerUtils::dataStartOffset; - } - if (manualFunctionId) - { - // If we have a Bare* and the first type has exactly 4 bytes, use it as - // function identifier. - _arguments.front()->accept(*this); - utils().convertType( - *_arguments.front()->annotation().type, - IntegerType(8 * CompilerUtils::dataStartOffset), - true - ); - for (unsigned i = 0; i < gasValueSize; ++i) - m_context << swapInstruction(gasValueSize - i); - gasStackPos++; - valueStackPos++; - } if (_functionType.bound()) { argumentTypes.push_back(_functionType.selfType()); parameterTypes.insert(parameterTypes.begin(), _functionType.selfType()); } - for (size_t i = manualFunctionId ? 1 : 0; i < _arguments.size(); ++i) + for (size_t i = 0; i < _arguments.size(); ++i) { _arguments[i]->accept(*this); argumentTypes.push_back(_arguments[i]->annotation().type); @@ -1903,19 +1886,20 @@ void ExpressionCompiler::appendExternalFunctionCall( // Copy function identifier to memory. utils().fetchFreeMemoryPointer(); - if (!_functionType.isBareCall() || manualFunctionId) + if (!_functionType.isBareCall()) { m_context << dupInstruction(2 + gasValueSize + CompilerUtils::sizeOnStack(argumentTypes)); utils().storeInMemoryDynamic(IntegerType(8 * CompilerUtils::dataStartOffset), false); } - // If the function takes arbitrary parameters, copy dynamic length data in place. + + // If the function takes arbitrary parameters or is a bare call, copy dynamic length data in place. // Move arguments to memory, will not update the free memory pointer (but will update the memory // pointer on the stack). utils().encodeToMemory( argumentTypes, parameterTypes, _functionType.padArguments(), - _functionType.takesArbitraryParameters(), + _functionType.takesArbitraryParameters() || _functionType.isBareCall(), isCallCode || isDelegateCall ); @@ -1996,9 +1980,9 @@ void ExpressionCompiler::appendExternalFunctionCall( unsigned remainsSize = 2 + // contract address, input_memory_end - _functionType.valueSet() + - _functionType.gasSet() + - (!_functionType.isBareCall() || manualFunctionId); + (_functionType.valueSet() ? 1 : 0) + + (_functionType.gasSet() ? 1 : 0) + + (!_functionType.isBareCall() ? 1 : 0); if (returnSuccessCondition) m_context << swapInstruction(remainsSize); diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 4e8d1461..aa33bad8 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -719,27 +719,10 @@ void CompilerStack::compileContract( string metadata = createMetadata(compiledContract); compiledContract.metadata = metadata; - // Prepare CBOR metadata for the bytecode - bytes cborEncodedHash = - // CBOR-encoding of the key "bzzr0" - bytes{0x65, 'b', 'z', 'z', 'r', '0'}+ - // CBOR-encoding of the hash - bytes{0x58, 0x20} + dev::swarmHash(metadata).asBytes(); - bytes cborEncodedMetadata; - if (onlySafeExperimentalFeaturesActivated(_contract.sourceUnit().annotation().experimentalFeatures)) - cborEncodedMetadata = - // CBOR-encoding of {"bzzr0": dev::swarmHash(metadata)} - bytes{0xa1} + - cborEncodedHash; - else - cborEncodedMetadata = - // CBOR-encoding of {"bzzr0": dev::swarmHash(metadata), "experimental": true} - bytes{0xa2} + - cborEncodedHash + - bytes{0x6c, 'e', 'x', 'p', 'e', 'r', 'i', 'm', 'e', 'n', 't', 'a', 'l', 0xf5}; - solAssert(cborEncodedMetadata.size() <= 0xffff, "Metadata too large"); - // 16-bit big endian length - cborEncodedMetadata += toCompactBigEndian(cborEncodedMetadata.size(), 2); + bytes cborEncodedMetadata = createCBORMetadata( + metadata, + !onlySafeExperimentalFeaturesActivated(_contract.sourceUnit().annotation().experimentalFeatures) + ); try { @@ -901,6 +884,31 @@ string CompilerStack::createMetadata(Contract const& _contract) const return jsonCompactPrint(meta); } +bytes CompilerStack::createCBORMetadata(string _metadata, bool _experimentalMode) +{ + bytes cborEncodedHash = + // CBOR-encoding of the key "bzzr0" + bytes{0x65, 'b', 'z', 'z', 'r', '0'}+ + // CBOR-encoding of the hash + bytes{0x58, 0x20} + dev::swarmHash(_metadata).asBytes(); + bytes cborEncodedMetadata; + if (_experimentalMode) + cborEncodedMetadata = + // CBOR-encoding of {"bzzr0": dev::swarmHash(metadata), "experimental": true} + bytes{0xa2} + + cborEncodedHash + + bytes{0x6c, 'e', 'x', 'p', 'e', 'r', 'i', 'm', 'e', 'n', 't', 'a', 'l', 0xf5}; + else + cborEncodedMetadata = + // CBOR-encoding of {"bzzr0": dev::swarmHash(metadata)} + bytes{0xa1} + + cborEncodedHash; + solAssert(cborEncodedMetadata.size() <= 0xffff, "Metadata too large"); + // 16-bit big endian length + cborEncodedMetadata += toCompactBigEndian(cborEncodedMetadata.size(), 2); + return cborEncodedMetadata; +} + string CompilerStack::computeSourceMapping(eth::AssemblyItems const& _items) const { string ret; diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h index 018c61ec..4359c3fa 100644 --- a/libsolidity/interface/CompilerStack.h +++ b/libsolidity/interface/CompilerStack.h @@ -122,6 +122,8 @@ public: m_optimizeRuns = _runs; } + /// Set the EVM version used before running compile. + /// When called without an argument it will revert to the default version. void setEVMVersion(EVMVersion _version = EVMVersion{}); /// Sets the list of requested contract names. If empty, no filtering is performed and every contract @@ -240,9 +242,7 @@ public: Json::Value gasEstimates(std::string const& _contractName) const; private: - /** - * Information pertaining to one source unit, filled gradually during parsing and compilation. - */ + /// The state per source unit. Filled gradually during parsing. struct Source { std::shared_ptr<Scanner> scanner; @@ -251,13 +251,14 @@ private: void reset() { scanner.reset(); ast.reset(); } }; + /// The state per contract. Filled gradually during compilation. struct Contract { ContractDefinition const* contract = nullptr; std::shared_ptr<Compiler> compiler; - eth::LinkerObject object; - eth::LinkerObject runtimeObject; - eth::LinkerObject cloneObject; + eth::LinkerObject object; ///< Deployment object (includes the runtime sub-object). + eth::LinkerObject runtimeObject; ///< Runtime object. + eth::LinkerObject cloneObject; ///< Clone object (deprecated). std::string metadata; ///< The metadata json that will be hashed into the chain. mutable std::unique_ptr<Json::Value const> abi; mutable std::unique_ptr<Json::Value const> userDocumentation; @@ -272,8 +273,10 @@ private: StringMap loadMissingSources(SourceUnit const& _ast, std::string const& _path); std::string applyRemapping(std::string const& _path, std::string const& _context); void resolveImports(); + /// @returns the absolute path corresponding to @a _path relative to @a _reference. static std::string absolutePath(std::string const& _path, std::string const& _reference); + /// Helper function to return path converted strings. static std::string sanitizePath(std::string const& _path) { return boost::filesystem::path(_path).generic_string(); } @@ -285,19 +288,42 @@ private: ContractDefinition const& _contract, std::map<ContractDefinition const*, eth::Assembly const*>& _compiledContracts ); + + /// Links all the known library addresses in the available objects. Any unknown + /// library will still be kept as an unlinked placeholder in the objects. void link(); + /// @returns the contract object for the given @a _contractName. + /// Can only be called after state is CompilationSuccessful. Contract const& contract(std::string const& _contractName) const; + + /// @returns the source object for the given @a _sourceName. + /// Can only be called after state is SourcesSet. Source const& source(std::string const& _sourceName) const; /// @returns the parsed contract with the supplied name. Throws an exception if the contract /// does not exist. ContractDefinition const& contractDefinition(std::string const& _contractName) const; + /// @returns the metadata JSON as a compact string for the given contract. std::string createMetadata(Contract const& _contract) const; + + /// @returns the metadata CBOR for the given serialised metadata JSON. + static bytes createCBORMetadata(std::string _metadata, bool _experimentalMode); + + /// @returns the computer source mapping string. std::string computeSourceMapping(eth::AssemblyItems const& _items) const; + + /// @returns the contract ABI as a JSON object. + /// This will generate the JSON object and store it in the Contract object if it is not present yet. Json::Value const& contractABI(Contract const&) const; + + /// @returns the Natspec User documentation as a JSON object. + /// This will generate the JSON object and store it in the Contract object if it is not present yet. Json::Value const& natspecUser(Contract const&) const; + + /// @returns the Natspec Developer documentation as a JSON object. + /// This will generate the JSON object and store it in the Contract object if it is not present yet. Json::Value const& natspecDev(Contract const&) const; /// @returns the offset of the entry point of the given function into the list of assembly items diff --git a/scripts/Dockerfile b/scripts/Dockerfile index 654a9f29..2b2de1e2 100644 --- a/scripts/Dockerfile +++ b/scripts/Dockerfile @@ -1,18 +1,39 @@ -FROM alpine +FROM alpine AS build MAINTAINER chriseth <chris@ethereum.org> #Official solidity docker image #Establish working directory as solidity WORKDIR /solidity + +# Build dependencies +ADD /scripts/install_deps.sh /solidity/scripts/install_deps.sh +RUN ./scripts/install_deps.sh + #Copy working directory on travis to the image COPY / $WORKDIR -#Install dependencies, eliminate annoying warnings, and build release, delete all remaining points and statically link. -RUN ./scripts/install_deps.sh && sed -i -E -e 's/include <sys\/poll.h>/include <poll.h>/' /usr/include/boost/asio/detail/socket_types.hpp &&\ -cmake -DCMAKE_BUILD_TYPE=Release -DTESTS=0 -DSOLC_LINK_STATIC=1 &&\ -make solc && install -s solc/solc /usr/bin &&\ -cd / && rm -rf solidity &&\ -apk del sed build-base git make cmake gcc g++ musl-dev curl-dev boost-dev &&\ -rm -rf /var/cache/apk/* +# Number of parallel jobs during build +# or 0 for auto-computing (max(1, CPU_core_count * 2/3), a greedy value) +ARG BUILD_CONCURRENCY="0" + +#Install dependencies, eliminate annoying warnings +RUN sed -i -E -e 's/include <sys\/poll.h>/include <poll.h>/' /usr/include/boost/asio/detail/socket_types.hpp +RUN cmake -DCMAKE_BUILD_TYPE=Release -DTESTS=0 -DSOLC_LINK_STATIC=1 +RUN make solc \ + -j$(awk "BEGIN { \ + if (${BUILD_CONCURRENCY} != 0) { \ + print(${BUILD_CONCURRENCY}); \ + } else { \ + x=($(grep -c ^processor /proc/cpuinfo) * 2/3); \ + if (x > 1) { \ + printf(\"%d\n\", x); \ + } else { \ + print(1); \ + } \ + } \ + }") +RUN strip solc/solc -ENTRYPOINT ["/usr/bin/solc"]
\ No newline at end of file +FROM scratch +COPY --from=build /solidity/solc/solc /usr/bin/solc +ENTRYPOINT ["/usr/bin/solc"] diff --git a/scripts/install_deps.sh b/scripts/install_deps.sh index ace6580a..96501499 100755 --- a/scripts/install_deps.sh +++ b/scripts/install_deps.sh @@ -133,7 +133,7 @@ case $(uname -s) in # Arch Linux #------------------------------------------------------------------------------ - Arch*) + Arch*|ManjaroLinux) #Arch echo "Installing solidity dependencies on Arch Linux." diff --git a/test/compilationTests/MultiSigWallet/Factory.sol b/test/compilationTests/MultiSigWallet/Factory.sol index f1be6884..f7a96cbd 100644 --- a/test/compilationTests/MultiSigWallet/Factory.sol +++ b/test/compilationTests/MultiSigWallet/Factory.sol @@ -23,6 +23,6 @@ contract Factory { { isInstantiation[instantiation] = true; instantiations[msg.sender].push(instantiation); - ContractInstantiation(msg.sender, instantiation); + emit ContractInstantiation(msg.sender, instantiation); } } diff --git a/test/compilationTests/MultiSigWallet/MultiSigWallet.sol b/test/compilationTests/MultiSigWallet/MultiSigWallet.sol index a6f67c7a..e534d09a 100644 --- a/test/compilationTests/MultiSigWallet/MultiSigWallet.sol +++ b/test/compilationTests/MultiSigWallet/MultiSigWallet.sol @@ -50,7 +50,7 @@ contract MultiSigWallet { } modifier transactionExists(uint transactionId) { - if (transactions[transactionId].destination == 0) + if (transactions[transactionId].destination == address(0)) throw; _; } @@ -74,7 +74,7 @@ contract MultiSigWallet { } modifier notNull(address _address) { - if (_address == 0) + if (_address == address(0)) throw; _; } @@ -90,10 +90,11 @@ contract MultiSigWallet { /// @dev Fallback function allows to deposit ether. function() + external payable { if (msg.value > 0) - Deposit(msg.sender, msg.value); + emit Deposit(msg.sender, msg.value); } /* @@ -102,12 +103,12 @@ 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. - function MultiSigWallet(address[] _owners, uint _required) + constructor(address[] _owners, uint _required) public validRequirement(_owners.length, _required) { for (uint i=0; i<_owners.length; i++) { - if (isOwner[_owners[i]] || _owners[i] == 0) + if (isOwner[_owners[i]] || _owners[i] == address(0)) throw; isOwner[_owners[i]] = true; } @@ -126,7 +127,7 @@ contract MultiSigWallet { { isOwner[owner] = true; owners.push(owner); - OwnerAddition(owner); + emit OwnerAddition(owner); } /// @dev Allows to remove an owner. Transaction has to be sent by wallet. @@ -145,7 +146,7 @@ contract MultiSigWallet { owners.length -= 1; if (required > owners.length) changeRequirement(owners.length); - OwnerRemoval(owner); + emit OwnerRemoval(owner); } /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. @@ -164,8 +165,8 @@ contract MultiSigWallet { } isOwner[owner] = false; isOwner[newOwner] = true; - OwnerRemoval(owner); - OwnerAddition(newOwner); + emit OwnerRemoval(owner); + emit OwnerAddition(newOwner); } /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet. @@ -176,7 +177,7 @@ contract MultiSigWallet { validRequirement(owners.length, _required) { required = _required; - RequirementChange(_required); + emit RequirementChange(_required); } /// @dev Allows an owner to submit and confirm a transaction. @@ -201,7 +202,7 @@ contract MultiSigWallet { notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; - Confirmation(msg.sender, transactionId); + emit Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } @@ -214,7 +215,7 @@ contract MultiSigWallet { notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; - Revocation(msg.sender, transactionId); + emit Revocation(msg.sender, transactionId); } /// @dev Allows anyone to execute a confirmed transaction. @@ -227,9 +228,9 @@ contract MultiSigWallet { Transaction tx = transactions[transactionId]; tx.executed = true; if (tx.destination.call.value(tx.value)(tx.data)) - Execution(transactionId); + emit Execution(transactionId); else { - ExecutionFailure(transactionId); + emit ExecutionFailure(transactionId); tx.executed = false; } } @@ -273,7 +274,7 @@ contract MultiSigWallet { executed: false }); transactionCount += 1; - Submission(transactionId); + emit Submission(transactionId); } /* diff --git a/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol b/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol index 024d3ef4..0ca9fa54 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. - function MultiSigWalletWithDailyLimit(address[] _owners, uint _required, uint _dailyLimit) + constructor(address[] _owners, uint _required, uint _dailyLimit) public MultiSigWallet(_owners, _required) { @@ -33,7 +33,7 @@ contract MultiSigWalletWithDailyLimit is MultiSigWallet { onlyWallet { dailyLimit = _dailyLimit; - DailyLimitChange(_dailyLimit); + emit DailyLimitChange(_dailyLimit); } /// @dev Allows anyone to execute a confirmed transaction or ether withdraws until daily limit is reached. @@ -49,9 +49,9 @@ contract MultiSigWalletWithDailyLimit is MultiSigWallet { if (!confirmed) spentToday += tx.value; if (tx.destination.call.value(tx.value)(tx.data)) - Execution(transactionId); + emit Execution(transactionId); else { - ExecutionFailure(transactionId); + emit ExecutionFailure(transactionId); tx.executed = false; if (!confirmed) spentToday -= tx.value; diff --git a/test/compilationTests/MultiSigWallet/TestToken.sol b/test/compilationTests/MultiSigWallet/TestToken.sol index 0f6cd20e..69727cbd 100644 --- a/test/compilationTests/MultiSigWallet/TestToken.sol +++ b/test/compilationTests/MultiSigWallet/TestToken.sol @@ -31,7 +31,7 @@ contract TestToken { } balances[msg.sender] -= _value; balances[_to] += _value; - Transfer(msg.sender, _to, _value); + emit Transfer(msg.sender, _to, _value); return true; } @@ -45,7 +45,7 @@ contract TestToken { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; - Transfer(_from, _to, _value); + emit Transfer(_from, _to, _value); return true; } @@ -54,7 +54,7 @@ contract TestToken { returns (bool success) { allowed[msg.sender][_spender] = _value; - Approval(msg.sender, _spender, _value); + emit Approval(msg.sender, _spender, _value); return true; } diff --git a/test/compilationTests/corion/ico.sol b/test/compilationTests/corion/ico.sol index c61e3448..54305d41 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; - function ico(address foundation, address priceSet, uint256 exchangeRate, uint256 startBlockNum, address[] genesisAddr, uint256[] genesisValue) { + constructor(address foundation, address priceSet, uint256 exchangeRate, uint256 startBlockNum, address[] genesisAddr, uint256[] genesisValue) { /* Installation function. @@ -162,7 +162,7 @@ contract ico is safeMath { interest_s memory _idb; address _addr = beneficiary; uint256 _to = (block.number - startBlock) / interestBlockDelay; - if ( _addr == 0x00 ) { _addr = msg.sender; } + if ( _addr == address(0x00) ) { _addr = msg.sender; } require( block.number > icoDelay ); require( ! aborted ); @@ -257,7 +257,7 @@ contract ico is safeMath { @premiumContractAddr Address of the corion premium token contract */ require( msg.sender == owner ); - require( tokenAddr == 0x00 && premiumAddr == 0x00 ); + require( tokenAddr == address(0x00) && premiumAddr == address(0x00) ); tokenAddr = tokenContractAddr; premiumAddr = premiumContractAddr; } @@ -275,13 +275,13 @@ contract ico is safeMath { require( msg.sender.send(_val) ); } - function () payable { + function () external payable { /* Callback function. Simply calls the buy function as a beneficiary and there is no affilate address. If they call the contract without any function then this process will be taken place. */ require( isICO() ); - require( buy(msg.sender, 0x00) ); + require( buy(msg.sender, address(0x00)) ); } function buy(address beneficiaryAddress, address affilateAddress) payable returns (bool success) { @@ -300,9 +300,9 @@ contract ico is safeMath { @affilateAddress The address of the person who offered who will get the referral reward. It can not be equal with the beneficiaryAddress. */ require( isICO() ); - if ( beneficiaryAddress == 0x00) { beneficiaryAddress = msg.sender; } + if ( beneficiaryAddress == address(0x00)) { beneficiaryAddress = msg.sender; } if ( beneficiaryAddress == affilateAddress ) { - affilateAddress = 0x00; + affilateAddress = address(0x00); } uint256 _value = msg.value; if ( beneficiaryAddress.balance < 0.2 ether ) { @@ -317,7 +317,7 @@ contract ico is safeMath { totalMint = safeAdd(totalMint, _reward); require( foundationAddress.send(_value * 10 / 100) ); uint256 extra; - if ( affilateAddress != 0x00 && ( brought[affilateAddress].eth > 0 || interestDB[affilateAddress][0].amount > 0 ) ) { + if ( affilateAddress != address(0x00) && ( brought[affilateAddress].eth > 0 || interestDB[affilateAddress][0].amount > 0 ) ) { affiliate[affilateAddress].weight = safeAdd(affiliate[affilateAddress].weight, _reward); extra = affiliate[affilateAddress].weight; uint256 rate; @@ -337,7 +337,7 @@ contract ico is safeMath { token(tokenAddr).mint(affilateAddress, extra); } checkPremium(beneficiaryAddress); - EICO(beneficiaryAddress, _reward, affilateAddress, extra); + emit EICO(beneficiaryAddress, _reward, affilateAddress, extra); return true; } diff --git a/test/compilationTests/corion/module.sol b/test/compilationTests/corion/module.sol index 51fb8231..5f13215f 100644 --- a/test/compilationTests/corion/module.sol +++ b/test/compilationTests/corion/module.sol @@ -123,7 +123,7 @@ contract module { @ret This is the module handler address or not */ - if ( moduleHandlerAddress == 0x00 ) { return true; } + if ( moduleHandlerAddress == address(0x00) ) { return true; } if ( moduleStatus != status.Connected ) { return false; } return addr == moduleHandlerAddress; } diff --git a/test/compilationTests/corion/moduleHandler.sol b/test/compilationTests/corion/moduleHandler.sol index d1f928c5..e77d9e09 100644 --- a/test/compilationTests/corion/moduleHandler.sol +++ b/test/compilationTests/corion/moduleHandler.sol @@ -35,8 +35,8 @@ contract moduleHandler is multiOwner, announcementTypes { address public foundationAddress; uint256 debugModeUntil = block.number + 1000000; - function moduleHandler(address[] newOwners) multiOwner(newOwners) {} + constructor(address[] newOwners) multiOwner(newOwners) {} function load(address foundation, bool forReplace, address Token, address Premium, address Publisher, address Schelling, address Provider) { /* Loading modulest to ModuleHandler. @@ -73,7 +73,7 @@ contract moduleHandler is multiOwner, announcementTypes { require( success && ! found ); (success, found, id) = getModuleIDByHash(input.name); require( success && ! found ); - (success, found, id) = getModuleIDByAddress(0x00); + (success, found, id) = getModuleIDByAddress(address(0x00)); require( success ); if ( ! found ) { id = modules.length; @@ -92,7 +92,7 @@ contract moduleHandler is multiOwner, announcementTypes { */ (bool _success, bool _found, uint256 _id) = getModuleIDByName(name); if ( _success && _found ) { return (true, true, modules[_id].addr); } - return (true, false, 0x00); + return (true, false, address(0x00)); } function getModuleIDByHash(bytes32 hashOfName) public constant returns( bool success, bool found, uint256 id ) { /* @@ -117,7 +117,7 @@ contract moduleHandler is multiOwner, announcementTypes { @id Index of module. @found Was there any result or not. */ - bytes32 _name = keccak256(name); + bytes32 _name = keccak256(bytes(name)); for ( uint256 a=0 ; a<modules.length ; a++ ) { if ( modules[a].name == _name ) { return (true, true, a); @@ -153,7 +153,7 @@ contract moduleHandler is multiOwner, announcementTypes { require( _success ); if ( ! ( _found && modules[_id].name == keccak256('Publisher') )) { require( block.number < debugModeUntil ); - if ( ! insertAndCheckDo(calcDoHash("replaceModule", keccak256(name, addr, callCallback))) ) { + if ( ! insertAndCheckDo(calcDoHash("replaceModule", keccak256(abi.encodePacked(name, addr, callCallback)))) ) { return true; } } @@ -169,7 +169,7 @@ contract moduleHandler is multiOwner, announcementTypes { function callReplaceCallback(string moduleName, address newModule) external returns (bool success) { require( block.number < debugModeUntil ); - if ( ! insertAndCheckDo(calcDoHash("callReplaceCallback", keccak256(moduleName, newModule))) ) { + if ( ! insertAndCheckDo(calcDoHash("callReplaceCallback", keccak256(abi.encodePacked(moduleName, newModule)))) ) { return true; } (bool _success, bool _found, uint256 _id) = getModuleIDByName(moduleName); @@ -192,11 +192,11 @@ contract moduleHandler is multiOwner, announcementTypes { require( _success ); if ( ! ( _found && modules[_id].name == keccak256('Publisher') )) { require( block.number < debugModeUntil ); - if ( ! insertAndCheckDo(calcDoHash("newModule", keccak256(name, addr, schellingEvent, transferEvent))) ) { + if ( ! insertAndCheckDo(calcDoHash("newModule", keccak256(abi.encodePacked(name, addr, schellingEvent, transferEvent)))) ) { return true; } } - addModule( modules_s(addr, keccak256(name), schellingEvent, transferEvent), true); + addModule( modules_s(addr, keccak256(bytes(name)), schellingEvent, transferEvent), true); return true; } function dropModule(string name, bool callCallback) external returns (bool success) { @@ -211,7 +211,7 @@ contract moduleHandler is multiOwner, announcementTypes { require( _success ); if ( ! ( _found && modules[_id].name == keccak256('Publisher') )) { require( block.number < debugModeUntil ); - if ( ! insertAndCheckDo(calcDoHash("replaceModule", keccak256(name, callCallback))) ) { + if ( ! insertAndCheckDo(calcDoHash("replaceModule", keccak256(abi.encodePacked(name, callCallback)))) ) { return true; } } @@ -226,7 +226,7 @@ contract moduleHandler is multiOwner, announcementTypes { function callDisableCallback(string moduleName) external returns (bool success) { require( block.number < debugModeUntil ); - if ( ! insertAndCheckDo(calcDoHash("callDisableCallback", keccak256(moduleName))) ) { + if ( ! insertAndCheckDo(calcDoHash("callDisableCallback", keccak256(bytes(moduleName)))) ) { return true; } (bool _success, bool _found, uint256 _id) = getModuleIDByName(moduleName); @@ -289,7 +289,7 @@ contract moduleHandler is multiOwner, announcementTypes { require( _success ); if ( ! ( _found && modules[_id].name == keccak256('Publisher') )) { require( block.number < debugModeUntil ); - if ( ! insertAndCheckDo(calcDoHash("replaceModuleHandler", keccak256(newHandler))) ) { + if ( ! insertAndCheckDo(calcDoHash("replaceModuleHandler", keccak256(abi.encodePacked(newHandler)))) ) { return true; } } @@ -419,7 +419,7 @@ contract moduleHandler is multiOwner, announcementTypes { require( _success ); if ( ! ( _found && modules[_id].name == keccak256('Publisher') )) { require( block.number < debugModeUntil ); - if ( ! insertAndCheckDo(calcDoHash("configureModule", keccak256(moduleName, aType, value))) ) { + if ( ! insertAndCheckDo(calcDoHash("configureModule", keccak256(abi.encodePacked(moduleName, aType, value)))) ) { return true; } } @@ -437,7 +437,7 @@ contract moduleHandler is multiOwner, announcementTypes { */ require( owners[msg.sender] ); if ( forever ) { - if ( ! insertAndCheckDo(calcDoHash("freezing", keccak256(forever))) ) { + if ( ! insertAndCheckDo(calcDoHash("freezing", keccak256(abi.encodePacked(forever)))) ) { return; } } diff --git a/test/compilationTests/corion/multiOwner.sol b/test/compilationTests/corion/multiOwner.sol index b8436c8b..2b8a46b9 100644 --- a/test/compilationTests/corion/multiOwner.sol +++ b/test/compilationTests/corion/multiOwner.sol @@ -12,7 +12,7 @@ contract multiOwner is safeMath { /* Constructor */ - function multiOwner(address[] newOwners) { + constructor(address[] newOwners) { for ( uint256 a=0 ; a<newOwners.length ; a++ ) { _addOwner(newOwners[a]); } @@ -21,12 +21,12 @@ contract multiOwner is safeMath { Externals */ function insertOwner(address addr) external { - if ( insertAndCheckDo(calcDoHash("insertOwner", keccak256(addr))) ) { + if ( insertAndCheckDo(calcDoHash("insertOwner", keccak256(abi.encodePacked(addr)))) ) { _addOwner(addr); } } function dropOwner(address addr) external { - if ( insertAndCheckDo(calcDoHash("dropOwner", keccak256(addr))) ) { + if ( insertAndCheckDo(calcDoHash("dropOwner", keccak256(abi.encodePacked(addr)))) ) { _delOwner(addr); } } @@ -42,7 +42,7 @@ contract multiOwner is safeMath { return ownerCount * 75 / 100; } function calcDoHash(string job, bytes32 data) public constant returns (bytes32 hash) { - return keccak256(job, data); + return keccak256(abi.encodePacked(job, data)); } function validDoHash(bytes32 doHash) public constant returns (bool valid) { return doDB[doHash].length > 0; diff --git a/test/compilationTests/corion/owned.sol b/test/compilationTests/corion/owned.sol index bd187775..4a5ba673 100644 --- a/test/compilationTests/corion/owned.sol +++ b/test/compilationTests/corion/owned.sol @@ -20,7 +20,7 @@ contract ownedDB { @bool Owner has called the contract or not
*/
- if ( owner == 0x00 ) {
+ if ( owner == address(0x00) ) {
return true;
}
return owner == msg.sender;
diff --git a/test/compilationTests/corion/premium.sol b/test/compilationTests/corion/premium.sol index 2cf76088..5a80ecc6 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; - function premium(bool forReplace, address moduleHandler, address dbAddress, address icoContractAddr, address[] genesisAddr, uint256[] genesisValue) { + constructor(bool forReplace, address moduleHandler, address dbAddress, address icoContractAddr, address[] genesisAddr, uint256[] genesisValue) { /* Setup function. If an ICOaddress is defined then the balance of the genesis addresses will be set as well. @@ -53,7 +53,7 @@ contract premium is module, safeMath { @genesisValue Array of the balance of the genesis addresses */ super.registerModuleHandler(moduleHandler); - require( dbAddress != 0x00 ); + require( dbAddress != address(0x00) ); db = ptokenDB(dbAddress); if ( ! forReplace ) { require( db.replaceOwner(this) ); @@ -63,7 +63,7 @@ contract premium is module, safeMath { for ( uint256 a=0 ; a<genesisAddr.length ; a++ ) { genesis[genesisAddr[a]] = true; require( db.increase(genesisAddr[a], genesisValue[a]) ); - Mint(genesisAddr[a], genesisValue[a]); + emit Mint(genesisAddr[a], genesisValue[a]); } } } @@ -137,7 +137,7 @@ contract premium is module, safeMath { require( msg.sender != spender ); require( db.balanceOf(msg.sender) >= amount ); require( db.setAllowance(msg.sender, spender, amount, nonce) ); - Approval(msg.sender, spender, amount); + emit Approval(msg.sender, spender, amount); } function allowance(address owner, address spender) constant returns (uint256 remaining, uint256 nonce) { @@ -178,7 +178,7 @@ contract premium is module, safeMath { } else { _transfer(msg.sender, to, amount); } - Transfer(msg.sender, to, amount, _data); + emit Transfer(msg.sender, to, amount, _data); return true; } @@ -207,7 +207,7 @@ contract premium is module, safeMath { _reamining = safeSub(_reamining, amount); _nonce = safeAdd(_nonce, 1); require( db.setAllowance(from, msg.sender, _reamining, _nonce) ); - AllowanceUsed(msg.sender, from, amount); + emit AllowanceUsed(msg.sender, from, amount); } bytes memory _data; if ( isContract(to) ) { @@ -215,7 +215,7 @@ contract premium is module, safeMath { } else { _transfer( from, to, amount); } - Transfer(from, to, amount, _data); + emit Transfer(from, to, amount, _data); return true; } @@ -242,7 +242,7 @@ contract premium is module, safeMath { } else { _transfer( msg.sender, to, amount); } - Transfer(msg.sender, to, amount, extraData); + emit Transfer(msg.sender, to, amount, extraData); return true; } @@ -273,7 +273,7 @@ contract premium is module, safeMath { @to For who? @amount Amount */ - require( from != 0x00 && to != 0x00 && to != 0xa636a97578d26a3b76b060bbc18226d954cf3757 ); + require( from != address(0x00) && to != address(0x00) && to != 0xa636A97578d26A3b76B060Bbc18226d954cf3757 ); require( ( ! isICO) || genesis[from] ); require( db.decrease(from, amount) ); require( db.increase(to, amount) ); @@ -301,7 +301,7 @@ contract premium is module, safeMath { @value Amount */ require( db.increase(owner, value) ); - Mint(owner, value); + emit Mint(owner, value); } function isContract(address addr) internal returns (bool success) { diff --git a/test/compilationTests/corion/provider.sol b/test/compilationTests/corion/provider.sol index 2cdd760d..0c1f69e5 100644 --- a/test/compilationTests/corion/provider.sol +++ b/test/compilationTests/corion/provider.sol @@ -118,7 +118,7 @@ contract provider is module, safeMath, announcementTypes { uint256 private currentSchellingRound = 1; - function provider(address _moduleHandler) { + constructor(address _moduleHandler) { /* Install function. @@ -161,7 +161,7 @@ contract provider is module, safeMath, announcementTypes { if ( schellingRound == 0 ) { schellingRound = currentSchellingRound; } - if ( clients[addr].providerAddress != 0 ) { + if ( clients[addr].providerAddress != address(0x00) ) { ProviderAddress = clients[addr].providerAddress; ProviderHeight = clients[addr].providerHeight; ConnectedOn = clients[addr].providerConnected; @@ -233,7 +233,7 @@ contract provider is module, safeMath, announcementTypes { @admin The admin’s address */ require( ! providers[msg.sender].data[providers[msg.sender].currentHeight].valid ); - require( clients[msg.sender].providerAddress == 0x00 ); + require( clients[msg.sender].providerAddress == address(0x00) ); require( ! checkICO() ); if ( priv ) { require( getTokenBalance(msg.sender) >= minFundsForPrivate ); @@ -245,7 +245,7 @@ contract provider is module, safeMath, announcementTypes { providers[msg.sender].currentHeight++; uint256 currHeight = providers[msg.sender].currentHeight; providers[msg.sender].data[currHeight].valid = true; - if ( admin == 0x00 ) { + if ( admin == address(0x00) ) { providers[msg.sender].data[currHeight].admin = msg.sender; } else { providers[msg.sender].data[currHeight].admin = admin; @@ -268,7 +268,7 @@ contract provider is module, safeMath, announcementTypes { } else { delete providers[msg.sender].data[currHeight].supply[currentSchellingRound]; } - EProviderOpen(msg.sender, currHeight); + emit EProviderOpen(msg.sender, currHeight); } function setProviderDetails(address addr, string website, string country, string info, uint8 rate, address admin) isReady external { /* @@ -288,7 +288,7 @@ contract provider is module, safeMath, announcementTypes { require( providers[addr].data[currHeight].valid ); require( checkCorrectRate(providers[addr].data[currHeight].priv, rate) ); require( providers[addr].data[currHeight].admin == msg.sender || msg.sender == addr ); - if ( admin != 0x00 ) { + if ( admin != address(0x00) ) { require( msg.sender == addr ); providers[addr].data[currHeight].admin = admin; } @@ -297,7 +297,7 @@ contract provider is module, safeMath, announcementTypes { providers[addr].data[currHeight].country = country; providers[addr].data[currHeight].info = info; providers[addr].data[currHeight].currentRate = rate; - EProviderDetailsChanged(addr, currHeight, website, country, info, rate, admin); + emit EProviderDetailsChanged(addr, currHeight, website, country, info, rate, admin); } function getProviderInfo(address addr, uint256 height) public constant returns (string name, string website, string country, string info, uint256 create) { /* @@ -367,7 +367,7 @@ contract provider is module, safeMath, announcementTypes { providers[msg.sender].data[currHeight].valid = false; providers[msg.sender].data[currHeight].close = currentSchellingRound; setRightForInterest(getProviderCurrentSupply(msg.sender), 0, providers[msg.sender].data[currHeight].priv); - EProviderClose(msg.sender, currHeight); + emit EProviderClose(msg.sender, currHeight); } function allowUsers(address provider, address[] addr) isReady external { /* @@ -419,7 +419,7 @@ contract provider is module, safeMath, announcementTypes { */ uint256 currHeight = providers[provider].currentHeight; require( ! providers[msg.sender].data[currHeight].valid ); - require( clients[msg.sender].providerAddress == 0x00 ); + require( clients[msg.sender].providerAddress == address(0x00) ); require( providers[provider].data[currHeight].valid ); if ( providers[provider].data[currHeight].priv ) { require( providers[provider].data[currHeight].allowedUsers[msg.sender] && @@ -437,7 +437,7 @@ contract provider is module, safeMath, announcementTypes { clients[msg.sender].paidUpTo = currentSchellingRound; clients[msg.sender].lastRate = providers[provider].data[currHeight].currentRate; clients[msg.sender].providerConnected = now; - ENewClient(msg.sender, provider, currHeight, bal); + emit ENewClient(msg.sender, provider, currHeight, bal); } function partProvider() isReady external { /* @@ -446,7 +446,7 @@ contract provider is module, safeMath, announcementTypes { It is only possible to disconnect those providers who were connected by us before. */ address provider = clients[msg.sender].providerAddress; - require( provider != 0x0 ); + require( provider != address(0x00) ); uint256 currHeight = clients[msg.sender].providerHeight; bool providerHasClosed = false; if ( providers[provider].data[currHeight].close > 0 ) { @@ -467,7 +467,7 @@ contract provider is module, safeMath, announcementTypes { delete clients[msg.sender].paidUpTo; delete clients[msg.sender].lastRate; delete clients[msg.sender].providerConnected; - EClientLost(msg.sender, provider, currHeight, bal); + emit EClientLost(msg.sender, provider, currHeight, bal); } function checkReward(address addr) public constant returns (uint256 reward) { /* @@ -479,7 +479,7 @@ contract provider is module, safeMath, announcementTypes { if ( providers[addr].data[providers[addr].currentHeight].valid ) { uint256 a; (reward, a) = getProviderReward(addr, 0); - } else if ( clients[addr].providerAddress != 0x0 ) { + } else if ( clients[addr].providerAddress != address(0x00) ) { reward = getClientReward(0); } } @@ -504,14 +504,14 @@ contract provider is module, safeMath, announcementTypes { address _beneficiary = beneficiary; address _provider = provider; if ( _limit == 0 ) { _limit = gasProtectMaxRounds; } - if ( _beneficiary == 0x00 ) { _beneficiary = msg.sender; } - if ( _provider == 0x00 ) { _provider = msg.sender; } + if ( _beneficiary == address(0x00) ) { _beneficiary = msg.sender; } + if ( _provider == address(0x00) ) { _provider = msg.sender; } uint256 clientReward; uint256 providerReward; if ( providers[_provider].data[providers[_provider].currentHeight].valid ) { require( providers[_provider].data[providers[_provider].currentHeight].admin == msg.sender || msg.sender == _provider ); (providerReward, clientReward) = getProviderReward(_provider, _limit); - } else if ( clients[msg.sender].providerAddress != 0x00 ) { + } else if ( clients[msg.sender].providerAddress != address(0x00) ) { clientReward = getClientReward(_limit); } else { throw; @@ -522,7 +522,7 @@ contract provider is module, safeMath, announcementTypes { if ( providerReward > 0 ) { require( moduleHandler(moduleHandlerAddress).transfer(address(this), provider, providerReward, false) ); } - EReward(msg.sender, provider, clientReward, providerReward); + emit EReward(msg.sender, provider, clientReward, providerReward); } function getClientReward(uint256 limit) internal returns (uint256 reward) { /* @@ -745,7 +745,7 @@ contract provider is module, safeMath, announcementTypes { @value Rate of the change. @neg ype of the change. If it is TRUE then the balance has been decreased if it is FALSE then it has been increased. */ - if ( clients[addr].providerAddress != 0 ) { + if ( clients[addr].providerAddress != address(0x00) ) { checkFloatingSupply(clients[addr].providerAddress, providers[clients[addr].providerAddress].currentHeight, ! neg, value); if (clients[addr].lastSupplyID != currentSchellingRound) { clients[addr].supply[currentSchellingRound] = TEMath(clients[addr].supply[clients[addr].lastSupplyID], value, neg); diff --git a/test/compilationTests/corion/publisher.sol b/test/compilationTests/corion/publisher.sol index 98d5af2a..0e8f825f 100644 --- a/test/compilationTests/corion/publisher.sol +++ b/test/compilationTests/corion/publisher.sol @@ -61,7 +61,7 @@ contract publisher is announcementTypes, module, safeMath { mapping (address => uint256[]) public opponents;
- function publisher(address moduleHandler) {
+ constructor(address moduleHandler) {
/*
Installation function. The installer will be registered in the admin list automatically
@@ -148,7 +148,7 @@ contract publisher is announcementTypes, module, safeMath { announcements[announcementsLength]._str = _str;
announcements[announcementsLength]._uint = _uint;
announcements[announcementsLength]._addr = _addr;
- ENewAnnouncement(announcementsLength, Type);
+ emit ENewAnnouncement(announcementsLength, Type);
}
function closeAnnouncement(uint256 id) onlyOwner external {
@@ -238,7 +238,7 @@ contract publisher is announcementTypes, module, safeMath { opponents[msg.sender].push(id);
}
announcements[id].oppositionWeight += _balance;
- EOppositeAnnouncement(id, msg.sender, _balance);
+ emit EOppositeAnnouncement(id, msg.sender, _balance);
}
function invalidateAnnouncement(uint256 id) onlyOwner external {
@@ -250,7 +250,7 @@ contract publisher is announcementTypes, module, safeMath { require( announcements[id].open );
announcements[id].end = block.number;
announcements[id].open = false;
- EInvalidateAnnouncement(id);
+ emit EInvalidateAnnouncement(id);
}
modifier onlyOwner() {
diff --git a/test/compilationTests/corion/schelling.sol b/test/compilationTests/corion/schelling.sol index 8f38ec64..f8c36fc5 100644 --- a/test/compilationTests/corion/schelling.sol +++ b/test/compilationTests/corion/schelling.sol @@ -37,7 +37,7 @@ contract schellingDB is safeMath, schellingVars { */ address private owner; function replaceOwner(address newOwner) external returns(bool) { - require( owner == 0x00 || msg.sender == owner ); + require( owner == address(0x00) || msg.sender == owner ); owner = newOwner; return true; } @@ -45,7 +45,7 @@ contract schellingDB is safeMath, schellingVars { /* Constructor */ - function schellingDB() { + constructor() { rounds.length = 2; rounds[0].blockHeight = block.number; currentSchellingRound = 1; @@ -247,7 +247,7 @@ contract schelling is module, announcementTypes, schellingVars { bytes1 public belowChar = 0x30; schellingDB private db; - function schelling(address _moduleHandler, address _db, bool _forReplace) { + constructor(address _moduleHandler, address _db, bool _forReplace) { /* Installation function. @@ -335,7 +335,7 @@ contract schelling is module, announcementTypes, schellingVars { require( voter.status == voterStatus.afterPrepareVote ); require( voter.roundID < currentRound ); - if ( keccak256(vote) == voter.hash ) { + if ( keccak256(bytes(vote)) == voter.hash ) { delete voter.hash; if (round.blockHeight+roundBlockDelay/2 >= block.number) { if ( bytes(vote)[0] == aboveChar ) { @@ -407,7 +407,7 @@ contract schelling is module, announcementTypes, schellingVars { uint256 funds = getFunds(msg.sender); address _beneficiary = msg.sender; - if (beneficiary != 0x0) { _beneficiary = beneficiary; } + if (beneficiary != address(0x00)) { _beneficiary = beneficiary; } uint256 reward; require( voter.rewards > 0 ); require( voter.status == voterStatus.base ); diff --git a/test/compilationTests/corion/token.sol b/test/compilationTests/corion/token.sol index 3a6a4598..0709baca 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; - function token(bool forReplace, address moduleHandler, address dbAddr, address icoContractAddr, address exchangeContractAddress, address[] genesisAddr, uint256[] genesisValue) payable { + constructor(bool forReplace, address moduleHandler, address dbAddr, address icoContractAddr, address exchangeContractAddress, address[] genesisAddr, uint256[] genesisValue) payable { /* Installation function @@ -63,9 +63,9 @@ contract token is safeMath, module, announcementTypes { @genesisValue Array of balance of genesis addresses */ super.registerModuleHandler(moduleHandler); - require( dbAddr != 0x00 ); - require( icoContractAddr != 0x00 ); - require( exchangeContractAddress != 0x00 ); + require( dbAddr != address(0x00) ); + require( icoContractAddr != address(0x00) ); + require( exchangeContractAddress != address(0x00) ); db = tokenDB(dbAddr); icoAddr = icoContractAddr; exchangeAddress = exchangeContractAddress; @@ -78,7 +78,7 @@ contract token is safeMath, module, announcementTypes { genesis[genesisAddr[a]] = true; require( db.increase(genesisAddr[a], genesisValue[a]) ); if ( ! genesisAddr[a].send(0.2 ether) ) {} - Mint(genesisAddr[a], genesisValue[a]); + emit Mint(genesisAddr[a], genesisValue[a]); } } } @@ -152,7 +152,7 @@ contract token is safeMath, module, announcementTypes { require( msg.sender != spender ); require( db.balanceOf(msg.sender) >= amount ); require( db.setAllowance(msg.sender, spender, amount, nonce) ); - Approval(msg.sender, spender, amount); + emit Approval(msg.sender, spender, amount); } function allowance(address owner, address spender) constant returns (uint256 remaining, uint256 nonce) { @@ -193,7 +193,7 @@ contract token is safeMath, module, announcementTypes { } else { _transfer( msg.sender, to, amount, true); } - Transfer(msg.sender, to, amount, _data); + emit Transfer(msg.sender, to, amount, _data); return true; } @@ -222,7 +222,7 @@ contract token is safeMath, module, announcementTypes { _reamining = safeSub(_reamining, amount); _nonce = safeAdd(_nonce, 1); require( db.setAllowance(from, msg.sender, _reamining, _nonce) ); - AllowanceUsed(msg.sender, from, amount); + emit AllowanceUsed(msg.sender, from, amount); } bytes memory _data; if ( isContract(to) ) { @@ -230,7 +230,7 @@ contract token is safeMath, module, announcementTypes { } else { _transfer( from, to, amount, true); } - Transfer(from, to, amount, _data); + emit Transfer(from, to, amount, _data); return true; } @@ -256,7 +256,7 @@ contract token is safeMath, module, announcementTypes { bytes memory _data; require( super.isModuleHandler(msg.sender) ); _transfer( from, to, amount, fee); - Transfer(from, to, amount, _data); + emit Transfer(from, to, amount, _data); return true; } @@ -284,7 +284,7 @@ contract token is safeMath, module, announcementTypes { } else { _transfer( msg.sender, to, amount, true); } - Transfer(msg.sender, to, amount, extraData); + emit Transfer(msg.sender, to, amount, extraData); return true; } @@ -325,7 +325,7 @@ contract token is safeMath, module, announcementTypes { require( success ); require( db.balanceOf(from) >= amount + _fee ); } - require( from != 0x00 && to != 0x00 && to != 0xa636a97578d26a3b76b060bbc18226d954cf3757 ); + require( from != address(0x00) && to != address(0x00) && to != 0xa636A97578d26A3b76B060Bbc18226d954cf3757 ); require( ( ! isICO) || genesis[from] ); require( db.decrease(from, amount) ); require( db.increase(to, amount) ); @@ -374,12 +374,12 @@ contract token is safeMath, module, announcementTypes { address _schellingAddr; (_success, _found, _schellingAddr) = moduleHandler(moduleHandlerAddress).getModuleAddressByName('Schelling'); require( _success ); - if ( _schellingAddr != 0x00 && _found) { + if ( _schellingAddr != address(0x00) && _found) { require( db.decrease(owner, _forSchelling) ); require( db.increase(_schellingAddr, _forSchelling) ); _burn(owner, _forBurn); bytes memory _data; - Transfer(owner, _schellingAddr, _forSchelling, _data); + emit Transfer(owner, _schellingAddr, _forSchelling, _data); require( moduleHandler(moduleHandlerAddress).broadcastTransfer(owner, _schellingAddr, _forSchelling) ); } else { _burn(owner, _fee); @@ -424,11 +424,11 @@ contract token is safeMath, module, announcementTypes { @value Quantity */ require( db.increase(owner, value) ); - require( moduleHandler(moduleHandlerAddress).broadcastTransfer(0x00, owner, value) ); + require( moduleHandler(moduleHandlerAddress).broadcastTransfer(address(0x00), owner, value) ); if ( isICO ) { require( ico(icoAddr).setInterestDB(owner, db.balanceOf(owner)) ); } - Mint(owner, value); + emit Mint(owner, value); } function burn(address owner, uint256 value) isReady external returns (bool success) { @@ -453,8 +453,8 @@ contract token is safeMath, module, announcementTypes { @value Quantity */ require( db.decrease(owner, value) ); - require( moduleHandler(moduleHandlerAddress).broadcastTransfer(owner, 0x00, value) ); - Burn(owner, value); + require( moduleHandler(moduleHandlerAddress).broadcastTransfer(owner, address(0x00), value) ); + emit Burn(owner, value); } function isContract(address addr) internal returns (bool success) { diff --git a/test/compilationTests/gnosis/Events/CategoricalEvent.sol b/test/compilationTests/gnosis/Events/CategoricalEvent.sol index fbd1d744..0f5196e8 100644 --- a/test/compilationTests/gnosis/Events/CategoricalEvent.sol +++ b/test/compilationTests/gnosis/Events/CategoricalEvent.sol @@ -13,7 +13,7 @@ contract CategoricalEvent is Event { /// @param _collateralToken Tokens used as collateral in exchange for outcome tokens /// @param _oracle Oracle contract used to resolve the event /// @param outcomeCount Number of event outcomes - function CategoricalEvent( + constructor( Token _collateralToken, Oracle _oracle, uint8 outcomeCount @@ -38,7 +38,7 @@ contract CategoricalEvent is Event { outcomeTokens[uint(outcome)].revoke(msg.sender, winnings); // Payout winnings require(collateralToken.transfer(msg.sender, winnings)); - WinningsRedemption(msg.sender, winnings); + emit WinningsRedemption(msg.sender, winnings); } /// @dev Calculates and returns event hash @@ -48,6 +48,6 @@ contract CategoricalEvent is Event { constant returns (bytes32) { - return keccak256(collateralToken, oracle, outcomeTokens.length); + return keccak256(abi.encodePacked(collateralToken, oracle, outcomeTokens.length)); } } diff --git a/test/compilationTests/gnosis/Events/Event.sol b/test/compilationTests/gnosis/Events/Event.sol index 9aa257c4..a6edb778 100644 --- a/test/compilationTests/gnosis/Events/Event.sol +++ b/test/compilationTests/gnosis/Events/Event.sol @@ -33,18 +33,18 @@ contract Event { /// @param _collateralToken Tokens used as collateral in exchange for outcome tokens /// @param _oracle Oracle contract used to resolve the event /// @param outcomeCount Number of event outcomes - function Event(Token _collateralToken, Oracle _oracle, uint8 outcomeCount) + constructor(Token _collateralToken, Oracle _oracle, uint8 outcomeCount) public { // Validate input - require(address(_collateralToken) != 0 && address(_oracle) != 0 && outcomeCount >= 2); + require(address(_collateralToken) != address(0) && address(_oracle) != address(0) && outcomeCount >= 2); collateralToken = _collateralToken; oracle = _oracle; // Create an outcome token for each outcome for (uint8 i = 0; i < outcomeCount; i++) { OutcomeToken outcomeToken = new OutcomeToken(); outcomeTokens.push(outcomeToken); - OutcomeTokenCreation(outcomeToken, i); + emit OutcomeTokenCreation(outcomeToken, i); } } @@ -58,7 +58,7 @@ contract Event { // Issue new outcome tokens to sender for (uint8 i = 0; i < outcomeTokens.length; i++) outcomeTokens[i].issue(msg.sender, collateralTokenCount); - OutcomeTokenSetIssuance(msg.sender, collateralTokenCount); + emit OutcomeTokenSetIssuance(msg.sender, collateralTokenCount); } /// @dev Sells equal number of tokens of all outcomes, exchanging collateral tokens and sets of outcome tokens 1:1 @@ -71,7 +71,7 @@ contract Event { outcomeTokens[i].revoke(msg.sender, outcomeTokenCount); // Transfer collateral tokens to sender require(collateralToken.transfer(msg.sender, outcomeTokenCount)); - OutcomeTokenSetRevocation(msg.sender, outcomeTokenCount); + emit OutcomeTokenSetRevocation(msg.sender, outcomeTokenCount); } /// @dev Sets winning event outcome @@ -83,7 +83,7 @@ contract Event { // Set winning outcome outcome = oracle.getOutcome(); isOutcomeSet = true; - OutcomeAssignment(outcome); + emit OutcomeAssignment(outcome); } /// @dev Returns outcome count diff --git a/test/compilationTests/gnosis/Events/EventFactory.sol b/test/compilationTests/gnosis/Events/EventFactory.sol index dfb1a579..cfe772ec 100644 --- a/test/compilationTests/gnosis/Events/EventFactory.sol +++ b/test/compilationTests/gnosis/Events/EventFactory.sol @@ -35,9 +35,9 @@ contract EventFactory { public returns (CategoricalEvent eventContract) { - bytes32 eventHash = keccak256(collateralToken, oracle, outcomeCount); + bytes32 eventHash = keccak256(abi.encodePacked(collateralToken, oracle, outcomeCount)); // Event should not exist yet - require(address(categoricalEvents[eventHash]) == 0); + require(address(categoricalEvents[eventHash]) == address(0)); // Create event eventContract = new CategoricalEvent( collateralToken, @@ -45,7 +45,7 @@ contract EventFactory { outcomeCount ); categoricalEvents[eventHash] = eventContract; - CategoricalEventCreation(msg.sender, eventContract, collateralToken, oracle, outcomeCount); + emit CategoricalEventCreation(msg.sender, eventContract, collateralToken, oracle, outcomeCount); } /// @dev Creates a new scalar event and adds it to the event mapping @@ -63,9 +63,9 @@ contract EventFactory { public returns (ScalarEvent eventContract) { - bytes32 eventHash = keccak256(collateralToken, oracle, lowerBound, upperBound); + bytes32 eventHash = keccak256(abi.encodePacked(collateralToken, oracle, lowerBound, upperBound)); // Event should not exist yet - require(address(scalarEvents[eventHash]) == 0); + require(address(scalarEvents[eventHash]) == address(0)); // Create event eventContract = new ScalarEvent( collateralToken, @@ -74,6 +74,6 @@ contract EventFactory { upperBound ); scalarEvents[eventHash] = eventContract; - ScalarEventCreation(msg.sender, eventContract, collateralToken, oracle, lowerBound, upperBound); + emit ScalarEventCreation(msg.sender, eventContract, collateralToken, oracle, lowerBound, upperBound); } } diff --git a/test/compilationTests/gnosis/Events/ScalarEvent.sol b/test/compilationTests/gnosis/Events/ScalarEvent.sol index 2e5718ef..d5cbef14 100644 --- a/test/compilationTests/gnosis/Events/ScalarEvent.sol +++ b/test/compilationTests/gnosis/Events/ScalarEvent.sol @@ -28,7 +28,7 @@ contract ScalarEvent is Event { /// @param _oracle Oracle contract used to resolve the event /// @param _lowerBound Lower bound for event outcome /// @param _upperBound Lower bound for event outcome - function ScalarEvent( + constructor( Token _collateralToken, Oracle _oracle, int _lowerBound, @@ -72,7 +72,7 @@ contract ScalarEvent is Event { outcomeTokens[LONG].revoke(msg.sender, longOutcomeTokenCount); // Payout winnings to sender require(collateralToken.transfer(msg.sender, winnings)); - WinningsRedemption(msg.sender, winnings); + emit WinningsRedemption(msg.sender, winnings); } /// @dev Calculates and returns event hash @@ -82,6 +82,6 @@ contract ScalarEvent is Event { constant returns (bytes32) { - return keccak256(collateralToken, oracle, lowerBound, upperBound); + return keccak256(abi.encodePacked(collateralToken, oracle, lowerBound, upperBound)); } } diff --git a/test/compilationTests/gnosis/Markets/Campaign.sol b/test/compilationTests/gnosis/Markets/Campaign.sol index 9aee1033..f99ede53 100644 --- a/test/compilationTests/gnosis/Markets/Campaign.sol +++ b/test/compilationTests/gnosis/Markets/Campaign.sol @@ -70,7 +70,7 @@ contract Campaign { /// @param _fee Market fee /// @param _funding Initial funding for market /// @param _deadline Campaign deadline - function Campaign( + constructor( Event _eventContract, MarketFactory _marketFactory, MarketMaker _marketMaker, @@ -81,9 +81,9 @@ contract Campaign { public { // Validate input - require( address(_eventContract) != 0 - && address(_marketFactory) != 0 - && address(_marketMaker) != 0 + require( address(_eventContract) != address(0) + && address(_marketFactory) != address(0) + && address(_marketMaker) != address(0) && _fee < FEE_RANGE && _funding > 0 && now < _deadline); @@ -111,7 +111,7 @@ contract Campaign { contributions[msg.sender] = contributions[msg.sender].add(amount); if (amount == maxAmount) stage = Stages.AuctionSuccessful; - CampaignFunding(msg.sender, amount); + emit CampaignFunding(msg.sender, amount); } /// @dev Withdraws refund amount @@ -126,7 +126,7 @@ contract Campaign { contributions[msg.sender] = 0; // Refund collateral tokens require(eventContract.collateralToken().transfer(msg.sender, refundAmount)); - CampaignRefund(msg.sender, refundAmount); + emit CampaignRefund(msg.sender, refundAmount); } /// @dev Allows to create market after successful funding @@ -141,7 +141,7 @@ contract Campaign { require(eventContract.collateralToken().approve(market, funding)); market.fund(funding); stage = Stages.MarketCreated; - MarketCreation(market); + emit MarketCreation(market); return market; } @@ -158,7 +158,7 @@ contract Campaign { eventContract.redeemWinnings(); finalBalance = eventContract.collateralToken().balanceOf(this); stage = Stages.MarketClosed; - MarketClosing(); + emit MarketClosing(); } /// @dev Allows to withdraw fees from campaign contract to contributor @@ -172,6 +172,6 @@ contract Campaign { contributions[msg.sender] = 0; // Send fee share to contributor require(eventContract.collateralToken().transfer(msg.sender, fees)); - FeeWithdrawal(msg.sender, fees); + emit FeeWithdrawal(msg.sender, fees); } } diff --git a/test/compilationTests/gnosis/Markets/CampaignFactory.sol b/test/compilationTests/gnosis/Markets/CampaignFactory.sol index 930ec2e2..d80d7d63 100644 --- a/test/compilationTests/gnosis/Markets/CampaignFactory.sol +++ b/test/compilationTests/gnosis/Markets/CampaignFactory.sol @@ -34,6 +34,6 @@ contract CampaignFactory { returns (Campaign campaign) { campaign = new Campaign(eventContract, marketFactory, marketMaker, fee, funding, deadline); - CampaignCreation(msg.sender, campaign, eventContract, marketFactory, marketMaker, fee, funding, deadline); + emit CampaignCreation(msg.sender, campaign, eventContract, marketFactory, marketMaker, fee, funding, deadline); } } diff --git a/test/compilationTests/gnosis/Markets/StandardMarket.sol b/test/compilationTests/gnosis/Markets/StandardMarket.sol index b973119a..84f30386 100644 --- a/test/compilationTests/gnosis/Markets/StandardMarket.sol +++ b/test/compilationTests/gnosis/Markets/StandardMarket.sol @@ -38,11 +38,11 @@ contract StandardMarket is Market { /// @param _eventContract Event contract /// @param _marketMaker Market maker contract /// @param _fee Market fee - function StandardMarket(address _creator, Event _eventContract, MarketMaker _marketMaker, uint24 _fee) + constructor(address _creator, Event _eventContract, MarketMaker _marketMaker, uint24 _fee) public { // Validate inputs - require(address(_eventContract) != 0 && address(_marketMaker) != 0 && _fee < FEE_RANGE); + require(address(_eventContract) != address(0) && address(_marketMaker) != address(0) && _fee < FEE_RANGE); creator = _creator; createdAtBlock = block.number; eventContract = _eventContract; @@ -65,7 +65,7 @@ contract StandardMarket is Market { eventContract.buyAllOutcomes(_funding); funding = _funding; stage = Stages.MarketFunded; - MarketFunding(funding); + emit MarketFunding(funding); } /// @dev Allows market creator to close the markets by transferring all remaining outcome tokens to the creator @@ -78,7 +78,7 @@ contract StandardMarket is Market { for (uint8 i = 0; i < outcomeCount; i++) require(eventContract.outcomeTokens(i).transfer(creator, eventContract.outcomeTokens(i).balanceOf(this))); stage = Stages.MarketClosed; - MarketClosing(); + emit MarketClosing(); } /// @dev Allows market creator to withdraw fees generated by trades @@ -91,7 +91,7 @@ contract StandardMarket is Market { fees = eventContract.collateralToken().balanceOf(this); // Transfer fees require(eventContract.collateralToken().transfer(creator, fees)); - FeeWithdrawal(fees); + emit FeeWithdrawal(fees); } /// @dev Allows to buy outcome tokens from market maker @@ -121,7 +121,7 @@ contract StandardMarket is Market { // Add outcome token count to market maker net balance require(int(outcomeTokenCount) >= 0); netOutcomeTokensSold[outcomeTokenIndex] = netOutcomeTokensSold[outcomeTokenIndex].add(int(outcomeTokenCount)); - OutcomeTokenPurchase(msg.sender, outcomeTokenIndex, outcomeTokenCount, cost); + emit OutcomeTokenPurchase(msg.sender, outcomeTokenIndex, outcomeTokenCount, cost); } /// @dev Allows to sell outcome tokens to market maker @@ -150,7 +150,7 @@ contract StandardMarket is Market { // Subtract outcome token count from market maker net balance require(int(outcomeTokenCount) >= 0); netOutcomeTokensSold[outcomeTokenIndex] = netOutcomeTokensSold[outcomeTokenIndex].sub(int(outcomeTokenCount)); - OutcomeTokenSale(msg.sender, outcomeTokenIndex, outcomeTokenCount, profit); + emit OutcomeTokenSale(msg.sender, outcomeTokenIndex, outcomeTokenCount, profit); } /// @dev Buys all outcomes, then sells all shares of selected outcome which were bought, keeping @@ -178,7 +178,7 @@ contract StandardMarket is Market { require(eventContract.outcomeTokens(i).transfer(msg.sender, outcomeTokenCount)); // Send change back to buyer require(eventContract.collateralToken().transfer(msg.sender, profit)); - OutcomeTokenShortSale(msg.sender, outcomeTokenIndex, outcomeTokenCount, cost); + emit OutcomeTokenShortSale(msg.sender, outcomeTokenIndex, outcomeTokenCount, cost); } /// @dev Calculates fee to be paid to market maker diff --git a/test/compilationTests/gnosis/Markets/StandardMarketFactory.sol b/test/compilationTests/gnosis/Markets/StandardMarketFactory.sol index 101c37a2..88dcbe79 100644 --- a/test/compilationTests/gnosis/Markets/StandardMarketFactory.sol +++ b/test/compilationTests/gnosis/Markets/StandardMarketFactory.sol @@ -20,6 +20,6 @@ contract StandardMarketFactory is MarketFactory { returns (Market market) { market = new StandardMarket(msg.sender, eventContract, marketMaker, fee); - MarketCreation(msg.sender, market, eventContract, marketMaker, fee); + emit MarketCreation(msg.sender, market, eventContract, marketMaker, fee); } } diff --git a/test/compilationTests/gnosis/Migrations.sol b/test/compilationTests/gnosis/Migrations.sol index 7e7fe8d4..c7d09bd2 100644 --- a/test/compilationTests/gnosis/Migrations.sol +++ b/test/compilationTests/gnosis/Migrations.sol @@ -8,7 +8,7 @@ contract Migrations { if (msg.sender == owner) _; } - function Migrations() { + constructor() { owner = msg.sender; } diff --git a/test/compilationTests/gnosis/Oracles/CentralizedOracle.sol b/test/compilationTests/gnosis/Oracles/CentralizedOracle.sol index 26acf526..362c514c 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 - function CentralizedOracle(address _owner, bytes _ipfsHash) + constructor(address _owner, bytes _ipfsHash) public { // Description hash cannot be null @@ -52,7 +52,7 @@ contract CentralizedOracle is Oracle { // Result is not set yet require(!isSet); owner = newOwner; - OwnerReplacement(newOwner); + emit OwnerReplacement(newOwner); } /// @dev Sets event outcome @@ -65,7 +65,7 @@ contract CentralizedOracle is Oracle { require(!isSet); isSet = true; outcome = _outcome; - OutcomeAssignment(_outcome); + emit OutcomeAssignment(_outcome); } /// @dev Returns if winning outcome is set diff --git a/test/compilationTests/gnosis/Oracles/CentralizedOracleFactory.sol b/test/compilationTests/gnosis/Oracles/CentralizedOracleFactory.sol index 62a12cf4..ca4e37d2 100644 --- a/test/compilationTests/gnosis/Oracles/CentralizedOracleFactory.sol +++ b/test/compilationTests/gnosis/Oracles/CentralizedOracleFactory.sol @@ -22,6 +22,6 @@ contract CentralizedOracleFactory { returns (CentralizedOracle centralizedOracle) { centralizedOracle = new CentralizedOracle(msg.sender, ipfsHash); - CentralizedOracleCreation(msg.sender, centralizedOracle, ipfsHash); + emit CentralizedOracleCreation(msg.sender, centralizedOracle, ipfsHash); } } diff --git a/test/compilationTests/gnosis/Oracles/DifficultyOracle.sol b/test/compilationTests/gnosis/Oracles/DifficultyOracle.sol index 87351dfa..94fc70ca 100644 --- a/test/compilationTests/gnosis/Oracles/DifficultyOracle.sol +++ b/test/compilationTests/gnosis/Oracles/DifficultyOracle.sol @@ -22,7 +22,7 @@ contract DifficultyOracle is Oracle { */ /// @dev Contract constructor validates and sets target block number /// @param _blockNumber Target block number - function DifficultyOracle(uint _blockNumber) + constructor(uint _blockNumber) public { // Block has to be in the future @@ -37,7 +37,7 @@ contract DifficultyOracle is Oracle { // Block number was reached and outcome was not set yet require(block.number >= blockNumber && difficulty == 0); difficulty = block.difficulty; - OutcomeAssignment(difficulty); + emit OutcomeAssignment(difficulty); } /// @dev Returns if difficulty is set diff --git a/test/compilationTests/gnosis/Oracles/DifficultyOracleFactory.sol b/test/compilationTests/gnosis/Oracles/DifficultyOracleFactory.sol index 2e97362c..fc5dcc3b 100644 --- a/test/compilationTests/gnosis/Oracles/DifficultyOracleFactory.sol +++ b/test/compilationTests/gnosis/Oracles/DifficultyOracleFactory.sol @@ -22,6 +22,6 @@ contract DifficultyOracleFactory { returns (DifficultyOracle difficultyOracle) { difficultyOracle = new DifficultyOracle(blockNumber); - DifficultyOracleCreation(msg.sender, difficultyOracle, blockNumber); + emit DifficultyOracleCreation(msg.sender, difficultyOracle, blockNumber); } } diff --git a/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol b/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol index 524103d8..7105f247 100644 --- a/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol +++ b/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol @@ -55,7 +55,7 @@ contract FutarchyOracle is Oracle { /// @param marketMaker Market maker contract /// @param fee Market fee /// @param _deadline Decision deadline - function FutarchyOracle( + constructor( address _creator, EventFactory eventFactory, Token collateralToken, @@ -105,7 +105,7 @@ contract FutarchyOracle is Oracle { require(market.eventContract().collateralToken().approve(market, funding)); market.fund(funding); } - FutarchyFunding(funding); + emit FutarchyFunding(funding); } /// @dev Closes market for winning outcome and redeems winnings and sends all collateral tokens to creator @@ -123,7 +123,7 @@ contract FutarchyOracle is Oracle { // Redeem collateral token for winning outcome tokens and transfer collateral tokens to creator categoricalEvent.redeemWinnings(); require(categoricalEvent.collateralToken().transfer(creator, categoricalEvent.collateralToken().balanceOf(this))); - FutarchyClosing(); + emit FutarchyClosing(); } /// @dev Allows to set the oracle outcome based on the market with largest long position @@ -144,7 +144,7 @@ contract FutarchyOracle is Oracle { } winningMarketIndex = highestIndex; isSet = true; - OutcomeAssignment(winningMarketIndex); + emit OutcomeAssignment(winningMarketIndex); } /// @dev Returns if winning outcome is set diff --git a/test/compilationTests/gnosis/Oracles/FutarchyOracleFactory.sol b/test/compilationTests/gnosis/Oracles/FutarchyOracleFactory.sol index 62eab4f0..3c6e5c15 100644 --- a/test/compilationTests/gnosis/Oracles/FutarchyOracleFactory.sol +++ b/test/compilationTests/gnosis/Oracles/FutarchyOracleFactory.sol @@ -33,10 +33,10 @@ contract FutarchyOracleFactory { */ /// @dev Constructor sets event factory contract /// @param _eventFactory Event factory contract - function FutarchyOracleFactory(EventFactory _eventFactory) + constructor(EventFactory _eventFactory) public { - require(address(_eventFactory) != 0); + require(address(_eventFactory) != address(0)); eventFactory = _eventFactory; } @@ -78,7 +78,7 @@ contract FutarchyOracleFactory { fee, deadline ); - FutarchyOracleCreation( + emit FutarchyOracleCreation( msg.sender, futarchyOracle, collateralToken, diff --git a/test/compilationTests/gnosis/Oracles/MajorityOracle.sol b/test/compilationTests/gnosis/Oracles/MajorityOracle.sol index 4b02c2de..24cf9dea 100644 --- a/test/compilationTests/gnosis/Oracles/MajorityOracle.sol +++ b/test/compilationTests/gnosis/Oracles/MajorityOracle.sol @@ -16,14 +16,14 @@ 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 - function MajorityOracle(Oracle[] _oracles) + constructor(Oracle[] _oracles) public { // At least 2 oracles should be defined require(_oracles.length > 2); for (uint i = 0; i < _oracles.length; i++) // Oracle address cannot be null - require(address(_oracles[i]) != 0); + require(address(_oracles[i]) != address(0)); oracles = _oracles; } diff --git a/test/compilationTests/gnosis/Oracles/MajorityOracleFactory.sol b/test/compilationTests/gnosis/Oracles/MajorityOracleFactory.sol index 0024516a..3c02fef4 100644 --- a/test/compilationTests/gnosis/Oracles/MajorityOracleFactory.sol +++ b/test/compilationTests/gnosis/Oracles/MajorityOracleFactory.sol @@ -22,6 +22,6 @@ contract MajorityOracleFactory { returns (MajorityOracle majorityOracle) { majorityOracle = new MajorityOracle(oracles); - MajorityOracleCreation(msg.sender, majorityOracle, oracles); + emit MajorityOracleCreation(msg.sender, majorityOracle, oracles); } } diff --git a/test/compilationTests/gnosis/Oracles/SignedMessageOracle.sol b/test/compilationTests/gnosis/Oracles/SignedMessageOracle.sol index d541ab46..121824ff 100644 --- a/test/compilationTests/gnosis/Oracles/SignedMessageOracle.sol +++ b/test/compilationTests/gnosis/Oracles/SignedMessageOracle.sol @@ -38,7 +38,7 @@ contract SignedMessageOracle is Oracle { /// @param v Signature parameter /// @param r Signature parameter /// @param s Signature parameter - function SignedMessageOracle(bytes32 _descriptionHash, uint8 v, bytes32 r, bytes32 s) + constructor(bytes32 _descriptionHash, uint8 v, bytes32 r, bytes32 s) public { signer = ecrecover(_descriptionHash, v, r, s); @@ -58,10 +58,10 @@ contract SignedMessageOracle is Oracle { // Result is not set yet and nonce and signer are valid require( !isSet && _nonce > nonce - && signer == ecrecover(keccak256(descriptionHash, newSigner, _nonce), v, r, s)); + && signer == ecrecover(keccak256(abi.encodePacked(descriptionHash, newSigner, _nonce)), v, r, s)); nonce = _nonce; signer = newSigner; - SignerReplacement(newSigner); + emit SignerReplacement(newSigner); } /// @dev Sets outcome based on signed message @@ -74,10 +74,10 @@ contract SignedMessageOracle is Oracle { { // Result is not set yet and signer is valid require( !isSet - && signer == ecrecover(keccak256(descriptionHash, _outcome), v, r, s)); + && signer == ecrecover(keccak256(abi.encodePacked(descriptionHash, _outcome)), v, r, s)); isSet = true; outcome = _outcome; - OutcomeAssignment(_outcome); + emit OutcomeAssignment(_outcome); } /// @dev Returns if winning outcome diff --git a/test/compilationTests/gnosis/Oracles/SignedMessageOracleFactory.sol b/test/compilationTests/gnosis/Oracles/SignedMessageOracleFactory.sol index 0884d8ca..ea70b2aa 100644 --- a/test/compilationTests/gnosis/Oracles/SignedMessageOracleFactory.sol +++ b/test/compilationTests/gnosis/Oracles/SignedMessageOracleFactory.sol @@ -26,6 +26,6 @@ contract SignedMessageOracleFactory { { signedMessageOracle = new SignedMessageOracle(descriptionHash, v, r, s); address oracle = ecrecover(descriptionHash, v, r, s); - SignedMessageOracleCreation(msg.sender, signedMessageOracle, oracle); + emit SignedMessageOracleCreation(msg.sender, signedMessageOracle, oracle); } } diff --git a/test/compilationTests/gnosis/Oracles/UltimateOracle.sol b/test/compilationTests/gnosis/Oracles/UltimateOracle.sol index fe8b4ec7..dd66c9ab 100644 --- a/test/compilationTests/gnosis/Oracles/UltimateOracle.sol +++ b/test/compilationTests/gnosis/Oracles/UltimateOracle.sol @@ -46,7 +46,7 @@ contract UltimateOracle is Oracle { /// @param _challengePeriod Time to challenge oracle outcome /// @param _challengeAmount Amount to challenge the outcome /// @param _frontRunnerPeriod Time to overbid the front-runner - function UltimateOracle( + constructor( Oracle _forwardedOracle, Token _collateralToken, uint8 _spreadMultiplier, @@ -57,8 +57,8 @@ contract UltimateOracle is Oracle { public { // Validate inputs - require( address(_forwardedOracle) != 0 - && address(_collateralToken) != 0 + require( address(_forwardedOracle) != address(0) + && address(_collateralToken) != address(0) && _spreadMultiplier >= 2 && _challengePeriod > 0 && _challengeAmount > 0 @@ -81,7 +81,7 @@ contract UltimateOracle is Oracle { && forwardedOracle.isOutcomeSet()); forwardedOutcome = forwardedOracle.getOutcome(); forwardedOutcomeSetTimestamp = now; - ForwardedOracleOutcomeAssignment(forwardedOutcome); + emit ForwardedOracleOutcomeAssignment(forwardedOutcome); } /// @dev Allows to challenge the oracle outcome @@ -98,7 +98,7 @@ contract UltimateOracle is Oracle { totalAmount = challengeAmount; frontRunner = _outcome; frontRunnerSetTimestamp = now; - OutcomeChallenge(msg.sender, _outcome); + emit OutcomeChallenge(msg.sender, _outcome); } /// @dev Allows to challenge the oracle outcome @@ -122,7 +122,7 @@ contract UltimateOracle is Oracle { frontRunner = _outcome; frontRunnerSetTimestamp = now; } - OutcomeVote(msg.sender, _outcome, amount); + emit OutcomeVote(msg.sender, _outcome, amount); } /// @dev Withdraws winnings for user @@ -137,7 +137,7 @@ contract UltimateOracle is Oracle { outcomeAmounts[msg.sender][frontRunner] = 0; // Transfer earnings to contributor require(collateralToken.transfer(msg.sender, amount)); - Withdrawal(msg.sender, amount); + emit Withdrawal(msg.sender, amount); } /// @dev Checks if time to challenge the outcome is over diff --git a/test/compilationTests/gnosis/Oracles/UltimateOracleFactory.sol b/test/compilationTests/gnosis/Oracles/UltimateOracleFactory.sol index 67f8a96e..51f5610e 100644 --- a/test/compilationTests/gnosis/Oracles/UltimateOracleFactory.sol +++ b/test/compilationTests/gnosis/Oracles/UltimateOracleFactory.sol @@ -50,7 +50,7 @@ contract UltimateOracleFactory { challengeAmount, frontRunnerPeriod ); - UltimateOracleCreation( + emit UltimateOracleCreation( msg.sender, ultimateOracle, oracle, diff --git a/test/compilationTests/gnosis/Tokens/EtherToken.sol b/test/compilationTests/gnosis/Tokens/EtherToken.sol index f6e73e5a..32e64583 100644 --- a/test/compilationTests/gnosis/Tokens/EtherToken.sol +++ b/test/compilationTests/gnosis/Tokens/EtherToken.sol @@ -30,7 +30,7 @@ contract EtherToken is StandardToken { { balances[msg.sender] = balances[msg.sender].add(msg.value); totalTokens = totalTokens.add(msg.value); - Deposit(msg.sender, msg.value); + emit Deposit(msg.sender, msg.value); } /// @dev Sells tokens in exchange for Ether, exchanging them 1:1 @@ -42,6 +42,6 @@ contract EtherToken is StandardToken { balances[msg.sender] = balances[msg.sender].sub(value); totalTokens = totalTokens.sub(value); msg.sender.transfer(value); - Withdrawal(msg.sender, value); + emit Withdrawal(msg.sender, value); } } diff --git a/test/compilationTests/gnosis/Tokens/OutcomeToken.sol b/test/compilationTests/gnosis/Tokens/OutcomeToken.sol index fd1fa590..0bc7307d 100644 --- a/test/compilationTests/gnosis/Tokens/OutcomeToken.sol +++ b/test/compilationTests/gnosis/Tokens/OutcomeToken.sol @@ -31,7 +31,7 @@ contract OutcomeToken is StandardToken { * Public functions */ /// @dev Constructor sets events contract address - function OutcomeToken() + constructor() public { eventContract = msg.sender; @@ -46,7 +46,7 @@ contract OutcomeToken is StandardToken { { balances[_for] = balances[_for].add(outcomeTokenCount); totalTokens = totalTokens.add(outcomeTokenCount); - Issuance(_for, outcomeTokenCount); + emit Issuance(_for, outcomeTokenCount); } /// @dev Events contract revokes tokens for address. Returns success @@ -58,6 +58,6 @@ contract OutcomeToken is StandardToken { { balances[_for] = balances[_for].sub(outcomeTokenCount); totalTokens = totalTokens.sub(outcomeTokenCount); - Revocation(_for, outcomeTokenCount); + emit Revocation(_for, outcomeTokenCount); } } diff --git a/test/compilationTests/gnosis/Tokens/StandardToken.sol b/test/compilationTests/gnosis/Tokens/StandardToken.sol index fc899ca6..b7d0d37a 100644 --- a/test/compilationTests/gnosis/Tokens/StandardToken.sol +++ b/test/compilationTests/gnosis/Tokens/StandardToken.sol @@ -30,7 +30,7 @@ contract StandardToken is Token { return false; balances[msg.sender] -= value; balances[to] += value; - Transfer(msg.sender, to, value); + emit Transfer(msg.sender, to, value); return true; } @@ -50,7 +50,7 @@ contract StandardToken is Token { balances[from] -= value; allowances[from][msg.sender] -= value; balances[to] += value; - Transfer(from, to, value); + emit Transfer(from, to, value); return true; } @@ -63,7 +63,7 @@ contract StandardToken is Token { returns (bool) { allowances[msg.sender][spender] = value; - Approval(msg.sender, spender, value); + emit Approval(msg.sender, spender, value); return true; } diff --git a/test/compilationTests/milestonetracker/MilestoneTracker.sol b/test/compilationTests/milestonetracker/MilestoneTracker.sol index 7a9158ae..56422169 100644 --- a/test/compilationTests/milestonetracker/MilestoneTracker.sol +++ b/test/compilationTests/milestonetracker/MilestoneTracker.sol @@ -108,7 +108,7 @@ contract MilestoneTracker { /// @param _arbitrator Address assigned to be the arbitrator /// @param _donor Address assigned to be the donor /// @param _recipient Address assigned to be the recipient - function MilestoneTracker ( + constructor ( address _arbitrator, address _donor, address _recipient @@ -179,7 +179,7 @@ contract MilestoneTracker { ) onlyRecipient campaignNotCanceled { proposedMilestones = _newMilestones; changingMilestones = true; - NewMilestoneListProposed(); + emit NewMilestoneListProposed(); } @@ -192,7 +192,7 @@ contract MilestoneTracker { function unproposeMilestones() onlyRecipient campaignNotCanceled { delete proposedMilestones; changingMilestones = false; - NewMilestoneListUnproposed(); + emit NewMilestoneListUnproposed(); } /// @notice `onlyDonor` Approves the proposed milestone list @@ -249,7 +249,7 @@ contract MilestoneTracker { delete proposedMilestones; changingMilestones = false; - NewMilestoneListAccepted(); + emit NewMilestoneListAccepted(); } /// @notice `onlyRecipientOrLeadLink`Marks a milestone as DONE and @@ -268,7 +268,7 @@ contract MilestoneTracker { if (now > milestone.maxCompletionDate) throw; milestone.status = MilestoneStatus.Completed; milestone.doneTime = now; - ProposalStatusChanged(_idMilestone, milestone.status); + emit ProposalStatusChanged(_idMilestone, milestone.status); } /// @notice `onlyReviewer` Approves a specific milestone @@ -297,7 +297,7 @@ contract MilestoneTracker { (milestone.status != MilestoneStatus.Completed)) throw; milestone.status = MilestoneStatus.AcceptedAndInProgress; - ProposalStatusChanged(_idMilestone, milestone.status); + emit ProposalStatusChanged(_idMilestone, milestone.status); } /// @notice `onlyRecipientOrLeadLink` Sends the milestone payment as @@ -330,7 +330,7 @@ contract MilestoneTracker { throw; milestone.status = MilestoneStatus.Canceled; - ProposalStatusChanged(_idMilestone, milestone.status); + emit ProposalStatusChanged(_idMilestone, milestone.status); } /// @notice `onlyArbitrator` Forces a milestone to be paid out as long as it @@ -350,7 +350,7 @@ contract MilestoneTracker { /// milestones. function arbitrateCancelCampaign() onlyArbitrator campaignNotCanceled { campaignCanceled = true; - CampaignCanceled(); + emit CampaignCanceled(); } // @dev This internal function is executed when the milestone is paid out @@ -362,6 +362,6 @@ contract MilestoneTracker { milestone.status = MilestoneStatus.AuthorizedForPayment; if (!milestone.paymentSource.call.value(0)(milestone.payData)) throw; - ProposalStatusChanged(_idMilestone, milestone.status); + emit ProposalStatusChanged(_idMilestone, milestone.status); } } diff --git a/test/compilationTests/zeppelin/Bounty.sol b/test/compilationTests/zeppelin/Bounty.sol index 4425b7a5..8be16a54 100644 --- a/test/compilationTests/zeppelin/Bounty.sol +++ b/test/compilationTests/zeppelin/Bounty.sol @@ -18,7 +18,7 @@ contract Bounty is PullPayment, Destructible { /** * @dev Fallback function allowing the contract to recieve funds, if they haven't already been claimed. */ - function() payable { + function() external payable { if (claimed) { throw; } @@ -32,7 +32,7 @@ contract Bounty is PullPayment, Destructible { function createTarget() returns(Target) { Target target = Target(deployContract()); researchers[target] = msg.sender; - TargetCreated(target); + emit TargetCreated(target); return target; } @@ -48,7 +48,7 @@ contract Bounty is PullPayment, Destructible { */ function claim(Target target) { address researcher = researchers[target]; - if (researcher == 0) { + if (researcher == address(0)) { throw; } // Check Target contract invariants diff --git a/test/compilationTests/zeppelin/DayLimit.sol b/test/compilationTests/zeppelin/DayLimit.sol index 3c8d5b0c..0bcb341a 100644 --- a/test/compilationTests/zeppelin/DayLimit.sol +++ b/test/compilationTests/zeppelin/DayLimit.sol @@ -15,7 +15,7 @@ contract DayLimit { * @dev Constructor that sets the passed value as a dailyLimit. * @param _limit uint256 to represent the daily limit. */ - function DayLimit(uint256 _limit) { + constructor(uint256 _limit) { dailyLimit = _limit; lastDay = today(); } diff --git a/test/compilationTests/zeppelin/LimitBalance.sol b/test/compilationTests/zeppelin/LimitBalance.sol index 57477c74..40edd014 100644 --- a/test/compilationTests/zeppelin/LimitBalance.sol +++ b/test/compilationTests/zeppelin/LimitBalance.sol @@ -15,7 +15,7 @@ contract LimitBalance { * @dev Constructor that sets the passed value as a limit. * @param _limit uint256 to represent the limit. */ - function LimitBalance(uint256 _limit) { + constructor(uint256 _limit) { limit = _limit; } diff --git a/test/compilationTests/zeppelin/MultisigWallet.sol b/test/compilationTests/zeppelin/MultisigWallet.sol index 939e70f2..96624d3a 100644 --- a/test/compilationTests/zeppelin/MultisigWallet.sol +++ b/test/compilationTests/zeppelin/MultisigWallet.sol @@ -25,8 +25,8 @@ contract MultisigWallet is Multisig, Shareable, DayLimit { * @param _owners A list of owners. * @param _required The amount required for a transaction to be approved. */ - function MultisigWallet(address[] _owners, uint256 _required, uint256 _daylimit) - Shareable(_owners, _required) + constructor(address[] _owners, uint256 _required, uint256 _daylimit) + Shareable(_owners, _required) DayLimit(_daylimit) { } /** @@ -39,10 +39,10 @@ contract MultisigWallet is Multisig, Shareable, DayLimit { /** * @dev Fallback function, receives value and emits a deposit event. */ - function() payable { + function() external payable { // just being sent some cash? if (msg.value > 0) - Deposit(msg.sender, msg.value); + emit Deposit(msg.sender, msg.value); } /** @@ -58,7 +58,7 @@ contract MultisigWallet is Multisig, Shareable, DayLimit { function execute(address _to, uint256 _value, bytes _data) external onlyOwner returns (bytes32 _r) { // first, take the opportunity to check that we're under the daily limit. if (underLimit(_value)) { - SingleTransact(msg.sender, _value, _to, _data); + emit SingleTransact(msg.sender, _value, _to, _data); // yes - just execute the call. if (!_to.call.value(_value)(_data)) { throw; @@ -66,12 +66,12 @@ contract MultisigWallet is Multisig, Shareable, DayLimit { return 0; } // determine our operation hash. - _r = keccak256(msg.data, block.number); - if (!confirm(_r) && txs[_r].to == 0) { + _r = keccak256(abi.encodePacked(msg.data, block.number)); + if (!confirm(_r) && txs[_r].to == address(0)) { txs[_r].to = _to; txs[_r].value = _value; txs[_r].data = _data; - ConfirmationNeeded(_r, msg.sender, _value, _to, _data); + emit ConfirmationNeeded(_r, msg.sender, _value, _to, _data); } } @@ -81,11 +81,11 @@ contract MultisigWallet is Multisig, Shareable, DayLimit { * @param _h The transaction hash to approve. */ function confirm(bytes32 _h) onlymanyowners(_h) returns (bool) { - if (txs[_h].to != 0) { + if (txs[_h].to != address(0)) { if (!txs[_h].to.call.value(txs[_h].value)(txs[_h].data)) { throw; } - MultiTransact(msg.sender, _h, txs[_h].value, txs[_h].to, txs[_h].data); + emit MultiTransact(msg.sender, _h, txs[_h].value, txs[_h].to, txs[_h].data); delete txs[_h]; return true; } diff --git a/test/compilationTests/zeppelin/crowdsale/CappedCrowdsale.sol b/test/compilationTests/zeppelin/crowdsale/CappedCrowdsale.sol index f04649f3..afae79b7 100644 --- a/test/compilationTests/zeppelin/crowdsale/CappedCrowdsale.sol +++ b/test/compilationTests/zeppelin/crowdsale/CappedCrowdsale.sol @@ -12,7 +12,7 @@ contract CappedCrowdsale is Crowdsale { uint256 public cap; - function CappedCrowdsale(uint256 _cap) { + constructor(uint256 _cap) { cap = _cap; } diff --git a/test/compilationTests/zeppelin/crowdsale/Crowdsale.sol b/test/compilationTests/zeppelin/crowdsale/Crowdsale.sol index bee1efd2..d798f41d 100644 --- a/test/compilationTests/zeppelin/crowdsale/Crowdsale.sol +++ b/test/compilationTests/zeppelin/crowdsale/Crowdsale.sol @@ -40,11 +40,11 @@ contract Crowdsale { event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); - function Crowdsale(uint256 _startBlock, uint256 _endBlock, uint256 _rate, address _wallet) { + constructor(uint256 _startBlock, uint256 _endBlock, uint256 _rate, address _wallet) { require(_startBlock >= block.number); require(_endBlock >= _startBlock); require(_rate > 0); - require(_wallet != 0x0); + require(_wallet != address(0x0)); token = createTokenContract(); startBlock = _startBlock; @@ -61,13 +61,13 @@ contract Crowdsale { // fallback function can be used to buy tokens - function () payable { + function () external payable { buyTokens(msg.sender); } // low level token purchase function function buyTokens(address beneficiary) payable { - require(beneficiary != 0x0); + require(beneficiary != address(0x0)); require(validPurchase()); uint256 weiAmount = msg.value; @@ -80,7 +80,7 @@ contract Crowdsale { weiRaised = updatedWeiRaised; token.mint(beneficiary, tokens); - TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); + emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } diff --git a/test/compilationTests/zeppelin/crowdsale/FinalizableCrowdsale.sol b/test/compilationTests/zeppelin/crowdsale/FinalizableCrowdsale.sol index 1a736083..7965a66d 100644 --- a/test/compilationTests/zeppelin/crowdsale/FinalizableCrowdsale.sol +++ b/test/compilationTests/zeppelin/crowdsale/FinalizableCrowdsale.sol @@ -23,7 +23,7 @@ contract FinalizableCrowdsale is Crowdsale, Ownable { require(hasEnded()); finalization(); - Finalized(); + emit Finalized(); isFinalized = true; } diff --git a/test/compilationTests/zeppelin/crowdsale/RefundVault.sol b/test/compilationTests/zeppelin/crowdsale/RefundVault.sol index cc92ff9f..0be45ec4 100644 --- a/test/compilationTests/zeppelin/crowdsale/RefundVault.sol +++ b/test/compilationTests/zeppelin/crowdsale/RefundVault.sol @@ -22,8 +22,8 @@ contract RefundVault is Ownable { event RefundsEnabled(); event Refunded(address indexed beneficiary, uint256 weiAmount); - function RefundVault(address _wallet) { - require(_wallet != 0x0); + constructor(address _wallet) { + require(_wallet != address(0x0)); wallet = _wallet; state = State.Active; } @@ -36,14 +36,14 @@ contract RefundVault is Ownable { function close() onlyOwner { require(state == State.Active); state = State.Closed; - Closed(); + emit Closed(); wallet.transfer(this.balance); } function enableRefunds() onlyOwner { require(state == State.Active); state = State.Refunding; - RefundsEnabled(); + emit RefundsEnabled(); } function refund(address investor) { @@ -51,6 +51,6 @@ contract RefundVault is Ownable { uint256 depositedValue = deposited[investor]; deposited[investor] = 0; investor.transfer(depositedValue); - Refunded(investor, depositedValue); + emit Refunded(investor, depositedValue); } } diff --git a/test/compilationTests/zeppelin/crowdsale/RefundableCrowdsale.sol b/test/compilationTests/zeppelin/crowdsale/RefundableCrowdsale.sol index f45df1d3..5e798d45 100644 --- a/test/compilationTests/zeppelin/crowdsale/RefundableCrowdsale.sol +++ b/test/compilationTests/zeppelin/crowdsale/RefundableCrowdsale.sol @@ -21,7 +21,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale { // refund vault used to hold funds while crowdsale is running RefundVault public vault; - function RefundableCrowdsale(uint256 _goal) { + constructor(uint256 _goal) { vault = new RefundVault(wallet); goal = _goal; } diff --git a/test/compilationTests/zeppelin/lifecycle/Destructible.sol b/test/compilationTests/zeppelin/lifecycle/Destructible.sol index 3561e3b7..00492590 100644 --- a/test/compilationTests/zeppelin/lifecycle/Destructible.sol +++ b/test/compilationTests/zeppelin/lifecycle/Destructible.sol @@ -10,7 +10,7 @@ import "../ownership/Ownable.sol"; */ contract Destructible is Ownable { - function Destructible() payable { } + constructor() payable { } /** * @dev Transfers the current balance to the owner and terminates the contract. diff --git a/test/compilationTests/zeppelin/lifecycle/Pausable.sol b/test/compilationTests/zeppelin/lifecycle/Pausable.sol index b14f8767..10b0fcd8 100644 --- a/test/compilationTests/zeppelin/lifecycle/Pausable.sol +++ b/test/compilationTests/zeppelin/lifecycle/Pausable.sol @@ -36,7 +36,7 @@ contract Pausable is Ownable { */ function pause() onlyOwner whenNotPaused returns (bool) { paused = true; - Pause(); + emit Pause(); return true; } @@ -45,7 +45,7 @@ contract Pausable is Ownable { */ function unpause() onlyOwner whenPaused returns (bool) { paused = false; - Unpause(); + emit Unpause(); return true; } } diff --git a/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol b/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol index fe0b46b6..f88a55aa 100644 --- a/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol +++ b/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol @@ -12,7 +12,7 @@ import "../token/ERC20Basic.sol"; */ contract TokenDestructible is Ownable { - function TokenDestructible() payable { } + constructor() payable { } /** * @notice Terminate contract and refund to owner diff --git a/test/compilationTests/zeppelin/ownership/Claimable.sol b/test/compilationTests/zeppelin/ownership/Claimable.sol index d063502d..14d0ac6a 100644 --- a/test/compilationTests/zeppelin/ownership/Claimable.sol +++ b/test/compilationTests/zeppelin/ownership/Claimable.sol @@ -35,6 +35,6 @@ contract Claimable is Ownable { */ function claimOwnership() onlyPendingOwner { owner = pendingOwner; - pendingOwner = 0x0; + pendingOwner = address(0x0); } } diff --git a/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol b/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol index f5fee614..93177dc6 100644 --- a/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol +++ b/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol @@ -36,7 +36,7 @@ contract DelayedClaimable is Claimable { if ((block.number > end) || (block.number < start)) throw; owner = pendingOwner; - pendingOwner = 0x0; + pendingOwner = address(0x0); end = 0; } diff --git a/test/compilationTests/zeppelin/ownership/HasNoEther.sol b/test/compilationTests/zeppelin/ownership/HasNoEther.sol index 2bcaf1b8..8f9edc03 100644 --- a/test/compilationTests/zeppelin/ownership/HasNoEther.sol +++ b/test/compilationTests/zeppelin/ownership/HasNoEther.sol @@ -21,7 +21,7 @@ contract HasNoEther is Ownable { * constructor. By doing it this way we prevent a payable constructor from working. Alternatively * we could use assembly to access msg.value. */ - function HasNoEther() payable { + constructor() payable { if(msg.value > 0) { throw; } diff --git a/test/compilationTests/zeppelin/ownership/Ownable.sol b/test/compilationTests/zeppelin/ownership/Ownable.sol index f1628454..0a2257d6 100644 --- a/test/compilationTests/zeppelin/ownership/Ownable.sol +++ b/test/compilationTests/zeppelin/ownership/Ownable.sol @@ -14,7 +14,7 @@ contract Ownable { * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ - function Ownable() { + constructor() { owner = msg.sender; } diff --git a/test/compilationTests/zeppelin/ownership/Shareable.sol b/test/compilationTests/zeppelin/ownership/Shareable.sol index b6cb1c16..f8059650 100644 --- a/test/compilationTests/zeppelin/ownership/Shareable.sol +++ b/test/compilationTests/zeppelin/ownership/Shareable.sol @@ -59,7 +59,7 @@ contract Shareable { * @param _owners A list of owners. * @param _required The amount required for a transaction to be approved. */ - function Shareable(address[] _owners, uint256 _required) { + constructor(address[] _owners, uint256 _required) { owners[1] = msg.sender; ownerIndex[msg.sender] = 1; for (uint256 i = 0; i < _owners.length; ++i) { @@ -87,7 +87,7 @@ contract Shareable { if (pending.ownersDone & ownerIndexBit > 0) { pending.yetNeeded++; pending.ownersDone -= ownerIndexBit; - Revoke(msg.sender, _operation); + emit Revoke(msg.sender, _operation); } } @@ -156,7 +156,7 @@ contract Shareable { uint256 ownerIndexBit = 2**index; // make sure we (the message sender) haven't confirmed this operation previously. if (pending.ownersDone & ownerIndexBit == 0) { - Confirmation(msg.sender, _operation); + emit Confirmation(msg.sender, _operation); // ok - check if count is enough to go ahead. if (pending.yetNeeded <= 1) { // enough confirmations: reset and run interior. diff --git a/test/compilationTests/zeppelin/token/BasicToken.sol b/test/compilationTests/zeppelin/token/BasicToken.sol index 5618227a..831f706e 100644 --- a/test/compilationTests/zeppelin/token/BasicToken.sol +++ b/test/compilationTests/zeppelin/token/BasicToken.sol @@ -22,7 +22,7 @@ contract BasicToken is ERC20Basic { function transfer(address _to, uint256 _value) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); - Transfer(msg.sender, _to, _value); + emit Transfer(msg.sender, _to, _value); } /** diff --git a/test/compilationTests/zeppelin/token/MintableToken.sol b/test/compilationTests/zeppelin/token/MintableToken.sol index 505d13c3..45926afb 100644 --- a/test/compilationTests/zeppelin/token/MintableToken.sol +++ b/test/compilationTests/zeppelin/token/MintableToken.sol @@ -34,7 +34,7 @@ contract MintableToken is StandardToken, Ownable { function mint(address _to, uint256 _amount) onlyOwner canMint returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); - Mint(_to, _amount); + emit Mint(_to, _amount); return true; } @@ -44,7 +44,7 @@ contract MintableToken is StandardToken, Ownable { */ function finishMinting() onlyOwner returns (bool) { mintingFinished = true; - MintFinished(); + emit MintFinished(); return true; } } diff --git a/test/compilationTests/zeppelin/token/SimpleToken.sol b/test/compilationTests/zeppelin/token/SimpleToken.sol index 898cb21d..a4ba9eb3 100644 --- a/test/compilationTests/zeppelin/token/SimpleToken.sol +++ b/test/compilationTests/zeppelin/token/SimpleToken.sol @@ -20,7 +20,7 @@ contract SimpleToken is StandardToken { /** * @dev Contructor that gives msg.sender all of existing tokens. */ - function SimpleToken() { + constructor() { totalSupply = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; } diff --git a/test/compilationTests/zeppelin/token/StandardToken.sol b/test/compilationTests/zeppelin/token/StandardToken.sol index d86aae4c..ab9f582e 100644 --- a/test/compilationTests/zeppelin/token/StandardToken.sol +++ b/test/compilationTests/zeppelin/token/StandardToken.sol @@ -32,7 +32,7 @@ contract StandardToken is ERC20, BasicToken { balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = _allowance.sub(_value); - Transfer(_from, _to, _value); + emit Transfer(_from, _to, _value); } /** @@ -49,7 +49,7 @@ contract StandardToken is ERC20, BasicToken { if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) throw; allowed[msg.sender][_spender] = _value; - Approval(msg.sender, _spender, _value); + emit Approval(msg.sender, _spender, _value); } /** diff --git a/test/compilationTests/zeppelin/token/TokenTimelock.sol b/test/compilationTests/zeppelin/token/TokenTimelock.sol index 595bf8d0..e9f998ba 100644 --- a/test/compilationTests/zeppelin/token/TokenTimelock.sol +++ b/test/compilationTests/zeppelin/token/TokenTimelock.sol @@ -19,7 +19,7 @@ contract TokenTimelock { // timestamp when token release is enabled uint releaseTime; - function TokenTimelock(ERC20Basic _token, address _beneficiary, uint _releaseTime) { + constructor(ERC20Basic _token, address _beneficiary, uint _releaseTime) { require(_releaseTime > now); token = _token; beneficiary = _beneficiary; diff --git a/test/compilationTests/zeppelin/token/VestedToken.sol b/test/compilationTests/zeppelin/token/VestedToken.sol index b7748b09..e9929018 100644 --- a/test/compilationTests/zeppelin/token/VestedToken.sol +++ b/test/compilationTests/zeppelin/token/VestedToken.sol @@ -65,7 +65,7 @@ contract VestedToken is StandardToken, LimitedTransferToken { transfer(_to, _value); - NewTokenGrant(msg.sender, _to, _value, count - 1); + emit NewTokenGrant(msg.sender, _to, _value, count - 1); } /** @@ -96,7 +96,7 @@ contract VestedToken is StandardToken, LimitedTransferToken { balances[receiver] = balances[receiver].add(nonVested); balances[_holder] = balances[_holder].sub(nonVested); - Transfer(_holder, receiver, nonVested); + emit Transfer(_holder, receiver, nonVested); } diff --git a/test/contracts/AuctionRegistrar.cpp b/test/contracts/AuctionRegistrar.cpp index 33b392d4..f5abb83d 100644 --- a/test/contracts/AuctionRegistrar.cpp +++ b/test/contracts/AuctionRegistrar.cpp @@ -70,7 +70,7 @@ contract AuctionSystem { var auction = m_auctions[_name]; if (auction.endDate > 0 && now > auction.endDate) { - AuctionEnded(_name, auction.highestBidder); + emit AuctionEnded(_name, auction.highestBidder); onAuctionEnd(_name); delete m_auctions[_name]; return; @@ -84,7 +84,7 @@ contract AuctionSystem { auction.highestBidder = _bidder; auction.endDate = now + c_biddingTime; - NewBid(_name, _bidder, _value); + emit NewBid(_name, _bidder, _value); } } @@ -122,8 +122,8 @@ contract GlobalRegistrar is Registrar, AuctionSystem { var previousOwner = record.owner; record.renewalDate = now + c_renewalInterval; record.owner = auction.highestBidder; - Changed(_name); - if (previousOwner != 0) { + emit Changed(_name); + if (previousOwner != 0x0000000000000000000000000000000000000000) { if (!record.owner.send(auction.sumOfBids - auction.highestBid / 100)) throw; } else { @@ -143,10 +143,10 @@ contract GlobalRegistrar is Registrar, AuctionSystem { bid(_name, msg.sender, msg.value); } else { Record record = m_toRecord[_name]; - if (record.owner != 0) + if (record.owner != 0x0000000000000000000000000000000000000000) throw; m_toRecord[_name].owner = msg.sender; - Changed(_name); + emit Changed(_name); } } @@ -158,35 +158,35 @@ contract GlobalRegistrar is Registrar, AuctionSystem { function transfer(string _name, address _newOwner) onlyrecordowner(_name) { m_toRecord[_name].owner = _newOwner; - Changed(_name); + emit Changed(_name); } function disown(string _name) onlyrecordowner(_name) { if (stringsEqual(m_toName[m_toRecord[_name].primary], _name)) { - PrimaryChanged(_name, m_toRecord[_name].primary); + emit PrimaryChanged(_name, m_toRecord[_name].primary); m_toName[m_toRecord[_name].primary] = ""; } delete m_toRecord[_name]; - Changed(_name); + emit Changed(_name); } function setAddress(string _name, address _a, bool _primary) onlyrecordowner(_name) { m_toRecord[_name].primary = _a; if (_primary) { - PrimaryChanged(_name, _a); + emit PrimaryChanged(_name, _a); m_toName[_a] = _name; } - Changed(_name); + emit Changed(_name); } function setSubRegistrar(string _name, address _registrar) onlyrecordowner(_name) { m_toRecord[_name].subRegistrar = _registrar; - Changed(_name); + emit Changed(_name); } function setContent(string _name, bytes32 _content) onlyrecordowner(_name) { m_toRecord[_name].content = _content; - Changed(_name); + emit Changed(_name); } function stringsEqual(string storage _a, string memory _b) internal returns (bool) { diff --git a/test/contracts/FixedFeeRegistrar.cpp b/test/contracts/FixedFeeRegistrar.cpp index a3a27c37..142f4144 100644 --- a/test/contracts/FixedFeeRegistrar.cpp +++ b/test/contracts/FixedFeeRegistrar.cpp @@ -76,32 +76,32 @@ contract FixedFeeRegistrar is Registrar { function reserve(string _name) payable { Record rec = m_record(_name); - if (rec.owner == 0 && msg.value >= c_fee) { + if (rec.owner == 0x0000000000000000000000000000000000000000 && msg.value >= c_fee) { rec.owner = msg.sender; - Changed(_name); + emit Changed(_name); } } function disown(string _name, address _refund) onlyrecordowner(_name) { - delete m_recordData[uint(keccak256(_name)) / 8]; + delete m_recordData[uint(keccak256(bytes(_name))) / 8]; if (!_refund.send(c_fee)) throw; - Changed(_name); + emit Changed(_name); } function transfer(string _name, address _newOwner) onlyrecordowner(_name) { m_record(_name).owner = _newOwner; - Changed(_name); + emit Changed(_name); } function setAddr(string _name, address _a) onlyrecordowner(_name) { m_record(_name).addr = _a; - Changed(_name); + emit Changed(_name); } function setSubRegistrar(string _name, address _registrar) onlyrecordowner(_name) { m_record(_name).subRegistrar = _registrar; - Changed(_name); + emit Changed(_name); } function setContent(string _name, bytes32 _content) onlyrecordowner(_name) { m_record(_name).content = _content; - Changed(_name); + emit Changed(_name); } function record(string _name) constant returns (address o_addr, address o_subRegistrar, bytes32 o_content, address o_owner) { @@ -118,7 +118,7 @@ contract FixedFeeRegistrar is Registrar { Record[2**253] m_recordData; function m_record(string _name) constant internal returns (Record storage o_record) { - return m_recordData[uint(keccak256(_name)) / 8]; + 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 1031e8f1..0a596b6d 100644 --- a/test/contracts/Wallet.cpp +++ b/test/contracts/Wallet.cpp @@ -123,7 +123,7 @@ contract multiowned { if (pending.ownersDone & ownerIndexBit > 0) { pending.yetNeeded++; pending.ownersDone -= ownerIndexBit; - Revoke(msg.sender, _operation); + emit Revoke(msg.sender, _operation); } } @@ -137,7 +137,7 @@ contract multiowned { m_owners[ownerIndex] = uint(_to); m_ownerIndex[uint(_from)] = 0; m_ownerIndex[uint(_to)] = ownerIndex; - OwnerChanged(_from, _to); + emit OwnerChanged(_from, _to); } function addOwner(address _owner) onlymanyowners(keccak256(msg.data)) external { @@ -151,7 +151,7 @@ contract multiowned { m_numOwners++; m_owners[m_numOwners] = uint(_owner); m_ownerIndex[uint(_owner)] = m_numOwners; - OwnerAdded(_owner); + emit OwnerAdded(_owner); } function removeOwner(address _owner) onlymanyowners(keccak256(msg.data)) external { @@ -163,14 +163,14 @@ contract multiowned { m_ownerIndex[uint(_owner)] = 0; clearPending(); reorganizeOwners(); //make sure m_numOwner is equal to the number of owners and always points to the optimal free slot - OwnerRemoved(_owner); + emit OwnerRemoved(_owner); } function changeRequirement(uint _newRequired) onlymanyowners(keccak256(msg.data)) external { if (_newRequired > m_numOwners) return; m_required = _newRequired; clearPending(); - RequirementChanged(_newRequired); + emit RequirementChanged(_newRequired); } function isOwner(address _addr) returns (bool) { @@ -215,7 +215,7 @@ contract multiowned { uint ownerIndexBit = 2**ownerIndex; // make sure we (the message sender) haven't confirmed this operation previously. if (pending.ownersDone & ownerIndexBit == 0) { - Confirmation(msg.sender, _operation); + emit Confirmation(msg.sender, _operation); // ok - check if count is enough to go ahead. if (pending.yetNeeded <= 1) { // enough confirmations: reset and run interior. @@ -379,10 +379,10 @@ contract Wallet is multisig, multiowned, daylimit { } // gets called when no other function matches - function() payable { + function() external payable { // just being sent some cash? if (msg.value > 0) - Deposit(msg.sender, msg.value); + emit Deposit(msg.sender, msg.value); } // Outside-visible transact entry point. Executes transacion immediately if below daily spend limit. @@ -392,27 +392,27 @@ contract Wallet is multisig, multiowned, daylimit { function execute(address _to, uint _value, bytes _data) external onlyowner returns (bytes32 _r) { // first, take the opportunity to check that we're under the daily limit. if (underLimit(_value)) { - SingleTransact(msg.sender, _value, _to, _data); + emit SingleTransact(msg.sender, _value, _to, _data); // yes - just execute the call. _to.call.value(_value)(_data); return 0; } // determine our operation hash. - _r = keccak256(msg.data, block.number); - if (!confirm(_r) && m_txs[_r].to == 0) { + _r = keccak256(abi.encodePacked(msg.data, block.number)); + if (!confirm(_r) && m_txs[_r].to == 0x0000000000000000000000000000000000000000) { m_txs[_r].to = _to; m_txs[_r].value = _value; m_txs[_r].data = _data; - ConfirmationNeeded(_r, msg.sender, _value, _to, _data); + emit ConfirmationNeeded(_r, msg.sender, _value, _to, _data); } } // 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) { - if (m_txs[_h].to != 0) { + if (m_txs[_h].to != 0x0000000000000000000000000000000000000000) { m_txs[_h].to.call.value(m_txs[_h].value)(m_txs[_h].data); - MultiTransact(msg.sender, _h, m_txs[_h].value, m_txs[_h].to, m_txs[_h].data); + emit MultiTransact(msg.sender, _h, m_txs[_h].value, m_txs[_h].to, m_txs[_h].data); delete m_txs[_h]; return true; } diff --git a/test/externalTests.sh b/test/externalTests.sh index 3125f92f..f2839083 100755 --- a/test/externalTests.sh +++ b/test/externalTests.sh @@ -61,6 +61,13 @@ function test_truffle # Replace fixed-version pragmas in Gnosis (part of Consensys best practice) find contracts test -name '*.sol' -type f -print0 | xargs -0 sed -i -e 's/pragma solidity 0/pragma solidity ^0/' fi + assertsol="node_modules/truffle/build/Assert.sol" + if [ -f "$assertsol" ] + then + echo "Replace Truffle's Assert.sol with a known good version" + rm "$assertsol" + wget https://raw.githubusercontent.com/trufflesuite/truffle-core/ef31bcaa15dbd9bd0f6a0070a5c63f271cde2dbc/lib/testing/Assert.sol -o "$assertsol" + fi npm run test ) rm -rf "$DIR" diff --git a/test/libjulia/CommonSubexpression.cpp b/test/libjulia/CommonSubexpression.cpp index 8a575c48..6c8edf1f 100644 --- a/test/libjulia/CommonSubexpression.cpp +++ b/test/libjulia/CommonSubexpression.cpp @@ -47,7 +47,7 @@ do\ }\ while(false) -BOOST_AUTO_TEST_SUITE(IuliaCSE) +BOOST_AUTO_TEST_SUITE(YulCSE) BOOST_AUTO_TEST_CASE(smoke_test) { diff --git a/test/libjulia/Disambiguator.cpp b/test/libjulia/Disambiguator.cpp index ba1a06b0..48e02c7e 100644 --- a/test/libjulia/Disambiguator.cpp +++ b/test/libjulia/Disambiguator.cpp @@ -39,7 +39,7 @@ do\ }\ while(false) -BOOST_AUTO_TEST_SUITE(IuliaDisambiguator) +BOOST_AUTO_TEST_SUITE(YulDisambiguator) BOOST_AUTO_TEST_CASE(smoke_test) { diff --git a/test/libjulia/FunctionGrouper.cpp b/test/libjulia/FunctionGrouper.cpp index 78f382cb..f1e83449 100644 --- a/test/libjulia/FunctionGrouper.cpp +++ b/test/libjulia/FunctionGrouper.cpp @@ -16,7 +16,7 @@ */ /** * @date 2017 - * Unit tests for the iulia function grouper. + * Unit tests for the Yul function grouper. */ #include <test/libjulia/Common.h> @@ -43,7 +43,7 @@ do\ }\ while(false) -BOOST_AUTO_TEST_SUITE(IuliaFunctionGrouper) +BOOST_AUTO_TEST_SUITE(YulFunctionGrouper) BOOST_AUTO_TEST_CASE(smoke_test) { diff --git a/test/libjulia/FunctionHoister.cpp b/test/libjulia/FunctionHoister.cpp index 3d6fff85..348963b4 100644 --- a/test/libjulia/FunctionHoister.cpp +++ b/test/libjulia/FunctionHoister.cpp @@ -16,7 +16,7 @@ */ /** * @date 2017 - * Unit tests for the iulia function hoister. + * Unit tests for the Yul function hoister. */ #include <test/libjulia/Common.h> @@ -43,7 +43,7 @@ do\ }\ while(false) -BOOST_AUTO_TEST_SUITE(IuliaFunctionHoister) +BOOST_AUTO_TEST_SUITE(YulFunctionHoister) BOOST_AUTO_TEST_CASE(smoke_test) { diff --git a/test/libjulia/Inliner.cpp b/test/libjulia/Inliner.cpp index 464dcd93..2f5b7cff 100644 --- a/test/libjulia/Inliner.cpp +++ b/test/libjulia/Inliner.cpp @@ -16,7 +16,7 @@ */ /** * @date 2017 - * Unit tests for the iulia function inliner. + * Unit tests for the Yul function inliner. */ #include <test/libjulia/Common.h> @@ -55,24 +55,24 @@ string inlinableFunctions(string const& _source) ); } -string inlineFunctions(string const& _source, bool _julia = true) +string inlineFunctions(string const& _source, bool _yul = true) { - auto ast = disambiguate(_source, _julia); + auto ast = disambiguate(_source, _yul); ExpressionInliner(ast).run(); - return assembly::AsmPrinter(_julia)(ast); + return assembly::AsmPrinter(_yul)(ast); } -string fullInline(string const& _source, bool _julia = true) +string fullInline(string const& _source, bool _yul = true) { - Block ast = disambiguate(_source, _julia); + Block ast = disambiguate(_source, _yul); (FunctionHoister{})(ast); (FunctionGrouper{})(ast);\ FullInliner(ast).run(); - return assembly::AsmPrinter(_julia)(ast); + return assembly::AsmPrinter(_yul)(ast); } } -BOOST_AUTO_TEST_SUITE(IuliaInlinableFunctionFilter) +BOOST_AUTO_TEST_SUITE(YulInlinableFunctionFilter) BOOST_AUTO_TEST_CASE(smoke_test) { @@ -121,7 +121,7 @@ BOOST_AUTO_TEST_CASE(negative) BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE(IuliaFunctionInliner) +BOOST_AUTO_TEST_SUITE(YulFunctionInliner) BOOST_AUTO_TEST_CASE(simple) { @@ -210,7 +210,7 @@ BOOST_AUTO_TEST_CASE(double_recursive_calls) BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE(IuliaFullInliner) +BOOST_AUTO_TEST_SUITE(YulFullInliner) BOOST_AUTO_TEST_CASE(simple) { diff --git a/test/libjulia/MainFunction.cpp b/test/libjulia/MainFunction.cpp index c26b002d..e7263d13 100644 --- a/test/libjulia/MainFunction.cpp +++ b/test/libjulia/MainFunction.cpp @@ -16,7 +16,7 @@ */ /** * @date 2018 - * Unit tests for the Julia MainFunction transformation. + * Unit tests for the Yul MainFunction transformation. */ #include <test/libjulia/Common.h> @@ -45,7 +45,7 @@ do\ }\ while(false) -BOOST_AUTO_TEST_SUITE(JuliaMainFunction) +BOOST_AUTO_TEST_SUITE(YulMainFunction) BOOST_AUTO_TEST_CASE(smoke_test) { diff --git a/test/libjulia/Parser.cpp b/test/libjulia/Parser.cpp index c59f91da..07154718 100644 --- a/test/libjulia/Parser.cpp +++ b/test/libjulia/Parser.cpp @@ -119,7 +119,7 @@ do \ BOOST_CHECK(searchErrorMessage(err, (substring))); \ } while(0) -BOOST_AUTO_TEST_SUITE(JuliaParser) +BOOST_AUTO_TEST_SUITE(YulParser) BOOST_AUTO_TEST_CASE(smoke_test) { diff --git a/test/libjulia/Rematerialiser.cpp b/test/libjulia/Rematerialiser.cpp index 8f928f8e..63e525d5 100644 --- a/test/libjulia/Rematerialiser.cpp +++ b/test/libjulia/Rematerialiser.cpp @@ -48,7 +48,7 @@ do\ }\ while(false) -BOOST_AUTO_TEST_SUITE(IuliaRematerialiser) +BOOST_AUTO_TEST_SUITE(YulRematerialiser) BOOST_AUTO_TEST_CASE(smoke_test) { diff --git a/test/libjulia/Simplifier.cpp b/test/libjulia/Simplifier.cpp index 4d4e8d53..8ed8287a 100644 --- a/test/libjulia/Simplifier.cpp +++ b/test/libjulia/Simplifier.cpp @@ -48,7 +48,7 @@ do\ }\ while(false) -BOOST_AUTO_TEST_SUITE(IuliaSimplifier) +BOOST_AUTO_TEST_SUITE(YulSimplifier) BOOST_AUTO_TEST_CASE(smoke_test) { diff --git a/test/libjulia/UnusedPruner.cpp b/test/libjulia/UnusedPruner.cpp index b86a54b3..649ee149 100644 --- a/test/libjulia/UnusedPruner.cpp +++ b/test/libjulia/UnusedPruner.cpp @@ -48,7 +48,7 @@ do\ }\ while(false) -BOOST_AUTO_TEST_SUITE(IuliaUnusedPruner) +BOOST_AUTO_TEST_SUITE(YulUnusedPruner) BOOST_AUTO_TEST_CASE(smoke_test) { diff --git a/test/libsolidity/ABIEncoderTests.cpp b/test/libsolidity/ABIEncoderTests.cpp index 227eadb5..9b6250d8 100644 --- a/test/libsolidity/ABIEncoderTests.cpp +++ b/test/libsolidity/ABIEncoderTests.cpp @@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(value_types) assembly { b := 7 } C c; assembly { c := sub(0, 5) } - E(10, uint16(uint256(-2)), uint24(0x12121212), int24(int256(-1)), bytes3(x), b, c); + emit E(10, uint16(uint256(-2)), uint24(0x12121212), int24(int256(-1)), bytes3(x), b, c); } } )"; @@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE(string_literal) contract C { event E(string, bytes20, string); function f() public { - E("abcdef", "abcde", "abcdefabcdefgehabcabcasdfjklabcdefabcedefghabcabcasdfjklabcdefabcdefghabcabcasdfjklabcdeefabcdefghabcabcasdefjklabcdefabcdefghabcabcasdfjkl"); + emit E("abcdef", "abcde", "abcdefabcdefgehabcabcasdfjklabcdefabcedefghabcabcasdfjklabcdefabcdefghabcabcasdfjklabcdeefabcdefghabcabcasdefjklabcdefabcdefghabcabcasdfjkl"); } } )"; @@ -133,7 +133,7 @@ BOOST_AUTO_TEST_CASE(conversion) int8 c; int16 d; assembly { a := sub(0, 1) c := 0x0101ff d := 0xff01 } - E(10, x, a, uint8(b), c, int8(d)); + emit E(10, x, a, uint8(b), c, int8(d)); } } )"; @@ -159,7 +159,7 @@ BOOST_AUTO_TEST_CASE(memory_array_one_dim) mstore(add(x, mul(add(i, 1), 0x20)), add(0xfffffffe, i)) } } - E(10, x, 11); + emit E(10, x, 11); } } )"; @@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE(memory_array_two_dim) x[0][2] = -1; x[1][0] = 4; x[1][1] = 5; - E(10, x, 11); + emit E(10, x, 11); } } )"; @@ -208,7 +208,7 @@ BOOST_AUTO_TEST_CASE(memory_byte_array) bytes[] memory x = new bytes[](2); x[0] = "abcabcdefghjklmnopqrsuvwabcdefgijklmnopqrstuwabcdefgijklmnoprstuvw"; x[1] = "abcdefghijklmnopqrtuvwabcfghijklmnopqstuvwabcdeghijklmopqrstuvw"; - E(10, x, 11); + emit E(10, x, 11); } } )"; @@ -234,7 +234,7 @@ BOOST_AUTO_TEST_CASE(storage_byte_array) function f() public { short = "123456789012345678901234567890a"; long = "ffff123456789012345678901234567890afffffffff123456789012345678901234567890a"; - E(short, long); + emit E(short, long); } } )"; @@ -261,7 +261,7 @@ BOOST_AUTO_TEST_CASE(storage_array) sstore(1, sub(0, 2)) sstore(2, sub(0, 3)) } - E(addr); + emit E(addr); } } )"; @@ -279,10 +279,10 @@ BOOST_AUTO_TEST_CASE(storage_array_dyn) address[] addr; event E(address[] a); function f() public { - addr.push(1); - addr.push(2); - addr.push(3); - E(addr); + addr.push(0x0000000000000000000000000000000000000001); + addr.push(0x0000000000000000000000000000000000000002); + addr.push(0x0000000000000000000000000000000000000003); + emit E(addr); } } )"; @@ -308,7 +308,7 @@ BOOST_AUTO_TEST_CASE(storage_array_compact) x.push(6); x.push(-7); x.push(8); - E(x); + emit E(x); } } )"; @@ -329,7 +329,7 @@ BOOST_AUTO_TEST_CASE(external_function) function(uint) external returns (uint) g; function f(uint) public returns (uint) { g = this.f; - E(this.f, g); + emit E(this.f, g); } } )"; @@ -351,7 +351,7 @@ BOOST_AUTO_TEST_CASE(external_function_cleanup) function f(uint) public returns (uint) { function(uint) external returns (uint)[1] memory h; assembly { sstore(0, sub(0, 1)) mstore(h, sub(0, 1)) } - E(h[0], g); + emit E(h[0], g); } } )"; @@ -368,7 +368,7 @@ BOOST_AUTO_TEST_CASE(calldata) contract C { event E(bytes); function f(bytes a) external { - E(a); + emit E(a); } } )"; @@ -426,7 +426,7 @@ BOOST_AUTO_TEST_CASE(structs) s.sub[0].x[0] = 11; s.sub[1].x[0] = 12; s.sub[2].x[1] = 13; - e(x, s); + emit e(x, s); return (x, s); } } diff --git a/test/libsolidity/GasMeter.cpp b/test/libsolidity/GasMeter.cpp index f16d9abe..b0cd5a93 100644 --- a/test/libsolidity/GasMeter.cpp +++ b/test/libsolidity/GasMeter.cpp @@ -152,7 +152,7 @@ BOOST_AUTO_TEST_CASE(simple_contract) contract test { bytes32 public shaValue; function f(uint a) { - shaValue = keccak256(a); + shaValue = keccak256(abi.encodePacked(a)); } } )"; @@ -165,7 +165,7 @@ BOOST_AUTO_TEST_CASE(store_keccak256) contract test { bytes32 public shaValue; function test(uint a) { - shaValue = keccak256(a); + shaValue = keccak256(abi.encodePacked(a)); } } )"; @@ -301,7 +301,7 @@ BOOST_AUTO_TEST_CASE(regular_functions_exclude_fallback) char const* sourceCode = R"( contract A { uint public x; - function() { x = 2; } + function() external { x = 2; } } )"; testCreationTimeGas(sourceCode); diff --git a/test/libsolidity/Imports.cpp b/test/libsolidity/Imports.cpp index 1b5dd4a5..4b700ceb 100644 --- a/test/libsolidity/Imports.cpp +++ b/test/libsolidity/Imports.cpp @@ -109,7 +109,7 @@ BOOST_AUTO_TEST_CASE(simple_alias) { CompilerStack c; c.addSource("a", "contract A {} pragma solidity >=0.0;"); - c.addSource("dir/a/b/c", "import \"../../.././a\" as x; contract B is x.A { function() { x.A r = x.A(20); } } pragma solidity >=0.0;"); + c.addSource("dir/a/b/c", "import \"../../.././a\" as x; contract B is x.A { function() external { x.A r = x.A(20); } } pragma solidity >=0.0;"); c.setEVMVersion(dev::test::Options::get().evmVersion()); BOOST_CHECK(c.compile()); } diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp index 18c8c025..57f414db 100644 --- a/test/libsolidity/SMTChecker.cpp +++ b/test/libsolidity/SMTChecker.cpp @@ -433,15 +433,15 @@ BOOST_AUTO_TEST_CASE(storage_value_vars) function f(uint x) public { if (x == 0) { - a = 100; + a = 0x0000000000000000000000000000000000000100; b = true; } else { - a = 200; + a = 0x0000000000000000000000000000000000000200; b = false; } - assert(a > 0 && b); + assert(a > 0x0000000000000000000000000000000000000000 && b); } } )"; @@ -464,19 +464,19 @@ BOOST_AUTO_TEST_CASE(storage_value_vars) function f(uint x) public { if (x == 0) { - a = 100; + a = 0x0000000000000000000000000000000000000100; b = true; } else { - a = 200; + a = 0x0000000000000000000000000000000000000200; b = false; } - assert(b == (a < 200)); + assert(b == (a < 0x0000000000000000000000000000000000000200)); } function g() public view { - require(a < 100); + require(a < 0x0000000000000000000000000000000000000100); assert(c >= 0); } address a; diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp index 107abc26..b1c8e567 100644 --- a/test/libsolidity/SolidityABIJSON.cpp +++ b/test/libsolidity/SolidityABIJSON.cpp @@ -843,7 +843,7 @@ BOOST_AUTO_TEST_CASE(include_fallback_function) { char const* sourceCode = R"( contract test { - function() {} + function() external {} } )"; @@ -897,7 +897,7 @@ BOOST_AUTO_TEST_CASE(payable_fallback_function) { char const* sourceCode = R"( contract test { - function () payable {} + function () external payable {} } )"; diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 65473f0d..b8c85a63 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -1456,7 +1456,7 @@ BOOST_AUTO_TEST_CASE(multiple_elementary_accessors) function test() { data = 8; name = "Celina"; - a_hash = keccak256(123); + a_hash = keccak256("\x7b"); an_address = address(0x1337); super_secret_data = 42; } @@ -1812,7 +1812,7 @@ BOOST_AUTO_TEST_CASE(transfer_ether) } contract C { - function () payable { + function () external payable { throw; } } @@ -1992,7 +1992,7 @@ BOOST_AUTO_TEST_CASE(keccak256) char const* sourceCode = R"( contract test { function a(bytes32 input) returns (bytes32 hash) { - return keccak256(input); + return keccak256(abi.encodePacked(input)); } } )"; @@ -2011,7 +2011,7 @@ BOOST_AUTO_TEST_CASE(sha256) char const* sourceCode = R"( contract test { function a(bytes32 input) returns (bytes32 sha256hash) { - return sha256(input); + return sha256(abi.encodePacked(input)); } } )"; @@ -2036,7 +2036,7 @@ BOOST_AUTO_TEST_CASE(ripemd) char const* sourceCode = R"( contract test { function a(bytes32 input) returns (bytes32 sha256hash) { - return ripemd160(input); + return ripemd160(abi.encodePacked(input)); } } )"; @@ -2063,7 +2063,7 @@ BOOST_AUTO_TEST_CASE(packed_keccak256) function a(bytes32 input) returns (bytes32 hash) { var b = 65536; uint c = 256; - return keccak256(8, input, b, input, c); + return keccak256(abi.encodePacked(8, input, b, input, c)); } } )"; @@ -2093,9 +2093,9 @@ BOOST_AUTO_TEST_CASE(packed_keccak256_complex_types) x[0] = y[0] = uint120(-2); x[1] = y[1] = uint120(-3); x[2] = y[2] = uint120(-4); - hash1 = keccak256(x); - hash2 = keccak256(y); - hash3 = keccak256(this.f); + hash1 = keccak256(abi.encodePacked(x)); + hash2 = keccak256(abi.encodePacked(y)); + hash3 = keccak256(abi.encodePacked(this.f)); } } )"; @@ -2115,7 +2115,7 @@ BOOST_AUTO_TEST_CASE(packed_sha256) function a(bytes32 input) returns (bytes32 hash) { var b = 65536; uint c = 256; - return sha256(8, input, b, input, c); + return sha256(abi.encodePacked(8, input, b, input, c)); } } )"; @@ -2142,7 +2142,7 @@ BOOST_AUTO_TEST_CASE(packed_ripemd160) function a(bytes32 input) returns (bytes32 hash) { var b = 65536; uint c = 256; - return ripemd160(8, input, b, input, c); + return ripemd160(abi.encodePacked(8, input, b, input, c)); } } )"; @@ -2506,7 +2506,7 @@ BOOST_AUTO_TEST_CASE(contracts_as_addresses) { char const* sourceCode = R"( contract helper { - function() payable { } // can receive ether + function() external payable { } // can receive ether } contract test { helper h; @@ -3054,7 +3054,7 @@ BOOST_AUTO_TEST_CASE(fallback_function) char const* sourceCode = R"( contract A { uint data; - function() { data = 1; } + function() external { data = 1; } function getData() returns (uint r) { return data; } } )"; @@ -3069,7 +3069,7 @@ BOOST_AUTO_TEST_CASE(inherited_fallback_function) char const* sourceCode = R"( contract A { uint data; - function() { data = 1; } + function() external { data = 1; } function getData() returns (uint r) { return data; } } contract B is A {} @@ -3082,13 +3082,13 @@ BOOST_AUTO_TEST_CASE(inherited_fallback_function) BOOST_AUTO_TEST_CASE(default_fallback_throws) { - char const* sourceCode = R"( + char const* sourceCode = R"YY( contract A { function f() returns (bool) { - return this.call(); + return this.call(""); } } - )"; + )YY"; compileAndRun(sourceCode); ABI_CHECK(callContractFunction("f()"), encodeArgs(0)); } @@ -3100,7 +3100,7 @@ BOOST_AUTO_TEST_CASE(short_data_calls_fallback) uint public x; // Signature is d88e0b00 function fow() { x = 3; } - function () { x = 2; } + function () external { x = 2; } } )"; compileAndRun(sourceCode); @@ -3122,7 +3122,7 @@ BOOST_AUTO_TEST_CASE(event) bytes32 s = 0x19dacbf83c5de6658e14cbf7bcae5c15eca2eedecf1c66fbca928e4d351bea0f; log3(bytes32(msg.value), s, bytes32(uint256(msg.sender)), _id); } else { - Deposit(msg.sender, _id, msg.value); + emit Deposit(msg.sender, _id, msg.value); } } } @@ -3172,7 +3172,7 @@ BOOST_AUTO_TEST_CASE(event_no_arguments) contract ClientReceipt { event Deposit(); function deposit() { - Deposit(); + emit Deposit(); } } )"; @@ -3186,28 +3186,6 @@ BOOST_AUTO_TEST_CASE(event_no_arguments) BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit()"))); } -BOOST_AUTO_TEST_CASE(event_access_through_base_name) -{ - char const* sourceCode = R"( - contract A { - event x(); - } - contract B is A { - function f() returns (uint) { - A.x(); - return 1; - } - } - )"; - compileAndRun(sourceCode); - callContractFunction("f()"); - BOOST_REQUIRE_EQUAL(m_logs.size(), 1); - BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress); - BOOST_CHECK(m_logs[0].data.empty()); - BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1); - BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("x()"))); -} - BOOST_AUTO_TEST_CASE(event_access_through_base_name_emit) { char const* sourceCode = R"( @@ -3238,67 +3216,15 @@ BOOST_AUTO_TEST_CASE(events_with_same_name) event Deposit(address _addr); event Deposit(address _addr, uint _amount); function deposit() returns (uint) { - Deposit(); - return 1; - } - function deposit(address _addr) returns (uint) { - Deposit(_addr); - return 1; - } - function deposit(address _addr, uint _amount) returns (uint) { - Deposit(_addr, _amount); - return 1; - } - } - )"; - u160 const c_loggedAddress = m_contractAddress; - - compileAndRun(sourceCode); - ABI_CHECK(callContractFunction("deposit()"), encodeArgs(u256(1))); - BOOST_REQUIRE_EQUAL(m_logs.size(), 1); - BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress); - BOOST_CHECK(m_logs[0].data.empty()); - BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1); - BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit()"))); - - ABI_CHECK(callContractFunction("deposit(address)", c_loggedAddress), encodeArgs(u256(1))); - BOOST_REQUIRE_EQUAL(m_logs.size(), 1); - BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress); - BOOST_CHECK(m_logs[0].data == encodeArgs(c_loggedAddress)); - BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1); - BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit(address)"))); - - ABI_CHECK(callContractFunction("deposit(address,uint256)", c_loggedAddress, u256(100)), encodeArgs(u256(1))); - BOOST_REQUIRE_EQUAL(m_logs.size(), 1); - BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress); - BOOST_CHECK(m_logs[0].data == encodeArgs(c_loggedAddress, 100)); - BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1); - BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit(address,uint256)"))); -} - -BOOST_AUTO_TEST_CASE(events_with_same_name_inherited) -{ - char const* sourceCode = R"( - contract A { - event Deposit(); - } - - contract B { - event Deposit(address _addr); - } - - contract ClientReceipt is A, B { - event Deposit(address _addr, uint _amount); - function deposit() returns (uint) { - Deposit(); + emit Deposit(); return 1; } function deposit(address _addr) returns (uint) { - Deposit(_addr); + emit Deposit(_addr); return 1; } function deposit(address _addr, uint _amount) returns (uint) { - Deposit(_addr, _amount); + emit Deposit(_addr, _amount); return 1; } } @@ -3386,7 +3312,7 @@ BOOST_AUTO_TEST_CASE(event_anonymous) contract ClientReceipt { event Deposit() anonymous; function deposit() { - Deposit(); + emit Deposit(); } } )"; @@ -3401,7 +3327,7 @@ BOOST_AUTO_TEST_CASE(event_anonymous_with_topics) contract ClientReceipt { event Deposit(address indexed _from, bytes32 indexed _id, uint indexed _value, uint indexed _value2, bytes32 data) anonymous; function deposit(bytes32 _id) payable { - Deposit(msg.sender, _id, msg.value, 2, "abc"); + emit Deposit(msg.sender, _id, msg.value, 2, "abc"); } } )"; @@ -3425,7 +3351,7 @@ BOOST_AUTO_TEST_CASE(event_lots_of_data) contract ClientReceipt { event Deposit(address _from, bytes32 _id, uint _value, bool _flag); function deposit(bytes32 _id) payable { - Deposit(msg.sender, _id, msg.value, true); + emit Deposit(msg.sender, _id, msg.value, true); } } )"; @@ -3446,7 +3372,7 @@ BOOST_AUTO_TEST_CASE(event_really_lots_of_data) contract ClientReceipt { event Deposit(uint fixeda, bytes dynx, uint fixedb); function deposit() { - Deposit(10, msg.data, 15); + emit Deposit(10, msg.data, 15); } } )"; @@ -3470,7 +3396,7 @@ BOOST_AUTO_TEST_CASE(event_really_lots_of_data_from_storage) x[0] = "A"; x[1] = "B"; x[2] = "C"; - Deposit(10, x, 15); + emit Deposit(10, x, 15); } } )"; @@ -3495,7 +3421,7 @@ BOOST_AUTO_TEST_CASE(event_really_really_lots_of_data_from_storage) x[1] = "B"; x[2] = "C"; x[30] = "Z"; - Deposit(10, x, 15); + emit Deposit(10, x, 15); } } )"; @@ -3523,7 +3449,7 @@ BOOST_AUTO_TEST_CASE(event_indexed_string) y[1] = 5; y[2] = 6; y[3] = 7; - E(x, y); + emit E(x, y); } } )"; @@ -3577,7 +3503,7 @@ BOOST_AUTO_TEST_CASE(sha256_empty) char const* sourceCode = R"( contract C { function f() returns (bytes32) { - return sha256(); + return sha256(""); } } )"; @@ -3590,7 +3516,7 @@ BOOST_AUTO_TEST_CASE(ripemd160_empty) char const* sourceCode = R"( contract C { function f() returns (bytes20) { - return ripemd160(); + return ripemd160(""); } } )"; @@ -3603,7 +3529,7 @@ BOOST_AUTO_TEST_CASE(keccak256_empty) char const* sourceCode = R"( contract C { function f() returns (bytes32) { - return keccak256(); + return keccak256(""); } } )"; @@ -3617,7 +3543,7 @@ BOOST_AUTO_TEST_CASE(keccak256_multiple_arguments) contract c { function foo(uint a, uint b, uint c) returns (bytes32 d) { - d = keccak256(a, b, c); + d = keccak256(abi.encodePacked(a, b, c)); } } )"; @@ -3638,7 +3564,7 @@ BOOST_AUTO_TEST_CASE(keccak256_multiple_arguments_with_numeric_literals) contract c { function foo(uint a, uint16 b) returns (bytes32 d) { - d = keccak256(a, b, 145); + d = keccak256(abi.encodePacked(a, b, 145)); } } )"; @@ -3663,7 +3589,7 @@ BOOST_AUTO_TEST_CASE(keccak256_multiple_arguments_with_string_literals) } function bar(uint a, uint16 b) returns (bytes32 d) { - d = keccak256(a, b, 145, "foo"); + d = keccak256(abi.encodePacked(a, b, 145, "foo")); } } )"; @@ -3702,7 +3628,7 @@ BOOST_AUTO_TEST_CASE(keccak256_with_bytes) BOOST_AUTO_TEST_CASE(iterated_keccak256_with_bytes) { - char const* sourceCode = R"( + char const* sourceCode = R"ABC( contract c { bytes data; function foo() returns (bytes32) @@ -3711,10 +3637,10 @@ BOOST_AUTO_TEST_CASE(iterated_keccak256_with_bytes) data[0] = "x"; data[1] = "y"; data[2] = "z"; - return keccak256("b", keccak256(data), "a"); + return keccak256(abi.encodePacked("b", keccak256(data), "a")); } } - )"; + )ABC"; compileAndRun(sourceCode); ABI_CHECK(callContractFunction("foo()"), encodeArgs( u256(dev::keccak256(bytes{'b'} + dev::keccak256("xyz").asBytes() + bytes{'a'})) @@ -3733,7 +3659,7 @@ BOOST_AUTO_TEST_CASE(generic_call) function doSend(address rec) returns (uint d) { bytes4 signature = bytes4(bytes32(keccak256("receive(uint256)"))); - rec.call.value(2)(signature, 23); + rec.call.value(2)(abi.encodeWithSelector(signature, 23)); return receiver(rec).received(); } } @@ -3763,7 +3689,7 @@ BOOST_AUTO_TEST_CASE(generic_delegatecall) function doSend(address rec) payable { bytes4 signature = bytes4(bytes32(keccak256("receive(uint256)"))); - if (rec.delegatecall(signature, 23)) {} + if (rec.delegatecall(abi.encodeWithSelector(signature, 23))) {} } } )**"; @@ -3860,7 +3786,7 @@ BOOST_AUTO_TEST_CASE(bytes_from_calldata_to_memory) char const* sourceCode = R"( contract C { function f() returns (bytes32) { - return keccak256("abc", msg.data); + return keccak256(abi.encodePacked("abc", msg.data)); } } )"; @@ -3876,11 +3802,11 @@ BOOST_AUTO_TEST_CASE(call_forward_bytes) contract receiver { uint public received; function receive(uint x) { received += x + 1; } - function() { received = 0x80; } + function() external { received = 0x80; } } contract sender { function sender() { rec = new receiver(); } - function() { savedData = msg.data; } + function() external { savedData = msg.data; } function forward() returns (bool) { !rec.call(savedData); return true; } function clear() returns (bool) { delete savedData; return true; } function val() returns (uint) { return rec.received(); } @@ -3904,7 +3830,7 @@ BOOST_AUTO_TEST_CASE(call_forward_bytes_length) char const* sourceCode = R"( contract receiver { uint public calledLength; - function() { calledLength = msg.data.length; } + function() external { calledLength = msg.data.length; } } contract sender { receiver rec; @@ -3929,21 +3855,15 @@ BOOST_AUTO_TEST_CASE(call_forward_bytes_length) compileAndRun(sourceCode, 0, "sender"); // No additional data, just function selector - ABI_CHECK(callContractFunction("viaCalldata()"), encodeArgs(0x20)); - // Should be this with 0.5.0: encodeArgs(4)); - ABI_CHECK(callContractFunction("viaMemory()"), encodeArgs(0x20)); - // Should be this with 0.5.0: encodeArgs(4)); - ABI_CHECK(callContractFunction("viaStorage()"), encodeArgs(0x20)); - // Should be this with 0.5.0: encodeArgs(4)); + ABI_CHECK(callContractFunction("viaCalldata()"), encodeArgs(4)); + ABI_CHECK(callContractFunction("viaMemory()"), encodeArgs(4)); + ABI_CHECK(callContractFunction("viaStorage()"), encodeArgs(4)); // Some additional unpadded data bytes unpadded = asBytes(string("abc")); - ABI_CHECK(callContractFunctionNoEncoding("viaCalldata()", unpadded), encodeArgs(0x20)); - // Should be this with 0.5.0: encodeArgs(7)); - ABI_CHECK(callContractFunctionNoEncoding("viaMemory()", unpadded), encodeArgs(0x20)); - // Should be this with 0.5.0: encodeArgs(7)); - ABI_CHECK(callContractFunctionNoEncoding("viaStorage()", unpadded), encodeArgs(0x20)); - // Should be this with 0.5.0: encodeArgs(7)); + ABI_CHECK(callContractFunctionNoEncoding("viaCalldata()", unpadded), encodeArgs(7)); + ABI_CHECK(callContractFunctionNoEncoding("viaMemory()", unpadded), encodeArgs(7)); + ABI_CHECK(callContractFunctionNoEncoding("viaStorage()", unpadded), encodeArgs(7)); } BOOST_AUTO_TEST_CASE(copying_bytes_multiassign) @@ -3952,11 +3872,11 @@ BOOST_AUTO_TEST_CASE(copying_bytes_multiassign) contract receiver { uint public received; function receive(uint x) { received += x + 1; } - function() { received = 0x80; } + function() external { received = 0x80; } } contract sender { function sender() { rec = new receiver(); } - function() { savedData1 = savedData2 = msg.data; } + function() external { savedData1 = savedData2 = msg.data; } function forward(bool selector) returns (bool) { if (selector) { rec.call(savedData1); delete savedData1; } else { rec.call(savedData2); delete savedData2; } @@ -3983,7 +3903,7 @@ BOOST_AUTO_TEST_CASE(delete_removes_bytes_data) { char const* sourceCode = R"( contract c { - function() { data = msg.data; } + function() external { data = msg.data; } function del() returns (bool) { delete data; return true; } bytes data; } @@ -4000,7 +3920,7 @@ BOOST_AUTO_TEST_CASE(copy_from_calldata_removes_bytes_data) char const* sourceCode = R"( contract c { function set() returns (bool) { data = msg.data; return true; } - function() { data = msg.data; } + function() external { data = msg.data; } bytes data; } )"; @@ -4246,7 +4166,7 @@ BOOST_AUTO_TEST_CASE(storing_invalid_boolean) assembly { tmp := 5 } - Ev(tmp); + emit Ev(tmp); return 1; } } @@ -6034,12 +5954,12 @@ BOOST_AUTO_TEST_CASE(invalid_enum_logged) assembly { garbled := 5 } - Log(garbled); + emit Log(garbled); return 1; } function test_log_ok() returns (uint) { X x = X.A; - Log(x); + emit Log(x); return 1; } } @@ -6345,7 +6265,7 @@ BOOST_AUTO_TEST_CASE(failing_send) char const* sourceCode = R"( contract Helper { uint[] data; - function () { + function () external { data[9]; // trigger exception } } @@ -6369,7 +6289,7 @@ BOOST_AUTO_TEST_CASE(send_zero_ether) // (it previously did not because the gas stipend was not provided by the EVM) char const* sourceCode = R"( contract Receiver { - function () payable { + function () external payable { } } contract Main { @@ -6398,7 +6318,7 @@ BOOST_AUTO_TEST_CASE(reusing_memory) mapping(uint => uint) map; function f(uint x) returns (uint) { map[x] = x; - return (new Helper(uint(keccak256(this.g(map[x]))))).flag(); + return (new Helper(uint(keccak256(abi.encodePacked(this.g(map[x])))))).flag(); } function g(uint a) returns (uint) { @@ -7885,7 +7805,7 @@ BOOST_AUTO_TEST_CASE(reject_ether_sent_to_library) function f(address x) returns (bool) { return x.send(1); } - function () payable {} + function () external payable {} } )"; compileAndRun(sourceCode, 0, "lib"); @@ -9386,7 +9306,7 @@ BOOST_AUTO_TEST_CASE(mutex) // 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 (!msg.sender.call.value(amount)("")) throw; shares -= amount; return shares; } @@ -9394,7 +9314,7 @@ BOOST_AUTO_TEST_CASE(mutex) // 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 (!msg.sender.call.value(amount)("")) throw; shares -= amount; return shares; } @@ -9415,7 +9335,7 @@ BOOST_AUTO_TEST_CASE(mutex) else return fund.withdrawUnprotected(10); } - function() payable { + function() external payable { callDepth++; if (callDepth < 4) attackInternal(); @@ -9460,14 +9380,14 @@ BOOST_AUTO_TEST_CASE(failing_ecrecover_invalid_input_proper) 0, // invalid v value 0x6944c77849b18048f6abe0db8084b0d0d0689cdddb53d2671c36967b58691ad4, 0xef4f06ba4f78319baafd0424365777241af4dfd3da840471b4b4b087b7750d0d, - 0xca35b7d915458ef540ade6068dfe2f44e8fa733c, - 0xca35b7d915458ef540ade6068dfe2f44e8fa733c + 0x00ca35b7d915458ef540ade6068dfe2f44e8fa733c, + 0x00ca35b7d915458ef540ade6068dfe2f44e8fa733c ); } function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s, uint blockExpired, bytes32 salt) returns (address) { - require(hash == keccak256(blockExpired, salt)); + require(hash == keccak256(abi.encodePacked(blockExpired, salt))); return ecrecover(hash, v, r, s); } } @@ -9499,7 +9419,7 @@ BOOST_AUTO_TEST_CASE(failing_ecrecover_invalid_input_asm) BOOST_AUTO_TEST_CASE(calling_nonexisting_contract_throws) { - char const* sourceCode = R"( + char const* sourceCode = R"YY( contract D { function g(); } contract C { D d = D(0x1212); @@ -9512,11 +9432,11 @@ BOOST_AUTO_TEST_CASE(calling_nonexisting_contract_throws) return 7; } function h() returns (uint) { - d.call(); // this does not throw (low-level) + d.call(""); // this does not throw (low-level) return 7; } } - )"; + )YY"; compileAndRun(sourceCode, 0, "C"); ABI_CHECK(callContractFunction("f()"), encodeArgs()); ABI_CHECK(callContractFunction("g()"), encodeArgs()); @@ -9541,7 +9461,7 @@ BOOST_AUTO_TEST_CASE(payable_function) function f() payable returns (uint) { return msg.value; } - function() payable { + function() external payable { a = msg.value + 1; } } @@ -9580,7 +9500,7 @@ BOOST_AUTO_TEST_CASE(non_payable_throw) function f() returns (uint) { return msg.value; } - function() { + function() external { a = msg.value + 1; } } @@ -11269,7 +11189,7 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages_through_transfer) { char const* sourceCode = R"( contract D { - function() public payable { + function() external payable { revert("message"); } function f() public { @@ -11420,7 +11340,7 @@ BOOST_AUTO_TEST_CASE(interface_contract) interface I { event A(); function f() returns (bool); - function() payable; + function() external payable; } contract A is I { @@ -11432,7 +11352,7 @@ BOOST_AUTO_TEST_CASE(interface_contract) return true; } - function() payable { + function() external payable { } } @@ -11520,17 +11440,17 @@ BOOST_AUTO_TEST_CASE(inlineasm_empty_let) BOOST_AUTO_TEST_CASE(bare_call_invalid_address) { - char const* sourceCode = R"( + char const* sourceCode = R"YY( contract C { /// Calling into non-existant account is successful (creates the account) function f() external returns (bool) { - return address(0x4242).call(); + return address(0x4242).call(""); } function h() external returns (bool) { - return address(0x4242).delegatecall(); + return address(0x4242).delegatecall(""); } } - )"; + )YY"; compileAndRun(sourceCode, 0, "C"); ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(1))); ABI_CHECK(callContractFunction("h()"), encodeArgs(u256(1))); @@ -11548,13 +11468,13 @@ BOOST_AUTO_TEST_CASE(delegatecall_return_value) return value; } function get_delegated() external returns (bool) { - return this.delegatecall(bytes4(keccak256("get()"))); + return this.delegatecall(abi.encodeWithSignature("get()")); } function assert0() external view { assert(value == 0); } function assert0_delegated() external returns (bool) { - return this.delegatecall(bytes4(keccak256("assert0()"))); + return this.delegatecall(abi.encodeWithSignature("assert0()")); } } )DELIMITER"; @@ -11932,7 +11852,7 @@ BOOST_AUTO_TEST_CASE(snark) input[7] = 9643208548031422463313148630985736896287522941726746581856185889848792022807; input[8] = 18066496933330839731877828156604; if (verify(input, proof) == 0) { - Verified("Transaction successfully verified."); + emit Verified("Transaction successfully verified."); return true; } else { return false; diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index ad26ce6b..ce8f4fe4 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -490,7 +490,7 @@ BOOST_AUTO_TEST_CASE(intermediately_overflowing_literals) // have been applied char const* sourceCode = R"( contract test { - function f() { var x = (0xffffffffffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffff01) & 0xbf; } + function f() { var x = (0x00ffffffffffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffff01) & 0xbf; } } )"; bytes code = compileFirstExpression(sourceCode); diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp index 3a8585f7..4ea307c0 100644 --- a/test/libsolidity/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -265,18 +265,18 @@ BOOST_AUTO_TEST_CASE(storage_write_in_loops) // Information in joining branches is not retained anymore. BOOST_AUTO_TEST_CASE(retain_information_in_branches) { - // This tests that the optimizer knows that we already have "z == keccak256(y)" inside both branches. + // This tests that the optimizer knows that we already have "z == keccak256(abi.encodePacked(y))" inside both branches. char const* sourceCode = R"( contract c { bytes32 d; uint a; function f(uint x, bytes32 y) returns (uint r_a, bytes32 r_d) { - bytes32 z = keccak256(y); + bytes32 z = keccak256(abi.encodePacked(y)); if (x > 8) { - z = keccak256(y); + z = keccak256(abi.encodePacked(y)); a = x; } else { - z = keccak256(y); + z = keccak256(abi.encodePacked(y)); a = x; } r_a = a; @@ -313,19 +313,19 @@ BOOST_AUTO_TEST_CASE(store_tags_as_unions) contract test { bytes32 data; function f(uint x, bytes32 y) external returns (uint r_a, bytes32 r_d) { - r_d = keccak256(y); + r_d = keccak256(abi.encodePacked(y)); shared(y); - r_d = keccak256(y); + r_d = keccak256(abi.encodePacked(y)); r_a = 5; } function g(uint x, bytes32 y) external returns (uint r_a, bytes32 r_d) { - r_d = keccak256(y); + r_d = keccak256(abi.encodePacked(y)); shared(y); - r_d = bytes32(uint(keccak256(y)) + 2); + r_d = bytes32(uint(keccak256(abi.encodePacked(y))) + 2); r_a = 7; } function shared(bytes32 y) internal { - data = keccak256(y); + data = keccak256(abi.encodePacked(y)); } } )"; @@ -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) returns (bool) { return sha256(a) == sha256(b); } + function f(string a, string b) returns (bool) { return sha256(bytes(a)) == sha256(bytes(b)); } } )"; compileBothVersions(sourceCode); diff --git a/test/libsolidity/SolidityTypes.cpp b/test/libsolidity/SolidityTypes.cpp index ba0e9d4f..b8b537e5 100644 --- a/test/libsolidity/SolidityTypes.cpp +++ b/test/libsolidity/SolidityTypes.cpp @@ -60,7 +60,21 @@ BOOST_AUTO_TEST_CASE(byte_types) BOOST_AUTO_TEST_CASE(fixed_types) { BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::Fixed, 0, 0)) == *make_shared<FixedPointType>(128, 18, FixedPointType::Modifier::Signed)); + for (unsigned i = 8; i <= 256; i += 8) + { + BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::FixedMxN, i, 0)) == *make_shared<FixedPointType>(i, 0, FixedPointType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::FixedMxN, i, 2)) == *make_shared<FixedPointType>(i, 2, FixedPointType::Modifier::Signed)); + } +} + +BOOST_AUTO_TEST_CASE(ufixed_types) +{ BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UFixed, 0, 0)) == *make_shared<FixedPointType>(128, 18, FixedPointType::Modifier::Unsigned)); + for (unsigned i = 8; i <= 256; i += 8) + { + BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UFixedMxN, i, 0)) == *make_shared<FixedPointType>(i, 0, FixedPointType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UFixedMxN, i, 2)) == *make_shared<FixedPointType>(i, 2, FixedPointType::Modifier::Unsigned)); + } } BOOST_AUTO_TEST_CASE(storage_layout_simple) @@ -115,12 +129,13 @@ BOOST_AUTO_TEST_CASE(storage_layout_arrays) BOOST_CHECK(ArrayType(DataLocation::Storage, make_shared<FixedBytesType>(32), 9).storageSize() == 9); } -BOOST_AUTO_TEST_CASE(type_escaping) +BOOST_AUTO_TEST_CASE(type_identifier_escaping) { BOOST_CHECK_EQUAL(Type::escapeIdentifier("("), "$_"); BOOST_CHECK_EQUAL(Type::escapeIdentifier(")"), "_$"); BOOST_CHECK_EQUAL(Type::escapeIdentifier(","), "_$_"); BOOST_CHECK_EQUAL(Type::escapeIdentifier("$"), "$$$"); + BOOST_CHECK_EQUAL(Type::escapeIdentifier(")$("), "_$$$$$_"); BOOST_CHECK_EQUAL(Type::escapeIdentifier("()"), "$__$"); BOOST_CHECK_EQUAL(Type::escapeIdentifier("(,)"), "$__$__$"); BOOST_CHECK_EQUAL(Type::escapeIdentifier("(,$,)"), "$__$_$$$_$__$"); @@ -137,7 +152,7 @@ BOOST_AUTO_TEST_CASE(type_identifiers) BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("int128")->identifier(), "t_int128"); BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("address")->identifier(), "t_address"); BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("uint8")->identifier(), "t_uint8"); - BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("ufixed8x64")->identifier(), "t_ufixed8x64"); + BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("ufixed64x2")->identifier(), "t_ufixed64x2"); BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("fixed128x8")->identifier(), "t_fixed128x8"); BOOST_CHECK_EQUAL(RationalNumberType(rational(7, 1)).identifier(), "t_rational_7_by_1"); BOOST_CHECK_EQUAL(RationalNumberType(rational(200, 77)).identifier(), "t_rational_200_by_77"); @@ -146,6 +161,7 @@ BOOST_AUTO_TEST_CASE(type_identifiers) StringLiteralType(Literal(SourceLocation{}, Token::StringLiteral, make_shared<string>("abc - def"))).identifier(), "t_stringliteral_196a9142ee0d40e274a6482393c762b16dd8315713207365e1e13d8d85b74fc4" ); + BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("byte")->identifier(), "t_bytes1"); BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("bytes8")->identifier(), "t_bytes8"); BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("bytes32")->identifier(), "t_bytes32"); BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("bool")->identifier(), "t_bool"); diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_2.sol b/test/libsolidity/syntaxTests/constants/cyclic_dependency_2.sol index 08d20c3a..9f1d9722 100644 --- a/test/libsolidity/syntaxTests/constants/cyclic_dependency_2.sol +++ b/test/libsolidity/syntaxTests/constants/cyclic_dependency_2.sol @@ -1,12 +1,10 @@ contract C { uint constant a = b * c; uint constant b = 7; - uint constant c = b + uint(keccak256(d)); + uint constant c = b + uint(keccak256(abi.encodePacked(d))); uint constant d = 2 + a; } // ---- -// Warning: (98-110): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (98-110): The provided argument of type uint256 is not implicitly convertible to expected type bytes memory. // TypeError: (17-40): The value of the constant a has a cyclic dependency via c. -// TypeError: (71-111): The value of the constant c has a cyclic dependency via d. -// TypeError: (117-140): The value of the constant d has a cyclic dependency via a. +// TypeError: (71-129): The value of the constant c has a cyclic dependency via d. +// TypeError: (135-158): The value of the constant d has a cyclic dependency via a. diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_4.sol b/test/libsolidity/syntaxTests/constants/cyclic_dependency_4.sol index df5cd969..cc34fad2 100644 --- a/test/libsolidity/syntaxTests/constants/cyclic_dependency_4.sol +++ b/test/libsolidity/syntaxTests/constants/cyclic_dependency_4.sol @@ -1,9 +1,7 @@ contract C { uint constant a = b * c; uint constant b = 7; - uint constant c = 4 + uint(keccak256(d)); + uint constant c = 4 + uint(keccak256(abi.encode(d))); uint constant d = 2 + b; } // ---- -// Warning: (98-110): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (98-110): The provided argument of type uint256 is not implicitly convertible to expected type bytes memory. diff --git a/test/libsolidity/syntaxTests/deprecated_functions.sol b/test/libsolidity/syntaxTests/deprecated_functions.sol index ff3af7d2..62dfcff9 100644 --- a/test/libsolidity/syntaxTests/deprecated_functions.sol +++ b/test/libsolidity/syntaxTests/deprecated_functions.sol @@ -1,12 +1,12 @@ contract test { function f() pure public { - bytes32 x = sha3(); + bytes32 x = sha3(""); x; } function g() public { - suicide(1); + suicide(0x0000000000000000000000000000000000000001); } } // ---- -// TypeError: (58-64): "sha3" has been deprecated in favour of "keccak256" -// TypeError: (99-109): "suicide" has been deprecated in favour of "selfdestruct" +// TypeError: (58-66): "sha3" has been deprecated in favour of "keccak256" +// TypeError: (101-152): "suicide" has been deprecated in favour of "selfdestruct" diff --git a/test/libsolidity/syntaxTests/empty_string_var.sol b/test/libsolidity/syntaxTests/empty_string_var.sol deleted file mode 100644 index e9837590..00000000 --- a/test/libsolidity/syntaxTests/empty_string_var.sol +++ /dev/null @@ -1,11 +0,0 @@ -contract C { - function f() { - var a = ""; - bytes1 b = bytes1(a); - bytes memory c = bytes(a); - string memory d = string(a); - } -} -// ---- -// Warning: (34-39): Use of the "var" keyword is deprecated. -// TypeError: (61-70): Explicit type conversion not allowed from "string memory" to "bytes1". diff --git a/test/libsolidity/syntaxTests/fallback/default_visibility.sol b/test/libsolidity/syntaxTests/fallback/default_visibility.sol new file mode 100644 index 00000000..2cb0af90 --- /dev/null +++ b/test/libsolidity/syntaxTests/fallback/default_visibility.sol @@ -0,0 +1,6 @@ +contract C { + // Check that visibility is also enforced for the fallback function. + function() {} +} +// ---- +// Warning: (90-103): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/fallback/pure_modifier.sol b/test/libsolidity/syntaxTests/fallback/pure_modifier.sol index 20d5b0ac..12d790d1 100644 --- a/test/libsolidity/syntaxTests/fallback/pure_modifier.sol +++ b/test/libsolidity/syntaxTests/fallback/pure_modifier.sol @@ -1,6 +1,6 @@ contract C { uint x; - function() pure { x = 2; } + function() external pure { x = 2; } } // ---- -// TypeError: (29-55): Fallback function must be payable or non-payable, but is "pure". +// TypeError: (29-64): Fallback function must be payable or non-payable, but is "pure". diff --git a/test/libsolidity/syntaxTests/fallback/view_modifier.sol b/test/libsolidity/syntaxTests/fallback/view_modifier.sol index 44c5d204..2497e9fa 100644 --- a/test/libsolidity/syntaxTests/fallback/view_modifier.sol +++ b/test/libsolidity/syntaxTests/fallback/view_modifier.sol @@ -1,6 +1,6 @@ contract C { uint x; - function() view { x = 2; } + function() external view { x = 2; } } // ---- -// TypeError: (29-55): Fallback function must be payable or non-payable, but is "view". +// TypeError: (29-64): Fallback function must be payable or non-payable, but is "view". diff --git a/test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol b/test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol index a6fe6c22..2481c455 100644 --- a/test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol +++ b/test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol @@ -3,15 +3,13 @@ contract C { function(uint) internal returns (uint) y; function f() public { delete x; - var a = y; + function(uint) internal returns (uint) a = y; delete a; delete y; - var c = f; + function() internal c = f; delete c; function(uint) internal returns (uint) g; delete g; } } // ---- -// Warning: (157-162): Use of the "var" keyword is deprecated. -// Warning: (212-217): Use of the "var" keyword is deprecated. diff --git a/test/libsolidity/syntaxTests/globalFunctions/call_with_wrong_arg_count.sol b/test/libsolidity/syntaxTests/globalFunctions/call_with_wrong_arg_count.sol new file mode 100644 index 00000000..e8134539 --- /dev/null +++ b/test/libsolidity/syntaxTests/globalFunctions/call_with_wrong_arg_count.sol @@ -0,0 +1,13 @@ +contract C { + function f() public { + require(address(this).call()); + require(address(this).call(bytes4(0x12345678))); + require(address(this).call(uint(1))); + require(address(this).call(uint(1), uint(2))); + } +} +// ---- +// TypeError: (55-75): Wrong argument count for function call: 0 arguments given but expected 1. This function requires a single bytes argument. Use "" as argument to provide empty calldata. +// TypeError: (113-131): Invalid type for argument in function call. Invalid implicit conversion from bytes4 to bytes memory requested. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it. +// TypeError: (170-177): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it. +// TypeError: (197-233): Wrong argument count for function call: 2 arguments given but expected 1. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it. diff --git a/test/libsolidity/syntaxTests/globalFunctions/callcode_with_wrong_arg_count.sol b/test/libsolidity/syntaxTests/globalFunctions/callcode_with_wrong_arg_count.sol new file mode 100644 index 00000000..2b424d53 --- /dev/null +++ b/test/libsolidity/syntaxTests/globalFunctions/callcode_with_wrong_arg_count.sol @@ -0,0 +1,11 @@ +contract C { + function f() public { + require(address(this).callcode()); + require(address(this).callcode(uint(1))); + require(address(this).callcode(uint(1), uint(2))); + } +} +// ---- +// TypeError: (55-79): Wrong argument count for function call: 0 arguments given but expected 1. This function requires a single bytes argument. Use "" as argument to provide empty calldata. +// TypeError: (121-128): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it. +// TypeError: (148-188): Wrong argument count for function call: 2 arguments given but expected 1. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it. diff --git a/test/libsolidity/syntaxTests/globalFunctions/delegatecall_with_wrong_arg_count.sol b/test/libsolidity/syntaxTests/globalFunctions/delegatecall_with_wrong_arg_count.sol new file mode 100644 index 00000000..be0347de --- /dev/null +++ b/test/libsolidity/syntaxTests/globalFunctions/delegatecall_with_wrong_arg_count.sol @@ -0,0 +1,11 @@ +contract C { + function f() public { + require(address(this).delegatecall()); + require(address(this).delegatecall(uint(1))); + require(address(this).delegatecall(uint(1), uint(2))); + } +} +// ---- +// TypeError: (55-83): Wrong argument count for function call: 0 arguments given but expected 1. This function requires a single bytes argument. Use "" as argument to provide empty calldata. +// TypeError: (129-136): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it. +// TypeError: (156-200): Wrong argument count for function call: 2 arguments given but expected 1. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it. diff --git a/test/libsolidity/syntaxTests/globalFunctions/keccak256_with_wrong_arg_count.sol b/test/libsolidity/syntaxTests/globalFunctions/keccak256_with_wrong_arg_count.sol new file mode 100644 index 00000000..4857bc2e --- /dev/null +++ b/test/libsolidity/syntaxTests/globalFunctions/keccak256_with_wrong_arg_count.sol @@ -0,0 +1,11 @@ +contract C { + function f() public { + require(keccak256() != 0); + require(keccak256(uint(1)) != 0); + require(keccak256(uint(1), uint(2)) != 0); + } +} +// ---- +// TypeError: (55-66): Wrong argument count for function call: 0 arguments given but expected 1. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. +// TypeError: (100-107): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. +// TypeError: (132-159): Wrong argument count for function call: 2 arguments given but expected 1. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. diff --git a/test/libsolidity/syntaxTests/globalFunctions/ripemd160_with_wrong_arg_count.sol b/test/libsolidity/syntaxTests/globalFunctions/ripemd160_with_wrong_arg_count.sol new file mode 100644 index 00000000..da41fccd --- /dev/null +++ b/test/libsolidity/syntaxTests/globalFunctions/ripemd160_with_wrong_arg_count.sol @@ -0,0 +1,11 @@ +contract C { + function f() public { + require(ripemd160() != 0); + require(ripemd160(uint(1)) != 0); + require(ripemd160(uint(1), uint(2)) != 0); + } +} +// ---- +// TypeError: (55-66): Wrong argument count for function call: 0 arguments given but expected 1. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. +// TypeError: (100-107): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. +// TypeError: (132-159): Wrong argument count for function call: 2 arguments given but expected 1. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. diff --git a/test/libsolidity/syntaxTests/globalFunctions/sha256_with_wrong_arg_count.sol b/test/libsolidity/syntaxTests/globalFunctions/sha256_with_wrong_arg_count.sol new file mode 100644 index 00000000..2939e7fc --- /dev/null +++ b/test/libsolidity/syntaxTests/globalFunctions/sha256_with_wrong_arg_count.sol @@ -0,0 +1,11 @@ +contract C { + function f() public { + require(sha256() != 0); + require(sha256(uint(1)) != 0); + require(sha256(uint(1), uint(2)) != 0); + } +} +// ---- +// TypeError: (55-63): Wrong argument count for function call: 0 arguments given but expected 1. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. +// TypeError: (94-101): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. +// TypeError: (126-150): Wrong argument count for function call: 2 arguments given but expected 1. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalid.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalid.sol deleted file mode 100644 index c8686ae8..00000000 --- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalid.sol +++ /dev/null @@ -1,8 +0,0 @@ -contract C { - function f() internal returns (uint, uint, uint, uint) { - var (uint a, uint b,,) = f(); - a; b; - } -} -// ---- -// ParserError: (81-85): Expected identifier but got 'uint' diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/005_type_inference_smoke_test.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/005_type_inference_smoke_test.sol deleted file mode 100644 index 4c4c62a5..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/005_type_inference_smoke_test.sol +++ /dev/null @@ -1,8 +0,0 @@ -contract test { - function f(uint256 arg1, uint32 arg2) public returns (bool ret) { - var x = arg1 + arg2 == 8; ret = x; - } -} -// ---- -// Warning: (94-99): Use of the "var" keyword is deprecated. -// Warning: (20-134): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/012_type_inference_explicit_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/012_type_inference_explicit_conversion.sol deleted file mode 100644 index 70d31f25..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/012_type_inference_explicit_conversion.sol +++ /dev/null @@ -1,6 +0,0 @@ -contract test { - function f() public returns (int256 r) { var x = int256(uint32(2)); return x; } -} -// ---- -// Warning: (61-66): Use of the "var" keyword is deprecated. -// Warning: (20-99): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/013_large_string_literal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/013_large_string_literal.sol index 18ff6054..7f858a4d 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/013_large_string_literal.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/013_large_string_literal.sol @@ -1,7 +1,6 @@ contract test { - function f() public { var x = "123456789012345678901234567890123"; } + function f() public { string memory x = "123456789012345678901234567890123"; } } // ---- -// Warning: (42-47): Use of the "var" keyword is deprecated. -// Warning: (42-47): Unused local variable. -// Warning: (20-88): Function state mutability can be restricted to pure +// Warning: (42-57): Unused local variable. +// Warning: (20-98): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol index 764f630f..8bf45c3f 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol @@ -4,10 +4,9 @@ contract test { } str data; function fun() public { - var a = data.map; + mapping(uint=>uint) a = data.map; data.map = a; } } // ---- -// Warning: (122-127): Use of the "var" keyword is deprecated. -// TypeError: (148-160): Mappings cannot be assigned to. +// TypeError: (164-176): Mappings cannot be assigned to. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/017_assignment_to_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/017_assignment_to_struct.sol index f7db0b24..6fbd09ae 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/017_assignment_to_struct.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/017_assignment_to_struct.sol @@ -4,9 +4,8 @@ contract test { } str data; function fun() public { - var a = data; + str storage a = data; data = a; } } // ---- -// Warning: (122-127): Use of the "var" keyword is deprecated. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/025_comparison_of_mapping_types.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/025_comparison_of_mapping_types.sol index 78d89ef8..27651d63 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/025_comparison_of_mapping_types.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/025_comparison_of_mapping_types.sol @@ -1,10 +1,9 @@ contract C { mapping(uint => uint) x; function f() public returns (bool ret) { - var y = x; + mapping(uint => uint) y = x; return x == y; } } // ---- -// Warning: (95-100): Use of the "var" keyword is deprecated. -// TypeError: (121-127): Operator == not compatible with types mapping(uint256 => uint256) and mapping(uint256 => uint256) +// TypeError: (139-145): Operator == not compatible with types mapping(uint256 => uint256) and mapping(uint256 => uint256) diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/074_fallback_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/074_fallback_function.sol index 7e64bbe2..466e80cb 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/074_fallback_function.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/074_fallback_function.sol @@ -1,4 +1,4 @@ contract C { uint x; - function() public { x = 2; } + function() external { x = 2; } } diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/075_fallback_function_with_arguments.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/075_fallback_function_with_arguments.sol index 2c1d2a1b..68d40952 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/075_fallback_function_with_arguments.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/075_fallback_function_with_arguments.sol @@ -1,6 +1,6 @@ contract C { uint x; - function(uint a) public { x = 2; } + function(uint a) external { x = 2; } } // ---- // TypeError: (37-45): Fallback function cannot take parameters. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/076_fallback_function_in_library.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/076_fallback_function_in_library.sol index 11fef976..25878a61 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/076_fallback_function_in_library.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/076_fallback_function_in_library.sol @@ -1,5 +1,5 @@ library C { - function() public {} + function() external {} } // ---- -// TypeError: (16-36): Libraries cannot have fallback functions. +// TypeError: (16-38): Libraries cannot have fallback functions. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/077_fallback_function_with_return_parameters.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/077_fallback_function_with_return_parameters.sol index 905bcd2d..3ff7a1c4 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/077_fallback_function_with_return_parameters.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/077_fallback_function_with_return_parameters.sol @@ -1,5 +1,5 @@ contract C { - function() public returns (uint) { } + function() external returns (uint) { } } // ---- -// TypeError: (43-49): Fallback function cannot return values. +// TypeError: (45-51): Fallback function cannot return values. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/078_fallback_function_twice.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/078_fallback_function_twice.sol index 8d839da0..e5746c63 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/078_fallback_function_twice.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/078_fallback_function_twice.sol @@ -1,7 +1,7 @@ contract C { uint x; - function() public { x = 2; } - function() public { x = 3; } + function() external { x = 2; } + function() external { x = 3; } } // ---- -// DeclarationError: (62-90): Only one fallback function is allowed. +// DeclarationError: (64-94): Only one fallback function is allowed. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/079_fallback_function_inheritance.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/079_fallback_function_inheritance.sol index a35a8093..c8c06c6e 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/079_fallback_function_inheritance.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/079_fallback_function_inheritance.sol @@ -1,7 +1,7 @@ contract A { uint x; - function() public { x = 1; } + function() external { x = 1; } } contract C is A { - function() public { x = 2; } + function() external { x = 2; } } diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/080_event.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/080_event.sol index 780d26a6..c5f9e4d0 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/080_event.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/080_event.sol @@ -1,6 +1,5 @@ contract c { event e(uint indexed a, bytes3 indexed s, bool indexed b); - function f() public { e(2, "abc", true); } + function f() public { emit e(2, "abc", true); } } // ---- -// Warning: (102-119): Invoking events without "emit" prefix is deprecated. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/090_event_call.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/090_event_call.sol index abf46f94..8cf50597 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/090_event_call.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/090_event_call.sol @@ -1,6 +1,5 @@ contract c { event e(uint a, bytes3 indexed s, bool indexed b); - function f() public { e(2, "abc", true); } + function f() public { emit e(2, "abc", true); } } // ---- -// Warning: (94-111): Invoking events without "emit" prefix is deprecated. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/094_event_inheritance.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/094_event_inheritance.sol index d177209b..b13d5755 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/094_event_inheritance.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/094_event_inheritance.sol @@ -2,7 +2,6 @@ contract base { event e(uint a, bytes3 indexed s, bool indexed b); } contract c is base { - function f() public { e(2, "abc", true); } + function f() public { emit e(2, "abc", true); } } // ---- -// Warning: (120-137): Invoking events without "emit" prefix is deprecated. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/109_disallow_declaration_of_void_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/109_disallow_declaration_of_void_type.sol deleted file mode 100644 index b79b976a..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/109_disallow_declaration_of_void_type.sol +++ /dev/null @@ -1,7 +0,0 @@ -contract c { - function f() public { var (x) = f(); } -} -// ---- -// Warning: (44-45): Use of the "var" keyword is deprecated. -// Warning: (39-52): Different number of components on the left hand side (1) than on the right hand side (0). -// TypeError: (39-52): Not enough components (0) in value to assign all variables (1). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/120_warn_var_from_uint8.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/120_warn_var_from_uint8.sol deleted file mode 100644 index db086252..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/120_warn_var_from_uint8.sol +++ /dev/null @@ -1,9 +0,0 @@ -contract test { - function f() pure public returns (uint) { - var i = 1; - return i; - } -} -// ---- -// Warning: (70-75): Use of the "var" keyword is deprecated. -// Warning: (70-79): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/121_warn_var_from_uint256.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/121_warn_var_from_uint256.sol deleted file mode 100644 index 2b48ce5d..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/121_warn_var_from_uint256.sol +++ /dev/null @@ -1,9 +0,0 @@ -contract test { - function f() pure public { - var i = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff; - i; - } -} -// ---- -// Warning: (55-60): Use of the "var" keyword is deprecated. -// Warning: (55-129): The type of this variable was inferred as uint256, which can hold values between 0 and 115792089237316195423570985008687907853269984665640564039457584007913129639935. This is probably not desired. Use an explicit type to silence this warning. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/122_warn_var_from_int8.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/122_warn_var_from_int8.sol deleted file mode 100644 index bebcbab5..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/122_warn_var_from_int8.sol +++ /dev/null @@ -1,9 +0,0 @@ -contract test { - function f() pure public { - var i = -2; - i; - } -} -// ---- -// Warning: (55-60): Use of the "var" keyword is deprecated. -// Warning: (55-65): The type of this variable was inferred as int8, which can hold values between -128 and 127. This is probably not desired. Use an explicit type to silence this warning. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/123_warn_var_from_zero.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/123_warn_var_from_zero.sol deleted file mode 100644 index 3d269993..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/123_warn_var_from_zero.sol +++ /dev/null @@ -1,8 +0,0 @@ - contract test { - function f() pure public { - for (var i = 0; i < msg.data.length; i++) { } - } - } -// ---- -// Warning: (63-68): Use of the "var" keyword is deprecated. -// Warning: (63-72): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/178_assignment_of_nonoverloaded_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/178_assignment_of_nonoverloaded_function.sol index f7daa33f..07fc1c43 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/178_assignment_of_nonoverloaded_function.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/178_assignment_of_nonoverloaded_function.sol @@ -1,7 +1,6 @@ contract test { function f(uint a) public returns (uint) { return 2 * a; } - function g() public returns (uint) { var x = f; return x(7); } + function g() public returns (uint) { function (uint) returns (uint) x = f; return x(7); } } // ---- -// Warning: (120-125): Use of the "var" keyword is deprecated. // Warning: (20-78): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/179_assignment_of_overloaded_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/179_assignment_of_overloaded_function.sol index 375980c3..9ed864f1 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/179_assignment_of_overloaded_function.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/179_assignment_of_overloaded_function.sol @@ -1,8 +1,7 @@ contract test { function f() public returns (uint) { return 1; } function f(uint a) public returns (uint) { return 2 * a; } - function g() public returns (uint) { var x = f; return x(7); } + function g() public returns (uint) { function (uint) returns (uint) x = f; return x(7); } } // ---- -// Warning: (173-178): Use of the "var" keyword is deprecated. -// TypeError: (181-182): No matching declaration found after variable lookup. +// TypeError: (208-209): No matching declaration found after variable lookup. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/183_uninitialized_var.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/183_uninitialized_var.sol deleted file mode 100644 index 61836b59..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/183_uninitialized_var.sol +++ /dev/null @@ -1,6 +0,0 @@ -contract C { - function f() public returns (uint) { var x; return 2; } -} -// ---- -// Warning: (54-59): Use of the "var" keyword is deprecated. -// TypeError: (54-59): Assignment necessary for type detection. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/188_string_index.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/188_string_index.sol index 8e838537..9d51e06b 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/188_string_index.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/188_string_index.sol @@ -1,7 +1,6 @@ contract C { string s; - function f() public { var a = s[2]; } + function f() public { bytes1 a = s[2]; } } // ---- -// Warning: (53-58): Use of the "var" keyword is deprecated. -// TypeError: (61-65): Index access for string is not possible. +// TypeError: (64-68): Index access for string is not possible. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/189_string_length.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/189_string_length.sol index 36be82c9..9e714d68 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/189_string_length.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/189_string_length.sol @@ -1,7 +1,6 @@ contract C { string s; - function f() public { var a = s.length; } + function f() public { uint a = s.length; } } // ---- -// Warning: (53-58): Use of the "var" keyword is deprecated. -// TypeError: (61-69): 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/196_integer_boolean_or.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/196_integer_boolean_or.sol index 1b522c00..db42786d 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/196_integer_boolean_or.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/196_integer_boolean_or.sol @@ -1,3 +1,3 @@ -contract test { function() public { uint x = 1; uint y = 2; x || y; } } +contract test { function() external { uint x = 1; uint y = 2; x || y; } } // ---- -// TypeError: (60-66): Operator || not compatible with types uint256 and uint256 +// TypeError: (62-68): Operator || not compatible with types uint256 and uint256 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/197_integer_boolean_and.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/197_integer_boolean_and.sol index cbc3732f..94d1c691 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/197_integer_boolean_and.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/197_integer_boolean_and.sol @@ -1,3 +1,3 @@ -contract test { function() public { uint x = 1; uint y = 2; x && y; } } +contract test { function() external { uint x = 1; uint y = 2; x && y; } } // ---- -// TypeError: (60-66): Operator && not compatible with types uint256 and uint256 +// TypeError: (62-68): Operator && not compatible with types uint256 and uint256 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/198_integer_boolean_not.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/198_integer_boolean_not.sol index 1d36b0b3..68fe6e94 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/198_integer_boolean_not.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/198_integer_boolean_not.sol @@ -1,3 +1,3 @@ -contract test { function() public { uint x = 1; !x; } } +contract test { function() external { uint x = 1; !x; } } // ---- -// TypeError: (48-50): Unary operator ! cannot be applied to type uint256 +// TypeError: (50-52): Unary operator ! cannot be applied to type uint256 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/199_integer_unsigned_exp_signed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/199_integer_unsigned_exp_signed.sol index 5b8b2d3f..fbeadfb6 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/199_integer_unsigned_exp_signed.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/199_integer_unsigned_exp_signed.sol @@ -1,3 +1,3 @@ -contract test { function() public { uint x = 3; int y = -4; x ** y; } } +contract test { function() external { uint x = 3; int y = -4; x ** y; } } // ---- -// TypeError: (60-66): Operator ** not compatible with types uint256 and int256 +// TypeError: (62-68): Operator ** not compatible with types uint256 and int256 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/200_integer_signed_exp_unsigned.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/200_integer_signed_exp_unsigned.sol index 95c19d17..75e92085 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/200_integer_signed_exp_unsigned.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/200_integer_signed_exp_unsigned.sol @@ -1,3 +1,3 @@ -contract test { function() public { uint x = 3; int y = -4; y ** x; } } +contract test { function() external { uint x = 3; int y = -4; y ** x; } } // ---- -// TypeError: (60-66): Operator ** not compatible with types int256 and uint256 +// TypeError: (62-68): Operator ** not compatible with types int256 and uint256 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/201_integer_signed_exp_signed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/201_integer_signed_exp_signed.sol index 394dec88..93e5f065 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/201_integer_signed_exp_signed.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/201_integer_signed_exp_signed.sol @@ -1,3 +1,3 @@ -contract test { function() public { int x = -3; int y = -4; x ** y; } } +contract test { function() external { int x = -3; int y = -4; x ** y; } } // ---- -// TypeError: (60-66): Operator ** not compatible with types int256 and int256 +// TypeError: (62-68): Operator ** not compatible with types int256 and int256 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/202_bytes_reference_compare_operators.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/202_bytes_reference_compare_operators.sol index d4c513dd..711b794c 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/202_bytes_reference_compare_operators.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/202_bytes_reference_compare_operators.sol @@ -1,3 +1,3 @@ -contract test { bytes a; bytes b; function() public { a == b; } } +contract test { bytes a; bytes b; function() external { a == b; } } // ---- -// TypeError: (54-60): Operator == not compatible with types bytes storage ref and bytes storage ref +// TypeError: (56-62): Operator == not compatible with types bytes storage ref and bytes storage ref diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/203_struct_reference_compare_operators.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/203_struct_reference_compare_operators.sol index de96b798..a74850b3 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/203_struct_reference_compare_operators.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/203_struct_reference_compare_operators.sol @@ -1,3 +1,10 @@ -contract test { struct s {uint a;} s x; s y; function() public { x == y; } } +contract test { + struct s {uint a;} + s x; + s y; + function() external { + x == y; + } +} // ---- -// TypeError: (65-71): Operator == not compatible with types struct test.s storage ref and struct test.s storage ref +// TypeError: (79-85): Operator == not compatible with types struct test.s storage ref and struct test.s storage ref diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/208_assignment_mem_to_local_storage_variable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/208_assignment_mem_to_local_storage_variable.sol index a2048a8a..febe39e6 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/208_assignment_mem_to_local_storage_variable.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/208_assignment_mem_to_local_storage_variable.sol @@ -1,10 +1,9 @@ contract C { uint[] data; function f(uint[] x) public { - var dataRef = data; + uint[] storage dataRef = data; dataRef = x; } } // ---- -// Warning: (72-83): Use of the "var" keyword is deprecated. -// TypeError: (110-111): Type uint256[] memory is not implicitly convertible to expected type uint256[] storage pointer. +// TypeError: (121-122): Type uint256[] memory is not implicitly convertible to expected type uint256[] storage pointer. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/213_no_delete_on_storage_pointers.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/213_no_delete_on_storage_pointers.sol index d17b62e4..7a6fb1c7 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/213_no_delete_on_storage_pointers.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/213_no_delete_on_storage_pointers.sol @@ -1,10 +1,9 @@ contract C { uint[] data; function f() public { - var x = data; + uint[] storage x = data; delete x; } } // ---- -// Warning: (64-69): Use of the "var" keyword is deprecated. -// TypeError: (86-94): Unary operator delete cannot be applied to type uint256[] storage pointer +// TypeError: (97-105): Unary operator delete cannot be applied to type uint256[] storage pointer diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/230_creating_contract_within_the_contract.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/230_creating_contract_within_the_contract.sol index 8dbaef9c..8624b0b0 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/230_creating_contract_within_the_contract.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/230_creating_contract_within_the_contract.sol @@ -1,6 +1,5 @@ contract Test { - function f() public { var x = new Test(); } + function f() public { Test x = new Test(); } } // ---- -// Warning: (42-47): Use of the "var" keyword is deprecated. -// TypeError: (50-58): Circular reference for contract creation (cannot create instance of derived or same contract). +// TypeError: (51-59): Circular reference for contract creation (cannot create instance of derived or same contract). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/235_abi_encode_with_large_integer_constant.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/235_abi_encode_with_large_integer_constant.sol new file mode 100644 index 00000000..fd9717f1 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/235_abi_encode_with_large_integer_constant.sol @@ -0,0 +1,5 @@ +contract C { + function f() pure public { abi.encode(2**500); } +} +// ---- +// TypeError: (55-61): Invalid rational number (too large or division by zero). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/235_keccak256_with_large_integer_constant.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/235_keccak256_with_large_integer_constant.sol deleted file mode 100644 index c39d0fe2..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/235_keccak256_with_large_integer_constant.sol +++ /dev/null @@ -1,7 +0,0 @@ -contract C { - function f() public { keccak256(2**500); } -} -// ---- -// Warning: (39-56): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (39-56): The provided argument of type int_const 3273...(143 digits omitted)...9376 is not implicitly convertible to expected type bytes memory. -// TypeError: (49-55): Invalid rational number (too large or division by zero). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/238_multi_variable_declaration_fail.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/238_multi_variable_declaration_fail.sol deleted file mode 100644 index de115d12..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/238_multi_variable_declaration_fail.sol +++ /dev/null @@ -1,5 +0,0 @@ -contract C { function f() public { var (x,y); x = 1; y = 1;} } -// ---- -// Warning: (40-41): Use of the "var" keyword is deprecated. -// Warning: (42-43): Use of the "var" keyword is deprecated. -// TypeError: (35-44): Assignment necessary for type detection. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/239_multi_variable_declaration_wildcards_fine.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/239_multi_variable_declaration_wildcards_fine.sol index a1cfb070..ae260ce4 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/239_multi_variable_declaration_wildcards_fine.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/239_multi_variable_declaration_wildcards_fine.sol @@ -3,24 +3,18 @@ contract C { function two() public returns (uint, uint); function none(); function f() public { - var (a,) = three(); - var (b,c,) = two(); - var (,d) = three(); - var (,e,g) = two(); + (uint a,) = three(); + (uint b, uint c,) = two(); + (,uint d) = three(); + (,uint e, uint g) = two(); var (,,) = three(); var () = none(); a;b;c;d;e;g; } } // ---- -// Warning: (177-178): Use of the "var" keyword is deprecated. -// Warning: (205-206): Use of the "var" keyword is deprecated. -// Warning: (207-208): Use of the "var" keyword is deprecated. -// Warning: (234-235): Use of the "var" keyword is deprecated. -// Warning: (262-263): Use of the "var" keyword is deprecated. -// Warning: (264-265): Use of the "var" keyword is deprecated. -// Warning: (172-190): Different number of components on the left hand side (2) than on the right hand side (3). -// Warning: (200-218): Different number of components on the left hand side (3) than on the right hand side (2). -// Warning: (228-246): Different number of components on the left hand side (2) than on the right hand side (3). -// Warning: (256-274): Different number of components on the left hand side (3) than on the right hand side (2). +// Warning: (172-191): Different number of components on the left hand side (2) than on the right hand side (3). +// Warning: (201-226): Different number of components on the left hand side (3) than on the right hand side (2). +// Warning: (236-255): Different number of components on the left hand side (2) than on the right hand side (3). +// Warning: (265-290): Different number of components on the left hand side (3) than on the right hand side (2). // Warning: (121-137): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/240_multi_variable_declaration_wildcards_fail_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/240_multi_variable_declaration_wildcards_fail_1.sol index 526ff4e8..0ccbb327 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/240_multi_variable_declaration_wildcards_fail_1.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/240_multi_variable_declaration_wildcards_fail_1.sol @@ -1,9 +1,7 @@ contract C { function one() public returns (uint); - function f() public { var (a, b, ) = one(); } + function f() public { (uint a, uint b, ) = one(); } } // ---- -// Warning: (86-87): Use of the "var" keyword is deprecated. -// Warning: (89-90): Use of the "var" keyword is deprecated. -// Warning: (81-101): Different number of components on the left hand side (3) than on the right hand side (1). -// TypeError: (81-101): Not enough components (1) in value to assign all variables (2). +// Warning: (81-107): Different number of components on the left hand side (3) than on the right hand side (1). +// TypeError: (81-107): Not enough components (1) in value to assign all variables (2). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/241_multi_variable_declaration_wildcards_fail_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/241_multi_variable_declaration_wildcards_fail_2.sol index e41edb64..8d5de125 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/241_multi_variable_declaration_wildcards_fail_2.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/241_multi_variable_declaration_wildcards_fail_2.sol @@ -1,8 +1,7 @@ contract C { function one() public returns (uint); - function f() public { var (a, , ) = one(); } + function f() public { (uint a, , ) = one(); } } // ---- -// Warning: (86-87): Use of the "var" keyword is deprecated. -// Warning: (81-100): Different number of components on the left hand side (3) than on the right hand side (1). -// TypeError: (81-100): Not enough components (1) in value to assign all variables (2). +// Warning: (81-101): Different number of components on the left hand side (3) than on the right hand side (1). +// TypeError: (81-101): Not enough components (1) in value to assign all variables (2). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/242_multi_variable_declaration_wildcards_fail_3.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/242_multi_variable_declaration_wildcards_fail_3.sol index 202b79c6..993df9b9 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/242_multi_variable_declaration_wildcards_fail_3.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/242_multi_variable_declaration_wildcards_fail_3.sol @@ -1,8 +1,7 @@ contract C { function one() public returns (uint); - function f() public { var (, , a) = one(); } + function f() public { (, , uint a) = one(); } } // ---- -// Warning: (90-91): Use of the "var" keyword is deprecated. -// Warning: (81-100): Different number of components on the left hand side (3) than on the right hand side (1). -// TypeError: (81-100): Not enough components (1) in value to assign all variables (2). +// Warning: (81-101): Different number of components on the left hand side (3) than on the right hand side (1). +// TypeError: (81-101): Not enough components (1) in value to assign all variables (2). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/243_multi_variable_declaration_wildcards_fail_4.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/243_multi_variable_declaration_wildcards_fail_4.sol index 79f2f3b5..0697b789 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/243_multi_variable_declaration_wildcards_fail_4.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/243_multi_variable_declaration_wildcards_fail_4.sol @@ -1,9 +1,7 @@ contract C { function one() public returns (uint); - function f() public { var (, a, b) = one(); } + function f() public { (, uint a, uint b) = one(); } } // ---- -// Warning: (88-89): Use of the "var" keyword is deprecated. -// Warning: (91-92): Use of the "var" keyword is deprecated. -// Warning: (81-101): Different number of components on the left hand side (3) than on the right hand side (1). -// TypeError: (81-101): Not enough components (1) in value to assign all variables (2). +// Warning: (81-107): Different number of components on the left hand side (3) than on the right hand side (1). +// TypeError: (81-107): Not enough components (1) in value to assign all variables (2). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/244_tuples.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/244_tuples.sol index 43553af9..3112f67a 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/244_tuples.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/244_tuples.sol @@ -1,17 +1,13 @@ contract C { function f() public { uint a = (1); - var (b,) = (uint8(1),); - var (c,d) = (uint32(1), 2 + a); - var (e,) = (uint64(1), 2, b); + (uint b,) = (uint8(1),); + (uint c, uint d) = (uint32(1), 2 + a); + (uint e,) = (uint64(1), 2, b); a;b;c;d;e; } } // ---- -// Warning: (74-75): Use of the "var" keyword is deprecated. -// Warning: (106-107): Use of the "var" keyword is deprecated. -// Warning: (108-109): Use of the "var" keyword is deprecated. -// Warning: (146-147): Use of the "var" keyword is deprecated. -// Warning: (69-91): Different number of components on the left hand side (2) than on the right hand side (1). -// Warning: (141-169): Different number of components on the left hand side (2) than on the right hand side (3). -// Warning: (17-195): Function state mutability can be restricted to pure +// Warning: (69-92): Different number of components on the left hand side (2) than on the right hand side (1). +// Warning: (149-178): Different number of components on the left hand side (2) than on the right hand side (3). +// Warning: (17-204): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/247_multi_variable_declaration_wildcards_fail_6.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/247_multi_variable_declaration_wildcards_fail_6.sol index 734ba09c..cc5953db 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/247_multi_variable_declaration_wildcards_fail_6.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/247_multi_variable_declaration_wildcards_fail_6.sol @@ -1,10 +1,7 @@ contract C { function two() public returns (uint, uint); - function f() public { var (a, b, c) = two(); } + function f() public { (uint a, uint b, uint c) = two(); } } // ---- -// Warning: (92-93): Use of the "var" keyword is deprecated. -// Warning: (95-96): Use of the "var" keyword is deprecated. -// Warning: (98-99): Use of the "var" keyword is deprecated. -// Warning: (87-108): Different number of components on the left hand side (3) than on the right hand side (2). -// TypeError: (87-108): Not enough components (2) in value to assign all variables (3). +// Warning: (87-119): Different number of components on the left hand side (3) than on the right hand side (2). +// TypeError: (87-119): Not enough components (2) in value to assign all variables (3). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/248_tuple_assignment_from_void_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/248_tuple_assignment_from_void_function.sol deleted file mode 100644 index f3e02ecb..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/248_tuple_assignment_from_void_function.sol +++ /dev/null @@ -1,11 +0,0 @@ -contract C { - function f() public { } - function g() public { - var (x,) = (f(), f()); - } -} -// ---- -// Warning: (80-81): Use of the "var" keyword is deprecated. -// Warning: (87-90): Tuple component cannot be empty. -// Warning: (92-95): Tuple component cannot be empty. -// TypeError: (80-81): Cannot declare variable with void (empty tuple) type. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/262_bound_function_in_var.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/262_bound_function_in_var.sol index 09e357e6..c3cc5232 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/262_bound_function_in_var.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/262_bound_function_in_var.sol @@ -3,9 +3,11 @@ contract C { using D for D.s; D.s x; function f(uint a) public returns (uint) { - var g = x.mul; - return g({x: a}); + function (D.s storage, uint) returns (uint) g = x.mul; + g(x, a); + g(a); } } // ---- -// Warning: (218-223): Use of the "var" keyword is deprecated. +// TypeError: (218-271): Type function (struct D.s storage pointer,uint256) returns (uint256) is not implicitly convertible to expected type function (struct D.s storage pointer,uint256) returns (uint256). +// TypeError: (298-302): Wrong argument count for function call: 1 arguments given but expected 2. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/263_create_memory_arrays.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/263_create_memory_arrays.sol index acb5a0b5..71f43992 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/263_create_memory_arrays.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/263_create_memory_arrays.sol @@ -5,12 +5,10 @@ library L { contract C { function f(uint size) public { L.S[][] memory x = new L.S[][](10); - var y = new uint[](20); - var z = new bytes(size); + uint[] memory y = new uint[](20); + bytes memory z = new bytes(size); x;y;z; } } // ---- -// Warning: (205-210): Use of the "var" keyword is deprecated. -// Warning: (237-242): Use of the "var" keyword is deprecated. -// Warning: (122-282): Function state mutability can be restricted to pure +// Warning: (122-301): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/264_mapping_in_memory_array.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/264_mapping_in_memory_array.sol index 8ad26fc0..f0bb557b 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/264_mapping_in_memory_array.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/264_mapping_in_memory_array.sol @@ -1,8 +1,7 @@ contract C { function f(uint size) public { - var x = new mapping(uint => uint)[](4); + mapping(uint => uint) x = new mapping(uint => uint)[](4); } } // ---- -// Warning: (56-61): Use of the "var" keyword is deprecated. -// TypeError: (68-91): Type cannot live outside storage. +// TypeError: (86-109): Type cannot live outside storage. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/265_new_for_non_array.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/265_new_for_non_array.sol index 1dd81fde..c4b2c692 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/265_new_for_non_array.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/265_new_for_non_array.sol @@ -1,8 +1,7 @@ contract C { function f(uint size) public { - var x = new uint(7); + uint x = new uint(7); } } // ---- -// Warning: (56-61): Use of the "var" keyword is deprecated. -// TypeError: (64-72): Contract or array type expected. +// TypeError: (65-73): Contract or array type expected. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/266_invalid_args_creating_memory_array.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/266_invalid_args_creating_memory_array.sol index ea3556de..078255e3 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/266_invalid_args_creating_memory_array.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/266_invalid_args_creating_memory_array.sol @@ -1,8 +1,7 @@ contract C { function f(uint size) public { - var x = new uint[](); + uint[] memory x = new uint[](); } } // ---- -// Warning: (56-61): Use of the "var" keyword is deprecated. -// TypeError: (64-76): Wrong argument count for function call: 0 arguments given but expected 1. +// TypeError: (74-86): Wrong argument count for function call: 0 arguments given but expected 1. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/267_invalid_args_creating_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/267_invalid_args_creating_struct.sol index 9a169468..35671e6f 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/267_invalid_args_creating_struct.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/267_invalid_args_creating_struct.sol @@ -2,9 +2,8 @@ contract C { struct S { uint a; uint b; } function f() public { - var s = S({a: 1}); + S memory s = S({a: 1}); } } // ---- -// Warning: (81-86): Use of the "var" keyword is deprecated. -// TypeError: (89-98): Wrong argument count for struct constructor: 1 arguments given but expected 2. +// TypeError: (94-103): Wrong argument count for struct constructor: 1 arguments given but expected 2. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/288_conditional_with_all_types.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/288_conditional_with_all_types.sol index 4075f6f3..41e72d60 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/288_conditional_with_all_types.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/288_conditional_with_all_types.sol @@ -25,7 +25,7 @@ contract C { h += 1; // Avoid unused var warning // string literal - var i = true ? "hello" : "world"; + string memory i = true ? "hello" : "world"; i = "used"; //Avoid unused var warning } function f2() public { @@ -38,18 +38,18 @@ contract C { // array byte[2] memory a; byte[2] memory b; - var k = true ? a : b; + byte[2] memory k = true ? a : b; k[0] = byte(0); //Avoid unused var warning bytes memory e; bytes memory f; - var l = true ? e : f; + bytes memory l = true ? e : f; l[0] = byte(0); // Avoid unused var warning // fixed bytes bytes2 c; bytes2 d; - var m = true ? c : d; + bytes2 m = true ? c : d; m &= m; } @@ -60,7 +60,7 @@ contract C { struct_x = true ? struct_x : struct_y; // function - var r = true ? fun_x : fun_y; + function () r = true ? fun_x : fun_y; r(); // Avoid unused var warning // enum small enum_x; @@ -68,13 +68,13 @@ contract C { enum_x = true ? enum_x : enum_y; // tuple - var (n, o) = true ? (1, 2) : (3, 4); + (uint n, uint o) = true ? (1, 2) : (3, 4); (n, o) = (o, n); // Avoid unused var warning // mapping - var p = true ? table1 : table2; + mapping(uint8 => uint8) p = true ? table1 : table2; p[0] = 0; // Avoid unused var warning // typetype - var q = true ? uint32(1) : uint32(2); + uint32 q = true ? uint32(1) : uint32(2); q += 1; // Avoid unused var warning // modifier doesn't fit in here @@ -84,17 +84,8 @@ contract C { } } // ---- -// Warning: (546-551): Use of the "var" keyword is deprecated. -// Warning: (878-883): Use of the "var" keyword is deprecated. -// Warning: (1008-1013): Use of the "var" keyword is deprecated. -// Warning: (1150-1155): Use of the "var" keyword is deprecated. -// Warning: (1357-1362): Use of the "var" keyword is deprecated. -// Warning: (1560-1561): Use of the "var" keyword is deprecated. -// Warning: (1563-1564): Use of the "var" keyword is deprecated. -// Warning: (1672-1677): Use of the "var" keyword is deprecated. -// Warning: (1778-1783): Use of the "var" keyword is deprecated. -// Warning: (984-998): This declaration shadows an existing declaration. +// Warning: (1005-1019): This declaration shadows an existing declaration. // Warning: (90-116): Function state mutability can be restricted to pure // Warning: (121-147): Function state mutability can be restricted to pure -// Warning: (257-632): Function state mutability can be restricted to pure -// Warning: (637-1194): Function state mutability can be restricted to pure +// Warning: (257-642): Function state mutability can be restricted to pure +// Warning: (647-1227): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/333_fixed_point_casting_exponents_15.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/333_fixed_point_casting_exponents_15.sol index cfaba794..0fd5f331 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/333_fixed_point_casting_exponents_15.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/333_fixed_point_casting_exponents_15.sol @@ -1,9 +1,7 @@ contract test { function f() public { - var a = 3 ** ufixed(1.5); + ufixed a = 3 ** ufixed(1.5); } } // ---- -// Warning: (50-55): Use of the "var" keyword is deprecated. -// TypeError: (58-74): Operator ** not compatible with types int_const 3 and ufixed128x18 -// Warning: (50-74): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning. +// TypeError: (61-77): Operator ** not compatible with types int_const 3 and ufixed128x18 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/334_fixed_point_casting_exponents_neg.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/334_fixed_point_casting_exponents_neg.sol index 7d2716fd..03d10f7c 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/334_fixed_point_casting_exponents_neg.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/334_fixed_point_casting_exponents_neg.sol @@ -1,9 +1,7 @@ contract test { function f() public { - var c = 42 ** fixed(-1/4); + ufixed c = 42 ** fixed(-1/4); } } // ---- -// Warning: (50-55): Use of the "var" keyword is deprecated. -// TypeError: (58-75): Operator ** not compatible with types int_const 42 and fixed128x18 -// Warning: (50-75): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning. +// TypeError: (61-78): Operator ** not compatible with types int_const 42 and fixed128x18 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/335_var_capable_of_holding_constant_rationals.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/335_var_capable_of_holding_constant_rationals.sol deleted file mode 100644 index dac35a54..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/335_var_capable_of_holding_constant_rationals.sol +++ /dev/null @@ -1,16 +0,0 @@ -contract test { - function f() public { - var a = 0.12345678; - var b = 12345678.352; - var c = 0.00000009; - a; b; c; - } -} -// ---- -// Warning: (50-55): Use of the "var" keyword is deprecated. -// Warning: (78-83): Use of the "var" keyword is deprecated. -// Warning: (108-113): Use of the "var" keyword is deprecated. -// Warning: (50-68): The type of this variable was inferred as ufixed24x8. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (78-98): The type of this variable was inferred as ufixed40x3. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (108-126): The type of this variable was inferred as ufixed8x8. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (20-150): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/336_var_and_rational_with_tuple.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/336_var_and_rational_with_tuple.sol deleted file mode 100644 index 2f781a5d..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/336_var_and_rational_with_tuple.sol +++ /dev/null @@ -1,12 +0,0 @@ -contract test { - function f() public { - var (a, b) = (.5, 1/3); - a; b; - } -} -// ---- -// Warning: (55-56): Use of the "var" keyword is deprecated. -// Warning: (58-59): Use of the "var" keyword is deprecated. -// Warning: (50-72): The type of this variable was inferred as ufixed8x1. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (50-72): The type of this variable was inferred as ufixed256x77. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (20-93): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/337_var_handle_divided_integers.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/337_var_handle_divided_integers.sol deleted file mode 100644 index ef2b912c..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/337_var_handle_divided_integers.sol +++ /dev/null @@ -1,10 +0,0 @@ -contract test { - function f() public { - var x = 1/3; - } -} -// ---- -// Warning: (50-55): Use of the "var" keyword is deprecated. -// Warning: (50-61): The type of this variable was inferred as ufixed256x77. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (50-55): Unused local variable. -// Warning: (20-68): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/405_address_checksum_type_deduction.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/405_address_checksum_type_deduction.sol index 221d513e..81cc7d0d 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/405_address_checksum_type_deduction.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/405_address_checksum_type_deduction.sol @@ -1,9 +1,6 @@ contract C { function f() public { - var x = 0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E; - x.send(2); + (0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E).transfer(2); } } // ---- -// Warning: (47-52): Use of the "var" keyword is deprecated. -// Warning: (107-116): Failure condition of 'send' ignored. Consider using 'transfer' instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/406_invalid_address_checksum.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/406_invalid_address_checksum.sol index 8084e0d1..fe4691c2 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/406_invalid_address_checksum.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/406_invalid_address_checksum.sol @@ -5,4 +5,4 @@ contract C { } } // ---- -// Warning: (64-106): This looks like an address but has an invalid checksum. If this is not used as an address, please prepend '00'. Correct checksummed address: '0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals +// SyntaxError: (64-106): This looks like an address but has an invalid checksum. Correct checksummed address: "0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E". If this is not used as an address, please prepend '00'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/407_invalid_address_no_checksum.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/407_invalid_address_no_checksum.sol index 51521fe6..6f4ac730 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/407_invalid_address_no_checksum.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/407_invalid_address_no_checksum.sol @@ -5,4 +5,4 @@ contract C { } } // ---- -// Warning: (64-106): This looks like an address but has an invalid checksum. If this is not used as an address, please prepend '00'. Correct checksummed address: '0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals +// SyntaxError: (64-106): This looks like an address but has an invalid checksum. Correct checksummed address: "0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E". If this is not used as an address, please prepend '00'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/408_invalid_address_length_short.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/408_invalid_address_length_short.sol index 4dd93c63..da5dc380 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/408_invalid_address_length_short.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/408_invalid_address_length_short.sol @@ -5,4 +5,4 @@ contract C { } } // ---- -// Warning: (64-105): This looks like an address but has an invalid checksum. If this is not used as an address, please prepend '00'. Correct checksummed address: '0x0A0BfC97E48458494ccD857e1A85Dc91f7f0046e'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals +// SyntaxError: (64-105): This looks like an address but is not exactly 40 hex digits. It is 39 hex digits. If this is not used as an address, please prepend '00'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/409_invalid_address_length_long.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/409_invalid_address_length_long.sol index 37c6aa05..749612c9 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/409_invalid_address_length_long.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/409_invalid_address_length_long.sol @@ -5,5 +5,4 @@ contract C { } } // ---- -// Warning: (64-107): This looks like an address but has an invalid checksum. If this is not used as an address, please prepend '00'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals -// TypeError: (52-107): Type int_const 2284...(42 digits omitted)...9360 is not implicitly convertible to expected type address. +// SyntaxError: (64-107): This looks like an address but is not exactly 40 hex digits. It is 41 hex digits. If this is not used as an address, please prepend '00'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/413_address_methods.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/413_address_methods.sol index d0c3769c..9c42bc8f 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/413_address_methods.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/413_address_methods.sol @@ -2,8 +2,8 @@ contract C { function f() public { address addr; uint balance = addr.balance; - bool callRet = addr.call(); - bool delegatecallRet = addr.delegatecall(); + bool callRet = addr.call(""); + bool delegatecallRet = addr.delegatecall(""); bool sendRet = addr.send(1); addr.transfer(1); balance; callRet; delegatecallRet; sendRet; diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/415_interface_functions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/415_interface_functions.sol index 1f227b54..a5d6561e 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/415_interface_functions.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/415_interface_functions.sol @@ -1,9 +1,5 @@ interface I { - function(); - function f(); + function() external; + function f() external; } // ---- -// Warning: (18-29): Functions in interfaces should be declared external. -// Warning: (34-47): Functions in interfaces should be declared external. -// Warning: (18-29): No visibility specified. Defaulting to "public". In interfaces it defaults to external. -// Warning: (34-47): No visibility specified. Defaulting to "public". In interfaces it defaults to external. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/424_using_interface_complex.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/424_using_interface_complex.sol index a73c29bf..a3dca996 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/424_using_interface_complex.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/424_using_interface_complex.sol @@ -1,17 +1,11 @@ interface I { event A(); - function f(); - function g(); - function(); + function f() external; + function g() external; + function() external; } contract C is I { function f() public { } } // ---- -// Warning: (33-46): Functions in interfaces should be declared external. -// Warning: (51-64): Functions in interfaces should be declared external. -// Warning: (69-80): Functions in interfaces should be declared external. -// Warning: (33-46): No visibility specified. Defaulting to "public". In interfaces it defaults to external. -// Warning: (51-64): No visibility specified. Defaulting to "public". In interfaces it defaults to external. -// Warning: (69-80): No visibility specified. Defaulting to "public". In interfaces it defaults to external. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/463_error_transfer_non_payable_fallback.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/463_error_transfer_non_payable_fallback.sol index 3f6b0283..2b2ef39e 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/463_error_transfer_non_payable_fallback.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/463_error_transfer_non_payable_fallback.sol @@ -2,16 +2,16 @@ // because A's fallback function is not payable. contract A { - function() public {} + function() external {} } contract B { A a; - function() public { + function() external { a.transfer(100); } } // ---- -// Warning: (209-219): Using contract member "transfer" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).transfer" instead. -// TypeError: (209-219): Value transfer to a contract without a payable fallback function. +// Warning: (213-223): Using contract member "transfer" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).transfer" instead. +// TypeError: (213-223): Value transfer to a contract without a payable fallback function. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/464_error_transfer_no_fallback.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/464_error_transfer_no_fallback.sol index afa86040..67398de7 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/464_error_transfer_no_fallback.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/464_error_transfer_no_fallback.sol @@ -6,10 +6,10 @@ contract A {} contract B { A a; - function() public { + function() external { a.transfer(100); } } // ---- -// Warning: (190-200): Using contract member "transfer" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).transfer" instead. -// TypeError: (190-200): Value transfer to a contract without a payable fallback function. +// Warning: (192-202): Using contract member "transfer" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).transfer" instead. +// TypeError: (192-202): Value transfer to a contract without a payable fallback function. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/465_error_send_non_payable_fallback.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/465_error_send_non_payable_fallback.sol index 36f7470b..1a4b2e81 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/465_error_send_non_payable_fallback.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/465_error_send_non_payable_fallback.sol @@ -2,16 +2,16 @@ // because A does not have a payable fallback function. contract A { - function() public {} + function() external {} } contract B { A a; - function() public { + function() external { require(a.send(100)); } } // ---- -// Warning: (220-226): Using contract member "send" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).send" instead. -// TypeError: (220-226): Value transfer to a contract without a payable fallback function. +// Warning: (224-230): Using contract member "send" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).send" instead. +// TypeError: (224-230): Value transfer to a contract without a payable fallback function. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/466_does_not_error_transfer_payable_fallback.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/466_does_not_error_transfer_payable_fallback.sol index 1fa567eb..2b7f8dae 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/466_does_not_error_transfer_payable_fallback.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/466_does_not_error_transfer_payable_fallback.sol @@ -2,15 +2,15 @@ // because A does not have a payable fallback function. contract A { - function() payable public {} + function() payable external {} } contract B { A a; - function() public { + function() external { a.transfer(100); } } // ---- -// Warning: (224-234): Using contract member "transfer" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).transfer" instead. +// Warning: (228-238): Using contract member "transfer" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).transfer" instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/467_does_not_error_transfer_regular_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/467_does_not_error_transfer_regular_function.sol index bf027e22..65b4a236 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/467_does_not_error_transfer_regular_function.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/467_does_not_error_transfer_regular_function.sol @@ -5,7 +5,7 @@ contract A { contract B { A a; - function() public { + function() external { a.transfer(); } } diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/488_function_types_selector_5.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/488_function_types_selector_5.sol index 2b96a7ee..5f601db2 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/488_function_types_selector_5.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/488_function_types_selector_5.sol @@ -1,10 +1,8 @@ contract C { function h() pure external { } - function f() view external returns (bytes4) { - var g = this.h; - return g.selector; + function f() pure external returns (bytes4) { + return this.h.selector; } } // ---- -// Warning: (110-115): Use of the "var" keyword is deprecated. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/490_function_types_selector_7.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/490_function_types_selector_7.sol index ed6c01c5..9ee7d9bb 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/490_function_types_selector_7.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/490_function_types_selector_7.sol @@ -3,9 +3,7 @@ contract C { } function f() view external returns (bytes4) { function () pure external g = this.h; - var i = g; - return i.selector; + return g.selector; } } // ---- -// Warning: (156-161): Use of the "var" keyword is deprecated. 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 bc8c7867..b99431f9 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 () 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 f29cd7dd..23c90acb 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 () 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 b20255fb..5884e212 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 () 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/502_builtin_keccak256_reject_value.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/502_builtin_keccak256_reject_value.sol index a58891d2..61e51eff 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/502_builtin_keccak256_reject_value.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/502_builtin_keccak256_reject_value.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// TypeError: (47-62): Member "value" not found or not visible after argument-dependent lookup in function () pure returns (bytes32) - did you forget the "payable" modifier? +// TypeError: (47-62): Member "value" not found or not visible after argument-dependent lookup in function (bytes memory) pure returns (bytes32) - did you forget the "payable" modifier? diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/503_builtin_sha256_reject_value.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/503_builtin_sha256_reject_value.sol index 19d671ff..11141a9b 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/503_builtin_sha256_reject_value.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/503_builtin_sha256_reject_value.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// TypeError: (47-59): Member "value" not found or not visible after argument-dependent lookup in function () pure returns (bytes32) - did you forget the "payable" modifier? +// TypeError: (47-59): Member "value" not found or not visible after argument-dependent lookup in function (bytes memory) pure returns (bytes32) - did you forget the "payable" modifier? diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/504_builtin_ripemd160_reject_value.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/504_builtin_ripemd160_reject_value.sol index 38bb2cb6..d120f3dd 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/504_builtin_ripemd160_reject_value.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/504_builtin_ripemd160_reject_value.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// TypeError: (47-62): Member "value" not found or not visible after argument-dependent lookup in function () pure returns (bytes20) - did you forget the "payable" modifier? +// TypeError: (47-62): Member "value" not found or not visible after argument-dependent lookup in function (bytes memory) pure returns (bytes20) - did you forget the "payable" modifier? diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external.sol new file mode 100644 index 00000000..6ac551e1 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external.sol @@ -0,0 +1,3 @@ +contract C { + function () external { } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal.sol new file mode 100644 index 00000000..2d425037 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal.sol @@ -0,0 +1,4 @@ +contract C { + function () internal { } +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private.sol new file mode 100644 index 00000000..2105c815 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private.sol @@ -0,0 +1,4 @@ +contract C { + function () private { } +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public.sol new file mode 100644 index 00000000..42585137 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public.sol @@ -0,0 +1,4 @@ +contract C { + function () public { } +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol index 4f185e4d..35f4639e 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol @@ -9,14 +9,13 @@ contract C { } contract D { function f() { - var x = (new C()).balance(); + uint x = (new C()).balance(); x; (new C()).transfer(5); } } // ---- -// Warning: (282-287): Use of the "var" keyword is deprecated. // Warning: (17-127): No visibility specified. Defaulting to "public". // Warning: (132-239): No visibility specified. Defaulting to "public". -// Warning: (259-358): No visibility specified. Defaulting to "public". +// Warning: (259-359): No visibility specified. Defaulting to "public". // Warning: (17-127): Function state mutability can be restricted to view diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/563_event_without_emit_deprecated.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/563_event_without_emit_deprecated.sol index d6068ff6..e9a56671 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/563_event_without_emit_deprecated.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/563_event_without_emit_deprecated.sol @@ -5,4 +5,4 @@ contract C { } } // ---- -// Warning: (62-65): Invoking events without "emit" prefix is deprecated. +// TypeError: (62-65): Event invocations have to be prefixed by "emit". diff --git a/test/libsolidity/syntaxTests/parsing/else_if_statement.sol b/test/libsolidity/syntaxTests/parsing/else_if_statement.sol index 727e6115..37763697 100644 --- a/test/libsolidity/syntaxTests/parsing/else_if_statement.sol +++ b/test/libsolidity/syntaxTests/parsing/else_if_statement.sol @@ -1,8 +1,8 @@ contract test { - function fun(uint256 a) returns (address b) { + function fun(uint256 a) returns (uint8 b) { if (a < 0) b = 0x67; else if (a == 0) b = 0x12; else b = 0x78; } } // ---- -// Warning: (20-142): No visibility specified. Defaulting to "public". -// Warning: (20-142): Function state mutability can be restricted to pure +// Warning: (20-140): No visibility specified. Defaulting to "public". +// Warning: (20-140): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/fallback_function.sol b/test/libsolidity/syntaxTests/parsing/fallback_function.sol index de32b030..054f57de 100644 --- a/test/libsolidity/syntaxTests/parsing/fallback_function.sol +++ b/test/libsolidity/syntaxTests/parsing/fallback_function.sol @@ -1,5 +1,4 @@ contract c { - function() { } + function() external { } } // ---- -// Warning: (17-31): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/parsing/if_statement.sol b/test/libsolidity/syntaxTests/parsing/if_statement.sol index 0819cb9f..451fba1f 100644 --- a/test/libsolidity/syntaxTests/parsing/if_statement.sol +++ b/test/libsolidity/syntaxTests/parsing/if_statement.sol @@ -1,11 +1,9 @@ contract test { function fun(uint256 a) returns (uint) { - if (a >= 8) { return 2; } else { var b = 7; } + if (a >= 8) { return 2; } else { uint b = 7; } } } // ---- -// Warning: (102-107): Use of the "var" keyword is deprecated. -// Warning: (102-111): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (20-120): No visibility specified. Defaulting to "public". -// Warning: (102-107): Unused local variable. -// Warning: (20-120): Function state mutability can be restricted to pure +// Warning: (20-121): No visibility specified. Defaulting to "public". +// Warning: (102-108): Unused local variable. +// Warning: (20-121): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/modifier.sol b/test/libsolidity/syntaxTests/parsing/modifier.sol index 3e659dcf..b995ce89 100644 --- a/test/libsolidity/syntaxTests/parsing/modifier.sol +++ b/test/libsolidity/syntaxTests/parsing/modifier.sol @@ -1,3 +1,3 @@ contract c { - modifier mod { if (msg.sender == 0) _; } + modifier mod { if (msg.sender == 0x0000000000000000000000000000000000000000) _; } } diff --git a/test/libsolidity/syntaxTests/parsing/multi_variable_declarations.sol b/test/libsolidity/syntaxTests/parsing/multi_variable_declarations.sol index 818999df..1984ed36 100644 --- a/test/libsolidity/syntaxTests/parsing/multi_variable_declarations.sol +++ b/test/libsolidity/syntaxTests/parsing/multi_variable_declarations.sol @@ -1,29 +1,15 @@ contract C { - function f() { - var (a,b,c) = g(); - var (d) = 2; - var (,e) = 3; - var (f,) = 4; - var (x,,) = g(); - var (,y,) = g(); - var () = g(); - var (,,) = g(); + function f() pure public { + (uint a, uint b, uint c) = g(); + (uint d) = 2; + (, uint e) = 3; + (uint h,) = 4; + (uint x,,) = g(); + (, uint y,) = g(); + a; b; c; d; e; h; x; y; } - function g() returns (uint, uint, uint) {} + function g() pure public returns (uint, uint, uint) {} } // ---- -// Warning: (36-37): Use of the "var" keyword is deprecated. -// Warning: (38-39): Use of the "var" keyword is deprecated. -// Warning: (40-41): Use of the "var" keyword is deprecated. -// Warning: (57-58): Use of the "var" keyword is deprecated. -// Warning: (73-74): Use of the "var" keyword is deprecated. -// Warning: (88-89): Use of the "var" keyword is deprecated. -// Warning: (104-105): Use of the "var" keyword is deprecated. -// Warning: (124-125): Use of the "var" keyword is deprecated. -// Warning: (88-89): This declaration shadows an existing declaration. -// Warning: (52-63): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (67-79): Different number of components on the left hand side (2) than on the right hand side (1). -// Warning: (67-79): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (83-95): Different number of components on the left hand side (2) than on the right hand side (1). -// Warning: (83-95): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning. -// TypeError: (137-149): Too many components (3) in value for variable assignment (0) needed +// Warning: (93-107): Different number of components on the left hand side (2) than on the right hand side (1). +// Warning: (111-124): Different number of components on the left hand side (2) than on the right hand side (1). diff --git a/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol b/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol index 72546dc0..e331440d 100644 --- a/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol +++ b/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol @@ -1,11 +1,9 @@ contract c { function fun() returns (uint r) { - var _ = 8; + uint _ = 8; return _ + 1; } } // ---- -// Warning: (59-64): Use of the "var" keyword is deprecated. -// Warning: (59-68): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (17-97): No visibility specified. Defaulting to "public". -// Warning: (17-97): Function state mutability can be restricted to pure +// Warning: (17-98): No visibility specified. Defaulting to "public". +// Warning: (17-98): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/tuples.sol b/test/libsolidity/syntaxTests/parsing/tuples.sol index 6f739740..d691da44 100644 --- a/test/libsolidity/syntaxTests/parsing/tuples.sol +++ b/test/libsolidity/syntaxTests/parsing/tuples.sol @@ -1,24 +1,17 @@ contract C { function f() { uint a = (1); - var (b,) = (1,); - var (c,d) = (1, 2 + a); - var (e,) = (1, 2, b); + (uint b,) = (1,); + (uint c, uint d) = (1, 2 + a); + (uint e,) = (1, 2, b); (a) = 3; } } // ---- -// Warning: (52-53): Use of the "var" keyword is deprecated. -// Warning: (71-72): Use of the "var" keyword is deprecated. -// Warning: (73-74): Use of the "var" keyword is deprecated. -// Warning: (97-98): Use of the "var" keyword is deprecated. -// Warning: (47-62): Different number of components on the left hand side (2) than on the right hand side (1). -// Warning: (47-62): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (66-88): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (92-112): Different number of components on the left hand side (2) than on the right hand side (3). -// Warning: (92-112): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (14-127): No visibility specified. Defaulting to "public". -// Warning: (71-72): Unused local variable. -// Warning: (73-74): Unused local variable. -// Warning: (97-98): Unused local variable. -// Warning: (14-127): Function state mutability can be restricted to pure +// Warning: (47-63): Different number of components on the left hand side (2) than on the right hand side (1). +// Warning: (100-121): Different number of components on the left hand side (2) than on the right hand side (3). +// Warning: (14-136): No visibility specified. Defaulting to "public". +// Warning: (68-74): Unused local variable. +// Warning: (76-82): Unused local variable. +// Warning: (101-107): Unused local variable. +// Warning: (14-136): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/specialFunctions/single_non_bytes_arg.sol b/test/libsolidity/syntaxTests/specialFunctions/single_non_bytes_arg.sol index a6ee4bf1..c17d0849 100644 --- a/test/libsolidity/syntaxTests/specialFunctions/single_non_bytes_arg.sol +++ b/test/libsolidity/syntaxTests/specialFunctions/single_non_bytes_arg.sol @@ -7,9 +7,6 @@ contract C { function g(bytes32) pure internal {} } // ---- -// Warning: (54-72): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (54-72): The provided argument of type uint256 is not implicitly convertible to expected type bytes memory. -// Warning: (85-100): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (85-100): The provided argument of type uint256 is not implicitly convertible to expected type bytes memory. -// Warning: (113-131): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (113-131): The provided argument of type uint256 is not implicitly convertible to expected type bytes memory. +// TypeError: (64-71): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. +// TypeError: (92-99): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. +// TypeError: (123-130): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol index f1b5606e..c97f588e 100644 --- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol @@ -1,13 +1,13 @@ contract C { function f() public pure { - bool a = address(this).call(address(this).delegatecall, super); - bool b = address(this).delegatecall(log0, tx, mulmod); + bool a = address(this).call(abi.encode(address(this).delegatecall, super)); + bool b = address(this).delegatecall(abi.encode(log0, tx, mulmod)); a; b; } } // ---- -// TypeError: (80-106): This type cannot be encoded. -// TypeError: (108-113): This type cannot be encoded. -// TypeError: (160-164): This type cannot be encoded. -// TypeError: (166-168): This type cannot be encoded. -// TypeError: (170-176): This type cannot be encoded. +// TypeError: (91-117): This type cannot be encoded. +// TypeError: (119-124): This type cannot be encoded. +// TypeError: (183-187): This type cannot be encoded. +// TypeError: (189-191): This type cannot be encoded. +// TypeError: (193-199): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol index 05f5db0b..a1d3f5af 100644 --- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol @@ -4,11 +4,10 @@ contract C { struct T { uint y; } T t; function f() public view { - bytes32 a = sha256(s, t); + bytes32 a = sha256(abi.encodePacked(s, t)); a; } } // ---- -// Warning: (132-144): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// TypeError: (139-140): This type cannot be encoded. -// TypeError: (142-143): This type cannot be encoded. +// TypeError: (156-157): This type cannot be encoded. +// TypeError: (159-160): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs_abiv2.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs_abiv2.sol index 977a7d73..38702825 100644 --- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs_abiv2.sol +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs_abiv2.sol @@ -6,12 +6,11 @@ contract C { struct T { uint y; } T t; function f() public view { - bytes32 a = sha256(s, t); + bytes32 a = sha256(abi.encodePacked(s, t)); a; } } // ---- // Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. -// Warning: (167-179): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// TypeError: (174-175): This type cannot be encoded. -// TypeError: (177-178): This type cannot be encoded. +// TypeError: (191-192): This type cannot be encoded. +// TypeError: (194-195): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol index e46a9050..b50d4449 100644 --- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol @@ -5,12 +5,13 @@ contract C { T t; enum A { X, Y } function f() public pure { - bool a = address(this).delegatecall(S, A, A.X, T, uint, uint[]); + bytes memory a = abi.encodePacked(S, A, A.X, T, uint, uint[]); + a; } } // ---- -// TypeError: (176-177): This type cannot be encoded. -// TypeError: (179-180): This type cannot be encoded. -// TypeError: (187-188): This type cannot be encoded. -// TypeError: (190-194): This type cannot be encoded. -// TypeError: (196-202): This type cannot be encoded. +// TypeError: (174-175): This type cannot be encoded. +// TypeError: (177-178): This type cannot be encoded. +// TypeError: (185-186): This type cannot be encoded. +// TypeError: (188-192): This type cannot be encoded. +// TypeError: (194-200): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/tight_packing_literals.sol b/test/libsolidity/syntaxTests/tight_packing_literals.sol index d6c7f0ba..be8482ff 100644 --- a/test/libsolidity/syntaxTests/tight_packing_literals.sol +++ b/test/libsolidity/syntaxTests/tight_packing_literals.sol @@ -1,26 +1,8 @@ contract C { - function f() pure public returns (bytes32) { - return keccak256(1); - } - function h() pure public returns (bytes32) { - return sha256(1); - } - function j() pure public returns (bytes32) { - return ripemd160(1); - } function k() pure public returns (bytes) { return abi.encodePacked(1); } } // ---- -// Warning: (87-88): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (77-89): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (77-89): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory. -// Warning: (168-169): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (161-170): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (161-170): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory. -// Warning: (252-253): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning. -// Warning: (242-254): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (242-254): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory. -// Warning: (341-342): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning. +// Warning: (92-93): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning. diff --git a/test/libsolidity/syntaxTests/tight_packing_literals_050.sol b/test/libsolidity/syntaxTests/tight_packing_literals_050.sol index b7557d2a..4e6210c6 100644 --- a/test/libsolidity/syntaxTests/tight_packing_literals_050.sol +++ b/test/libsolidity/syntaxTests/tight_packing_literals_050.sol @@ -1,34 +1,9 @@ pragma experimental "v0.5.0"; contract C { - function f() pure public returns (bytes32) { - return keccak256(1); - } - function g() pure public returns (bytes32) { - return sha3(1); - } - function h() pure public returns (bytes32) { - return sha256(1); - } - function j() pure public returns (bytes32) { - return ripemd160(1); - } function k() pure public returns (bytes) { return abi.encodePacked(1); } } // ---- -// TypeError: (117-118): Cannot perform packed encoding for a literal. Please convert it to an explicit type first. -// TypeError: (107-119): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// TypeError: (107-119): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory. -// TypeError: (191-198): "sha3" has been deprecated in favour of "keccak256" -// TypeError: (196-197): Cannot perform packed encoding for a literal. Please convert it to an explicit type first. -// TypeError: (191-198): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// TypeError: (191-198): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory. -// TypeError: (277-278): Cannot perform packed encoding for a literal. Please convert it to an explicit type first. -// TypeError: (270-279): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// TypeError: (270-279): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory. -// TypeError: (361-362): Cannot perform packed encoding for a literal. Please convert it to an explicit type first. -// TypeError: (351-363): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// TypeError: (351-363): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory. -// TypeError: (450-451): Cannot perform packed encoding for a literal. Please convert it to an explicit type first. +// TypeError: (122-123): Cannot perform packed encoding for a literal. Please convert it to an explicit type first. diff --git a/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol b/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol index 27665b52..7bbc36d0 100644 --- a/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol +++ b/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol @@ -1,13 +1,4 @@ contract C { - function f() pure public returns (bytes32) { - return keccak256(uint8(1)); - } - function h() pure public returns (bytes32) { - return sha256(uint8(1)); - } - function j() pure public returns (bytes32) { - return ripemd160(uint8(1)); - } function k() pure public returns (bytes) { return abi.encodePacked(uint8(1)); } @@ -16,9 +7,3 @@ contract C { } } // ---- -// Warning: (77-96): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (77-96): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory. -// Warning: (168-184): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (168-184): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory. -// Warning: (256-275): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. -// Warning: (256-275): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory. diff --git a/test/libsolidity/syntaxTests/tupleAssignments/warn_fill_vardecl.sol b/test/libsolidity/syntaxTests/tupleAssignments/warn_fill_vardecl.sol index 1d243c7c..23484567 100644 --- a/test/libsolidity/syntaxTests/tupleAssignments/warn_fill_vardecl.sol +++ b/test/libsolidity/syntaxTests/tupleAssignments/warn_fill_vardecl.sol @@ -1,11 +1,8 @@ contract C { function f() public pure returns (uint, uint, uint, uint) { - // Can later be replaced by (uint a, uint b,) = f(); - var (a,b,) = f(); + (uint a, uint b,) = f(); a; b; } } // ---- -// Warning: (136-137): Use of the "var" keyword is deprecated. -// Warning: (138-139): Use of the "var" keyword is deprecated. -// Warning: (131-147): Different number of components on the left hand side (3) than on the right hand side (4). +// Warning: (76-99): Different number of components on the left hand side (3) than on the right hand side (4). diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_event.sol b/test/libsolidity/syntaxTests/types/empty_tuple_event.sol index 3e40b155..24327db0 100644 --- a/test/libsolidity/syntaxTests/types/empty_tuple_event.sol +++ b/test/libsolidity/syntaxTests/types/empty_tuple_event.sol @@ -2,9 +2,8 @@ pragma solidity ^0.4.3; contract C { event SomeEvent(); function a() public { - (SomeEvent(), 7); + (emit SomeEvent(), 7); } } // ---- -// Warning: (95-106): Invoking events without "emit" prefix is deprecated. -// Warning: (95-106): Tuple component cannot be empty. +// ParserError: (95-99): Expected primary expression. diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_event_050.sol b/test/libsolidity/syntaxTests/types/empty_tuple_event_050.sol deleted file mode 100644 index aec5ff2a..00000000 --- a/test/libsolidity/syntaxTests/types/empty_tuple_event_050.sol +++ /dev/null @@ -1,10 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - event SomeEvent(); - function a() public { - (SomeEvent(), 7); - } -} -// ---- -// TypeError: (101-112): Event invocations have to be prefixed by "emit". -// TypeError: (101-112): Tuple component cannot be empty. diff --git a/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol index dbefb8b6..51e36a58 100644 --- a/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol +++ b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol @@ -3,16 +3,16 @@ contract C { address(this).transfer(1); require(address(this).send(2)); selfdestruct(address(this)); - require(address(this).delegatecall()); - require(address(this).call()); + require(address(this).delegatecall("")); + require(address(this).call("")); } function g() pure public { bytes32 x = keccak256("abc"); bytes32 y = sha256("abc"); - address z = ecrecover(1, 2, 3, 4); + address z = ecrecover(bytes32(1), uint8(2), bytes32(3), bytes32(4)); require(true); assert(true); x; y; z; } - function() payable public {} + function() payable external {} } |