diff options
98 files changed, 370 insertions, 350 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml index 30dccead..c577be7b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -158,6 +158,23 @@ jobs: - store_artifacts: *solc_artifact - persist_to_workspace: *all_artifacts + test_check_spelling: + docker: + - image: circleci/python:3.6 + environment: + TERM: xterm + steps: + - checkout + - attach_workspace: + at: build + - run: + name: Install dependencies + command: | + pip install --user codespell + - run: + name: Check spelling + command: ~/.local/bin/codespell -S "*.enc,.git" -I ./scripts/codespell_whitelist.txt + test_x86_linux: docker: - image: buildpack-deps:artful @@ -220,6 +237,7 @@ workflows: version: 2 build_all: jobs: + - test_check_spelling: *build_on_tags - build_emscripten: *build_on_tags - test_emscripten_solcjs: <<: *build_on_tags @@ -35,6 +35,7 @@ build/ docs/_build docs/utils/__pycache__ docs/utils/*.pyc +/deps/downloads/ # vim stuff *.swp @@ -43,3 +44,5 @@ docs/utils/*.pyc .idea browse.VC.db CMakeLists.txt.user +/CMakeSettings.json +/.vs diff --git a/Changelog.md b/Changelog.md index 1e92863b..fbdf9206 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,6 +3,7 @@ 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))``. + * Make your fallback functions ``external``. Breaking Changes: @@ -32,10 +33,14 @@ Breaking Changes: * Type Checker: Disallow assignments between tuples with different numbers of components. This was already the case in the experimental 0.5.0 mode. * Type Checker: Disallow values for constants that are not compile-time constants. This was already the case in the experimental 0.5.0 mode. * Type Checker: Disallow arithmetic operations for boolean variables. + * Type Checker: Disallow tight packing of literals. This was already the case in the experimental 0.5.0 mode. * Type Checker: Disallow conversions between ``bytesX`` and ``uintY`` of different size. + * Type Checker: Disallow empty tuple components. This was partly already the case in the experimental 0.5.0 mode. * Type Checker: Disallow specifying base constructor arguments multiple times in the same inheritance hierarchy. This was already the case in the experimental 0.5.0 mode. + * Type Checker: Disallow calling constructor with wrong argument count. This was already the case in the experimental 0.5.0 mode. * Type Checker: Disallow uninitialized storage variables. This was already the case in the experimental 0.5.0 mode. * Type Checker: Only accept a single ``bytes`` type for ``.call()`` (and family), ``keccak256()``, ``sha256()`` and ``ripemd160()``. + * Type Checker: Fallback function must be external. This was already the case in the experimental 0.5.0 mode. * 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. * Syntax Checker: Disallow unary ``+``. This was already the case in the experimental 0.5.0 mode. @@ -54,6 +59,7 @@ Compiler Features: Bugfixes: * Tests: Fix chain parameters to make ipc tests work with newer versions of cpp-ethereum. * Code Generator: Fix allocation of byte arrays (zeroed out too much memory). + * Type System: Allow arbitrary exponents for literals with a mantissa of zero. ### 0.4.24 (2018-05-16) @@ -705,7 +711,7 @@ Bugfixes: * Conditional: `x ? y : z` * Bugfix: Fixed several bugs where the optimizer generated invalid code. * Bugfix: Enums and structs were not accessible to other contracts. - * Bugfix: Fixed segfault connected to function paramater types, appeared during gas estimation. + * Bugfix: Fixed segfault connected to function parameter types, appeared during gas estimation. * Bugfix: Type checker crash for wrong number of base constructor parameters. * Bugfix: Allow function overloads with different array types. * Bugfix: Allow assignments of type `(x) = 7`. diff --git a/ReleaseChecklist.md b/ReleaseChecklist.md index ebdb7539..b84ae4c4 100644 --- a/ReleaseChecklist.md +++ b/ReleaseChecklist.md @@ -8,7 +8,7 @@ Checklist for making a release: - [ ] Make a final check that there are no platform-dependency issues in the ``solc-test-bytecode`` repository. - [ ] Wait for the tests for the commit on ``release``, create a release in Github, creating the tag. - [ ] Thank voluntary contributors in the Github release page (use ``git shortlog -s -n -e origin/release..origin/develop``). - - [ ] Wait for the CI runs on the tag itself (they should push artefacts onto the Github release page). + - [ ] Wait for the CI runs on the tag itself (they should push artifacts onto the Github release page). - [ ] Run ``scripts/release_ppa.sh release`` to create the PPA release (you need the relevant openssl key). - [ ] Check that the Docker release was pushed to Docker Hub (this still seems to have problems, run ``./scripts/docker_deploy_manual.sh release``). - [ ] Update the homebrew realease in https://github.com/ethereum/homebrew-ethereum/blob/master/solidity.rb (version and hash) diff --git a/cmake/EthCompilerSettings.cmake b/cmake/EthCompilerSettings.cmake index 683d1d2e..468a8593 100644 --- a/cmake/EthCompilerSettings.cmake +++ b/cmake/EthCompilerSettings.cmake @@ -90,7 +90,7 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA if (EMSCRIPTEN) # Do not emit a separate memory initialiser file set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --memory-init-file 0") - # Leave only exported symbols as public and agressively remove others + # Leave only exported symbols as public and aggressively remove others set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdata-sections -ffunction-sections -Wl,--gc-sections -fvisibility=hidden") # Optimisation level set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") @@ -132,17 +132,6 @@ elseif (DEFINED MSVC) add_compile_options(-D_WIN32_WINNT=0x0600) # declare Windows Vista API requirement add_compile_options(-DNOMINMAX) # undefine windows.h MAX && MIN macros cause it cause conflicts with std::min && std::max functions - # Always use Release variant of C++ runtime. - # We don't want to provide Debug variants of all dependencies. Some default - # flags set by CMake must be tweaked. - string(REPLACE "/MDd" "/MD" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") - string(REPLACE "/D_DEBUG" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") - string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") - string(REPLACE "/MDd" "/MD" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") - string(REPLACE "/D_DEBUG" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") - string(REPLACE "/RTC1" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") - set_property(GLOBAL PROPERTY DEBUG_CONFIGURATIONS OFF) - # disable empty object file warning set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221") # warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/SAFESEH' specification diff --git a/cmake/jsoncpp.cmake b/cmake/jsoncpp.cmake index 0c110b53..e886c609 100644 --- a/cmake/jsoncpp.cmake +++ b/cmake/jsoncpp.cmake @@ -35,9 +35,7 @@ ExternalProject_Add(jsoncpp-project -DJSONCPP_WITH_TESTS=OFF -DJSONCPP_WITH_PKGCONFIG_SUPPORT=OFF -DCMAKE_CXX_FLAGS=${JSONCPP_EXTRA_FLAGS} - # Overwrite build and install commands to force Release build on MSVC. - BUILD_COMMAND cmake --build <BINARY_DIR> --config Release - INSTALL_COMMAND cmake --build <BINARY_DIR> --config Release --target install + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${byproducts} ) diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst index 07596ec2..ab1650d8 100644 --- a/docs/abi-spec.rst +++ b/docs/abi-spec.rst @@ -279,13 +279,13 @@ All together, the encoding is (newline after function selector and each 32-bytes Let us apply the same principle to encode the data for a function with a signature ``g(uint[][],string[])`` with values ``([[1, 2], [3]], ["one", "two", "three"])`` but start from the most atomic parts of the encoding: -First we encode the length and data of the first embeded dynamic array ``[1, 2]`` of the first root array ``[[1, 2], [3]]``: +First we encode the length and data of the first embedded dynamic array ``[1, 2]`` of the first root array ``[[1, 2], [3]]``: - ``0x0000000000000000000000000000000000000000000000000000000000000002`` (number of elements in the first array, 2; the elements themselves are ``1`` and ``2``) - ``0x0000000000000000000000000000000000000000000000000000000000000001`` (first element) - ``0x0000000000000000000000000000000000000000000000000000000000000002`` (second element) -Then we encode the length and data of the second embeded dynamic array ``[3]`` of the first root array ``[[1, 2], [3]]``: +Then we encode the length and data of the second embedded dynamic array ``[3]`` of the first root array ``[[1, 2], [3]]``: - ``0x0000000000000000000000000000000000000000000000000000000000000001`` (number of elements in the second array, 1; the element is ``3``) - ``0x0000000000000000000000000000000000000000000000000000000000000003`` (first element) @@ -307,7 +307,7 @@ Offset ``a`` points to the start of the content of the array ``[1, 2]`` which is Offset ``b`` points to the start of the content of the array ``[3]`` which is line 5 (160 bytes); thus ``b = 0x00000000000000000000000000000000000000000000000000000000000000a0``. -Then we encode the embeded strings of the second root array: +Then we encode the embedded strings of the second root array: - ``0x0000000000000000000000000000000000000000000000000000000000000003`` (number of characters in word ``"one"``) - ``0x6f6e650000000000000000000000000000000000000000000000000000000000`` (utf8 representation of word ``"one"``) @@ -337,7 +337,7 @@ Offset ``d`` points to the start of the content of the string ``"two"`` which is Offset ``e`` points to the start of the content of the string ``"three"`` which is line 7 (224 bytes); thus ``e = 0x00000000000000000000000000000000000000000000000000000000000000e0``. -Note that the encodings of the embeded elements of the root arrays are not dependent on each other and have the same encodings for a fuction with a signature ``g(string[],uint[][])``. +Note that the encodings of the embedded elements of the root arrays are not dependent on each other and have the same encodings for a function with a signature ``g(string[],uint[][])``. Then we encode the length of the first root array: diff --git a/docs/assembly.rst b/docs/assembly.rst index 3bab289e..cf114c12 100644 --- a/docs/assembly.rst +++ b/docs/assembly.rst @@ -212,9 +212,9 @@ In the grammar, opcodes are represented as pre-defined identifiers. +-------------------------+-----+---+-----------------------------------------------------------------+ | sar(x, y) | | C | arithmetic shift right y by x bits | +-------------------------+-----+---+-----------------------------------------------------------------+ -| addmod(x, y, m) | | F | (x + y) % m with arbitrary precision arithmetics | +| addmod(x, y, m) | | F | (x + y) % m with arbitrary precision arithmetic | +-------------------------+-----+---+-----------------------------------------------------------------+ -| mulmod(x, y, m) | | F | (x * y) % m with arbitrary precision arithmetics | +| mulmod(x, y, m) | | F | (x * y) % m with arbitrary precision arithmetic | +-------------------------+-----+---+-----------------------------------------------------------------+ | signextend(i, x) | | F | sign extend from (i*8+7)th bit counting from least significant | +-------------------------+-----+---+-----------------------------------------------------------------+ @@ -228,9 +228,9 @@ In the grammar, opcodes are represented as pre-defined identifiers. +-------------------------+-----+---+-----------------------------------------------------------------+ | pop(x) | `-` | F | remove the element pushed by x | +-------------------------+-----+---+-----------------------------------------------------------------+ -| dup1 ... dup16 | | F | copy ith stack slot to the top (counting from top) | +| dup1 ... dup16 | | F | copy nth stack slot to the top (counting from top) | +-------------------------+-----+---+-----------------------------------------------------------------+ -| swap1 ... swap16 | `*` | F | swap topmost and ith stack slot below it | +| swap1 ... swap16 | `*` | F | swap topmost and nth stack slot below it | +-------------------------+-----+---+-----------------------------------------------------------------+ | mload(p) | | F | mem[p...(p+32)) | +-------------------------+-----+---+-----------------------------------------------------------------+ diff --git a/docs/contracts.rst b/docs/contracts.rst index 53e50656..a745bea8 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -20,7 +20,7 @@ Contracts can be created "from outside" via Ethereum transactions or from within IDEs, such as `Remix <https://remix.ethereum.org/>`_, make the creation process seamless using UI elements. -Creating contracts programatically on Ethereum is best done via using the JavaScript API `web3.js <https://github.com/ethereum/web3.js>`_. +Creating contracts programmatically on Ethereum is best done via using the JavaScript API `web3.js <https://github.com/ethereum/web3.js>`_. As of today it has a method called `web3.eth.Contract <https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#new-contract>`_ to facilitate contract creation. @@ -1042,7 +1042,7 @@ constant and defines the behaviour of the contract or describes it. The second way has to be used if the constructor arguments of the base depend on those of the derived contract. Arguments have to be given either in the -inheritance list or in modifier-style in the derived constuctor. +inheritance list or in modifier-style in the derived constructor. Specifying arguments in both places is an error. If a derived contract doesn't specify the arguments to all of its base diff --git a/docs/contributing.rst b/docs/contributing.rst index 231cbdfc..ddc02883 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -110,13 +110,13 @@ Example: ``./test/libsolidity/syntaxTests/double_stateVariable_declaration.sol`` // ---- // DeclarationError: Identifier already declared. -A syntax test must contain at least the contract under test itself, followed by the seperator ``----``. The additional comments above are used to describe the +A syntax test must contain at least the contract under test itself, followed by the separator ``----``. The additional comments above are used to describe the expected compiler errors or warnings. This section can be empty in case that the contract should compile without any errors or warnings. In the above example, the state variable ``variable`` was declared twice, which is not allowed. This will result in a ``DeclarationError`` stating that the identifier was already declared. The tool that is being used for those tests is called ``isoltest`` and can be found under ``./test/tools/``. It is an interactive tool which allows -editing of failing contracts using your prefered text editor. Let's try to break this test by removing the second declaration of ``variable``: +editing of failing contracts using your preferred text editor. Let's try to break this test by removing the second declaration of ``variable``: :: @@ -237,7 +237,7 @@ Othwerise, upon execution the fuzzer will halt with an error saying binary is no Location : check_binary(), afl-fuzz.c:6920 -Next, you need some example source files. This will make it much easer for the fuzzer +Next, you need some example source files. This will make it much easier 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/control-structures.rst b/docs/control-structures.rst index 7beca65e..50c401e2 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -39,7 +39,7 @@ write:: pragma solidity ^0.4.16; contract Simple { - function arithmetics(uint _a, uint _b) + function arithmetic(uint _a, uint _b) public pure returns (uint o_sum, uint o_product) diff --git a/docs/frequently-asked-questions.rst b/docs/frequently-asked-questions.rst index 75693bdd..e64849ea 100644 --- a/docs/frequently-asked-questions.rst +++ b/docs/frequently-asked-questions.rst @@ -69,7 +69,7 @@ Can you return an array or a ``string`` from a solidity function call? Yes. See `array_receiver_and_returner.sol <https://github.com/fivedogit/solidity-baby-steps/blob/master/contracts/60_array_receiver_and_returner.sol>`_. What is problematic, though, is returning any variably-sized data (e.g. a -variably-sized array like ``uint[]``) from a fuction **called from within Solidity**. +variably-sized array like ``uint[]``) from a function **called from within Solidity**. This is a limitation of the EVM and will be solved with the next protocol update. Returning variably-sized data as part of an external transaction or call is fine. @@ -260,7 +260,7 @@ The third one is the stack, which is used to hold small local variables. It is almost free to use, but can only hold a limited amount of values. For almost all types, you cannot specify where they should be stored, because -they are copied everytime they are used. +they are copied every time they are used. The types where the so-called storage location is important are structs and arrays. If you e.g. pass such variables in function calls, their diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst index 1d5add9a..c0c7cb1b 100644 --- a/docs/miscellaneous.rst +++ b/docs/miscellaneous.rst @@ -319,7 +319,7 @@ Global Variables ================ - ``abi.encode(...) returns (bytes)``: :ref:`ABI <ABI>`-encodes the given arguments -- ``abi.encodePacked(...) returns (bytes)``: Performes :ref:`packed encoding <abi_packed_mode>` of the given arguments +- ``abi.encodePacked(...) returns (bytes)``: Performs :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(bytes(signature)), ...)``` diff --git a/docs/solidity-by-example.rst b/docs/solidity-by-example.rst index 07cb76c9..b1985426 100644 --- a/docs/solidity-by-example.rst +++ b/docs/solidity-by-example.rst @@ -679,7 +679,7 @@ Creating the signature ---------------------- Alice does not need to interact with Ethereum network to -sign the transaction, the proccess is completely offline. +sign the transaction, the process is completely offline. In this tutorial, we will sign messages in the browser using ``web3.js`` and ``MetaMask``. In particular, we will use the standard way described in `EIP-762 <https://github.com/ethereum/EIPs/pull/712>`_, @@ -1034,7 +1034,7 @@ The full contract } /// if the timeout is reached without the recipient closing the channel, - /// then the Ether is realeased back to the sender. + /// then the Ether is released back to the sender. function clainTimeout() public { require(now >= expiration); selfdestruct(sender); diff --git a/docs/style-guide.rst b/docs/style-guide.rst index 8311e925..19e3aae5 100644 --- a/docs/style-guide.rst +++ b/docs/style-guide.rst @@ -188,8 +188,8 @@ Event Definitions and Event Emitters Yes:: event LongAndLotsOfArgs( - adress sender, - adress recipient, + address sender, + address recipient, uint256 publicKey, uint256 amount, bytes32[] options @@ -205,8 +205,8 @@ Yes:: No:: - event LongAndLotsOfArgs(adress sender, - adress recipient, + event LongAndLotsOfArgs(address sender, + address recipient, uint256 publicKey, uint256 amount, bytes32[] options); @@ -830,7 +830,7 @@ The naming recommendations given here are intended to improve the readability, and thus they are not rules, but rather guidelines to try and help convey the most information through the names of things. -Lastly, consistency within a codebase should always supercede any conventions +Lastly, consistency within a codebase should always supersede any conventions outlined in this document. diff --git a/docs/units-and-global-variables.rst b/docs/units-and-global-variables.rst index 455231cd..61ae51a8 100644 --- a/docs/units-and-global-variables.rst +++ b/docs/units-and-global-variables.rst @@ -100,7 +100,7 @@ ABI Encoding Functions ---------------------- - ``abi.encode(...) returns (bytes)``: ABI-encodes the given arguments -- ``abi.encodePacked(...) returns (bytes)``: Performes :ref:`packed encoding <abi_packed_mode>` of the given arguments +- ``abi.encodePacked(...) returns (bytes)``: Performs :ref:`packed encoding <abi_packed_mode>` of the given arguments - ``abi.encodeWithSelector(bytes4 selector, ...) returns (bytes)``: ABI-encodes the given arguments starting from the second and prepends the given four-byte selector - ``abi.encodeWithSignature(string signature, ...) returns (bytes)``: Equivalent to ``abi.encodeWithSelector(bytes4(keccak256(bytes(signature)), ...)``` diff --git a/docs/yul.rst b/docs/yul.rst index 4f5ef98f..87ec0c03 100644 --- a/docs/yul.rst +++ b/docs/yul.rst @@ -338,7 +338,7 @@ The following functions must be available: +---------------------------------------------+-----------------------------------------------------------------+ | xor(x:bool, y:bool) -> z:bool | xor | +---------------------------------------------+-----------------------------------------------------------------+ -| *Arithmetics* | +| *Arithmetic* | +---------------------------------------------+-----------------------------------------------------------------+ | addu256(x:u256, y:u256) -> z:u256 | x + y | +---------------------------------------------+-----------------------------------------------------------------+ @@ -358,9 +358,9 @@ The following functions must be available: +---------------------------------------------+-----------------------------------------------------------------+ | expu256(x:u256, y:u256) -> z:u256 | x to the power of y | +---------------------------------------------+-----------------------------------------------------------------+ -| addmodu256(x:u256, y:u256, m:u256) -> z:u256| (x + y) % m with arbitrary precision arithmetics | +| addmodu256(x:u256, y:u256, m:u256) -> z:u256| (x + y) % m with arbitrary precision arithmetic | +---------------------------------------------+-----------------------------------------------------------------+ -| mulmodu256(x:u256, y:u256, m:u256) -> z:u256| (x * y) % m with arbitrary precision arithmetics | +| mulmodu256(x:u256, y:u256, m:u256) -> z:u256| (x * y) % m with arbitrary precision arithmetic | +---------------------------------------------+-----------------------------------------------------------------+ | ltu256(x:u256, y:u256) -> z:bool | true if x < y, false otherwise | +---------------------------------------------+-----------------------------------------------------------------+ diff --git a/libevmasm/ControlFlowGraph.h b/libevmasm/ControlFlowGraph.h index ebef543f..f0c9356c 100644 --- a/libevmasm/ControlFlowGraph.h +++ b/libevmasm/ControlFlowGraph.h @@ -39,7 +39,7 @@ using KnownStatePointer = std::shared_ptr<KnownState>; /** * Identifier for a block, coincides with the tag number of an AssemblyItem but adds a special - * ID for the inital block. + * ID for the initial block. */ class BlockId { diff --git a/libevmasm/GasMeter.h b/libevmasm/GasMeter.h index b131802f..fc3740d2 100644 --- a/libevmasm/GasMeter.h +++ b/libevmasm/GasMeter.h @@ -112,9 +112,10 @@ public: static GasConsumption infinite() { return GasConsumption(0, true); } GasConsumption& operator+=(GasConsumption const& _other); - bool operator<(GasConsumption const& _other) const { return this->tuple() < _other.tuple(); } - - std::tuple<bool const&, u256 const&> tuple() const { return std::tie(isInfinite, value); } + bool operator<(GasConsumption const& _other) const + { + return std::make_pair(isInfinite, value) < std::make_pair(_other.isInfinite, _other.value); + } u256 value; bool isInfinite; diff --git a/libevmasm/LinkerObject.cpp b/libevmasm/LinkerObject.cpp index 8b7d9e06..1d5efecb 100644 --- a/libevmasm/LinkerObject.cpp +++ b/libevmasm/LinkerObject.cpp @@ -68,7 +68,7 @@ LinkerObject::matchLibrary( if (it != _libraryAddresses.end()) return &it->second; // If the user did not supply a fully qualified library name, - // try to match only the simple libary name + // try to match only the simple library name size_t colon = _linkRefName.find(':'); if (colon == string::npos) return nullptr; diff --git a/libevmasm/RuleList.h b/libevmasm/RuleList.h index 2b7da01b..7a2bc484 100644 --- a/libevmasm/RuleList.h +++ b/libevmasm/RuleList.h @@ -59,7 +59,7 @@ std::vector<SimplificationRule<Pattern>> simplificationRuleList( { std::vector<SimplificationRule<Pattern>> rules; rules += std::vector<SimplificationRule<Pattern>>{ - // arithmetics on constants + // arithmetic on constants {{Instruction::ADD, {A, B}}, [=]{ return A.d() + B.d(); }, false}, {{Instruction::MUL, {A, B}}, [=]{ return A.d() * B.d(); }, false}, {{Instruction::SUB, {A, B}}, [=]{ return A.d() - B.d(); }, false}, diff --git a/libevmasm/SimplificationRules.cpp b/libevmasm/SimplificationRules.cpp index 53a5f9fc..504dbc24 100644 --- a/libevmasm/SimplificationRules.cpp +++ b/libevmasm/SimplificationRules.cpp @@ -67,7 +67,7 @@ void Rules::addRule(SimplificationRule<Pattern> const& _rule) Rules::Rules() { - // Multiple occurences of one of these inside one rule must match the same equivalence class. + // Multiple occurrences of one of these inside one rule must match the same equivalence class. // Constants. Pattern A(Push); Pattern B(Push); diff --git a/libjulia/backends/evm/AbstractAssembly.h b/libjulia/backends/evm/AbstractAssembly.h index 46fa7796..6b1b5c23 100644 --- a/libjulia/backends/evm/AbstractAssembly.h +++ b/libjulia/backends/evm/AbstractAssembly.h @@ -68,7 +68,7 @@ public: virtual LabelID newLabelId() = 0; /// Returns a label identified by the given name. Creates it if it does not yet exist. virtual LabelID namedLabel(std::string const& _name) = 0; - /// Append a reference to a to-be-linked symobl. + /// Append a reference to a to-be-linked symbol. /// Currently, we assume that the value is always a 20 byte number. virtual void appendLinkerSymbol(std::string const& _name) = 0; diff --git a/libjulia/backends/evm/EVMAssembly.h b/libjulia/backends/evm/EVMAssembly.h index 593cee6a..56ae7655 100644 --- a/libjulia/backends/evm/EVMAssembly.h +++ b/libjulia/backends/evm/EVMAssembly.h @@ -54,7 +54,7 @@ public: virtual LabelID newLabelId() override; /// Returns a label identified by the given name. Creates it if it does not yet exist. virtual LabelID namedLabel(std::string const& _name) override; - /// Append a reference to a to-be-linked symobl. + /// Append a reference to a to-be-linked symbol. /// Currently, we assume that the value is always a 20 byte number. virtual void appendLinkerSymbol(std::string const& _name) override; diff --git a/libjulia/optimiser/DataFlowAnalyzer.h b/libjulia/optimiser/DataFlowAnalyzer.h index 4cb3d4cd..66df2f48 100644 --- a/libjulia/optimiser/DataFlowAnalyzer.h +++ b/libjulia/optimiser/DataFlowAnalyzer.h @@ -56,7 +56,7 @@ protected: /// Registers the assignment. void handleAssignment(std::set<std::string> const& _names, Expression* _value); - /// Clears information about the valuse assigned to the given variables, + /// Clears information about the values assigned to the given variables, /// for example at points where control flow is merged. void clearValues(std::set<std::string> const& _names); diff --git a/libjulia/optimiser/SimplificationRules.cpp b/libjulia/optimiser/SimplificationRules.cpp index 070d5484..a5e296c3 100644 --- a/libjulia/optimiser/SimplificationRules.cpp +++ b/libjulia/optimiser/SimplificationRules.cpp @@ -64,7 +64,7 @@ void SimplificationRules::addRule(SimplificationRule<Pattern> const& _rule) SimplificationRules::SimplificationRules() { - // Multiple occurences of one of these inside one rule must match the same equivalence class. + // Multiple occurrences of one of these inside one rule must match the same equivalence class. // Constants. Pattern A(PatternKind::Constant); Pattern B(PatternKind::Constant); diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp index 63f8fac3..4311e77d 100644 --- a/libsolidity/analysis/SyntaxChecker.cpp +++ b/libsolidity/analysis/SyntaxChecker.cpp @@ -254,15 +254,6 @@ bool SyntaxChecker::visit(FunctionTypeName const& _node) return true; } -bool SyntaxChecker::visit(VariableDeclaration const& _declaration) -{ - if (!_declaration.typeName()) - { - m_errorReporter.syntaxError(_declaration.location(), "Use of the \"var\" keyword is disallowed."); - } - return true; -} - bool SyntaxChecker::visit(StructDefinition const& _struct) { if (_struct.members().empty()) diff --git a/libsolidity/analysis/SyntaxChecker.h b/libsolidity/analysis/SyntaxChecker.h index 1579df57..8ee3df37 100644 --- a/libsolidity/analysis/SyntaxChecker.h +++ b/libsolidity/analysis/SyntaxChecker.h @@ -69,8 +69,6 @@ private: virtual bool visit(FunctionDefinition const& _function) override; virtual bool visit(FunctionTypeName const& _node) override; - virtual bool visit(VariableDeclaration const& _declaration) override; - virtual bool visit(StructDefinition const& _struct) override; ErrorReporter& m_errorReporter; diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index a11b1879..8ea0a4d7 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -23,6 +23,7 @@ #include <libsolidity/analysis/TypeChecker.h> #include <memory> #include <boost/algorithm/string/predicate.hpp> +#include <boost/algorithm/string/join.hpp> #include <boost/range/adaptor/reversed.hpp> #include <libsolidity/ast/AST.h> #include <libsolidity/inlineasm/AsmAnalysis.h> @@ -123,10 +124,7 @@ bool TypeChecker::visit(ContractDefinition const& _contract) m_errorReporter.typeError(function->parameterList().location(), "Fallback function cannot take parameters."); if (!function->returnParameters().empty()) m_errorReporter.typeError(function->returnParameterList()->location(), "Fallback function cannot return values."); - if ( - _contract.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050) && - function->visibility() != FunctionDefinition::Visibility::External - ) + if (function->visibility() != FunctionDefinition::Visibility::External) m_errorReporter.typeError(function->location(), "Fallback function must be defined as \"external\"."); } @@ -451,7 +449,7 @@ void TypeChecker::overrideError(FunctionDefinition const& function, FunctionDefi { m_errorReporter.typeError( function.location(), - SecondarySourceLocation().append("Overriden function is here:", super.location()), + SecondarySourceLocation().append("Overridden function is here:", super.location()), message ); } @@ -551,33 +549,18 @@ void TypeChecker::endVisit(InheritanceSpecifier const& _inheritance) if (arguments) { - bool v050 = m_scope->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050); - if (parameterTypes.size() != arguments->size()) { - if (arguments->size() == 0 && !v050) - m_errorReporter.warning( - _inheritance.location(), - "Wrong argument count for constructor call: " + - toString(arguments->size()) + - " arguments given but expected " + - toString(parameterTypes.size()) + - "." - ); - else - { - m_errorReporter.typeError( - _inheritance.location(), - "Wrong argument count for constructor call: " + - toString(arguments->size()) + - " arguments given but expected " + - toString(parameterTypes.size()) + - "." - ); - return; - } + m_errorReporter.typeError( + _inheritance.location(), + "Wrong argument count for constructor call: " + + toString(arguments->size()) + + " arguments given but expected " + + toString(parameterTypes.size()) + + ". Remove parentheses if you do not want to provide arguments here." + ); } - for (size_t i = 0; i < arguments->size(); ++i) + for (size_t i = 0; i < std::min(arguments->size(), parameterTypes.size()); ++i) if (!type(*(*arguments)[i])->isImplicitlyConvertibleTo(*parameterTypes[i])) m_errorReporter.typeError( (*arguments)[i]->location(), @@ -1054,6 +1037,47 @@ void TypeChecker::endVisit(EmitStatement const& _emit) m_insideEmitStatement = false; } +namespace +{ +/** + * @returns a suggested left-hand-side of a multi-variable declaration contairing + * the variable declarations given in @a _decls. + */ +string createTupleDecl(vector<VariableDeclaration const*> const& _decls) +{ + vector<string> components; + for (VariableDeclaration const* decl: _decls) + if (decl) + components.emplace_back(decl->annotation().type->toString(false) + " " + decl->name()); + else + components.emplace_back(); + + if (_decls.size() == 1) + return components.front(); + else + return "(" + boost::algorithm::join(components, ", ") + ")"; +} + +bool typeCanBeExpressed(vector<VariableDeclaration const*> const& decls) +{ + for (VariableDeclaration const* decl: decls) + { + // skip empty tuples (they can be expressed of course) + if (!decl) + continue; + + if (auto functionType = dynamic_cast<FunctionType const*>(decl->annotation().type.get())) + if ( + functionType->kind() != FunctionType::Kind::Internal && + functionType->kind() != FunctionType::Kind::External + ) + return false; + } + + return true; +} +} + bool TypeChecker::visit(VariableDeclarationStatement const& _statement) { bool const v050 = m_scope->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050); @@ -1164,6 +1188,8 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement) else assignments[assignments.size() - i - 1] = variables[variables.size() - i - 1].get(); + bool autoTypeDeductionNeeded = false; + for (size_t i = 0; i < assignments.size(); ++i) { if (!assignments[i]) @@ -1174,6 +1200,8 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement) solAssert(!!valueComponentType, ""); if (!var.annotation().type) { + autoTypeDeductionNeeded = true; + // Infer type from value. solAssert(!var.typeName(), ""); var.annotation().type = valueComponentType->mobileType(); @@ -1217,14 +1245,6 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement) } else solAssert(dynamic_cast<FixedPointType const*>(var.annotation().type.get()), "Unknown type."); - - m_errorReporter.warning( - _statement.location(), - "The type of this variable was inferred as " + - typeName + - extension + - ". This is probably not desired. Use an explicit type to silence this warning." - ); } var.accept(*this); @@ -1261,6 +1281,23 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement) } } } + + if (autoTypeDeductionNeeded) + { + if (!typeCanBeExpressed(assignments)) + m_errorReporter.syntaxError( + _statement.location(), + "Use of the \"var\" keyword is disallowed. " + "Type cannot be expressed in syntax." + ); + else + m_errorReporter.syntaxError( + _statement.location(), + "Use of the \"var\" keyword is disallowed. " + "Use explicit declaration `" + createTupleDecl(assignments) + " = ...´ instead." + ); + } + return false; } @@ -1408,14 +1445,12 @@ bool TypeChecker::visit(TupleExpression const& _tuple) } else { - bool const v050 = m_scope->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050); bool isPure = true; TypePointer inlineArrayType; for (size_t i = 0; i < components.size(); ++i) { - // Outside of an lvalue-context, the only situation where a component can be empty is (x,). - if (!components[i] && !(i == 1 && components.size() == 2)) + if (!components[i]) m_errorReporter.fatalTypeError(_tuple.location(), "Tuple component cannot be empty."); else if (components[i]) { @@ -1427,10 +1462,7 @@ bool TypeChecker::visit(TupleExpression const& _tuple) { if (_tuple.isInlineArray()) m_errorReporter.fatalTypeError(components[i]->location(), "Array component cannot be empty."); - if (v050) - m_errorReporter.fatalTypeError(components[i]->location(), "Tuple component cannot be empty."); - else - m_errorReporter.warning(components[i]->location(), "Tuple component cannot be empty."); + m_errorReporter.typeError(components[i]->location(), "Tuple component cannot be empty."); } // Note: code generation will visit each of the expression even if they are not assigned from. @@ -1468,11 +1500,7 @@ bool TypeChecker::visit(TupleExpression const& _tuple) if (components.size() == 1) _tuple.annotation().type = type(*components[0]); else - { - if (components.size() == 2 && !components[1]) - types.pop_back(); _tuple.annotation().type = make_shared<TupleType>(types); - } } } @@ -1663,8 +1691,6 @@ bool TypeChecker::visit(FunctionCall const& _functionCall) else _functionCall.annotation().type = make_shared<TupleType>(returnTypes); - bool const v050 = m_scope->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050); - if (auto functionName = dynamic_cast<Identifier const*>(&_functionCall.expression())) { if (functionName->name() == "sha3" && functionType->kind() == FunctionType::Kind::SHA3) @@ -1684,23 +1710,15 @@ bool TypeChecker::visit(FunctionCall const& _functionCall) auto const& argType = type(*arguments[i]); if (auto literal = dynamic_cast<RationalNumberType const*>(argType.get())) { - /* If no mobile type is available an error will be raised elsewhere. */ if (literal->mobileType()) + m_errorReporter.typeError( + arguments[i]->location(), + "Cannot perform packed encoding for a literal. Please convert it to an explicit type first." + ); + else { - if (v050) - m_errorReporter.typeError( - arguments[i]->location(), - "Cannot perform packed encoding for a literal. Please convert it to an explicit type first." - ); - else - m_errorReporter.warning( - arguments[i]->location(), - "The type of \"" + - argType->toString() + - "\" was inferred as " + - literal->mobileType()->toString() + - ". This is probably not desired. Use an explicit type to silence this warning." - ); + /* If no mobile type is available an error will be raised elsewhere. */ + solAssert(m_errorReporter.hasErrors(), ""); } } } @@ -1827,7 +1845,7 @@ bool TypeChecker::visit(FunctionCall const& _functionCall) if (functionType->takesArbitraryParameters()) m_errorReporter.typeError( _functionCall.location(), - "Named arguments cannnot be used for functions that take arbitrary parameters." + "Named arguments cannot be used for functions that take arbitrary parameters." ); else if (parameterNames.size() > argumentNames.size()) m_errorReporter.typeError(_functionCall.location(), "Some argument names are missing."); diff --git a/libsolidity/analysis/TypeChecker.h b/libsolidity/analysis/TypeChecker.h index 2245abd6..8dc6b376 100644 --- a/libsolidity/analysis/TypeChecker.h +++ b/libsolidity/analysis/TypeChecker.h @@ -68,7 +68,7 @@ private: void checkContractDuplicateFunctions(ContractDefinition const& _contract); void checkContractDuplicateEvents(ContractDefinition const& _contract); void checkContractIllegalOverrides(ContractDefinition const& _contract); - /// Reports a type error with an appropiate message if overriden function signature differs. + /// Reports a type error with an appropriate message if overridden function signature differs. /// Also stores the direct super function in the AST annotations. void checkFunctionOverride(FunctionDefinition const& function, FunctionDefinition const& super); void overrideError(FunctionDefinition const& function, FunctionDefinition const& super, std::string message); diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 9906fa68..e862fd62 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -1169,11 +1169,11 @@ public: Statement const& body() const { return *m_body; } private: - /// For statement's initialization expresion. for(XXX; ; ). Can be empty + /// For statement's initialization expression. for(XXX; ; ). Can be empty ASTPointer<Statement> m_initExpression; - /// For statement's condition expresion. for(; XXX ; ). Can be empty + /// For statement's condition expression. for(; XXX ; ). Can be empty ASTPointer<Expression> m_condExpression; - /// For statement's loop expresion. for(;;XXX). Can be empty + /// For statement's loop expression. for(;;XXX). Can be empty ASTPointer<ExpressionStatement> m_loopExpression; /// The body of the loop ASTPointer<Statement> m_body; diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 23614e58..dd0736e9 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -771,20 +771,23 @@ tuple<bool, rational> RationalNumberType::isValidLiteral(Literal const& _literal } else if (expPoint != _literal.value().end()) { - // Parse base and exponent. Checks numeric limit. - bigint exp = bigint(string(expPoint + 1, _literal.value().end())); + // Parse mantissa and exponent. Checks numeric limit. + tuple<bool, rational> mantissa = parseRational(string(_literal.value().begin(), expPoint)); - if (exp > numeric_limits<int32_t>::max() || exp < numeric_limits<int32_t>::min()) + if (!get<0>(mantissa)) return make_tuple(false, rational(0)); + value = get<1>(mantissa); - uint32_t expAbs = bigint(abs(exp)).convert_to<uint32_t>(); - + // 0E... is always zero. + if (value == 0) + return make_tuple(true, rational(0)); - tuple<bool, rational> base = parseRational(string(_literal.value().begin(), expPoint)); + bigint exp = bigint(string(expPoint + 1, _literal.value().end())); - if (!get<0>(base)) + if (exp > numeric_limits<int32_t>::max() || exp < numeric_limits<int32_t>::min()) return make_tuple(false, rational(0)); - value = get<1>(base); + + uint32_t expAbs = bigint(abs(exp)).convert_to<uint32_t>(); if (exp < 0) { @@ -949,7 +952,7 @@ TypePointer RationalNumberType::binaryOperatorResult(Token::Value _operator, Typ RationalNumberType const& other = dynamic_cast<RationalNumberType const&>(*_other); if (Token::isCompareOp(_operator)) { - // Since we do not have a "BoolConstantType", we have to do the acutal comparison + // Since we do not have a "BoolConstantType", we have to do the actual comparison // at runtime and convert to mobile typse first. Such a comparison is not a very common // use-case and will be optimized away. TypePointer thisMobile = mobileType(); diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index 4415fb4b..135f4a0e 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -1031,7 +1031,7 @@ public: /// @param _selfType if the function is bound, this has to be supplied and is the type of the /// expression the function is called on. bool canTakeArguments(TypePointers const& _arguments, TypePointer const& _selfType = TypePointer()) const; - /// @returns true if the types of parameters are equal (does't check return parameter types) + /// @returns true if the types of parameters are equal (doesn't check return parameter types) bool hasEqualArgumentTypes(FunctionType const& _other) const; /// @returns true if the ABI is used for this call (only meaningful for external calls) diff --git a/libsolidity/codegen/ABIFunctions.cpp b/libsolidity/codegen/ABIFunctions.cpp index 4818e111..b3f1bc7e 100644 --- a/libsolidity/codegen/ABIFunctions.cpp +++ b/libsolidity/codegen/ABIFunctions.cpp @@ -1188,7 +1188,8 @@ string ABIFunctions::abiDecodingFunctionCalldataArray(ArrayType const& _type) solAssert(_type.dataStoredIn(DataLocation::CallData), ""); if (!_type.isDynamicallySized()) solAssert(_type.length() < u256("0xffffffffffffffff"), ""); - solAssert(!_type.baseType()->isDynamicallyEncoded(), ""); + if (_type.baseType()->isDynamicallyEncoded()) + solUnimplemented("Calldata arrays with non-value base types are not yet supported by Solidity."); solAssert(_type.baseType()->calldataEncodedSize() < u256("0xffffffffffffffff"), ""); string functionName = diff --git a/libsolidity/codegen/ABIFunctions.h b/libsolidity/codegen/ABIFunctions.h index 6bfb3f15..3caaa1d9 100644 --- a/libsolidity/codegen/ABIFunctions.h +++ b/libsolidity/codegen/ABIFunctions.h @@ -203,7 +203,7 @@ private: std::string arrayLengthFunction(ArrayType const& _type); /// @returns the name of a function that computes the number of bytes required /// to store an array in memory given its length (internally encoded, not ABI encoded). - /// The function reverts for too large lengthes. + /// The function reverts for too large lengths. std::string arrayAllocationSizeFunction(ArrayType const& _type); /// @returns the name of a function that converts a storage slot number /// or a memory pointer to the slot number / memory pointer for the data position of an array diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index 2f45765a..2e335ca5 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -363,8 +363,8 @@ void CompilerUtils::encodeToMemory( // Stack during operation: // <v1> <v2> ... <vn> <mem_start> <dyn_head_1> ... <dyn_head_r> <end_of_mem> - // The values dyn_head_i are added during the first loop and they point to the head part - // of the ith dynamic parameter, which is filled once the dynamic parts are processed. + // The values dyn_head_n are added during the first loop and they point to the head part + // of the nth dynamic parameter, which is filled once the dynamic parts are processed. // store memory start pointer m_context << Instruction::DUP1; diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 2e548e32..483faae4 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -1751,7 +1751,7 @@ void ExpressionCompiler::appendShiftOperatorCode(Token::Value _operator, Type co { if (c_valueSigned) // In the following assembly snippet, xor_mask will be zero, if value_to_shift is positive. - // Therefor xor'ing with xor_mask is the identity and the computation reduces to + // Therefore xor'ing with xor_mask is the identity and the computation reduces to // div(value_to_shift, exp(2, shift_amount)), which is correct, since for positive values // arithmetic right shift is dividing by a power of two (which, as a bitwise operation, results // in discarding bits on the right and filling with zeros from the left). @@ -1879,7 +1879,7 @@ void ExpressionCompiler::appendExternalFunctionCall( { m_context << u256(0); utils().fetchFreeMemoryPointer(); - // This touches too much, but that way we save some rounding arithmetics + // This touches too much, but that way we save some rounding arithmetic m_context << u256(retSize) << Instruction::ADD << Instruction::MSTORE; } } diff --git a/libsolidity/formal/SMTChecker.cpp b/libsolidity/formal/SMTChecker.cpp index a4d9500b..e2a51267 100644 --- a/libsolidity/formal/SMTChecker.cpp +++ b/libsolidity/formal/SMTChecker.cpp @@ -95,7 +95,7 @@ bool SMTChecker::visit(FunctionDefinition const& _function) void SMTChecker::endVisit(FunctionDefinition const&) { - // TOOD we could check for "reachability", i.e. satisfiability here. + // TODO we could check for "reachability", i.e. satisfiability here. // We only handle local variables, so we clear at the beginning of the function. // If we add storage variables, those should be cleared differently. removeLocalVariables(); diff --git a/libsolidity/inlineasm/AsmParser.cpp b/libsolidity/inlineasm/AsmParser.cpp index 7df9ab88..cd429a98 100644 --- a/libsolidity/inlineasm/AsmParser.cpp +++ b/libsolidity/inlineasm/AsmParser.cpp @@ -150,7 +150,7 @@ assembly::Statement Parser::parseStatement() expectToken(Token::Comma); elementary = parseElementaryOperation(); if (elementary.type() != typeid(assembly::Identifier)) - fatalParserError("Variable name expected in multiple assignemnt."); + fatalParserError("Variable name expected in multiple assignment."); assignment.variableNames.emplace_back(boost::get<assembly::Identifier>(elementary)); } while (currentToken() == Token::Comma); diff --git a/libsolidity/interface/AssemblyStack.cpp b/libsolidity/interface/AssemblyStack.cpp index a4b0265e..46fa1d6b 100644 --- a/libsolidity/interface/AssemblyStack.cpp +++ b/libsolidity/interface/AssemblyStack.cpp @@ -119,7 +119,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const julia::EVMAssembly assembly(true); julia::CodeTransform(assembly, *m_analysisInfo, m_language == Language::Yul, true)(*m_parserResult); object.bytecode = make_shared<eth::LinkerObject>(assembly.finalize()); - /// TOOD: fill out text representation + /// TODO: fill out text representation return object; } case Machine::eWasm: diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h index 4359c3fa..0578ac86 100644 --- a/libsolidity/interface/CompilerStack.h +++ b/libsolidity/interface/CompilerStack.h @@ -93,7 +93,7 @@ public: m_errorList(), m_errorReporter(m_errorList) {} - /// @returns the list of errors that occured during parsing and type checking. + /// @returns the list of errors that occurred during parsing and type checking. ErrorList const& errors() const { return m_errorReporter.errors(); } /// @returns the current state. diff --git a/libsolidity/interface/ErrorReporter.h b/libsolidity/interface/ErrorReporter.h index d1a0030f..fd53587a 100644 --- a/libsolidity/interface/ErrorReporter.h +++ b/libsolidity/interface/ErrorReporter.h @@ -92,6 +92,12 @@ public: void clear(); + /// @returns true iff there is any error (ignores warnings). + bool hasErrors() const + { + return m_errorCount > 0; + } + private: void error(Error::Type _type, SourceLocation const& _location, diff --git a/libsolidity/interface/Natspec.h b/libsolidity/interface/Natspec.h index 0701f821..6a827d3b 100644 --- a/libsolidity/interface/Natspec.h +++ b/libsolidity/interface/Natspec.h @@ -45,7 +45,7 @@ public: /// @param _contractDef The contract definition /// @return A JSON representation of the contract's user documentation static Json::Value userDocumentation(ContractDefinition const& _contractDef); - /// Genereates the Developer's documentation of the contract + /// Generates the Developer's documentation of the contract /// @param _contractDef The contract definition /// @return A JSON representation /// of the contract's developer documentation diff --git a/libsolidity/interface/StandardCompiler.h b/libsolidity/interface/StandardCompiler.h index 11a0b4c2..2772394a 100644 --- a/libsolidity/interface/StandardCompiler.h +++ b/libsolidity/interface/StandardCompiler.h @@ -31,7 +31,7 @@ namespace solidity { /** - * Standard JSON compiler interface, which expects a JSON input and returns a JSON ouput. + * Standard JSON compiler interface, which expects a JSON input and returns a JSON output. * See docs/using-the-compiler#compiler-input-and-output-json-description. */ class StandardCompiler: boost::noncopyable diff --git a/libsolidity/parsing/Scanner.h b/libsolidity/parsing/Scanner.h index 0adaa6fd..8a3011eb 100644 --- a/libsolidity/parsing/Scanner.h +++ b/libsolidity/parsing/Scanner.h @@ -223,7 +223,7 @@ private: bool isSourcePastEndOfInput() const { return m_source.isPastEndOfInput(); } TokenDesc m_skippedComment; // desc for current skipped comment - TokenDesc m_nextSkippedComment; // desc for next skiped comment + TokenDesc m_nextSkippedComment; // desc for next skipped comment TokenDesc m_currentToken; // desc for current token (as returned by Next()) TokenDesc m_nextToken; // desc for next token (one token look-ahead) diff --git a/scripts/codespell_whitelist.txt b/scripts/codespell_whitelist.txt new file mode 100644 index 00000000..31f03981 --- /dev/null +++ b/scripts/codespell_whitelist.txt @@ -0,0 +1,3 @@ +iff +nd +assignend diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 8b331c75..4811f767 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -447,7 +447,7 @@ bool CommandLineInterface::readInputFilesAndConfigureRemappings() m_sourceCodes[g_stdinFileName] = dev::readStandardInput(); if (m_sourceCodes.size() == 0) { - cerr << "No input files given. If you wish to use the standard input please specify \"-\" explicity." << endl; + cerr << "No input files given. If you wish to use the standard input please specify \"-\" explicitly." << endl; return false; } diff --git a/test/compilationTests/corion/ico.sol b/test/compilationTests/corion/ico.sol index 80444395..7b27c201 100644 --- a/test/compilationTests/corion/ico.sol +++ b/test/compilationTests/corion/ico.sol @@ -277,7 +277,7 @@ contract ico is safeMath { function () external payable { /* - Callback function. Simply calls the buy function as a beneficiary and there is no affilate address. + Callback function. Simply calls the buy function as a beneficiary and there is no affiliate address. If they call the contract without any function then this process will be taken place. */ require( isICO() ); @@ -290,9 +290,9 @@ contract ico is safeMath { If there is not at least 0.2 ether balance on the beneficiaryAddress then the amount of the ether which was intended for the purchase will be reduced by 0.2 and that will be sent to the address of the beneficiary. From the remaining amount calculate the reward with the help of the getIcoReward function. - Only that affilate address is valid which has some token on it’s account. - If there is a valid affilate address then calculate and credit the reward as well in the following way: - With more than 1e12 token contract credit 5% reward based on the calculation that how many tokens did they buy when he was added as an affilate. + Only that affiliate address is valid which has some token on it’s account. + If there is a valid affiliate address then calculate and credit the reward as well in the following way: + With more than 1e12 token contract credit 5% reward based on the calculation that how many tokens did they buy when he was added as an affiliate. More than 1e11 token: 4% More than 1e10 token: 3% More than 1e9 token: 2% below 1% @@ -345,7 +345,7 @@ contract ico is safeMath { /* Crediting the premium token - @owner The corion token balance of this address will be set based on the calculation which shows that how many times can be the amount of the purchased tokens devided by 5000. So after each 5000 token we give 1 premium token. + @owner The corion token balance of this address will be set based on the calculation which shows that how many times can be the amount of the purchased tokens divided by 5000. So after each 5000 token we give 1 premium token. */ uint256 _reward = (brought[owner].cor / 5e9) - brought[owner].corp; if ( _reward > 0 ) { @@ -372,5 +372,5 @@ contract ico is safeMath { return startBlock <= block.number && block.number <= icoDelay && ( ! aborted ) && ( ! closed ); } - event EICO(address indexed Address, uint256 indexed value, address Affilate, uint256 AffilateValue); + event EICO(address indexed Address, uint256 indexed value, address Affiliate, uint256 AffilateValue); } diff --git a/test/compilationTests/corion/module.sol b/test/compilationTests/corion/module.sol index 362283ef..62f44af7 100644 --- a/test/compilationTests/corion/module.sol +++ b/test/compilationTests/corion/module.sol @@ -131,7 +131,7 @@ contract module { /* Check self for ready for functions or not. - @success Function call was successfull or not + @success Function call was successful or not @active Ready for functions or not */ return (true, moduleStatus == status.Connected && block.number >= disabledUntil); diff --git a/test/compilationTests/corion/moduleHandler.sol b/test/compilationTests/corion/moduleHandler.sol index 441f7fba..fddd2a29 100644 --- a/test/compilationTests/corion/moduleHandler.sol +++ b/test/compilationTests/corion/moduleHandler.sol @@ -63,7 +63,7 @@ contract moduleHandler is multiOwner, announcementTypes { function addModule(modules_s input, bool call) internal { /* Inside function for registration of the modules in the database. - If the call is false, wont happen any direct call. + If the call is false, won't happen any direct call. @input _Structure of module. @call Is connect to the module or not. @@ -88,7 +88,7 @@ contract moduleHandler is multiOwner, announcementTypes { @name Name of module. @addr Address of module. @found Is there any result. - @success Was the transaction succesfull or not. + @success Was the transaction successful or not. */ (bool _success, bool _found, uint256 _id) = getModuleIDByName(name); if ( _success && _found ) { return (true, true, modules[_id].addr); } @@ -204,7 +204,7 @@ contract moduleHandler is multiOwner, announcementTypes { Deleting module from the database. Can be called only by the Publisher contract. @name Name of module to delete. - @bool Was the function successfull? + @bool Was the function successful? @callCallback Call the replaceable module to confirm replacement or not. */ (bool _success, bool _found, uint256 _id) = getModuleIDByAddress(msg.sender); @@ -245,7 +245,7 @@ contract moduleHandler is multiOwner, announcementTypes { @from from who. @to to who. @value amount. - @bool Was the function successfull? + @bool Was the function successful? */ (bool _success, bool _found, uint256 _id) = getModuleIDByAddress(msg.sender); require( _success && _found && modules[_id].name == keccak256('Token') ); @@ -264,7 +264,7 @@ contract moduleHandler is multiOwner, announcementTypes { @roundID Number of Schelling round. @reward Coin emission in this Schelling round. - @bool Was the function successfull? + @bool Was the function successful? */ (bool _success, bool _found, uint256 _id) = getModuleIDByAddress(msg.sender); require( _success && _found && modules[_id].name == keccak256('Schelling') ); @@ -283,7 +283,7 @@ contract moduleHandler is multiOwner, announcementTypes { Every module will be informed about the ModuleHandler replacement. @newHandler Address of the new ModuleHandler. - @bool Was the function successfull? + @bool Was the function successful? */ (bool _success, bool _found, uint256 _id) = getModuleIDByAddress(msg.sender); require( _success ); @@ -304,7 +304,7 @@ contract moduleHandler is multiOwner, announcementTypes { @owner address @value balance. - @success was the function successfull? + @success was the function successful? */ (bool _success, bool _found, uint256 _id) = getModuleIDByName('Token'); require( _success && _found ); @@ -315,7 +315,7 @@ contract moduleHandler is multiOwner, announcementTypes { Query of the whole token amount. @value amount. - @success was the function successfull? + @success was the function successful? */ (bool _success, bool _found, uint256 _id) = getModuleIDByName('Token'); require( _success && _found ); @@ -326,7 +326,7 @@ contract moduleHandler is multiOwner, announcementTypes { Query of ICO state @ico Is ICO in progress?. - @success was the function successfull? + @success was the function successful? */ (bool _success, bool _found, uint256 _id) = getModuleIDByName('Token'); require( _success && _found ); @@ -337,7 +337,7 @@ contract moduleHandler is multiOwner, announcementTypes { Query of number of the actual Schelling round. @round Schelling round. - @success was the function successfull? + @success was the function successful? */ (bool _success, bool _found, uint256 _id) = getModuleIDByName('Schelling'); require( _success && _found ); @@ -350,7 +350,7 @@ contract moduleHandler is multiOwner, announcementTypes { @to Place of new token @value Token amount - @success Was the function successfull? + @success Was the function successful? */ (bool _success, bool _found, uint256 _id) = getModuleIDByAddress(msg.sender); require( _success && _found && modules[_id].name == keccak256('Provider') ); @@ -367,7 +367,7 @@ contract moduleHandler is multiOwner, announcementTypes { @to To who. @value Token amount. @fee Transaction fee will be charged or not? - @success Was the function successfull? + @success Was the function successful? */ (bool _success, bool _found, uint256 _id) = getModuleIDByAddress(msg.sender); require( _success && _found ); @@ -382,7 +382,7 @@ contract moduleHandler is multiOwner, announcementTypes { @from From who. @value Token amount. - @success Was the function successfull? + @success Was the function successful? */ (bool _success, bool _found, uint256 _id) = getModuleIDByAddress(msg.sender); require( _success && _found && modules[_id].name == keccak256('Provider') ); @@ -397,7 +397,7 @@ contract moduleHandler is multiOwner, announcementTypes { @from From who. @value Token amount. - @success Was the function successfull? + @success Was the function successful? */ (bool _success, bool _found, uint256 _id) = getModuleIDByAddress(msg.sender); require( _success && _found && modules[_id].name == keccak256('Schelling') ); @@ -413,7 +413,7 @@ contract moduleHandler is multiOwner, announcementTypes { @moduleName Module name which will be configured @aType Type of variable (announcementType). @value New value - @success Was the function successfull? + @success Was the function successful? */ (bool _success, bool _found, uint256 _id) = getModuleIDByAddress(msg.sender); require( _success ); @@ -431,7 +431,7 @@ contract moduleHandler is multiOwner, announcementTypes { function freezing(bool forever) external { /* Freezing CORION Platform. Can be called only by the owner. - Freez can not be recalled! + Freeze can not be recalled! @forever Is it forever or not? */ diff --git a/test/compilationTests/corion/premium.sol b/test/compilationTests/corion/premium.sol index 14f18ad2..e1f12ed0 100644 --- a/test/compilationTests/corion/premium.sol +++ b/test/compilationTests/corion/premium.sol @@ -118,7 +118,7 @@ contract premium is module, safeMath { @extraData Extra data to be received by the receiver @nonce Transaction count - @sucess Was the Function successful? + @success Was the Function successful? */ _approve(spender, amount, nonce); require( thirdPartyPContractAbstract(spender).approvedCorionPremiumToken(msg.sender, amount, extraData) ); diff --git a/test/compilationTests/corion/provider.sol b/test/compilationTests/corion/provider.sol index 83edcc01..35ade69f 100644 --- a/test/compilationTests/corion/provider.sol +++ b/test/compilationTests/corion/provider.sol @@ -18,7 +18,7 @@ contract provider is module, safeMath, announcementTypes { } function transferEvent(address from, address to, uint256 value) external returns (bool success) { /* - Transaction completed. This function is ony available for the modulehandler. + Transaction completed. This function is only available for the modulehandler. It should be checked if the sender or the acceptor does not connect to the provider or it is not a provider itself if so than the change should be recorded. @from From whom? @@ -35,7 +35,7 @@ contract provider is module, safeMath, announcementTypes { /* New schelling round. This function is only available for the moduleHandler. We are recording the new schelling round and we are storing the whole current quantity of the tokens. - We generate a reward quantity of tokens directed to the providers address. The collected interest will be tranfered from this contract. + We generate a reward quantity of tokens directed to the providers address. The collected interest will be transferred from this contract. @roundID Number of the schelling round. @reward token emission @@ -228,7 +228,7 @@ contract provider is module, safeMath, announcementTypes { @website Provider’s website @country Provider’s country @info Provider’s short introduction. - @rate Rate of the emission what is going to be transfered to the client by the provider. + @rate Rate of the emission what is going to be transferred to the client by the provider. @isForRent is for Rent or not? @admin The admin’s address */ @@ -328,7 +328,7 @@ contract provider is module, safeMath, announcementTypes { @addr Address of the provider @height Height - @rate The rate of the emission which will be transfered to the client. + @rate The rate of the emission which will be transferred to the client. @isForRent Rent or not. @clientsCount Number of the clients. @priv Private or not? @@ -356,7 +356,7 @@ contract provider is module, safeMath, announcementTypes { } function closeProvider() isReady external { /* - Closing and inactivate the provider. + Closing and deactivating the provider. It is only possible to close that active provider which is owned by the sender itself after calling the whole share of the emission. Whom were connected to the provider those clients will have to disconnect after they’ve called their share of emission which was not called before. */ @@ -373,7 +373,7 @@ contract provider is module, safeMath, announcementTypes { /* Permition of the user to be able to connect to the provider. This can only be invited by the provider’s admin. - With this kind of call only 100 address can be permited. + With this kind of call only 100 address can be permitted. @addr Array of the addresses for whom the connection is allowed. */ @@ -391,7 +391,7 @@ contract provider is module, safeMath, announcementTypes { /* Disable of the user not to be able to connect to the provider. It is can called only for the admin of the provider. - With this kind of call only 100 address can be permited. + With this kind of call only 100 address can be permitted. @addr Array of the addresses for whom the connection is allowed. */ @@ -411,7 +411,7 @@ contract provider is module, safeMath, announcementTypes { Providers can not connect to other providers. If is a client at any provider, then it is not possible to connect to other provider one. It is only possible to connect to valid and active providers. - If is an active provider then the client can only connect, if address is permited at the provider (Whitelist). + If is an active provider then the client can only connect, if address is permitted at the provider (Whitelist). At private providers, the number of the client is restricted. If it reaches the limit no further clients are allowed to connect. This process has a transaction fee based on the senders whole token quantity. @@ -487,12 +487,12 @@ contract provider is module, safeMath, announcementTypes { /* Polling the share from the token emission token emission for clients and for providers. - It is optionaly possible to give an address of a beneficiary for whom we can transfer the accumulated amount. In case we don’t enter any address then the amount will be transfered to the caller’s address. + It is optionally possible to give an address of a beneficiary for whom we can transfer the accumulated amount. In case we don’t enter any address then the amount will be transferred to the caller’s address. As the interest should be checked at each schelling round in order to get the share from that so to avoid the overflow of the gas the number of the check-rounds should be limited. - Opcionalisan megadhato az ellenorzes koreinek szama. It is possible to enter optionaly the number of the check-rounds. If it is 0 then it is automatic. + Opcionalisan megadhato az ellenorzes koreinek szama. It is possible to enter optionally the number of the check-rounds. If it is 0 then it is automatic. Provider variable should only be entered if the real owner of the provider is not the caller’s address. In case the client/provider was far behind then it is possible that this function should be called several times to check the total generated schelling rounds and to collect the share. - If is neighter a client nor a provider then the function is not available. + If is neither a client nor a provider then the function is not available. The tokens will be sent to the beneficiary from the address of the provider without any transaction fees. @beneficiary Address of the beneficiary @@ -784,7 +784,7 @@ contract provider is module, safeMath, announcementTypes { /* Inner function to check the ICO status. - @isICO Is the ICO in proccess or not? + @isICO Is the ICO in process or not? */ (bool _success, bool _isICO) = moduleHandler(moduleHandlerAddress).isICO(); require( _success ); diff --git a/test/compilationTests/corion/publisher.sol b/test/compilationTests/corion/publisher.sol index 3a332706..44bc5964 100644 --- a/test/compilationTests/corion/publisher.sol +++ b/test/compilationTests/corion/publisher.sol @@ -264,7 +264,7 @@ contract publisher is announcementTypes, module, safeMath { function checkICO() internal returns (bool isICO) {
/*
Inner function to check the ICO status.
- @bool Is the ICO in proccess or not?
+ @bool Is the ICO in process or not?
*/
(bool _success, bool _isICO) = moduleHandler(moduleHandlerAddress).isICO();
require( _success );
diff --git a/test/compilationTests/corion/schelling.sol b/test/compilationTests/corion/schelling.sol index 0f84239d..b8beaa3a 100644 --- a/test/compilationTests/corion/schelling.sol +++ b/test/compilationTests/corion/schelling.sol @@ -147,7 +147,7 @@ contract schelling is module, announcementTypes, schellingVars { @from From who @to To who @value Amount - @bool Was the transaction succesfull? + @bool Was the transaction successful? */ require( super.isModuleHandler(msg.sender) ); if ( to == address(this) ) { @@ -442,14 +442,14 @@ contract schelling is module, announcementTypes, schellingVars { if ( ! round.voted ) { newRound.reward = round.reward; } - uint256 aboves; + uint256 above; for ( uint256 a=currentRound ; a>=currentRound-interestCheckRounds ; a-- ) { if (a == 0) { break; } prevRound = getRound(a); - if ( prevRound.totalAboveWeight > prevRound.totalBelowWeight ) { aboves++; } + if ( prevRound.totalAboveWeight > prevRound.totalBelowWeight ) { above++; } } uint256 expansion; - if ( aboves >= interestCheckAboves ) { + if ( above >= interestCheckAboves ) { expansion = getTotalSupply() * interestRate / interestRateM / 100; } diff --git a/test/compilationTests/milestonetracker/MilestoneTracker.sol b/test/compilationTests/milestonetracker/MilestoneTracker.sol index 545acb0a..fc7008cd 100644 --- a/test/compilationTests/milestonetracker/MilestoneTracker.sol +++ b/test/compilationTests/milestonetracker/MilestoneTracker.sol @@ -22,7 +22,7 @@ pragma solidity ^0.4.6; /// @dev This contract tracks the -/// is rules the relation betwen a donor and a recipient +/// is rules the relation between a donor and a recipient /// in order to guaranty to the donor that the job will be done and to guaranty /// to the recipient that he will be paid diff --git a/test/compilationTests/zeppelin/Bounty.sol b/test/compilationTests/zeppelin/Bounty.sol index 6341610b..5b2124ca 100644 --- a/test/compilationTests/zeppelin/Bounty.sol +++ b/test/compilationTests/zeppelin/Bounty.sol @@ -16,7 +16,7 @@ contract Bounty is PullPayment, Destructible { event TargetCreated(address createdAddress); /** - * @dev Fallback function allowing the contract to recieve funds, if they haven't already been claimed. + * @dev Fallback function allowing the contract to receive funds, if they haven't already been claimed. */ function() external payable { if (claimed) { diff --git a/test/compilationTests/zeppelin/ReentrancyGuard.sol b/test/compilationTests/zeppelin/ReentrancyGuard.sol index ca8b643b..60c7927b 100644 --- a/test/compilationTests/zeppelin/ReentrancyGuard.sol +++ b/test/compilationTests/zeppelin/ReentrancyGuard.sol @@ -1,7 +1,7 @@ pragma solidity ^0.4.11; /** - * @title Helps contracts guard agains rentrancy attacks. + * @title Helps contracts guard against rentrancy attacks. * @author Remco Bloemen <remco@2π.com> * @notice If you mark a function `nonReentrant`, you should also * mark it `external`. diff --git a/test/compilationTests/zeppelin/token/LimitedTransferToken.sol b/test/compilationTests/zeppelin/token/LimitedTransferToken.sol index 5a056f78..052c28e6 100644 --- a/test/compilationTests/zeppelin/token/LimitedTransferToken.sol +++ b/test/compilationTests/zeppelin/token/LimitedTransferToken.sol @@ -29,7 +29,7 @@ contract LimitedTransferToken is ERC20 { /** * @dev Checks modifier and allows transfer if tokens are not locked. - * @param _to The address that will recieve the tokens. + * @param _to The address that will receive the tokens. * @param _value The amount of tokens to be transferred. */ function transfer(address _to, uint256 _value) canTransfer(msg.sender, _value) public { @@ -39,7 +39,7 @@ contract LimitedTransferToken is ERC20 { /** * @dev Checks modifier and allows transfer if tokens are not locked. * @param _from The address that will send the tokens. - * @param _to The address that will recieve the tokens. + * @param _to The address that will receive the tokens. * @param _value The amount of tokens to be transferred. */ function transferFrom(address _from, address _to, uint256 _value) public canTransfer(_from, _value) { diff --git a/test/compilationTests/zeppelin/token/MintableToken.sol b/test/compilationTests/zeppelin/token/MintableToken.sol index 4c4787e3..f99964d0 100644 --- a/test/compilationTests/zeppelin/token/MintableToken.sol +++ b/test/compilationTests/zeppelin/token/MintableToken.sol @@ -27,7 +27,7 @@ contract MintableToken is StandardToken, Ownable { /** * @dev Function to mint tokens - * @param _to The address that will recieve the minted tokens. + * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ diff --git a/test/compilationTests/zeppelin/token/SimpleToken.sol b/test/compilationTests/zeppelin/token/SimpleToken.sol index d0232bca..6c3f5740 100644 --- a/test/compilationTests/zeppelin/token/SimpleToken.sol +++ b/test/compilationTests/zeppelin/token/SimpleToken.sol @@ -18,7 +18,7 @@ contract SimpleToken is StandardToken { uint256 public INITIAL_SUPPLY = 10000; /** - * @dev Contructor that gives msg.sender all of existing tokens. + * @dev Constructor that gives msg.sender all of existing tokens. */ constructor() public { totalSupply = INITIAL_SUPPLY; diff --git a/test/compilationTests/zeppelin/token/StandardToken.sol b/test/compilationTests/zeppelin/token/StandardToken.sol index a55d961c..94b12e57 100644 --- a/test/compilationTests/zeppelin/token/StandardToken.sol +++ b/test/compilationTests/zeppelin/token/StandardToken.sol @@ -21,7 +21,7 @@ contract StandardToken is ERC20, BasicToken { * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to - * @param _value uint256 the amout of tokens to be transfered + * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public { uint256 _allowance = allowed[_from][msg.sender]; @@ -56,7 +56,7 @@ contract StandardToken is ERC20, BasicToken { * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. - * @return A uint256 specifing the amount of tokens still avaible for the spender. + * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; diff --git a/test/compilationTests/zeppelin/token/VestedToken.sol b/test/compilationTests/zeppelin/token/VestedToken.sol index 17141bdf..893a51db 100644 --- a/test/compilationTests/zeppelin/token/VestedToken.sol +++ b/test/compilationTests/zeppelin/token/VestedToken.sol @@ -69,7 +69,7 @@ contract VestedToken is StandardToken, LimitedTransferToken { } /** - * @dev Revoke the grant of tokens of a specifed address. + * @dev Revoke the grant of tokens of a specified address. * @param _holder The address which will have its tokens revoked. * @param _grantId The id of the token grant. */ @@ -135,13 +135,13 @@ contract VestedToken is StandardToken, LimitedTransferToken { } /** - * @dev Calculate amount of vested tokens at a specifc time. - * @param tokens uint256 The amount of tokens grantted. + * @dev Calculate amount of vested tokens at a specific time. + * @param tokens uint256 The amount of tokens granted. * @param time uint64 The time to be checked - * @param start uint64 A time representing the begining of the grant + * @param start uint64 A time representing the beginning of the grant * @param cliff uint64 The cliff period. * @param vesting uint64 The vesting period. - * @return An uint256 representing the amount of vested tokensof a specif grant. + * @return An uint256 representing the amount of vested tokens of a specific grant. * transferableTokens * | _/-------- vestedTokens rect * | _/ @@ -186,7 +186,7 @@ contract VestedToken is StandardToken, LimitedTransferToken { } /** - * @dev Get all information about a specifc grant. + * @dev Get all information about a specific grant. * @param _holder The address which will have its tokens revoked. * @param _grantId The id of the token grant. * @return Returns all the values that represent a TokenGrant(address, value, start, cliff, @@ -226,7 +226,7 @@ contract VestedToken is StandardToken, LimitedTransferToken { * @dev Calculate the amount of non vested tokens at a specific time. * @param grant TokenGrant The grant to be checked. * @param time uint64 The time to be checked - * @return An uint256 representing the amount of non vested tokens of a specifc grant on the + * @return An uint256 representing the amount of non vested tokens of a specific grant on the * passed time frame. */ function nonVestedTokens(TokenGrant grant, uint64 time) private view returns (uint256) { diff --git a/test/contracts/Wallet.cpp b/test/contracts/Wallet.cpp index fb104300..b3a096a3 100644 --- a/test/contracts/Wallet.cpp +++ b/test/contracts/Wallet.cpp @@ -385,7 +385,7 @@ contract Wallet is multisig, multiowned, daylimit { emit Deposit(msg.sender, msg.value); } - // Outside-visible transact entry point. Executes transacion immediately if below daily spend limit. + // Outside-visible transact entry point. Executes transaction immediately if below daily spend limit. // If not, goes into multisig process. We provide a hash on return to allow the sender to provide // shortcuts for the other confirmations (allowing them to avoid replicating the _to, _value // and _data arguments). They still get the option of using them if they want, anyways. diff --git a/test/libjulia/Parser.cpp b/test/libjulia/Parser.cpp index 07154718..3f329d28 100644 --- a/test/libjulia/Parser.cpp +++ b/test/libjulia/Parser.cpp @@ -267,7 +267,7 @@ BOOST_AUTO_TEST_CASE(recursion_depth) BOOST_AUTO_TEST_CASE(multiple_assignment) { CHECK_ERROR("{ let x:u256 function f() -> a:u256, b:u256 {} 123:u256, x := f() }", ParserError, "Label name / variable name must precede \",\" (multiple assignment)."); - CHECK_ERROR("{ let x:u256 function f() -> a:u256, b:u256 {} x, 123:u256 := f() }", ParserError, "Variable name expected in multiple assignemnt."); + CHECK_ERROR("{ let x:u256 function f() -> a:u256, b:u256 {} x, 123:u256 := f() }", ParserError, "Variable name expected in multiple assignment."); /// NOTE: Travis hiccups if not having a variable char const* text = R"( diff --git a/test/libsolidity/InlineAssembly.cpp b/test/libsolidity/InlineAssembly.cpp index 3046372f..a9ce6e49 100644 --- a/test/libsolidity/InlineAssembly.cpp +++ b/test/libsolidity/InlineAssembly.cpp @@ -461,7 +461,7 @@ BOOST_AUTO_TEST_CASE(recursion_depth) BOOST_AUTO_TEST_CASE(multiple_assignment) { CHECK_PARSE_ERROR("{ let x function f() -> a, b {} 123, x := f() }", ParserError, "Label name / variable name must precede \",\" (multiple assignment)."); - CHECK_PARSE_ERROR("{ let x function f() -> a, b {} x, 123 := f() }", ParserError, "Variable name expected in multiple assignemnt."); + CHECK_PARSE_ERROR("{ let x function f() -> a, b {} x, 123 := f() }", ParserError, "Variable name expected in multiple assignment."); /// NOTE: Travis hiccups if not having a variable char const* text = R"( diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp index c366e866..736b0b33 100644 --- a/test/libsolidity/SolidityABIJSON.cpp +++ b/test/libsolidity/SolidityABIJSON.cpp @@ -199,7 +199,7 @@ BOOST_AUTO_TEST_CASE(multiple_params) BOOST_AUTO_TEST_CASE(multiple_methods_order) { - // methods are expected to be in alpabetical order + // methods are expected to be in alphabetical order char const* sourceCode = R"( contract test { function f(uint a) public returns (uint d) { return a * 7; } diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index fbc6a9c6..3cd3b9b7 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -2082,7 +2082,7 @@ BOOST_AUTO_TEST_CASE(packed_keccak256) function a(bytes32 input) public returns (bytes32 hash) { uint24 b = 65536; uint c = 256; - return keccak256(abi.encodePacked(8, input, b, input, c)); + return keccak256(abi.encodePacked(uint8(8), input, b, input, c)); } } )"; @@ -2134,7 +2134,7 @@ BOOST_AUTO_TEST_CASE(packed_sha256) function a(bytes32 input) public returns (bytes32 hash) { uint24 b = 65536; uint c = 256; - return sha256(abi.encodePacked(8, input, b, input, c)); + return sha256(abi.encodePacked(uint8(8), input, b, input, c)); } } )"; @@ -2161,7 +2161,7 @@ BOOST_AUTO_TEST_CASE(packed_ripemd160) function a(bytes32 input) public returns (bytes32 hash) { uint24 b = 65536; uint c = 256; - return ripemd160(abi.encodePacked(8, input, b, input, c)); + return ripemd160(abi.encodePacked(uint8(8), input, b, input, c)); } } )"; @@ -3560,7 +3560,7 @@ BOOST_AUTO_TEST_CASE(keccak256_multiple_arguments_with_numeric_literals) contract c { function foo(uint a, uint16 b) public returns (bytes32 d) { - d = keccak256(abi.encodePacked(a, b, 145)); + d = keccak256(abi.encodePacked(a, b, uint8(145))); } } )"; @@ -3585,7 +3585,7 @@ BOOST_AUTO_TEST_CASE(keccak256_multiple_arguments_with_string_literals) } function bar(uint a, uint16 b) public returns (bytes32 d) { - d = keccak256(abi.encodePacked(a, b, 145, "foo")); + d = keccak256(abi.encodePacked(a, b, uint8(145), "foo")); } } )"; @@ -6387,9 +6387,9 @@ BOOST_AUTO_TEST_CASE(return_multiple_strings_of_various_sizes) "ABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZ" "ABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZ" ); - vector<size_t> lengthes{0, 30, 32, 63, 64, 65, 210, 300}; - for (auto l1: lengthes) - for (auto l2: lengthes) + vector<size_t> lengths{0, 30, 32, 63, 64, 65, 210, 300}; + for (auto l1: lengths) + for (auto l2: lengths) { bytes dyn1 = encodeArgs(u256(l1), s1.substr(0, l1)); bytes dyn2 = encodeArgs(u256(l2), s2.substr(0, l2)); @@ -6456,9 +6456,9 @@ BOOST_AUTO_TEST_CASE(bytes_in_function_calls) compileAndRun(sourceCode, 0, "Main"); string s1("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); string s2("ABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZ"); - vector<size_t> lengthes{0, 31, 64, 65}; - for (auto l1: lengthes) - for (auto l2: lengthes) + vector<size_t> lengths{0, 31, 64, 65}; + for (auto l1: lengths) + for (auto l2: lengths) { bytes dyn1 = encodeArgs(u256(l1), s1.substr(0, l1)); bytes dyn2 = encodeArgs(u256(l2), s2.substr(0, l2)); @@ -6497,8 +6497,8 @@ BOOST_AUTO_TEST_CASE(return_bytes_internal) )"; compileAndRun(sourceCode, 0, "Main"); string s1("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); - vector<size_t> lengthes{0, 31, 64, 65}; - for (auto l1: lengthes) + vector<size_t> lengths{0, 31, 64, 65}; + for (auto l1: lengths) { bytes dyn1 = encodeArgs(u256(l1), s1.substr(0, l1)); bytes args1 = encodeArgs(u256(0x20)) + dyn1; @@ -7916,7 +7916,7 @@ BOOST_AUTO_TEST_CASE(string_tuples) return (h(), "def"); } function h() public returns (string) { - return ("abc",); + return ("abc"); } } )"; diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index 949045ea..26b7914f 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -77,7 +77,7 @@ Declaration const& resolveDeclaration( ) { ASTNode const* scope = &_sourceUnit; - // bracers are required, cause msvc couldnt handle this macro in for statement + // bracers are required, cause msvc couldn't handle this macro in for statement for (string const& namePart: _namespacedName) { auto declarations = _resolver.resolveName(namePart, scope); @@ -319,7 +319,7 @@ BOOST_AUTO_TEST_CASE(short_circuiting) BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } -BOOST_AUTO_TEST_CASE(arithmetics) +BOOST_AUTO_TEST_CASE(arithmetic) { char const* sourceCode = R"( contract test { diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp index d375beff..a144068d 100644 --- a/test/libsolidity/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -104,7 +104,7 @@ public: "\nOptimized: " + toHex(optimizedOutput)); } - /// @returns the number of intructions in the given bytecode, not taking the metadata hash + /// @returns the number of instructions in the given bytecode, not taking the metadata hash /// into account. size_t numInstructions(bytes const& _bytecode, boost::optional<Instruction> _which = boost::optional<Instruction>{}) { diff --git a/test/libsolidity/ViewPureChecker.cpp b/test/libsolidity/ViewPureChecker.cpp index bb5480b2..299cd084 100644 --- a/test/libsolidity/ViewPureChecker.cpp +++ b/test/libsolidity/ViewPureChecker.cpp @@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(environment_access) "this", "address(1).balance" }; - // ``block.blockhash`` and ``blockhash`` are tested seperately below because their usage will + // ``block.blockhash`` and ``blockhash`` are tested separately below because their usage will // produce warnings that can't be handled in a generic way. vector<string> pure{ "msg.data", diff --git a/test/libsolidity/syntaxTests/fallback/default_visibility.sol b/test/libsolidity/syntaxTests/fallback/default_visibility.sol index f45bbd3c..31123d59 100644 --- a/test/libsolidity/syntaxTests/fallback/default_visibility.sol +++ b/test/libsolidity/syntaxTests/fallback/default_visibility.sol @@ -3,4 +3,4 @@ contract C { function() {} } // ---- -// Warning: (90-103): No visibility specified. Defaulting to "public". +// TypeError: (90-103): Fallback function must be defined as "external". diff --git a/test/libsolidity/syntaxTests/functionCalls/named_arguments_for_functions_that_take_arbitrary_parameters.sol b/test/libsolidity/syntaxTests/functionCalls/named_arguments_for_functions_that_take_arbitrary_parameters.sol new file mode 100644 index 00000000..089e1dbf --- /dev/null +++ b/test/libsolidity/syntaxTests/functionCalls/named_arguments_for_functions_that_take_arbitrary_parameters.sol @@ -0,0 +1,7 @@ +contract C { + function f() pure public { + abi.encodeWithSelector({selector:"abc"}); + } +} +// ---- +// TypeError: (52-92): Named arguments cannot be used for functions that take arbitrary parameters. diff --git a/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol b/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol index 0b18b995..692b1827 100644 --- a/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol +++ b/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol @@ -4,4 +4,4 @@ contract Base { contract Derived is Base(2) { } contract Derived2 is Base(), Derived() { } // ---- -// Warning: (101-107): Wrong argument count for constructor call: 0 arguments given but expected 1. +// TypeError: (101-107): Wrong argument count for constructor call: 0 arguments given but expected 1. Remove parentheses if you do not want to provide arguments here. diff --git a/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses_V050.sol b/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses_V050.sol deleted file mode 100644 index db04ab8c..00000000 --- a/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses_V050.sol +++ /dev/null @@ -1,9 +0,0 @@ -pragma experimental "v0.5.0"; - -contract Base { - constructor(uint) public {} -} -contract Derived is Base(2) { } -contract Derived2 is Base(), Derived() { } -// ---- -// TypeError: (132-138): Wrong argument count for constructor call: 0 arguments given but expected 1. diff --git a/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol b/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol index c55c41f2..1ce48200 100644 --- a/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol +++ b/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol @@ -6,5 +6,5 @@ contract Derived2 is Base { constructor() Base(2) public { } } // ---- -// TypeError: (74-81): Wrong argument count for constructor call: 1 arguments given but expected 2. +// TypeError: (74-81): Wrong argument count for constructor call: 1 arguments given but expected 2. Remove parentheses if you do not want to provide arguments here. // TypeError: (130-137): Wrong argument count for modifier invocation: 1 arguments given but expected 2. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol index 55c83674..b6dd12b8 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol @@ -1,6 +1,6 @@ contract C { uint[] x; - function() public { + function() external { uint[] storage y = x; assembly { pop(y) @@ -8,4 +8,4 @@ contract C { } } // ---- -// TypeError: (117-118): You have to use the _slot or _offset suffix to access storage reference variables. +// TypeError: (119-120): You have to use the _slot or _offset suffix to access storage reference variables. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol index 3ae24b34..84f98ed9 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol @@ -1,6 +1,6 @@ contract C { uint[] x; - function() public { + function() external { uint[] storage y = x; assembly { pop(y_slot) diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/244_tuples.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/244_tuples.sol index 3112f67a..95e8cf37 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/244_tuples.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/244_tuples.sol @@ -1,13 +1,13 @@ contract C { function f() public { uint a = (1); - (uint b,) = (uint8(1),); + (uint b,) = uint8(1); (uint c, uint d) = (uint32(1), 2 + a); (uint e,) = (uint64(1), 2, b); a;b;c;d;e; } } // ---- -// 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 +// Warning: (69-89): Different number of components on the left hand side (2) than on the right hand side (1). +// Warning: (146-175): Different number of components on the left hand side (2) than on the right hand side (3). +// Warning: (17-201): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol index 8e5d81e2..56fc4051 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol @@ -1,4 +1,4 @@ -// This tests a crash that occured because we did not stop for fatal errors. +// This tests a crash that occurred because we did not stop for fatal errors. contract C { struct S { ftring a; @@ -8,4 +8,4 @@ contract C { } } // ---- -// DeclarationError: (113-119): Identifier not found or not unique. +// DeclarationError: (114-120): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/525_reject_interface_constructors.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/525_reject_interface_constructors.sol index d65c639f..ad08eca6 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/525_reject_interface_constructors.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/525_reject_interface_constructors.sol @@ -1,4 +1,4 @@ interface I {} contract C is I(2) {} // ---- -// TypeError: (29-33): Wrong argument count for constructor call: 1 arguments given but expected 0. +// TypeError: (29-33): Wrong argument count for constructor call: 1 arguments given but expected 0. Remove parentheses if you do not want to provide arguments here. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external_v050.sol deleted file mode 100644 index f13a87ec..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external_v050.sol +++ /dev/null @@ -1,4 +0,0 @@ -pragma experimental "v0.5.0"; -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 index 2d425037..b8e1c654 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal.sol @@ -2,3 +2,4 @@ contract C { function () internal { } } // ---- +// TypeError: (17-41): Fallback function must be defined as "external". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal_v050.sol deleted file mode 100644 index 6c8b23c8..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal_v050.sol +++ /dev/null @@ -1,6 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function () internal { } -} -// ---- -// TypeError: (47-71): Fallback function must be defined as "external". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private.sol index 2105c815..6038a99f 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private.sol @@ -2,3 +2,4 @@ contract C { function () private { } } // ---- +// TypeError: (17-40): Fallback function must be defined as "external". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private_v050.sol deleted file mode 100644 index be381909..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private_v050.sol +++ /dev/null @@ -1,6 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function () private { } -} -// ---- -// TypeError: (47-70): Fallback function must be defined as "external". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public.sol index 42585137..d9c1580f 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public.sol @@ -2,3 +2,4 @@ contract C { function () public { } } // ---- +// TypeError: (17-39): Fallback function must be defined as "external". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public_v050.sol deleted file mode 100644 index d0beffda..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public_v050.sol +++ /dev/null @@ -1,6 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function () public { } -} -// ---- -// TypeError: (47-69): Fallback function must be defined as "external". diff --git a/test/libsolidity/syntaxTests/parsing/tuples.sol b/test/libsolidity/syntaxTests/parsing/tuples.sol index 8266c94f..ca2f9d6b 100644 --- a/test/libsolidity/syntaxTests/parsing/tuples.sol +++ b/test/libsolidity/syntaxTests/parsing/tuples.sol @@ -1,16 +1,16 @@ contract C { function f() public { uint a = (1); - (uint b,) = (1,); + (uint b,) = 1; (uint c, uint d) = (1, 2 + a); (uint e,) = (1, 2, b); (a) = 3; } } // ---- -// Warning: (54-70): Different number of components on the left hand side (2) than on the right hand side (1). -// Warning: (107-128): Different number of components on the left hand side (2) than on the right hand side (3). -// Warning: (75-81): Unused local variable. -// Warning: (83-89): Unused local variable. -// Warning: (108-114): Unused local variable. -// Warning: (14-143): Function state mutability can be restricted to pure +// Warning: (54-67): Different number of components on the left hand side (2) than on the right hand side (1). +// Warning: (104-125): Different number of components on the left hand side (2) than on the right hand side (3). +// Warning: (72-78): Unused local variable. +// Warning: (80-86): Unused local variable. +// Warning: (105-111): Unused local variable. +// Warning: (14-140): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/tight_packing_literals.sol b/test/libsolidity/syntaxTests/tight_packing_literals.sol index be8482ff..a136aa77 100644 --- a/test/libsolidity/syntaxTests/tight_packing_literals.sol +++ b/test/libsolidity/syntaxTests/tight_packing_literals.sol @@ -5,4 +5,4 @@ contract C { } // ---- -// 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. +// TypeError: (92-93): Cannot perform packed encoding for a literal. Please convert it to an explicit type first. diff --git a/test/libsolidity/syntaxTests/tight_packing_literals_050.sol b/test/libsolidity/syntaxTests/tight_packing_literals_050.sol deleted file mode 100644 index 4e6210c6..00000000 --- a/test/libsolidity/syntaxTests/tight_packing_literals_050.sol +++ /dev/null @@ -1,9 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function k() pure public returns (bytes) { - return abi.encodePacked(1); - } -} - -// ---- -// TypeError: (122-123): Cannot perform packed encoding for a literal. Please convert it to an explicit type first. diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_function.sol b/test/libsolidity/syntaxTests/types/empty_tuple_function.sol index 05b54442..ff31d440 100644 --- a/test/libsolidity/syntaxTests/types/empty_tuple_function.sol +++ b/test/libsolidity/syntaxTests/types/empty_tuple_function.sol @@ -8,5 +8,5 @@ contract C { } } // ---- -// Warning: (162-165): Tuple component cannot be empty. -// Warning: (181-184): Tuple component cannot be empty. +// TypeError: (162-165): Tuple component cannot be empty. +// TypeError: (181-184): Tuple component cannot be empty. diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_function_050.sol b/test/libsolidity/syntaxTests/types/empty_tuple_function_050.sol deleted file mode 100644 index c4b9e03f..00000000 --- a/test/libsolidity/syntaxTests/types/empty_tuple_function_050.sol +++ /dev/null @@ -1,11 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function f() private pure {} - function a() public pure { - bool x = true; - bool y = true; - (x) ? (f(), y = false) : (f(), y = false); - } -} -// ---- -// TypeError: (168-171): Tuple component cannot be empty. diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol index cba30c1b..3d252f0b 100644 --- a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol +++ b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol @@ -8,6 +8,6 @@ contract C { } } // ---- -// Warning: (146-149): Tuple component cannot be empty. -// Warning: (151-154): Tuple component cannot be empty. +// TypeError: (146-149): Tuple component cannot be empty. +// TypeError: (151-154): Tuple component cannot be empty. // TypeError: (145-155): Type tuple(tuple(),tuple()) is not implicitly convertible to expected type tuple(uint256,uint256). diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_050.sol b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_050.sol deleted file mode 100644 index b0691778..00000000 --- a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_050.sol +++ /dev/null @@ -1,11 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function f() private pure {} - function a() public { - uint x; - uint y; - (x, y) = (f(), f()); - } -} -// ---- -// TypeError: (152-155): Tuple component cannot be empty. diff --git a/test/libsolidity/syntaxTests/types/no_singleton_tuple.sol b/test/libsolidity/syntaxTests/types/no_singleton_tuple.sol new file mode 100644 index 00000000..62a58f83 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/no_singleton_tuple.sol @@ -0,0 +1,8 @@ +contract C { + function f() public pure { + uint a; + (a,) = (uint(1),); + } +} +// ---- +// TypeError: (60-70): Tuple component cannot be empty. diff --git a/test/libsolidity/syntaxTests/types/rational_number_exp_limit.sol b/test/libsolidity/syntaxTests/types/rational_number_exp_limit_fail.sol index 6785f580..058db2e9 100644 --- a/test/libsolidity/syntaxTests/types/rational_number_exp_limit.sol +++ b/test/libsolidity/syntaxTests/types/rational_number_exp_limit_fail.sol @@ -4,9 +4,6 @@ contract c { a = 4 ** 4 ** 2 ** 4 ** 4 ** 4 ** 4; a = -4 ** 4 ** 2 ** 4 ** 4 ** 4 ** 4 ** 4; a = 4 ** (-(2 ** 4 ** 4 ** 4 ** 4 ** 4)); - a = 0 ** 1E1233; // fine - a = 1 ** 1E1233; // fine - a = -1 ** 1E1233; // fine a = 2 ** 1E1233; a = -2 ** 1E1233; a = 2 ** -1E1233; @@ -28,23 +25,23 @@ contract c { // TypeError: (116-153): Operator ** not compatible with types int_const 1797...(301 digits omitted)...7216 and int_const 4 // TypeError: (116-153): Type int_const 1797...(301 digits omitted)...7216 is not implicitly convertible to expected type int256. // TypeError: (167-203): Operator ** not compatible with types int_const 4 and int_const -179...(302 digits omitted)...7216 -// TypeError: (317-328): Operator ** not compatible with types int_const 2 and int_const 1000...(1226 digits omitted)...0000 -// TypeError: (342-354): Operator ** not compatible with types int_const -2 and int_const 1000...(1226 digits omitted)...0000 -// TypeError: (368-380): Operator ** not compatible with types int_const 2 and int_const -100...(1227 digits omitted)...0000 -// TypeError: (394-407): Operator ** not compatible with types int_const -2 and int_const -100...(1227 digits omitted)...0000 -// TypeError: (421-432): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const 2 -// TypeError: (421-432): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. -// TypeError: (446-458): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const 2 -// TypeError: (446-458): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. -// TypeError: (472-484): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const -2 -// TypeError: (472-484): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. -// TypeError: (498-511): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const -2 -// TypeError: (498-511): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. -// TypeError: (525-541): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const 1000...(1226 digits omitted)...0000 -// TypeError: (525-541): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. -// TypeError: (555-572): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const -100...(1227 digits omitted)...0000 -// TypeError: (555-572): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. -// TypeError: (586-603): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const 1000...(1226 digits omitted)...0000 -// TypeError: (586-603): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. -// TypeError: (617-635): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const -100...(1227 digits omitted)...0000 -// TypeError: (617-635): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (217-228): Operator ** not compatible with types int_const 2 and int_const 1000...(1226 digits omitted)...0000 +// TypeError: (242-254): Operator ** not compatible with types int_const -2 and int_const 1000...(1226 digits omitted)...0000 +// TypeError: (268-280): Operator ** not compatible with types int_const 2 and int_const -100...(1227 digits omitted)...0000 +// TypeError: (294-307): Operator ** not compatible with types int_const -2 and int_const -100...(1227 digits omitted)...0000 +// TypeError: (321-332): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const 2 +// TypeError: (321-332): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (346-358): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const 2 +// TypeError: (346-358): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (372-384): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const -2 +// TypeError: (372-384): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (398-411): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const -2 +// TypeError: (398-411): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (425-441): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const 1000...(1226 digits omitted)...0000 +// TypeError: (425-441): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (455-472): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const -100...(1227 digits omitted)...0000 +// TypeError: (455-472): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (486-503): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const 1000...(1226 digits omitted)...0000 +// TypeError: (486-503): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (517-535): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const -100...(1227 digits omitted)...0000 +// TypeError: (517-535): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. diff --git a/test/libsolidity/syntaxTests/types/rational_number_exp_limit_fine.sol b/test/libsolidity/syntaxTests/types/rational_number_exp_limit_fine.sol new file mode 100644 index 00000000..66d02eb9 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/rational_number_exp_limit_fine.sol @@ -0,0 +1,9 @@ +contract c { + function f() public pure { + int a; + a = 0 ** 1E1233; + a = 1 ** 1E1233; + a = -1 ** 1E1233; + a = 0E123456789; + } +} diff --git a/test/libsolidity/syntaxTests/types/var_type_suggest.sol b/test/libsolidity/syntaxTests/types/var_type_suggest.sol new file mode 100644 index 00000000..176fab96 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/var_type_suggest.sol @@ -0,0 +1,23 @@ +contract C { + function h() internal pure returns (uint, uint, uint) { + return (1, 2, 4); + } + function g(uint x) internal pure returns (uint) { + return x; + } + function f() internal pure { + var i = 31415; + var t = "string"; + var g2 = g; + var myblockhash = block.blockhash; + var (a, b) = (2, "troi"); + var (x,, z) = h(); + } +} +// ---- +// SyntaxError: (224-237): Use of the "var" keyword is disallowed. Use explicit declaration `uint16 i = ...´ instead. +// SyntaxError: (247-263): Use of the "var" keyword is disallowed. Use explicit declaration `string memory t = ...´ instead. +// SyntaxError: (273-283): Use of the "var" keyword is disallowed. Use explicit declaration `function (uint256) pure returns (uint256) g2 = ...´ instead. +// SyntaxError: (293-326): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. +// SyntaxError: (336-360): Use of the "var" keyword is disallowed. Use explicit declaration `(uint8 a, string memory b) = ...´ instead. +// SyntaxError: (370-387): Use of the "var" keyword is disallowed. Use explicit declaration `(uint256 x, , uint256 z) = ...´ instead. |