diff --git a/CMakeLists.txt b/CMakeLists.txt index 18949721e..31a36aae2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ include(EthPolicy) eth_policy() # project name and version should be set after cmake_policy CMP0048 -set(PROJECT_VERSION "0.6.12") +set(PROJECT_VERSION "0.7.0") # OSX target needed in order to support std::visit set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14") project(solidity VERSION ${PROJECT_VERSION} LANGUAGES C CXX) diff --git a/Changelog.md b/Changelog.md index 79cbf3e10..467bca127 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,39 @@ +### 0.7.0 (unreleased) + +Breaking changes: + * Type Checker: Disallow virtual for library functions. + * Constructors should not have visibility. + * Deprecated dot syntax for `value` and `gas`. + * Deprecated the identifier `now`. + * Disallow `gwei` as identifier. + * JSON AST: Removes members with ``null`` value from JSON output. + * Parser: NatSpec comments on variables are only allowed for public state variables. + * Type Checker: Disallow shifts by signed types. + * Type Checker: Exponentiation and shifts of literals by non-literals will always use ``uint256`` or ``int256`` as a type. + * Type Checker: Disallow structs and arrays in memory or calldata if they contain nested mappings. + * Type Checker: Disallow assignments to state variables that contain nested mappings. + * Type checker: Disallow events with same name and parameter types in inheritance hierarchy. + * ``using A for B`` only affects the contract it is mentioned in and not all derived contracts + * Inline Assembly: Disallow `.` in user-defined function and variable names. + * Inline Assembly: Slot and offset of storage pointer variable ``x`` are accessed via ``x.slot`` and ``x.offset`` instead of ``x_slot`` and ``x_offset``. + * Remove the finney and szabo denominations. + +Language Features: + * State mutability: Do not issue recommendation for stricter mutability for virtual functions but do issue it for functions that override. + * Yul: Disallow EVM instruction `pc()`. + * Yul: Disallow consecutive and trailing dots in identifiers. Leading dots were already disallowed. + * Inheritance: Allow overrides to have stricter state mutability: ``view`` can override ``nonpayable`` and ``pure`` can override ``view``. + +Compiler Features: + * Variable declarations using the ``var`` keyword are not recognized anymore. + + +Bugfixes: + * NatSpec: Constructors and functions have consistent userdoc output. + * Inheritance: Disallow public state variables overwriting ``pure`` functions. + * State Mutability: Constant public state variables are considered ``pure`` functions. + + ### 0.6.12 (2020-07-22) Language Features: @@ -29,6 +65,7 @@ Build System: ### 0.6.11 (2020-07-07) + Language Features: * General: Add unit denomination ``gwei`` * Yul: Support ``linkersymbol`` builtin in standalone assembly mode to refer to library addresses. diff --git a/README.md b/README.md index c3636ff06..6696feabd 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ found in the [Solidity documentation](https://solidity.readthedocs.io/en/latest/ A "Hello World" program in Solidity is of even less use than in other languages, but still: ```solidity -pragma solidity ^0.6.0; +pragma solidity >=0.6.0 <0.8.0; contract HelloWorld { function helloWorld() external pure returns (string memory) { diff --git a/docs/050-breaking-changes.rst b/docs/050-breaking-changes.rst index 68d917f9f..207a311fe 100644 --- a/docs/050-breaking-changes.rst +++ b/docs/050-breaking-changes.rst @@ -311,7 +311,7 @@ This will no longer compile with Solidity v0.5.0. However, you can define a comp :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >=0.5.0 <0.8.0; interface OldContract { function someOldFunction(uint8 a) external; function anotherOldFunction() external returns (bool); @@ -329,7 +329,7 @@ Given the interface defined above, you can now easily use the already deployed p :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >=0.5.0 <0.8.0; interface OldContract { function someOldFunction(uint8 a) external; diff --git a/docs/070-breaking-changes.rst b/docs/070-breaking-changes.rst new file mode 100644 index 000000000..df06692de --- /dev/null +++ b/docs/070-breaking-changes.rst @@ -0,0 +1,124 @@ +******************************** +Solidity v0.7.0 Breaking Changes +******************************** + +This section highlights the main breaking changes introduced in Solidity +version 0.7.0, along with the reasoning behind the changes and how to update +affected code. +For the full list check +`the release changelog `_. + + +Silent Changes of the Semantics +=============================== + +* Exponentiation and shifts of literals by non-literals (e.g. ``1 << x`` or ``2 ** x``) + will always use either the type ``uint256`` (for non-negative literals) or + ``int256`` (for negative literals) to perform the operation. + Previously, the operation was performed in the type of the shift amount / the + exponent which can be misleading. + + +Changes to the Syntax +===================== + +* In external function and contract creation calls, Ether and gas is now specified using a new syntax: + ``x.f{gas: 10000, value: 2 ether}(arg1, arg2)``. + The old syntax -- ``x.f.gas(10000).value(2 ether)(arg1, arg2)`` -- will cause an error. +* The global variable ``now`` is deprecated, ``block.timestamp`` should be used instead. + The single identifier ``now`` is too generic for a global variable and could give the impression + that it changes during transaction processing, whereas ``block.timestamp`` correctly + reflects the fact that it is just a property of the block. +* NatSpec comments on variables are only allowed for public state variables and not + for local or internal variables. + +* The token ``gwei`` is a keyword now (used to specify, e.g. ``2 gwei`` as a number) + and cannot be used as an identifier. + +* State Mutability: The state mutability of functions can now be restricted during inheritance: + Functions with default state mutability can be overridden by ``pure`` and ``view`` functions + while ``view`` functions can be overridden by ``pure`` functions. + At the same time, public state variables are considered ``view`` and even ``pure`` + if they are constants. + + + +Inline Assembly +--------------- + +* Disallow ``.`` in user-defined function and variable names in inline assembly. + It is still valid if you use Solidity in Yul-only mode. + +* Slot and offset of storage pointer variable ``x`` are accessed via ``x.slot`` + and ``x.offset`` instead of ``x_slot`` and ``x_offset``. + +Removal of Unused or Unsafe Features +==================================== + +Mappings outside Storage +------------------------ + +* If a struct or array contains a mapping, it can only be used in storage. + Previously, mapping members were silently skipped in memory, which + is confusing and error-prone. + +* Assignments to structs or arrays in storage does not work if they contain + mappings. + Previously, mappings were silently skipped during the copy operation, which + is misleading and error-prone. + +Functions and Events +-------------------- + +* Visibility (``public`` / ``external``) is not needed for constructors anymore: + To prevent a contract from being created, it can be marked ``abstract``. + This makes the visibility concept for constructors obsolete. + +* Type Checker: Disallow ``virtual`` for library functions: + Since libraries cannot be inherited from, library functions should not be virtual. + +* Multiple events with the same name and parameter types in the same + inheritance hierarchy are disallowed. + +* ``using A for B`` only affects the contract it is mentioned in. + Previously, the effect was inherited. Now, you have to repeat the ``using`` + statement in all derived contracts that make use of the feature. + +Expressions +----------- + +* Shifts by signed types are disallowed. + Previously, shifts by negative amounts were allowed, but reverted at runtime. + +* The ``finney`` and ``szabo`` denominations are removed. + They are rarely used and do not make the actual amount readily visible. Instead, explicit + values like ``1e20`` or the very common ``gwei`` can be used. + +Declarations +------------ + +* The keyword ``var`` cannot be used anymore. + Previously, this keyword would parse but result in a type error and + a suggestion about which type to use. Now, it results in a parser error. + +Interface Changes +================= + +* JSON AST: Members with value ``null`` are removed from JSON output. +* NatSpec: Constructors and functions have consistent userdoc output. + + +How to update your code +======================= + +This section gives detailed instructions on how to update prior code for every breaking change. + +* Change ``x.f.value(...)()`` to ``x.f{value: ...}()``. Similarly ``(new C).value(...)()`` to + ``new C{value: ...}()`` and ``x.f.gas(...).value(...)()`` to ``x.f{gas: ..., value: ...}()``. +* Change ``now`` to ``block.timestamp``. +* Change types of right operand in shift operators to unsigned types. For example change ``x >> (256 - y)`` to + ``x >> uint(256 - y)``. +* Repeat the ``using A for B`` statements in all derived contracts if needed. +* Remove the ``public`` keyword from every constructor. +* Remove the ``internal`` keyword from every constructor and add ``abstract`` to the contract (if not already present). +* Change ``_slot`` and ``_offset`` suffixes in inline assembly to ``.slot`` and ``.offset``, respectively. diff --git a/docs/Solidity.g4 b/docs/Solidity.g4 index af351731b..f86d95fc4 100644 --- a/docs/Solidity.g4 +++ b/docs/Solidity.g4 @@ -306,7 +306,7 @@ assemblyBlock : '{' assemblyItem* '}' ; assemblyExpression - : assemblyCall | assemblyLiteral ; + : assemblyCall | assemblyLiteral | assemblyIdentifier ; assemblyCall : ( 'return' | 'address' | 'byte' | identifier ) ( '(' assemblyExpression? ( ',' assemblyExpression )* ')' )? ; @@ -318,7 +318,10 @@ assemblyAssignment : assemblyIdentifierList ':=' assemblyExpression ; assemblyIdentifierList - : identifier ( ',' identifier )* ; + : assemblyIdentifier ( ',' assemblyIdentifier )* ; + +assemblyIdentifier + : identifier ( '.' identifier )* ; assemblyStackAssignment : '=:' identifier ; @@ -358,11 +361,12 @@ assemblyType subAssembly : 'assembly' identifier assemblyBlock ; +// 'finney' and 'szabo' are no longer supported as denominations by latest Solidity. numberLiteral - : (DecimalNumber | HexNumber) (NumberUnit | Gwei)?; + : (DecimalNumber | HexNumber) (NumberUnit | Gwei | Finney | Szabo)?; identifier - : (Gwei | 'from' | 'calldata' | 'address' | Identifier) ; + : (Gwei | Finney | Szabo | 'from' | 'calldata' | 'address' | Identifier) ; BooleanLiteral : 'true' | 'false' ; @@ -382,10 +386,12 @@ HexDigits : HexCharacter ( '_'? HexCharacter )* ; NumberUnit - : 'wei' | 'szabo' | 'finney' | 'ether' + : 'wei' | 'ether' | 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'years' ; Gwei: 'gwei' ; +Szabo: 'szabo' ; +Finney: 'finney' ; HexLiteralFragment : 'hex' (('"' HexDigits? '"') | ('\'' HexDigits? '\'')) ; diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst index ccb76b37c..e46d0d650 100644 --- a/docs/abi-spec.rst +++ b/docs/abi-spec.rst @@ -233,7 +233,7 @@ Given the contract: :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.16 <0.7.0; + pragma solidity >=0.4.16 <0.8.0; contract Foo { function bar(bytes3[2] memory) public pure {} @@ -537,11 +537,11 @@ For example, :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >0.6.99 <0.8.0; contract Test { - constructor() public { b = hex"12345678901234567890123456789012"; } + constructor() { b = hex"12345678901234567890123456789012"; } event Event(uint indexed a, bytes32 b); event Event2(uint indexed a, bytes32 b); function foo(uint a) public { emit Event(a, b); } @@ -586,7 +586,7 @@ As an example, the code :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.19 <0.7.0; + pragma solidity >=0.4.19 <0.8.0; pragma experimental ABIEncoderV2; contract Test { diff --git a/docs/assembly.rst b/docs/assembly.rst index c42e9d70d..b54800d46 100644 --- a/docs/assembly.rst +++ b/docs/assembly.rst @@ -42,7 +42,7 @@ without a compiler change. .. code:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.16 <0.7.0; + pragma solidity >=0.4.16 <0.8.0; library GetCode { function at(address _addr) public view returns (bytes memory o_code) { @@ -68,7 +68,7 @@ efficient code, for example: .. code:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.16 <0.7.0; + pragma solidity >=0.4.16 <0.8.0; library VectorSum { @@ -132,14 +132,15 @@ For local storage variables or state variables, a single Yul identifier is not sufficient, since they do not necessarily occupy a single full storage slot. Therefore, their "address" is composed of a slot and a byte-offset inside that slot. To retrieve the slot pointed to by the variable ``x``, you -use ``x_slot``, and to retrieve the byte-offset you use ``x_offset``. +use ``x.slot``, and to retrieve the byte-offset you use ``x.offset``. +Using ``x`` itself will result in an error. Local Solidity variables are available for assignments, for example: .. code:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.16 <0.7.0; + pragma solidity >0.6.99 <0.8.0; contract C { uint b; @@ -147,7 +148,7 @@ Local Solidity variables are available for assignments, for example: assembly { // We ignore the storage slot offset, we know it is zero // in this special case. - r := mul(x, sload(b_slot)) + r := mul(x, sload(b.slot)) } } } @@ -164,20 +165,21 @@ Local Solidity variables are available for assignments, for example: ``assembly { signextend(, x) }`` -Since Solidity 0.6.0 the name of a inline assembly variable may not end in ``_offset`` or ``_slot`` -and it may not shadow any declaration visible in the scope of the inline assembly block -(including variable, contract and function declarations). Similarly, if the name of a declared -variable contains a dot ``.``, the prefix up to the ``.`` may not conflict with any -declaration visible in the scope of the inline assembly block. +Since Solidity 0.6.0 the name of a inline assembly variable may not +shadow any declaration visible in the scope of the inline assembly block +(including variable, contract and function declarations). +Since Solidity 0.7.0, variables and functions declared inside the +inline assembly block may not contain ``.``, but using ``.`` is +valid to access Solidity variables from outside the inline assembly block. Assignments are possible to assembly-local variables and to function-local variables. Take care that when you assign to variables that point to memory or storage, you will only change the pointer and not the data. -You can assign to the ``_slot`` part of a local storage variable pointer. -For these (structs, arrays or mappings), the ``_offset`` part is always zero. -It is not possible to assign to the ``_slot`` or ``_offset`` part of a state variable, +You can assign to the ``.slot`` part of a local storage variable pointer. +For these (structs, arrays or mappings), the ``.offset`` part is always zero. +It is not possible to assign to the ``.slot`` or ``.offset`` part of a state variable, though. diff --git a/docs/cheatsheet.rst b/docs/cheatsheet.rst index 5e673f7b0..29b338e93 100644 --- a/docs/cheatsheet.rst +++ b/docs/cheatsheet.rst @@ -67,7 +67,7 @@ The following is the order of precedence for operators, listed in order of evalu | *15* | Comma operator | ``,`` | +------------+-------------------------------------+--------------------------------------------+ -.. index:: assert, block, coinbase, difficulty, number, block;number, timestamp, block;timestamp, msg, data, gas, sender, value, now, gas price, origin, revert, require, keccak256, ripemd160, sha256, ecrecover, addmod, mulmod, cryptography, this, super, selfdestruct, balance, send +.. index:: assert, block, coinbase, difficulty, number, block;number, timestamp, block;timestamp, msg, data, gas, sender, value, gas price, origin, revert, require, keccak256, ripemd160, sha256, ecrecover, addmod, mulmod, cryptography, this, super, selfdestruct, balance, send Global Variables ================ @@ -91,7 +91,6 @@ Global Variables - ``msg.data`` (``bytes``): complete calldata - ``msg.sender`` (``address payable``): sender of the message (current call) - ``msg.value`` (``uint``): number of wei sent with the message -- ``now`` (``uint``): current block timestamp (alias for ``block.timestamp``) - ``tx.gasprice`` (``uint``): gas price of the transaction - ``tx.origin`` (``address payable``): sender of the transaction (full call chain) - ``assert(bool condition)``: abort execution and revert state changes if condition is ``false`` (use for internal error) @@ -126,7 +125,7 @@ Global Variables - ``type(T).max`` (``T``): the maximum value representable by the integer type ``T``, see :ref:`Type Information`. .. note:: - Do not rely on ``block.timestamp``, ``now`` and ``blockhash`` as a source of randomness, + Do not rely on ``block.timestamp`` or ``blockhash`` as a source of randomness, unless you know what you are doing. Both the timestamp and the block hash can be influenced by miners to some degree. @@ -146,6 +145,8 @@ Global Variables In version 0.5.0, the following aliases were removed: ``suicide`` as alias for ``selfdestruct``, ``msg.gas`` as alias for ``gasleft``, ``block.blockhash`` as alias for ``blockhash`` and ``sha3`` as alias for ``keccak256``. +.. note:: + In version 0.7.0, the alias ``now`` (for ``block.timestamp``) was removed. .. index:: visibility, public, private, external, internal diff --git a/docs/common-patterns.rst b/docs/common-patterns.rst index ad33c52fc..5dcc33ed6 100644 --- a/docs/common-patterns.rst +++ b/docs/common-patterns.rst @@ -28,7 +28,7 @@ you receive the funds of the person who is now the richest. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >0.6.99 <0.8.0; contract WithdrawalContract { address public richest; @@ -36,7 +36,7 @@ you receive the funds of the person who is now the richest. mapping (address => uint) pendingWithdrawals; - constructor() public payable { + constructor() payable { richest = msg.sender; mostSent = msg.value; } @@ -62,13 +62,13 @@ This is as opposed to the more intuitive sending pattern: :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >0.6.99 <0.8.0; contract SendContract { address payable public richest; uint public mostSent; - constructor() public payable { + constructor() payable { richest = msg.sender; mostSent = msg.value; } @@ -124,14 +124,14 @@ restrictions highly readable. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.22 <0.7.0; + pragma solidity >=0.4.22 <0.8.0; contract AccessRestriction { // These will be assigned at the construction // phase, where `msg.sender` is the account // creating this contract. address public owner = msg.sender; - uint public creationTime = now; + uint public creationTime = block.timestamp; // Modifiers can be used to change // the body of a function. @@ -162,7 +162,7 @@ restrictions highly readable. modifier onlyAfter(uint _time) { require( - now >= _time, + block.timestamp >= _time, "Function called too early." ); _; @@ -277,7 +277,7 @@ function finishes. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.22 <0.7.0; + pragma solidity >=0.4.22 <0.8.0; contract StateMachine { enum Stages { @@ -291,7 +291,7 @@ function finishes. // This is the current stage. Stages public stage = Stages.AcceptingBlindedBids; - uint public creationTime = now; + uint public creationTime = block.timestamp; modifier atStage(Stages _stage) { require( @@ -310,10 +310,10 @@ function finishes. // will not take the new stage into account. modifier timedTransitions() { if (stage == Stages.AcceptingBlindedBids && - now >= creationTime + 10 days) + block.timestamp >= creationTime + 10 days) nextStage(); if (stage == Stages.RevealBids && - now >= creationTime + 12 days) + block.timestamp >= creationTime + 12 days) nextStage(); // The other stages transition by transaction _; diff --git a/docs/contracts/abstract-contracts.rst b/docs/contracts/abstract-contracts.rst index 908fa5072..fe31c0b32 100644 --- a/docs/contracts/abstract-contracts.rst +++ b/docs/contracts/abstract-contracts.rst @@ -14,7 +14,7 @@ defined as abstract, because the function ``utterance()`` was defined, but no im provided (no implementation body ``{ }`` was given).:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.0 <0.7.0; + pragma solidity >=0.6.0 <0.8.0; abstract contract Feline { function utterance() public virtual returns (bytes32); @@ -24,14 +24,14 @@ Such abstract contracts can not be instantiated directly. This is also true, if all defined functions. The usage of an abstract contract as a base class is shown in the following example:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity ^0.6.0; + pragma solidity >=0.6.0 <0.8.0; abstract contract Feline { - function utterance() public virtual returns (bytes32); + function utterance() public pure virtual returns (bytes32); } contract Cat is Feline { - function utterance() public override returns (bytes32) { return "miaow"; } + function utterance() public pure override returns (bytes32) { return "miaow"; } } If a contract inherits from an abstract contract and does not implement all non-implemented diff --git a/docs/contracts/constant-state-variables.rst b/docs/contracts/constant-state-variables.rst index 7424cd66a..c5c520d33 100644 --- a/docs/contracts/constant-state-variables.rst +++ b/docs/contracts/constant-state-variables.rst @@ -18,7 +18,7 @@ Not all types for constants and immutables are implemented at this time. The onl :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >0.6.4 <0.7.0; + pragma solidity >0.6.99 <0.8.0; contract C { uint constant X = 32**22 + 8; @@ -28,7 +28,7 @@ Not all types for constants and immutables are implemented at this time. The onl uint immutable maxBalance; address immutable owner = msg.sender; - constructor(uint _decimals, address _reference) public { + constructor(uint _decimals, address _reference) { decimals = _decimals; // Assignments to immutables can even access the environment. maxBalance = _reference.balance; @@ -45,7 +45,7 @@ Constant For ``constant`` variables, the value has to be a constant at compile time and it has to be assigned where the variable is declared. Any expression -that accesses storage, blockchain data (e.g. ``now``, ``address(this).balance`` or +that accesses storage, blockchain data (e.g. ``block.timestamp``, ``address(this).balance`` or ``block.number``) or execution data (``msg.value`` or ``gasleft()``) or makes calls to external contracts is disallowed. Expressions that might have a side-effect on memory allocation are allowed, but those that diff --git a/docs/contracts/creating-contracts.rst b/docs/contracts/creating-contracts.rst index a2a628237..2679d05a5 100644 --- a/docs/contracts/creating-contracts.rst +++ b/docs/contracts/creating-contracts.rst @@ -35,7 +35,7 @@ This means that cyclic creation dependencies are impossible. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.22 <0.7.0; + pragma solidity >=0.4.22 <0.8.0; contract OwnedToken { @@ -48,7 +48,7 @@ This means that cyclic creation dependencies are impossible. // This is the constructor which registers the // creator and the assigned name. - constructor(bytes32 _name) public { + constructor(bytes32 _name) { // State variables are accessed via their name // and not via e.g. `this.owner`. Functions can // be accessed directly or through `this.f`, diff --git a/docs/contracts/events.rst b/docs/contracts/events.rst index e4e74bde4..3183d3c3f 100644 --- a/docs/contracts/events.rst +++ b/docs/contracts/events.rst @@ -66,7 +66,7 @@ is that they are cheaper to deploy and call. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.21 <0.7.0; + pragma solidity >=0.4.21 <0.8.0; contract ClientReceipt { event Deposit( @@ -140,7 +140,7 @@ as topics. The event call above can be performed in the same way as :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.10 <0.7.0; + pragma solidity >=0.4.10 <0.8.0; contract C { function f() public payable { diff --git a/docs/contracts/function-modifiers.rst b/docs/contracts/function-modifiers.rst index b64143d90..823e6e6ac 100644 --- a/docs/contracts/function-modifiers.rst +++ b/docs/contracts/function-modifiers.rst @@ -18,10 +18,10 @@ if they are marked ``virtual``. For details, please see :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >0.6.99 <0.8.0; contract owned { - constructor() public { owner = msg.sender; } + constructor() { owner = msg.sender; } address payable owner; // This contract only defines a modifier but does not use @@ -63,7 +63,7 @@ if they are marked ``virtual``. For details, please see mapping (address => bool) registeredAddresses; uint price; - constructor(uint initialPrice) public { price = initialPrice; } + constructor(uint initialPrice) { price = initialPrice; } // It is important to also provide the // `payable` keyword here, otherwise the function will diff --git a/docs/contracts/functions.rst b/docs/contracts/functions.rst index acdfc0185..41174c958 100644 --- a/docs/contracts/functions.rst +++ b/docs/contracts/functions.rst @@ -24,7 +24,7 @@ For example, if you want your contract to accept one kind of external call with two integers, you would use something like the following:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.16 <0.7.0; + pragma solidity >=0.4.16 <0.8.0; contract Simple { uint sum; @@ -57,7 +57,7 @@ For example, suppose you want to return two results: the sum and the product of two integers passed as function parameters, then you use something like:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.16 <0.7.0; + pragma solidity >=0.4.16 <0.8.0; contract Simple { function arithmetic(uint _a, uint _b) @@ -82,7 +82,7 @@ or you can provide return values statement:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.16 <0.7.0; + pragma solidity >=0.4.16 <0.8.0; contract Simple { function arithmetic(uint _a, uint _b) @@ -146,11 +146,11 @@ The following statements are considered modifying the state: :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >=0.5.0 <0.8.0; contract C { function f(uint a, uint b) public view returns (uint) { - return a * (b + 42) + now; + return a * (b + 42) + block.timestamp; } } @@ -192,7 +192,7 @@ In addition to the list of state modifying statements explained above, the follo :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >=0.5.0 <0.8.0; contract C { function f(uint a, uint b) public pure returns (uint) { @@ -286,7 +286,7 @@ Below you can see an example of a Sink contract that uses function ``receive``. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity ^0.6.0; + pragma solidity >=0.6.0 <0.8.0; // This contract keeps all Ether sent to it with no way // to get it back. @@ -342,7 +342,7 @@ operations as long as there is enough gas passed on to it. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.2 <0.7.0; + pragma solidity >=0.6.2 <0.8.0; contract Test { // This function is called for all messages sent to @@ -415,7 +415,7 @@ The following example shows overloading of the function :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.16 <0.7.0; + pragma solidity >=0.4.16 <0.8.0; contract A { function f(uint _in) public pure returns (uint out) { @@ -434,7 +434,7 @@ externally visible functions differ by their Solidity types but not by their ext :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.16 <0.7.0; + pragma solidity >=0.4.16 <0.8.0; // This will not compile contract A { @@ -468,7 +468,7 @@ candidate, resolution fails. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.16 <0.7.0; + pragma solidity >=0.4.16 <0.8.0; contract A { function f(uint8 _in) public pure returns (uint8 out) { diff --git a/docs/contracts/inheritance.rst b/docs/contracts/inheritance.rst index 07bb74636..f628d49fb 100644 --- a/docs/contracts/inheritance.rst +++ b/docs/contracts/inheritance.rst @@ -39,11 +39,11 @@ Details are given in the following example. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity ^0.6.0; + pragma solidity >0.6.99 <0.8.0; contract Owned { - constructor() public { owner = msg.sender; } + constructor() { owner = msg.sender; } address payable owner; } @@ -80,7 +80,7 @@ Details are given in the following example. // also a base class of `Destructible`, yet there is only a single // instance of `owned` (as for virtual inheritance in C++). contract Named is Owned, Destructible { - constructor(bytes32 name) public { + constructor(bytes32 name) { Config config = Config(0xD5f9D8D94886E70b06E474c3fB14Fd43E2f23970); NameReg(config.lookup(1)).register(name); } @@ -106,8 +106,8 @@ Details are given in the following example. // If a constructor takes an argument, it needs to be - // provided in the header (or modifier-invocation-style at - // the constructor of the derived contract (see below)). + // provided in the header or modifier-invocation-style at + // the constructor of the derived contract (see below). contract PriceFeed is Owned, Destructible, Named("GoldFeed") { function updateInfo(uint newInfo) public { if (msg.sender == owner) info = newInfo; @@ -127,10 +127,10 @@ destruction request. The way this is done is problematic, as seen in the following example:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity ^0.6.0; + pragma solidity >0.6.99 <0.8.0; contract owned { - constructor() public { owner = msg.sender; } + constructor() { owner = msg.sender; } address payable owner; } @@ -157,10 +157,10 @@ explicitly in the final override, but this function will bypass ``Base1.destroy``. The way around this is to use ``super``:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.0 <0.7.0; + pragma solidity >0.6.99 <0.8.0; contract owned { - constructor() public { owner = msg.sender; } + constructor() { owner = msg.sender; } address payable owner; } @@ -203,23 +203,29 @@ Function Overriding Base functions can be overridden by inheriting contracts to change their behavior if they are marked as ``virtual``. The overriding function must then -use the ``override`` keyword in the function header as shown in this example: +use the ``override`` keyword in the function header. +The overriding function may only change the visibility of the overridden function from ``external`` to ``public``. +The mutability may be changed to a more strict one following the order: +``nonpayable`` can be overridden by ``view`` and ``pure``. ``view`` can be overridden by ``pure``. +``payable`` is an exception and cannot be changed to any other mutability. + +The following example demonstrates changing mutability and visibility: :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.0 <0.7.0; + pragma solidity >0.6.99 <0.8.0; contract Base { - function foo() virtual public {} + function foo() virtual external view {} } contract Middle is Base {} contract Inherited is Middle { - function foo() public override {} + function foo() override public pure {} } For multiple inheritance, the most derived base contracts that define the same @@ -232,7 +238,7 @@ bases, it has to explicitly override it: :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.0 <0.7.0; + pragma solidity >=0.6.0 <0.8.0; contract Base1 { @@ -259,7 +265,7 @@ that already overrides all other functions. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.0 <0.7.0; + pragma solidity >=0.6.0 <0.8.0; contract A { function f() public pure{} } contract B is A {} @@ -300,11 +306,11 @@ of the variable: :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.0 <0.7.0; + pragma solidity >=0.6.0 <0.8.0; contract A { - function f() external pure virtual returns(uint) { return 5; } + function f() external view virtual returns(uint) { return 5; } } contract B is A @@ -332,7 +338,7 @@ and the ``override`` keyword must be used in the overriding modifier: :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.0 <0.7.0; + pragma solidity >=0.6.0 <0.8.0; contract Base { @@ -351,7 +357,7 @@ explicitly: :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.0 <0.7.0; + pragma solidity >=0.6.0 <0.8.0; contract Base1 { @@ -392,33 +398,39 @@ and all functions that are reachable from there through function calls. It does not include the constructor code or internal functions that are only called from the constructor. -Constructor functions can be either ``public`` or ``internal``. If there is no +If there is no constructor, the contract will assume the default constructor, which is -equivalent to ``constructor() public {}``. For example: +equivalent to ``constructor() {}``. For example: :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >0.6.99 <0.8.0; - contract A { + abstract contract A { uint public a; - constructor(uint _a) internal { + constructor(uint _a) { a = _a; } } contract B is A(1) { - constructor() public {} + constructor() {} } -A constructor set as ``internal`` causes the contract to be marked as :ref:`abstract `. +You can use internal parameters in a constructor (for example storage pointers). In this case, +the contract has to be marked :ref:`abstract `, because these parameters +cannot be assigned valid values from outside but only through the constructors of derived contracts. .. warning :: Prior to version 0.4.22, constructors were defined as functions with the same name as the contract. This syntax was deprecated and is not allowed anymore in version 0.5.0. +.. warning :: + Prior to version 0.7.0, you had to specify the visibility of constructors as either + ``internal`` or ``public``. + .. index:: ! base;constructor @@ -430,21 +442,21 @@ linearization rules explained below. If the base constructors have arguments, derived contracts need to specify all of them. This can be done in two ways:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.22 <0.7.0; + pragma solidity >0.6.99 <0.8.0; contract Base { uint x; - constructor(uint _x) public { x = _x; } + constructor(uint _x) { x = _x; } } // Either directly specify in the inheritance list... contract Derived1 is Base(7) { - constructor() public {} + constructor() {} } // or through a "modifier" of the derived constructor. contract Derived2 is Base { - constructor(uint _y) Base(_y * _y) public {} + constructor(uint _y) Base(_y * _y) {} } One way is directly in the inheritance list (``is Base(7)``). The other is in @@ -490,7 +502,7 @@ error "Linearization of inheritance graph impossible". :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.7.0; + pragma solidity >=0.4.0 <0.8.0; contract X {} contract A is X {} @@ -511,14 +523,14 @@ One area where inheritance linearization is especially important and perhaps not :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.22 <0.7.0; + pragma solidity >0.6.99 <0.8.0; contract Base1 { - constructor() public {} + constructor() {} } contract Base2 { - constructor() public {} + constructor() {} } // Constructors are executed in the following order: @@ -526,7 +538,7 @@ One area where inheritance linearization is especially important and perhaps not // 2 - Base2 // 3 - Derived1 contract Derived1 is Base1, Base2 { - constructor() public Base1() Base2() {} + constructor() Base1() Base2() {} } // Constructors are executed in the following order: @@ -534,7 +546,7 @@ One area where inheritance linearization is especially important and perhaps not // 2 - Base1 // 3 - Derived2 contract Derived2 is Base2, Base1 { - constructor() public Base2() Base1() {} + constructor() Base2() Base1() {} } // Constructors are still executed in the following order: @@ -542,7 +554,7 @@ One area where inheritance linearization is especially important and perhaps not // 2 - Base1 // 3 - Derived3 contract Derived3 is Base2, Base1 { - constructor() public Base1() Base2() {} + constructor() Base1() Base2() {} } diff --git a/docs/contracts/interfaces.rst b/docs/contracts/interfaces.rst index 7b1421791..4ed25584e 100644 --- a/docs/contracts/interfaces.rst +++ b/docs/contracts/interfaces.rst @@ -23,7 +23,7 @@ Interfaces are denoted by their own keyword: :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.2 <0.7.0; + pragma solidity >=0.6.2 <0.8.0; interface Token { enum TokenType { Fungible, NonFungible } @@ -44,7 +44,7 @@ inheritance. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.2 <0.7.0; + pragma solidity >=0.6.2 <0.8.0; interface ParentA { function test() external returns (uint256); diff --git a/docs/contracts/libraries.rst b/docs/contracts/libraries.rst index f58bf0f4e..e28a16da2 100644 --- a/docs/contracts/libraries.rst +++ b/docs/contracts/libraries.rst @@ -30,9 +30,8 @@ not possible to destroy a library. Libraries can be seen as implicit base contracts of the contracts that use them. They will not be explicitly visible in the inheritance hierarchy, but calls to library functions look just like calls to functions of explicit base -contracts (``L.f()`` if ``L`` is the name of the library). Furthermore, -``internal`` functions of libraries are visible in all contracts, just as -if the library were a base contract. Of course, calls to internal functions +contracts (using qualified access like ``L.f()``). +Of course, calls to internal functions use the internal calling convention, which means that all internal types can be passed and types :ref:`stored in memory ` will be passed by reference and not copied. To realize this in the EVM, code of internal library functions @@ -48,7 +47,7 @@ more advanced example to implement a set). :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.0 <0.7.0; + pragma solidity >=0.6.0 <0.8.0; // We define a new struct datatype that will be used to @@ -127,7 +126,7 @@ custom types without the overhead of external function calls: :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.0 <0.7.0; + pragma solidity >=0.6.0 <0.8.0; struct bigint { uint[] limbs; @@ -242,7 +241,7 @@ Its value can be obtained from Solidity using the ``.selector`` member as follow :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.14 <0.7.0; + pragma solidity >=0.5.14 <0.8.0; library L { function f(uint256) external {} diff --git a/docs/contracts/using-for.rst b/docs/contracts/using-for.rst index 8853bad24..dc4827e67 100644 --- a/docs/contracts/using-for.rst +++ b/docs/contracts/using-for.rst @@ -30,7 +30,7 @@ Let us rewrite the set example from the :ref:`libraries` in this way:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.0 <0.7.0; + pragma solidity >=0.6.0 <0.8.0; // This is the same code as before, just without comments @@ -83,7 +83,7 @@ Let us rewrite the set example from the It is also possible to extend elementary types in that way:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.16 <0.7.0; + pragma solidity >=0.4.16 <0.8.0; library Search { function indexOf(uint[] storage self, uint value) diff --git a/docs/contracts/visibility-and-getters.rst b/docs/contracts/visibility-and-getters.rst index 7e7785f3a..feecbc457 100644 --- a/docs/contracts/visibility-and-getters.rst +++ b/docs/contracts/visibility-and-getters.rst @@ -55,7 +55,7 @@ return parameter list for functions. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.16 <0.7.0; + pragma solidity >=0.4.16 <0.8.0; contract C { function f(uint a) private pure returns (uint b) { return a + 1; } @@ -70,7 +70,7 @@ In the following example, ``D``, can call ``c.getData()`` to retrieve the value :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.16 <0.7.0; + pragma solidity >=0.4.16 <0.8.0; contract C { uint private data; @@ -115,7 +115,7 @@ when they are declared. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.16 <0.7.0; + pragma solidity >=0.4.16 <0.8.0; contract C { uint public data = 42; @@ -136,7 +136,7 @@ it evaluates to a state variable. If it is accessed externally :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.7.0; + pragma solidity >=0.4.0 <0.8.0; contract C { uint public data; @@ -156,7 +156,7 @@ to write a function, for example: :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.16 <0.7.0; + pragma solidity >=0.4.16 <0.8.0; contract arrayExample { // public state variable @@ -183,7 +183,7 @@ The next example is more complex: :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.7.0; + pragma solidity >=0.4.0 <0.8.0; contract Complex { struct Data { diff --git a/docs/contributing.rst b/docs/contributing.rst index 395439018..5c9f90cbd 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -443,7 +443,7 @@ or ``interface`` using the ``./test/cmdlineTests.sh`` script when you create a P ensure they work and pass tests before creating the PR. Ensure that all code examples begin with a ``pragma`` version that spans the largest where the contract code is valid. -For example ``pragma solidity >=0.4.0 <0.7.0;``. +For example ``pragma solidity >=0.4.0 <0.8.0;``. Running Documentation Tests --------------------------- diff --git a/docs/control-structures.rst b/docs/control-structures.rst index 811e612c0..3b4bc4448 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -42,7 +42,7 @@ Functions of the current contract can be called directly ("internally"), also re this nonsensical example:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.22 <0.7.0; + pragma solidity >=0.4.22 <0.8.0; contract C { function g(uint a) public pure returns (uint ret) { return a + f(); } @@ -84,7 +84,7 @@ to the total balance of that contract: :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.2 <0.7.0; + pragma solidity >=0.6.2 <0.8.0; contract InfoFeed { function info() public payable returns (uint ret) { return 42; } @@ -125,9 +125,9 @@ throws an exception or goes out of gas. so your contract is not vulnerable to a reentrancy exploit. .. note:: - Before Solidity 0.6.2, the recommended way to specify the value and gas - was to use ``f.value(x).gas(g)()``. This is still possible but deprecated - and will be removed with Solidity 0.7.0. + Before Solidity 0.6.2, the recommended way to specify the value and gas was to + use ``f.value(x).gas(g)()``. This was deprecated in Solidity 0.6.2 and is no + longer possible since Solidity 0.7.0. Named Calls and Anonymous Function Parameters --------------------------------------------- @@ -140,7 +140,7 @@ parameters from the function declaration, but can be in arbitrary order. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.7.0; + pragma solidity >=0.4.0 <0.8.0; contract C { mapping(uint => uint) data; @@ -164,7 +164,7 @@ Those parameters will still be present on the stack, but they are inaccessible. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.22 <0.7.0; + pragma solidity >=0.4.22 <0.8.0; contract C { // omitted name for parameter @@ -188,11 +188,11 @@ is compiled so recursive creation-dependencies are not possible. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.2 <0.7.0; + pragma solidity >0.6.99 <0.8.0; contract D { uint public x; - constructor(uint a) public payable { + constructor(uint a) payable { x = a; } } @@ -244,11 +244,11 @@ which only need to be created if there is a dispute. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.2 <0.7.0; + pragma solidity >0.6.99 <0.8.0; contract D { uint public x; - constructor(uint a) public { + constructor(uint a) { x = a; } } @@ -314,7 +314,7 @@ groupings of expressions. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >=0.5.0 <0.8.0; contract C { uint index; @@ -360,7 +360,7 @@ because only a reference and not a copy is passed. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.22 <0.7.0; + pragma solidity >=0.4.22 <0.8.0; contract C { uint[20] x; @@ -419,7 +419,7 @@ the two variables have the same name but disjoint scopes. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >=0.5.0 <0.8.0; contract C { function minimalScoping() pure public { { @@ -441,7 +441,7 @@ In any case, you will get a warning about the outer variable being shadowed. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >=0.5.0 <0.8.0; // This will report a warning contract C { function f() pure public returns (uint) { @@ -463,7 +463,7 @@ In any case, you will get a warning about the outer variable being shadowed. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >=0.5.0 <0.8.0; // This will not compile contract C { function f() pure public returns (uint) { @@ -552,7 +552,7 @@ and ``assert`` for internal error checking. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >=0.5.0 <0.8.0; contract Sharer { function sendHalf(address payable addr) public payable returns (uint balance) { @@ -597,7 +597,7 @@ The following example shows how to use an error string together with ``revert`` :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >=0.5.0 <0.8.0; contract VendingMachine { function buy(uint amount) public payable { @@ -641,7 +641,7 @@ A failure in an external call can be caught using a try/catch statement, as foll :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity ^0.6.0; + pragma solidity >=0.6.0 <0.8.0; interface DataFeed { function getData(address token) external returns (uint value); } @@ -730,4 +730,4 @@ in scope in the block that follows. out-of-gas situation and not a deliberate error condition: The caller always retains 63/64th of the gas in a call and thus even if the called contract goes out of gas, the caller still - has some gas left. \ No newline at end of file + has some gas left. diff --git a/docs/examples/blind-auction.rst b/docs/examples/blind-auction.rst index 30c177baa..3034b6915 100644 --- a/docs/examples/blind-auction.rst +++ b/docs/examples/blind-auction.rst @@ -25,7 +25,7 @@ to receive their money - contracts cannot activate themselves. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >0.6.99 <0.8.0; contract SimpleAuction { // Parameters of the auction. Times are either @@ -60,9 +60,9 @@ to receive their money - contracts cannot activate themselves. constructor( uint _biddingTime, address payable _beneficiary - ) public { + ) { beneficiary = _beneficiary; - auctionEndTime = now + _biddingTime; + auctionEndTime = block.timestamp + _biddingTime; } /// Bid on the auction with the value sent @@ -79,7 +79,7 @@ to receive their money - contracts cannot activate themselves. // Revert the call if the bidding // period is over. require( - now <= auctionEndTime, + block.timestamp <= auctionEndTime, "Auction already ended." ); @@ -141,7 +141,7 @@ to receive their money - contracts cannot activate themselves. // external contracts. // 1. Conditions - require(now >= auctionEndTime, "Auction not yet ended."); + require(block.timestamp >= auctionEndTime, "Auction not yet ended."); require(!ended, "auctionEnd has already been called."); // 2. Effects @@ -186,7 +186,7 @@ invalid bids. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >0.6.99 <0.8.0; contract BlindAuction { struct Bid { @@ -213,16 +213,16 @@ invalid bids. /// functions. `onlyBefore` is applied to `bid` below: /// The new function body is the modifier's body where /// `_` is replaced by the old function body. - modifier onlyBefore(uint _time) { require(now < _time); _; } - modifier onlyAfter(uint _time) { require(now > _time); _; } + modifier onlyBefore(uint _time) { require(block.timestamp < _time); _; } + modifier onlyAfter(uint _time) { require(block.timestamp > _time); _; } constructor( uint _biddingTime, uint _revealTime, address payable _beneficiary - ) public { + ) { beneficiary = _beneficiary; - biddingEnd = now + _biddingTime; + biddingEnd = block.timestamp + _biddingTime; revealEnd = biddingEnd + _revealTime; } @@ -328,4 +328,4 @@ invalid bids. highestBidder = bidder; return true; } - } \ No newline at end of file + } diff --git a/docs/examples/micropayment.rst b/docs/examples/micropayment.rst index 93dcd26f0..b68de3cad 100644 --- a/docs/examples/micropayment.rst +++ b/docs/examples/micropayment.rst @@ -143,14 +143,14 @@ The full contract :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.24 <0.7.0; + pragma solidity >0.6.99 <0.8.0; contract ReceiverPays { address owner = msg.sender; mapping(uint256 => bool) usedNonces; - constructor() public payable {} + constructor() payable {} function claimPayment(uint256 amount, uint256 nonce, bytes memory signature) public { require(!usedNonces[nonce]); @@ -340,7 +340,7 @@ The full contract :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >0.6.99 <0.8.0; contract SimplePaymentChannel { address payable public sender; // The account sending payments. @@ -348,12 +348,11 @@ The full contract uint256 public expiration; // Timeout in case the recipient never closes. constructor (address payable _recipient, uint256 duration) - public payable { sender = msg.sender; recipient = _recipient; - expiration = now + duration; + expiration = block.timestamp + duration; } /// the recipient can close the channel at any time by presenting a @@ -378,7 +377,7 @@ The full contract /// if the timeout is reached without the recipient closing the channel, /// then the Ether is released back to the sender. function claimTimeout() public { - require(now >= expiration); + require(block.timestamp >= expiration); selfdestruct(sender); } diff --git a/docs/examples/modular.rst b/docs/examples/modular.rst index ff6a64077..78986ece5 100644 --- a/docs/examples/modular.rst +++ b/docs/examples/modular.rst @@ -20,7 +20,7 @@ and the sum of all balances is an invariant across the lifetime of the contract. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >=0.5.0 <0.8.0; library Balances { function move(mapping(address => uint256) storage balances, address from, address to, uint amount) internal { diff --git a/docs/examples/safe-remote.rst b/docs/examples/safe-remote.rst index c8e0eecc1..bae6a3a50 100644 --- a/docs/examples/safe-remote.rst +++ b/docs/examples/safe-remote.rst @@ -26,7 +26,7 @@ you can use state machine-like constructs inside a contract. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >0.6.99 <0.8.0; contract Purchase { uint public value; @@ -74,7 +74,7 @@ you can use state machine-like constructs inside a contract. // Ensure that `msg.value` is an even number. // Division will truncate if it is an odd number. // Check via multiplication that it wasn't an odd number. - constructor() public payable { + constructor() payable { seller = msg.sender; value = msg.value / 2; require((2 * value) == msg.value, "Value has to be even."); diff --git a/docs/examples/voting.rst b/docs/examples/voting.rst index 8d97a57ee..56a880edf 100644 --- a/docs/examples/voting.rst +++ b/docs/examples/voting.rst @@ -33,7 +33,7 @@ of votes. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.22 <0.7.0; + pragma solidity >0.6.99 <0.8.0; /// @title Voting with delegation. contract Ballot { @@ -63,7 +63,7 @@ of votes. Proposal[] public proposals; /// Create a new ballot to choose one of `proposalNames`. - constructor(bytes32[] memory proposalNames) public { + constructor(bytes32[] memory proposalNames) { chairperson = msg.sender; voters[chairperson].weight = 1; diff --git a/docs/index.rst b/docs/index.rst index d616d6e88..b81140fe1 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -127,6 +127,7 @@ Contents 050-breaking-changes.rst 060-breaking-changes.rst + 070-breaking-changes.rst natspec-format.rst security-considerations.rst resources.rst diff --git a/docs/internals/layout_in_storage.rst b/docs/internals/layout_in_storage.rst index 5e102a38a..d43858f55 100644 --- a/docs/internals/layout_in_storage.rst +++ b/docs/internals/layout_in_storage.rst @@ -72,7 +72,7 @@ the position of ``data[4][9].b`` is at ``keccak256(uint256(9) . keccak256(uint25 // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.7.0; + pragma solidity >=0.4.0 <0.8.0; contract C { @@ -173,7 +173,7 @@ value and reference types, types that are encoded packed, and nested types. .. code:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.7.0; + pragma solidity >=0.4.0 <0.8.0; contract A { struct S { uint128 a; diff --git a/docs/introduction-to-smart-contracts.rst b/docs/introduction-to-smart-contracts.rst index 6a59f1373..556d486f7 100644 --- a/docs/introduction-to-smart-contracts.rst +++ b/docs/introduction-to-smart-contracts.rst @@ -18,7 +18,7 @@ Storage Example :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.16 <0.7.0; + pragma solidity >=0.4.16 <0.8.0; contract SimpleStorage { uint storedData; @@ -83,7 +83,7 @@ registering with a username and password, all you need is an Ethereum keypair. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >0.5.99 <0.8.0; contract Coin { // The keyword "public" makes variables @@ -97,7 +97,7 @@ registering with a username and password, all you need is an Ethereum keypair. // Constructor code is only run when the contract // is created - constructor() public { + constructor() { minter = msg.sender; } @@ -186,7 +186,7 @@ and any user interface calls the automatically generated ``balances`` function f .. index:: coin -The :ref:`constructor` is a special function run during the creation of the contract and +The :ref:`constructor` is a special function that is executed during the creation of the contract and cannot be called afterwards. In this case, it permanently stores the address of the person creating the contract. The ``msg`` variable (together with ``tx`` and ``block``) is a :ref:`special global variable ` that diff --git a/docs/layout-of-source-files.rst b/docs/layout-of-source-files.rst index f01e23ac5..54cb8c59a 100644 --- a/docs/layout-of-source-files.rst +++ b/docs/layout-of-source-files.rst @@ -317,7 +317,7 @@ for the two function parameters and two return variables. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.21 <0.7.0; + pragma solidity >=0.4.21 <0.8.0; /** @title Shape calculator. */ contract ShapeCalculator { diff --git a/docs/natspec-format.rst b/docs/natspec-format.rst index c566d5407..d4777df31 100644 --- a/docs/natspec-format.rst +++ b/docs/natspec-format.rst @@ -49,7 +49,7 @@ The following example shows a contract and a function using all available tags. .. code:: solidity // SPDX-License-Identifier: GPL-3.0 - pragma solidity >0.6.10 <0.7.0; + pragma solidity >0.6.10 <0.8.0; /// @title A simulator for trees /// @author Larry A. Gardner diff --git a/docs/security-considerations.rst b/docs/security-considerations.rst index f73cb0dbf..a471fdd00 100644 --- a/docs/security-considerations.rst +++ b/docs/security-considerations.rst @@ -59,7 +59,7 @@ complete contract): :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.7.0; + pragma solidity >=0.4.0 <0.8.0; // THIS CONTRACT CONTAINS A BUG - DO NOT USE contract Fund { @@ -83,7 +83,7 @@ as it uses ``call`` which forwards all remaining gas by default: :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.2 <0.7.0; + pragma solidity >=0.6.2 <0.8.0; // THIS CONTRACT CONTAINS A BUG - DO NOT USE contract Fund { @@ -103,7 +103,7 @@ outlined further below: :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.11 <0.7.0; + pragma solidity >=0.4.11 <0.8.0; contract Fund { /// @dev Mapping of ether shares of the contract. @@ -201,13 +201,13 @@ Never use tx.origin for authorization. Let's say you have a wallet contract like :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >0.6.99 <0.8.0; // THIS CONTRACT CONTAINS A BUG - DO NOT USE contract TxUserWallet { address owner; - constructor() public { + constructor() { owner = msg.sender; } @@ -222,7 +222,7 @@ Now someone tricks you into sending Ether to the address of this attack wallet: :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity ^0.6.0; + pragma solidity >0.6.99 <0.8.0; interface TxUserWallet { function transferTo(address payable dest, uint amount) external; @@ -231,7 +231,7 @@ Now someone tricks you into sending Ether to the address of this attack wallet: contract TxAttackWallet { address payable owner; - constructor() public { + constructor() { owner = msg.sender; } @@ -283,7 +283,7 @@ field of a ``struct`` that is the base type of a dynamic storage array. The :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.0 <0.7.0; + pragma solidity >=0.6.0 <0.8.0; contract Map { mapping (uint => uint)[] array; diff --git a/docs/structure-of-a-contract.rst b/docs/structure-of-a-contract.rst index 8e744bef2..016130730 100644 --- a/docs/structure-of-a-contract.rst +++ b/docs/structure-of-a-contract.rst @@ -27,7 +27,7 @@ storage. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.7.0; + pragma solidity >=0.4.0 <0.8.0; contract SimpleStorage { uint storedData; // State variable @@ -48,7 +48,7 @@ Functions are the executable units of code within a contract. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.7.0; + pragma solidity >=0.4.0 <0.8.0; contract SimpleAuction { function bid() public payable { // Function @@ -77,7 +77,7 @@ Like functions, modifiers can be :ref:`overridden `. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.22 <0.7.0; + pragma solidity >=0.4.22 <0.8.0; contract Purchase { address public seller; @@ -105,7 +105,7 @@ Events are convenience interfaces with the EVM logging facilities. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.21 <0.7.0; + pragma solidity >=0.4.21 <0.8.0; contract SimpleAuction { event HighestBidIncreased(address bidder, uint amount); // Event @@ -130,7 +130,7 @@ Structs are custom defined types that can group several variables (see :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.7.0; + pragma solidity >=0.4.0 <0.8.0; contract Ballot { struct Voter { // Struct @@ -152,7 +152,7 @@ Enums can be used to create custom types with a finite set of 'constant values' :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.7.0; + pragma solidity >=0.4.0 <0.8.0; contract Purchase { enum State { Created, Locked, Inactive } // Enum diff --git a/docs/style-guide.rst b/docs/style-guide.rst index 9d51bb224..30ceec3a9 100644 --- a/docs/style-guide.rst +++ b/docs/style-guide.rst @@ -56,7 +56,7 @@ Surround top level declarations in solidity source with two blank lines. Yes:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.7.0; + pragma solidity >=0.4.0 <0.8.0; contract A { // ... @@ -75,7 +75,7 @@ Yes:: No:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.7.0; + pragma solidity >=0.4.0 <0.8.0; contract A { // ... @@ -95,7 +95,7 @@ Blank lines may be omitted between groups of related one-liners (such as stub fu Yes:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity ^0.6.0; + pragma solidity >=0.6.0 <0.8.0; abstract contract A { function spam() public virtual pure; @@ -116,7 +116,7 @@ Yes:: No:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.0 <0.7.0; + pragma solidity >=0.6.0 <0.8.0; abstract contract A { function spam() virtual pure public; @@ -251,7 +251,7 @@ Import statements should always be placed at the top of the file. Yes:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.7.0; + pragma solidity >=0.4.0 <0.8.0; import "./Owned.sol"; @@ -266,7 +266,7 @@ Yes:: No:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.7.0; + pragma solidity >=0.4.0 <0.8.0; contract A { // ... @@ -300,10 +300,10 @@ Within a grouping, place the ``view`` and ``pure`` functions last. Yes:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity ^0.6.0; + pragma solidity >0.6.99 <0.8.0; contract A { - constructor() public { + constructor() { // ... } @@ -337,7 +337,7 @@ Yes:: No:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity ^0.6.0; + pragma solidity >0.6.99 <0.8.0; contract A { @@ -357,7 +357,7 @@ No:: // Public functions // ... - constructor() public { + constructor() { // ... } @@ -445,7 +445,7 @@ should: Yes:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.7.0; + pragma solidity >=0.4.0 <0.8.0; contract Coin { struct Bank { @@ -457,7 +457,7 @@ Yes:: No:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.7.0; + pragma solidity >=0.4.0 <0.8.0; contract Coin { @@ -758,19 +758,19 @@ manner as modifiers if the function declaration is long or hard to read. Yes:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.22 <0.7.0; + pragma solidity >0.6.99 <0.8.0; // Base contracts just to make this compile contract B { - constructor(uint) public { + constructor(uint) { } } contract C { - constructor(uint, uint) public { + constructor(uint, uint) { } } contract D { - constructor(uint) public { + constructor(uint) { } } @@ -781,7 +781,6 @@ Yes:: B(param1) C(param2, param3) D(param4) - public { // do something with param5 x = param5; @@ -791,24 +790,24 @@ Yes:: No:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.22 <0.7.0; + pragma solidity >0.6.99 <0.8.0; // Base contracts just to make this compile contract B { - constructor(uint) public { + constructor(uint) { } } contract C { - constructor(uint, uint) public { + constructor(uint, uint) { } } contract D { - constructor(uint) public { + constructor(uint) { } } @@ -819,8 +818,7 @@ No:: constructor(uint param1, uint param2, uint param3, uint param4, uint param5) B(param1) C(param2, param3) - D(param4) - public { + D(param4) { x = param5; } } @@ -832,8 +830,7 @@ No:: constructor(uint param1, uint param2, uint param3, uint param4, uint param5) B(param1) C(param2, param3) - D(param4) - public { + D(param4) { x = param5; } } @@ -1015,14 +1012,14 @@ As shown in the example below, if the contract name is ``Congress`` and the libr Yes:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.22 <0.7.0; + pragma solidity >0.6.99 <0.8.0; // Owned.sol contract Owned { address public owner; - constructor() public { + constructor() { owner = msg.sender; } @@ -1039,7 +1036,7 @@ Yes:: and in ``Congress.sol``:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.7.0; + pragma solidity >=0.4.0 <0.8.0; import "./Owned.sol"; @@ -1051,14 +1048,14 @@ and in ``Congress.sol``:: No:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.22 <0.7.0; + pragma solidity >0.6.99 <0.8.0; // owned.sol contract owned { address public owner; - constructor() public { + constructor() { owner = msg.sender; } @@ -1096,7 +1093,7 @@ Events should be named using the CapWords style. Examples: ``Deposit``, ``Transf Function Names ============== -Functions other than constructors should use mixedCase. Examples: ``getBalance``, ``transfer``, ``verifyOwner``, ``addMember``, ``changeOwner``. +Functions should use mixedCase. Examples: ``getBalance``, ``transfer``, ``verifyOwner``, ``addMember``, ``changeOwner``. Function Argument Names @@ -1156,7 +1153,7 @@ For example, the contract from `a simple smart contract ` added looks like the one below:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.16 <0.7.0; + pragma solidity >=0.4.16 <0.8.0; /// @author The Solidity Team diff --git a/docs/types/mapping-types.rst b/docs/types/mapping-types.rst index 5226f36a3..ed27d0508 100644 --- a/docs/types/mapping-types.rst +++ b/docs/types/mapping-types.rst @@ -26,6 +26,7 @@ are allowed for state variables, as storage reference types in functions, or as parameters for library functions. They cannot be used as parameters or return parameters of contract functions that are publicly visible. +These restrictions are also true for arrays and structs that contain mappings. You can mark state variables of mapping type as ``public`` and Solidity creates a :ref:`getter ` for you. The ``_KeyType`` becomes a parameter for the getter. @@ -42,7 +43,7 @@ contract that returns the value at the specified address. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.7.0; + pragma solidity >=0.4.0 <0.8.0; contract MappingExample { mapping(address => uint) public balances; @@ -68,7 +69,7 @@ The example below uses ``_allowances`` to record the amount someone else is allo :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.22 <0.7.0; + pragma solidity >=0.4.22 <0.8.0; contract MappingExample { @@ -123,7 +124,7 @@ the ``sum`` function iterates over to sum all the values. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.0 <0.7.0; + pragma solidity >=0.6.0 <0.8.0; struct IndexValue { uint keyIndex; uint value; } struct KeyFlag { uint key; bool deleted; } diff --git a/docs/types/operators.rst b/docs/types/operators.rst index 76726ec6f..bbde72e26 100644 --- a/docs/types/operators.rst +++ b/docs/types/operators.rst @@ -43,7 +43,7 @@ value it referred to previously. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.7.0; + pragma solidity >=0.4.0 <0.8.0; contract DeleteExample { uint data; diff --git a/docs/types/reference-types.rst b/docs/types/reference-types.rst index 17a52f43b..336cf5b2e 100644 --- a/docs/types/reference-types.rst +++ b/docs/types/reference-types.rst @@ -63,7 +63,7 @@ Data locations are not only relevant for persistency of data, but also for the s :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.5.0 <0.7.0; + pragma solidity >=0.5.0 <0.8.0; contract C { // The data location of x is storage. @@ -174,7 +174,7 @@ or create a new memory array and copy every element. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.16 <0.7.0; + pragma solidity >=0.4.16 <0.8.0; contract C { function f(uint len) public pure { @@ -206,7 +206,7 @@ the first element to ``uint``. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.16 <0.7.0; + pragma solidity >=0.4.16 <0.8.0; contract C { function f() public pure { @@ -223,7 +223,7 @@ memory arrays, i.e. the following is not possible: :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.7.0; + pragma solidity >=0.4.0 <0.8.0; // This will not compile. contract C { @@ -243,7 +243,7 @@ individual elements: :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.7.0; + pragma solidity >=0.4.0 <0.8.0; contract C { function f() public pure { @@ -301,7 +301,7 @@ Array Members :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.0 <0.7.0; + pragma solidity >=0.6.0 <0.8.0; contract ArrayContract { uint[2**20] m_aLotOfIntegers; @@ -434,13 +434,13 @@ Array slices are useful to ABI-decode secondary data passed in function paramete :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.0 <0.7.0; + pragma solidity >0.6.99 <0.8.0; contract Proxy { /// @dev Address of the client contract managed by proxy i.e., this contract address client; - constructor(address _client) public { + constructor(address _client) { client = _client; } @@ -478,7 +478,7 @@ shown in the following example: :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.0 <0.7.0; + pragma solidity >=0.6.0 <0.8.0; // Defines a new type with two fields. // Declaring a struct outside of a contract allows @@ -505,12 +505,11 @@ shown in the following example: function newCampaign(address payable beneficiary, uint goal) public returns (uint campaignID) { campaignID = numCampaigns++; // campaignID is return variable - // Creates new struct in memory and copies it to storage. - // We leave out the mapping type, because it is not valid in memory. - // If structs are copied (even from storage to storage), - // types that are not valid outside of storage (ex. mappings and array of mappings) - // are always omitted, because they cannot be enumerated. - campaigns[campaignID] = Campaign(beneficiary, goal, 0, 0); + // We cannot use "campaigns[campaignID] = Campaign(beneficiary, goal, 0, 0)" + // because the RHS creates a memory-struct "Campaign" that contains a mapping. + Campaign storage c = campaigns[campaignID]; + c.beneficiary = beneficiary; + c.fundingGoal = goal; } function contribute(uint campaignID) public payable { diff --git a/docs/types/value-types.rst b/docs/types/value-types.rst index 29a91c836..16c371c18 100644 --- a/docs/types/value-types.rst +++ b/docs/types/value-types.rst @@ -64,11 +64,11 @@ Shifts ^^^^^^ The result of a shift operation has the type of the left operand, truncating the result to match the type. +Right operand must be unsigned type. Trying to shift by signed type will produce a compilation error. - For positive and negative ``x`` values, ``x << y`` is equivalent to ``x * 2**y``. - For positive ``x`` values, ``x >> y`` is equivalent to ``x / 2**y``. - For negative ``x`` values, ``x >> y`` is equivalent to ``(x + 1) / 2**y - 1`` (which is the same as dividing ``x`` by ``2**y`` while rounding down towards negative infinity). -- In all cases, shifting by a negative ``y`` throws a runtime exception. .. warning:: Before version ``0.5.0`` a right shift ``x >> y`` for negative ``x`` was equivalent to ``x / 2**y``, @@ -370,9 +370,9 @@ Operators: * Shift operators: ``<<`` (left shift), ``>>`` (right shift) * Index access: If ``x`` is of type ``bytesI``, then ``x[k]`` for ``0 <= k < I`` returns the ``k`` th byte (read-only). -The shifting operator works with any integer type as right operand (but +The shifting operator works with unsigned integer type as right operand (but returns the type of the left operand), which denotes the number of bits to shift by. -Shifting by a negative amount causes a runtime exception. +Shifting by a signed type will produce a compilation error. Members: @@ -444,6 +444,11 @@ long as the operands are integers. If any of the two is fractional, bit operatio and exponentiation is disallowed if the exponent is fractional (because that might result in a non-rational number). +Shifts and exponentiation with literal numbers as left (or base) operand and integer types +as the right (exponent) operand are always performed +in the ``uint256`` (for non-negative literals) or ``int256`` (for a negative literals) type, +regardless of the type of the right (exponent) operand. + .. warning:: Division on integer literals used to truncate in Solidity prior to version 0.4.0, but it now converts into a rational number, i.e. ``5 / 2`` is not equal to ``2``, but to ``2.5``. @@ -544,7 +549,7 @@ subsequent unsigned integer values starting from ``0``. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.16 <0.7.0; + pragma solidity >=0.4.16 <0.8.0; contract test { enum ActionChoices { GoLeft, GoRight, GoStraight, SitStill } @@ -645,18 +650,19 @@ External (or public) functions have the following members: * ``.address`` returns the address of the contract of the function. * ``.selector`` returns the :ref:`ABI function selector ` -* ``.gas(uint)`` returns a callable function object which, when called, will send - the specified amount of gas to the target function. Deprecated - use ``{gas: ...}`` instead. - See :ref:`External Function Calls ` for more information. -* ``.value(uint)`` returns a callable function object which, when called, will - send the specified amount of wei to the target function. Deprecated - use ``{value: ...}`` instead. - See :ref:`External Function Calls ` for more information. + +.. note:: + External (or public) functions used to have the additional members + ``.gas(uint)`` and ``.value(uint)``. These were deprecated in Solidity 0.6.2 + and removed in Solidity 0.7.0. Instead use ``{gas: ...}`` and ``{value: ...}`` + to specify the amount of gas or the amount of wei sent to a function, + respectively. See :ref:`External Function Calls ` for + more information. Example that shows how to use the members:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.0 <0.7.0; - // This will report a warning + pragma solidity >=0.6.4 <0.8.0; contract Example { function f() public payable returns (bytes4) { @@ -665,16 +671,14 @@ Example that shows how to use the members:: } function g() public { - this.f.gas(10).value(800)(); - // New syntax: - // this.f{gas: 10, value: 800}() + this.f{gas: 10, value: 800}(); } } Example that shows how to use internal function types:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.16 <0.7.0; + pragma solidity >=0.4.16 <0.8.0; library ArrayUtils { // internal functions can be used in internal library functions because @@ -732,7 +736,7 @@ Example that shows how to use internal function types:: Another example that uses external function types:: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.22 <0.7.0; + pragma solidity >=0.4.22 <0.8.0; contract Oracle { diff --git a/docs/units-and-global-variables.rst b/docs/units-and-global-variables.rst index 213390be4..a32900a50 100644 --- a/docs/units-and-global-variables.rst +++ b/docs/units-and-global-variables.rst @@ -2,23 +2,23 @@ Units and Globally Available Variables ************************************** -.. index:: wei, finney, szabo, ether +.. index:: wei, finney, szabo, gwei, ether Ether Units =========== -A literal number can take a suffix of ``wei``, ``gwei``, ``finney``, ``szabo`` or ``ether`` to specify a subdenomination of Ether, where Ether numbers without a postfix are assumed to be Wei. +A literal number can take a suffix of ``wei``, ``gwei`` or ``ether`` to specify a subdenomination of Ether, where Ether numbers without a postfix are assumed to be Wei. :: assert(1 wei == 1); assert(1 gwei == 1e9); - assert(1 szabo == 1e12); - assert(1 finney == 1e15); assert(1 ether == 1e18); The only effect of the subdenomination suffix is a multiplication by a power of ten. +.. note:: + The denominations ``finney`` and ``szabo`` have been removed in version 0.7.0. .. index:: time, seconds, minutes, hours, days, weeks, years @@ -48,7 +48,7 @@ These suffixes cannot be applied to variables. For example, if you want to interpret a function parameter in days, you can in the following way:: function f(uint start, uint daysAfter) public { - if (now >= start + daysAfter * 1 days) { + if (block.timestamp >= start + daysAfter * 1 days) { // ... } } @@ -62,7 +62,7 @@ There are special variables and functions which always exist in the global namespace and are mainly used to provide information about the blockchain or are general-use utility functions. -.. index:: abi, block, coinbase, difficulty, encode, number, block;number, timestamp, block;timestamp, msg, data, gas, sender, value, now, gas price, origin +.. index:: abi, block, coinbase, difficulty, encode, number, block;number, timestamp, block;timestamp, msg, data, gas, sender, value, gas price, origin Block and Transaction Properties @@ -79,7 +79,6 @@ Block and Transaction Properties - ``msg.sender`` (``address payable``): sender of the message (current call) - ``msg.sig`` (``bytes4``): first four bytes of the calldata (i.e. function identifier) - ``msg.value`` (``uint``): number of wei sent with the message -- ``now`` (``uint``): current block timestamp (alias for ``block.timestamp``) - ``tx.gasprice`` (``uint``): gas price of the transaction - ``tx.origin`` (``address payable``): sender of the transaction (full call chain) @@ -89,7 +88,7 @@ Block and Transaction Properties This includes calls to library functions. .. note:: - Do not rely on ``block.timestamp``, ``now`` and ``blockhash`` as a source of randomness, + Do not rely on ``block.timestamp`` or ``blockhash`` as a source of randomness, unless you know what you are doing. Both the timestamp and the block hash can be influenced by miners to some degree. @@ -113,6 +112,9 @@ Block and Transaction Properties The function ``gasleft`` was previously known as ``msg.gas``, which was deprecated in version 0.4.21 and removed in version 0.5.0. +.. note:: + In version 0.7.0, the alias ``now`` (for ``block.timestamp``) was removed. + .. index:: abi, encoding, packed ABI Encoding and Decoding Functions diff --git a/docs/using-the-compiler.rst b/docs/using-the-compiler.rst index 65f3f7ace..9ef1758c1 100644 --- a/docs/using-the-compiler.rst +++ b/docs/using-the-compiler.rst @@ -566,27 +566,40 @@ the latest version of the compiler. Available upgrade modules ~~~~~~~~~~~~~~~~~~~~~~~~~ -+-----------------+---------+--------------------------------------------------+ -| Module | Version | Description | -+=================+=========+==================================================+ -| ``constructor`` | 0.5.0 | Constructors must now be defined using the | -| | | ``constructor`` keyword. | -+-----------------+---------+--------------------------------------------------+ -| ``visibility`` | 0.5.0 | Explicit function visibility is now mandatory, | -| | | defaults to ``public``. | -+-----------------+---------+--------------------------------------------------+ -| ``abstract`` | 0.6.0 | The keyword ``abstract`` has to be used if a | -| | | contract does not implement all its functions. | -+-----------------+---------+--------------------------------------------------+ -| ``virtual`` | 0.6.0 | Functions without implementation outside an | -| | | interface have to be marked ``virtual``. | -+-----------------+---------+--------------------------------------------------+ -| ``override`` | 0.6.0 | When overriding a function or modifier, the new | -| | | keyword ``override`` must be used. | -+-----------------+---------+--------------------------------------------------+ ++----------------------------+---------+--------------------------------------------------+ +| Module | Version | Description | ++============================+=========+==================================================+ +| ``constructor`` | 0.5.0 | Constructors must now be defined using the | +| | | ``constructor`` keyword. | ++----------------------------+---------+--------------------------------------------------+ +| ``visibility`` | 0.5.0 | Explicit function visibility is now mandatory, | +| | | defaults to ``public``. | ++----------------------------+---------+--------------------------------------------------+ +| ``abstract`` | 0.6.0 | The keyword ``abstract`` has to be used if a | +| | | contract does not implement all its functions. | ++----------------------------+---------+--------------------------------------------------+ +| ``virtual`` | 0.6.0 | Functions without implementation outside an | +| | | interface have to be marked ``virtual``. | ++----------------------------+---------+--------------------------------------------------+ +| ``override`` | 0.6.0 | When overriding a function or modifier, the new | +| | | keyword ``override`` must be used. | ++----------------------------+---------+--------------------------------------------------+ +| ``dotsyntax`` | 0.7.0 | The following syntax is deprecated: | +| | | ``f.gas(...)()``, ``f.value(...)()`` and | +| | | ``(new C).value(...)()``. Replace these calls by | +| | | ``f{gas: ..., value: ...}()`` and | +| | | ``(new C){value: ...}()``. | ++----------------------------+---------+--------------------------------------------------+ +| ``now`` | 0.7.0 | The ``now`` keyword is deprecated. Use | +| | | ``block.timestamp`` instead. | ++----------------------------+---------+--------------------------------------------------+ +| ``constructor-visibility`` | 0.7.0 | Removes visibility of constructors. | +| | | | ++----------------------------+---------+--------------------------------------------------+ -Please read :doc:`0.5.0 release notes <050-breaking-changes>` and -:doc:`0.6.0 release notes <060-breaking-changes>` for further details. +Please read :doc:`0.5.0 release notes <050-breaking-changes>`, +:doc:`0.6.0 release notes <060-breaking-changes>` and +:doc:`0.7.0 release notes <070-breaking-changes>` for further details. Synopsis ~~~~~~~~ @@ -622,115 +635,88 @@ If you found a bug or if you have a feature request, please Example ~~~~~~~ -Assume you have the following contracts you want to update declared in ``Source.sol``: +Assume that you have the following contract in ``Source.sol``: -.. code-block:: none +.. code-block:: solidity - // This will not compile after 0.5.0 + pragma solidity >=0.6.0 <0.6.4; + // This will not compile after 0.7.0 // SPDX-License-Identifier: GPL-3.0 - pragma solidity >0.4.23 <0.5.0; - - contract Updateable { - function run() public view returns (bool); - function update() public; + contract C { + // FIXME: remove constructor visibility and make the contract abstract + constructor() internal {} } - contract Upgradable { - function run() public view returns (bool); - function upgrade(); + contract D { + uint time; + + function f() public payable { + // FIXME: change now to block.timestamp + time = now; + } } - contract Source is Updateable, Upgradable { - function Source() public {} + contract E { + D d; - function run() - public - view - returns (bool) {} + // FIXME: remove constructor visibility + constructor() public {} - function update() {} - function upgrade() {} + function g() public { + // FIXME: change .value(5) => {value: 5} + d.f.value(5)(); + } } + Required changes ^^^^^^^^^^^^^^^^ -To bring the contracts up to date with the current Solidity version, the -following upgrade modules have to be executed: ``constructor``, -``visibility``, ``abstract``, ``override`` and ``virtual``. Please read the -documentation on :ref:`available modules ` for further details. +The above contract will not compile starting from 0.7.0. To bring the contract up to date with the +current Solidity version, the following upgrade modules have to be executed: +``constructor-visibility``, ``now`` and ``dotsyntax``. Please read the documentation on +:ref:`available modules ` for further details. + Running the upgrade ^^^^^^^^^^^^^^^^^^^ -In this example, all modules needed to upgrade the contracts above, -are available and all of them are activated by default. Therefore you -do not need to specify the ``--modules`` option. +It is recommended to explicitly specify the upgrade modules by using ``--modules`` argument. .. code-block:: none - $ solidity-upgrade Source.sol --dry-run + $ solidity-upgrade --modules constructor-visibility,now,dotsyntax Source.sol -.. code-block:: none - - Running analysis (and upgrade) on given source files. - .............. - - After upgrade: - - Found 0 errors. - Found 0 upgrades. - -The above performs a dry-ran upgrade on the given file and logs statistics after all. -In this case, the upgrade was successful and no further adjustments are needed. - -Finally, you can run the upgrade and also write to the source file. - -.. code-block:: none - - $ solidity-upgrade Source.sol - -.. code-block:: none - - Running analysis (and upgrade) on given source files. - .............. - - After upgrade: - - Found 0 errors. - Found 0 upgrades. - - -Review changes -^^^^^^^^^^^^^^ - -The command above applies all changes as shown below. Please review them carefully. +The command above applies all changes as shown below. Please review them carefully (the pragmas will +have to be updated manually.) .. code-block:: solidity + pragma solidity >0.6.99 <0.8.0; // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.6.0 <0.7.0; - - abstract contract Updateable { - function run() public view virtual returns (bool); - function update() public virtual; + abstract contract C { + // FIXME: remove constructor visibility and make the contract abstract + constructor() {} } - abstract contract Upgradable { - function run() public view virtual returns (bool); - function upgrade() public virtual; + contract D { + uint time; + + function f() public payable { + // FIXME: change now to block.timestamp + time = block.timestamp; + } } - contract Source is Updateable, Upgradable { - constructor() public {} + contract E { + D d; - function run() - public - view - override(Updateable,Upgradable) - returns (bool) {} + // FIXME: remove constructor visibility + constructor() {} - function update() public override {} - function upgrade() public override {} + function g() public { + // FIXME: change .value(5) => {value: 5} + d.f{value: 5}(); + } } diff --git a/liblangutil/Token.h b/liblangutil/Token.h index 916f71c75..ab4eba8ba 100644 --- a/liblangutil/Token.h +++ b/liblangutil/Token.h @@ -189,15 +189,13 @@ namespace solidity::langutil K(Throw, "throw", 0) \ K(Type, "type", 0) \ K(Using, "using", 0) \ - K(Var, "var", 0) \ K(View, "view", 0) \ K(Virtual, "virtual", 0) \ K(While, "while", 0) \ \ /* Ether subdenominations */ \ K(SubWei, "wei", 0) \ - K(SubSzabo, "szabo", 0) \ - K(SubFinney, "finney", 0) \ + K(SubGwei, "gwei", 0) \ K(SubEther, "ether", 0) \ K(SubSecond, "seconds", 0) \ K(SubMinute, "minutes", 0) \ @@ -232,7 +230,6 @@ namespace solidity::langutil \ /* Identifiers (not keywords or future reserved words). */ \ T(Identifier, nullptr, 0) \ - T(SubGwei, "gwei", 0) \ \ /* Keywords reserved for future use. */ \ K(After, "after", 0) \ @@ -267,6 +264,7 @@ namespace solidity::langutil K(Typedef, "typedef", 0) \ K(TypeOf, "typeof", 0) \ K(Unchecked, "unchecked", 0) \ + K(Var, "var", 0) \ \ /* Illegal token - not able to scan. */ \ T(Illegal, "ILLEGAL", 0) \ @@ -307,13 +305,12 @@ namespace TokenTraits constexpr bool isVisibilitySpecifier(Token op) { return isVariableVisibilitySpecifier(op) || op == Token::External; } constexpr bool isLocationSpecifier(Token op) { return op == Token::Memory || op == Token::Storage || op == Token::CallData; } - constexpr bool isStateMutabilitySpecifier(Token op, bool _allowConstant = true) + constexpr bool isStateMutabilitySpecifier(Token op) { - return (op == Token::Constant && _allowConstant) - || op == Token::Pure || op == Token::View || op == Token::Payable; + return op == Token::Pure || op == Token::View || op == Token::Payable; } - constexpr bool isEtherSubdenomination(Token op) { return op == Token::SubWei || op == Token::SubSzabo || op == Token::SubFinney || op == Token::SubEther; } + constexpr bool isEtherSubdenomination(Token op) { return op >= Token::SubWei && op <= Token::SubEther; } constexpr bool isTimeSubdenomination(Token op) { return op == Token::SubSecond || op == Token::SubMinute || op == Token::SubHour || op == Token::SubDay || op == Token::SubWeek || op == Token::SubYear; } constexpr bool isReservedKeyword(Token op) { return (Token::After <= op && op <= Token::Unchecked); } diff --git a/libsolidity/analysis/ContractLevelChecker.cpp b/libsolidity/analysis/ContractLevelChecker.cpp index 8d40ace0e..ff6b30e79 100644 --- a/libsolidity/analysis/ContractLevelChecker.cpp +++ b/libsolidity/analysis/ContractLevelChecker.cpp @@ -122,8 +122,9 @@ void ContractLevelChecker::checkDuplicateEvents(ContractDefinition const& _contr /// Checks that two events with the same name defined in this contract have different /// argument types map> events; - for (EventDefinition const* event: _contract.events()) - events[event->name()].push_back(event); + for (auto const* contract: _contract.annotation().linearizedBaseContracts) + for (EventDefinition const* event: contract->events()) + events[event->name()].push_back(event); findDuplicateDefinitions(events); } diff --git a/libsolidity/analysis/DeclarationTypeChecker.cpp b/libsolidity/analysis/DeclarationTypeChecker.cpp index 0027b3045..d3408e379 100644 --- a/libsolidity/analysis/DeclarationTypeChecker.cpp +++ b/libsolidity/analysis/DeclarationTypeChecker.cpp @@ -113,18 +113,16 @@ bool DeclarationTypeChecker::visit(StructDefinition const& _struct) for (ASTPointer const& member: _struct.members()) { Type const* memberType = member->annotation().type; - while (auto arrayType = dynamic_cast(memberType)) - { - if (arrayType->isDynamicallySized()) - break; - memberType = arrayType->baseType(); - } + + if (auto arrayType = dynamic_cast(memberType)) + memberType = arrayType->finalBaseType(true); + if (auto structType = dynamic_cast(memberType)) if (_cycleDetector.run(structType->structDefinition())) return; } }; - if (util::CycleDetector(visitor).run(_struct) != nullptr) + if (util::CycleDetector(visitor).run(_struct)) m_errorReporter.fatalTypeError(2046_error, _struct.location(), "Recursive struct definition."); return false; @@ -296,15 +294,6 @@ void DeclarationTypeChecker::endVisit(VariableDeclaration const& _variable) "The \"immutable\" keyword can only be used for state variables." ); - if (!_variable.typeName()) - { - // This can still happen in very unusual cases where a developer uses constructs, such as - // `var a;`, however, such code will have generated errors already. - // However, we cannot blindingly solAssert() for that here, as the TypeChecker (which is - // invoking ReferencesResolver) is generating it, so the error is most likely(!) generated - // after this step. - return; - } using Location = VariableDeclaration::Location; Location varLoc = _variable.referenceLocation(); DataLocation typeLoc = DataLocation::Memory; @@ -385,7 +374,7 @@ void DeclarationTypeChecker::endVisit(VariableDeclaration const& _variable) solAssert(!_variable.hasReferenceOrMappingType(), "Data location not properly set."); } - TypePointer type = _variable.typeName()->annotation().type; + TypePointer type = _variable.typeName().annotation().type; if (auto ref = dynamic_cast(type)) { bool isPointer = !_variable.isStateVariable(); diff --git a/libsolidity/analysis/DocStringTagParser.cpp b/libsolidity/analysis/DocStringTagParser.cpp index 36fec2f2c..70f677c6a 100644 --- a/libsolidity/analysis/DocStringTagParser.cpp +++ b/libsolidity/analysis/DocStringTagParser.cpp @@ -61,25 +61,12 @@ bool DocStringTagParser::visit(VariableDeclaration const& _variable) { if (_variable.isStateVariable()) { - static set const validPublicTags = set{"dev", "notice", "return", "title", "author", "inheritdoc"}; + static set const validPublicTags = set{"dev", "notice", "return", "inheritdoc"}; + static set const validNonPublicTags = set{"dev", "inheritdoc"}; if (_variable.isPublic()) parseDocStrings(_variable, _variable.annotation(), validPublicTags, "public state variables"); else - { - parseDocStrings(_variable, _variable.annotation(), validPublicTags, "non-public state variables"); - if (_variable.annotation().docTags.count("notice") > 0) - m_errorReporter.warning( - 7816_error, _variable.documentation()->location(), - "Documentation tag on non-public state variables will be disallowed in 0.7.0. " - "You will need to use the @dev tag explicitly." - ); - } - if (_variable.annotation().docTags.count("title") > 0 || _variable.annotation().docTags.count("author") > 0) - m_errorReporter.warning( - 8532_error, _variable.documentation()->location(), - "Documentation tag @title and @author is only allowed on contract definitions. " - "It will be disallowed in 0.7.0." - ); + parseDocStrings(_variable, _variable.annotation(), validNonPublicTags, "non-public state variables"); } return false; } @@ -139,8 +126,8 @@ void DocStringTagParser::handleCallable( StructurallyDocumentedAnnotation& _annotation ) { - static set const validEventTags = set{"author", "dev", "notice", "return", "param"}; - static set const validTags = set{"author", "dev", "notice", "return", "param", "inheritdoc"}; + static set const validEventTags = set{"dev", "notice", "return", "param"}; + static set const validTags = set{"dev", "notice", "return", "param", "inheritdoc"}; if (dynamic_cast(&_callable)) parseDocStrings(_node, _annotation, validEventTags, "events"); @@ -148,13 +135,6 @@ void DocStringTagParser::handleCallable( parseDocStrings(_node, _annotation, validTags, "functions"); checkParameters(_callable, _node, _annotation); - - if (_node.documentation() && _annotation.docTags.count("author") > 0) - m_errorReporter.warning( - 9843_error, _node.documentation()->location(), - "Documentation tag @author is only allowed on contract definitions. " - "It will be disallowed in 0.7.0." - ); } void DocStringTagParser::parseDocStrings( diff --git a/libsolidity/analysis/OverrideChecker.cpp b/libsolidity/analysis/OverrideChecker.cpp index 42a6230a2..0bfb032b1 100644 --- a/libsolidity/analysis/OverrideChecker.cpp +++ b/libsolidity/analysis/OverrideChecker.cpp @@ -290,7 +290,7 @@ StateMutability OverrideProxy::stateMutability() const return std::visit(GenericVisitor{ [&](FunctionDefinition const* _item) { return _item->stateMutability(); }, [&](ModifierDefinition const*) { solAssert(false, "Requested state mutability from modifier."); return StateMutability{}; }, - [&](VariableDeclaration const*) { return StateMutability::View; } + [&](VariableDeclaration const* _var) { return _var->isConstant() ? StateMutability::Pure : StateMutability::View; } }, m_item); } @@ -585,29 +585,35 @@ void OverrideChecker::checkOverride(OverrideProxy const& _overriding, OverridePr "Overridden " + _overriding.astNodeName() + " is here:" ); - // This is only relevant for a function overriding a function. - if (_overriding.isFunction()) - { - if (_overriding.stateMutability() != _super.stateMutability()) - overrideError( - _overriding, - _super, - 6959_error, - "Overriding function changes state mutability from \"" + - stateMutabilityToString(_super.stateMutability()) + - "\" to \"" + - stateMutabilityToString(_overriding.stateMutability()) + - "\"." - ); + // Stricter mutability is always okay except when super is Payable + if ( + (_overriding.isFunction() || _overriding.isVariable()) && + ( + _overriding.stateMutability() > _super.stateMutability() || + _super.stateMutability() == StateMutability::Payable + ) && + _overriding.stateMutability() != _super.stateMutability() + ) + overrideError( + _overriding, + _super, + 6959_error, + "Overriding " + + _overriding.astNodeName() + + " changes state mutability from \"" + + stateMutabilityToString(_super.stateMutability()) + + "\" to \"" + + stateMutabilityToString(_overriding.stateMutability()) + + "\"." + ); - if (_overriding.unimplemented() && !_super.unimplemented()) - overrideError( - _overriding, - _super, - 4593_error, - "Overriding an implemented function with an unimplemented function is not allowed." - ); - } + if (_overriding.unimplemented() && !_super.unimplemented()) + overrideError( + _overriding, + _super, + 4593_error, + "Overriding an implemented function with an unimplemented function is not allowed." + ); } } diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp index 4d26f1888..82cb18937 100644 --- a/libsolidity/analysis/ReferencesResolver.cpp +++ b/libsolidity/analysis/ReferencesResolver.cpp @@ -34,15 +34,16 @@ #include #include +#include #include #include using namespace std; +using namespace solidity; using namespace solidity::langutil; +using namespace solidity::frontend; -namespace solidity::frontend -{ bool ReferencesResolver::resolve(ASTNode const& _root) { @@ -202,6 +203,10 @@ bool ReferencesResolver::visit(Return const& _return) void ReferencesResolver::operator()(yul::FunctionDefinition const& _function) { + validateYulIdentifierName(_function.name, _function.location); + for (yul::TypedName const& varName: _function.parameters + _function.returnVariables) + validateYulIdentifierName(varName.name, varName.location); + bool wasInsideFunction = m_yulInsideFunction; m_yulInsideFunction = true; this->operator()(_function.body); @@ -210,9 +215,10 @@ void ReferencesResolver::operator()(yul::FunctionDefinition const& _function) void ReferencesResolver::operator()(yul::Identifier const& _identifier) { - bool isSlot = boost::algorithm::ends_with(_identifier.name.str(), "_slot"); - bool isOffset = boost::algorithm::ends_with(_identifier.name.str(), "_offset"); + bool isSlot = boost::algorithm::ends_with(_identifier.name.str(), ".slot"); + bool isOffset = boost::algorithm::ends_with(_identifier.name.str(), ".offset"); + // Could also use `pathFromCurrentScope`, split by '.' auto declarations = m_resolver.nameFromCurrentScope(_identifier.name.str()); if (isSlot || isOffset) { @@ -222,19 +228,22 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier) return; string realName = _identifier.name.str().substr(0, _identifier.name.str().size() - ( isSlot ? - string("_slot").size() : - string("_offset").size() + string(".slot").size() : + string(".offset").size() )); if (realName.empty()) { m_errorReporter.declarationError( 4794_error, _identifier.location, - "In variable names _slot and _offset can only be used as a suffix." + "In variable names .slot and .offset can only be used as a suffix." ); return; } declarations = m_resolver.nameFromCurrentScope(realName); + if (!declarations.empty()) + // To support proper path resolution, we have to use pathFromCurrentScope. + solAssert(!util::contains(realName, '.'), ""); } if (declarations.size() > 1) { @@ -246,7 +255,18 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier) return; } else if (declarations.size() == 0) + { + if ( + boost::algorithm::ends_with(_identifier.name.str(), "_slot") || + boost::algorithm::ends_with(_identifier.name.str(), "_offset") + ) + m_errorReporter.declarationError( + 9467_error, + _identifier.location, + "Identifier not found. Use ``.slot`` and ``.offset`` to access storage variables." + ); return; + } if (auto var = dynamic_cast(declarations.front())) if (var->isLocalVariable() && m_yulInsideFunction) { @@ -267,18 +287,11 @@ void ReferencesResolver::operator()(yul::VariableDeclaration const& _varDecl) { for (auto const& identifier: _varDecl.variables) { - bool isSlot = boost::algorithm::ends_with(identifier.name.str(), "_slot"); - bool isOffset = boost::algorithm::ends_with(identifier.name.str(), "_offset"); + validateYulIdentifierName(identifier.name, identifier.location); - string namePrefix = identifier.name.str().substr(0, identifier.name.str().find('.')); - if (isSlot || isOffset) - m_errorReporter.declarationError( - 9155_error, - identifier.location, - "In variable declarations _slot and _offset can not be used as a suffix." - ); - else if ( - auto declarations = m_resolver.nameFromCurrentScope(namePrefix); + + if ( + auto declarations = m_resolver.nameFromCurrentScope(identifier.name.str()); !declarations.empty() ) { @@ -290,8 +303,6 @@ void ReferencesResolver::operator()(yul::VariableDeclaration const& _varDecl) 3859_error, identifier.location, ssl, - namePrefix.size() < identifier.name.str().size() ? - "The prefix of this declaration conflicts with a declaration outside the inline assembly block." : "This declaration shadows a declaration outside the inline assembly block." ); } @@ -350,4 +361,12 @@ void ReferencesResolver::resolveInheritDoc(StructuredDocumentation const& _docum } } +void ReferencesResolver::validateYulIdentifierName(yul::YulString _name, SourceLocation const& _location) +{ + if (util::contains(_name.str(), '.')) + m_errorReporter.declarationError( + 3927_error, + _location, + "User-defined identifiers in inline assembly cannot contain '.'." + ); } diff --git a/libsolidity/analysis/ReferencesResolver.h b/libsolidity/analysis/ReferencesResolver.h index fc71b4d4e..2c984f9b2 100644 --- a/libsolidity/analysis/ReferencesResolver.h +++ b/libsolidity/analysis/ReferencesResolver.h @@ -92,6 +92,9 @@ private: void resolveInheritDoc(StructuredDocumentation const& _documentation, StructurallyDocumentedAnnotation& _annotation); + /// Checks if the name contains a '.'. + void validateYulIdentifierName(yul::YulString _name, langutil::SourceLocation const& _location); + langutil::ErrorReporter& m_errorReporter; NameAndTypeResolver& m_resolver; langutil::EVMVersion m_evmVersion; diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp index 26d90f4f1..7f27e11ab 100644 --- a/libsolidity/analysis/SyntaxChecker.cpp +++ b/libsolidity/analysis/SyntaxChecker.cpp @@ -302,7 +302,7 @@ bool SyntaxChecker::visit(ContractDefinition const& _contract) bool SyntaxChecker::visit(FunctionDefinition const& _function) { - if (_function.noVisibilitySpecified()) + if (!_function.isConstructor() && _function.noVisibilitySpecified()) { string suggestedVisibility = _function.isFallback() || _function.isReceive() || m_isInterface ? "external" : "public"; m_errorReporter.syntaxError( diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 0a14d5cc9..8b8ceadd5 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -327,10 +327,14 @@ bool TypeChecker::visit(FunctionDefinition const& _function) { if (_function.markedVirtual()) { - if (_function.annotation().contract->isInterface()) + if (_function.isConstructor()) + m_errorReporter.typeError(7001_error, _function.location(), "Constructors cannot be virtual."); + else if (_function.annotation().contract->isInterface()) m_errorReporter.warning(5815_error, _function.location(), "Interface functions are implicitly \"virtual\""); - if (_function.visibility() == Visibility::Private) + else if (_function.visibility() == Visibility::Private) m_errorReporter.typeError(3942_error, _function.location(), "\"virtual\" and \"private\" cannot be used together."); + else if (_function.libraryFunction()) + m_errorReporter.typeError(7801_error, _function.location(), "Library functions cannot be \"virtual\"."); } if (_function.isPayable()) @@ -340,45 +344,62 @@ bool TypeChecker::visit(FunctionDefinition const& _function) if (_function.isOrdinary() && !_function.isPartOfExternalInterface()) m_errorReporter.typeError(5587_error, _function.location(), "\"internal\" and \"private\" functions cannot be payable."); } - auto checkArgumentAndReturnParameter = [&](VariableDeclaration const& var) { - if (type(var)->category() == Type::Category::Mapping) - { - if (var.referenceLocation() != VariableDeclaration::Location::Storage) - { - if (!_function.libraryFunction() && _function.isPublic()) - m_errorReporter.typeError(3442_error, var.location(), "Mapping types can only have a data location of \"storage\" and thus only be parameters or return variables for internal or library functions."); - else - m_errorReporter.typeError(5380_error, var.location(), "Mapping types can only have a data location of \"storage\"." ); - } - else - solAssert(_function.libraryFunction() || !_function.isPublic(), "Mapping types for parameters or return variables can only be used in internal or library functions."); - } - else - { - if (!type(var)->canLiveOutsideStorage() && _function.isPublic()) - m_errorReporter.typeError(3312_error, var.location(), "Type is required to live outside storage."); - if (_function.isPublic()) - { - auto iType = type(var)->interfaceType(_function.libraryFunction()); - if (!iType) - { - solAssert(!iType.message().empty(), "Expected detailed error message!"); - m_errorReporter.fatalTypeError(4103_error, var.location(), iType.message()); - } - } - } + vector internalParametersInConstructor; + + auto checkArgumentAndReturnParameter = [&](VariableDeclaration const& _var) { + if (type(_var)->containsNestedMapping()) + if (_var.referenceLocation() == VariableDeclaration::Location::Storage) + solAssert( + _function.libraryFunction() || _function.isConstructor() || !_function.isPublic(), + "Mapping types for parameters or return variables " + "can only be used in internal or library functions." + ); + bool functionIsExternallyVisible = + (!_function.isConstructor() && _function.isPublic()) || + (_function.isConstructor() && !m_currentContract->abstract()); if ( - _function.isPublic() && - !experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2) && - !typeSupportedByOldABIEncoder(*type(var), _function.libraryFunction()) + _function.isConstructor() && + _var.referenceLocation() == VariableDeclaration::Location::Storage && + !m_currentContract->abstract() ) m_errorReporter.typeError( - 4957_error, - var.location(), - "This type is only supported in ABIEncoderV2. " - "Use \"pragma experimental ABIEncoderV2;\" to enable the feature." + 3644_error, + _var.location(), + "This parameter has a type that can only be used internally. " + "You can make the contract abstract to avoid this problem." ); + else if (functionIsExternallyVisible) + { + auto iType = type(_var)->interfaceType(_function.libraryFunction()); + + if (!iType) + { + string message = iType.message(); + solAssert(!message.empty(), "Expected detailed error message!"); + if (_function.isConstructor()) + message += " You can make the contract abstract to avoid this problem."; + m_errorReporter.typeError(4103_error, _var.location(), message); + } + else if ( + !experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2) && + !typeSupportedByOldABIEncoder(*type(_var), _function.libraryFunction()) + ) + { + string message = + "This type is only supported in ABIEncoderV2. " + "Use \"pragma experimental ABIEncoderV2;\" to enable the feature."; + if (_function.isConstructor()) + message += + " Alternatively, make the contract abstract and supply the " + "constructor arguments from a derived contract."; + m_errorReporter.typeError( + 4957_error, + _var.location(), + message + ); + } + } }; for (ASTPointer const& var: _function.parameters()) { @@ -390,6 +411,7 @@ bool TypeChecker::visit(FunctionDefinition const& _function) checkArgumentAndReturnParameter(*var); var->accept(*this); } + set modifiers; for (ASTPointer const& modifier: _function.modifiers()) { @@ -415,11 +437,10 @@ bool TypeChecker::visit(FunctionDefinition const& _function) if (_function.isImplemented()) m_errorReporter.typeError(4726_error, _function.location(), "Functions in interfaces cannot have an implementation."); - if (_function.visibility() != Visibility::External) - m_errorReporter.typeError(1560_error, _function.location(), "Functions in interfaces must be declared external."); - if (_function.isConstructor()) m_errorReporter.typeError(6482_error, _function.location(), "Constructor cannot be defined in interfaces."); + else if (_function.visibility() != Visibility::External) + m_errorReporter.typeError(1560_error, _function.location(), "Functions in interfaces must be declared external."); } else if (m_currentContract->contractKind() == ContractKind::Library) if (_function.isConstructor()) @@ -446,8 +467,7 @@ bool TypeChecker::visit(FunctionDefinition const& _function) bool TypeChecker::visit(VariableDeclaration const& _variable) { - if (_variable.typeName()) - _variable.typeName()->accept(*this); + _variable.typeName().accept(*this); // type is filled either by ReferencesResolver directly from the type name or by // TypeChecker at the VariableDeclarationStatement level. @@ -459,9 +479,13 @@ bool TypeChecker::visit(VariableDeclaration const& _variable) m_errorReporter.typeError(1273_error, _variable.location(), "The type of a variable cannot be a library."); if (_variable.value()) { - if (_variable.isStateVariable() && dynamic_cast(varType)) + if (_variable.isStateVariable() && varType->containsNestedMapping()) { - m_errorReporter.typeError(6280_error, _variable.location(), "Mappings cannot be assigned to."); + m_errorReporter.typeError( + 6280_error, + _variable.location(), + "Types in storage containing (nested) mappings cannot be assigned to." + ); _variable.value()->accept(*this); } else @@ -501,9 +525,16 @@ bool TypeChecker::visit(VariableDeclaration const& _variable) if (!_variable.isStateVariable()) { - if (varType->dataStoredIn(DataLocation::Memory) || varType->dataStoredIn(DataLocation::CallData)) - if (!varType->canLiveOutsideStorage()) - m_errorReporter.typeError(4061_error, _variable.location(), "Type " + varType->toString() + " is only valid in storage."); + if ( + _variable.referenceLocation() == VariableDeclaration::Location::CallData || + _variable.referenceLocation() == VariableDeclaration::Location::Memory + ) + if (varType->containsNestedMapping()) + m_errorReporter.fatalTypeError( + 4061_error, + _variable.location(), + "Type " + varType->toString(true) + " is only valid in storage because it contains a (nested) mapping." + ); } else if (_variable.visibility() >= Visibility::Public) { @@ -534,7 +565,7 @@ bool TypeChecker::visit(VariableDeclaration const& _variable) if (auto referenceType = dynamic_cast(varType)) { auto result = referenceType->validForLocation(referenceType->location()); - if (result && _variable.isPublicCallableParameter()) + if (result && (_variable.isConstructorParameter() || _variable.isPublicCallableParameter())) result = referenceType->validForLocation(DataLocation::CallData); if (!result) { @@ -560,15 +591,11 @@ bool TypeChecker::visit(VariableDeclaration const& _variable) if (_variable.isStateVariable()) m_errorReporter.warning(3408_error, _variable.location(), collisionMessage(_variable.name(), true)); else - m_errorReporter.warning( - 2332_error, - _variable.typeName() ? _variable.typeName()->location() : _variable.location(), - collisionMessage(varType->canonicalName(), false) - ); + m_errorReporter.warning(2332_error, _variable.typeName().location(), collisionMessage(varType->canonicalName(), false)); } vector oversizedSubtypes = frontend::oversizedSubtypes(*varType); for (Type const* subtype: oversizedSubtypes) - m_errorReporter.warning(7325_error, _variable.typeName()->location(), collisionMessage(subtype->canonicalName(), false)); + m_errorReporter.warning(7325_error, _variable.typeName().location(), collisionMessage(subtype->canonicalName(), false)); } return false; @@ -646,8 +673,12 @@ bool TypeChecker::visit(EventDefinition const& _eventDef) { if (var->isIndexed()) numIndexed++; - if (!type(*var)->canLiveOutsideStorage()) - m_errorReporter.typeError(3448_error, var->location(), "Type is required to live outside storage."); + if (type(*var)->containsNestedMapping()) + m_errorReporter.typeError( + 3448_error, + var->location(), + "Type containing a (nested) mapping is not allowed as event parameter type." + ); if (!type(*var)->interfaceType(false)) m_errorReporter.typeError(3417_error, var->location(), "Internal or recursive type is not allowed as event parameter type."); if ( @@ -724,7 +755,7 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly) } else if (requiresStorage) { - m_errorReporter.typeError(6617_error, _identifier.location, "The suffixes _offset and _slot can only be used on non-constant storage variables."); + m_errorReporter.typeError(6617_error, _identifier.location, "The suffixes .offset and .slot can only be used on non-constant storage variables."); return false; } else if (var && var->value() && !var->value()->annotation().type && !dynamic_cast(var->value().get())) @@ -752,7 +783,7 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly) { if (!var->isStateVariable() && !var->type()->dataStoredIn(DataLocation::Storage)) { - m_errorReporter.typeError(3622_error, _identifier.location, "The suffixes _offset and _slot can only be used on storage variables."); + m_errorReporter.typeError(3622_error, _identifier.location, "The suffixes .offset and .slot can only be used on storage variables."); return false; } else if (_context == yul::IdentifierContext::LValue) @@ -764,7 +795,7 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly) } else if (identifierInfo.isOffset) { - m_errorReporter.typeError(9739_error, _identifier.location, "Only _slot can be assigned to."); + m_errorReporter.typeError(9739_error, _identifier.location, "Only .slot can be assigned to."); return false; } else @@ -773,12 +804,12 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly) } else if (!var->isConstant() && var->isStateVariable()) { - m_errorReporter.typeError(1408_error, _identifier.location, "Only local variables are supported. To access storage variables, use the _slot and _offset suffixes."); + m_errorReporter.typeError(1408_error, _identifier.location, "Only local variables are supported. To access storage variables, use the .slot and .offset suffixes."); return false; } else if (var->type()->dataStoredIn(DataLocation::Storage)) { - m_errorReporter.typeError(9068_error, _identifier.location, "You have to use the _slot or _offset suffix to access storage reference variables."); + m_errorReporter.typeError(9068_error, _identifier.location, "You have to use the .slot or .offset suffix to access storage reference variables."); return false; } else if (var->type()->sizeOnStack() != 1) @@ -792,7 +823,7 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly) } else if (requiresStorage) { - m_errorReporter.typeError(7944_error, _identifier.location, "The suffixes _offset and _slot can only be used on storage variables."); + m_errorReporter.typeError(7944_error, _identifier.location, "The suffixes .offset and .slot can only be used on storage variables."); return false; } else if (_context == yul::IdentifierContext::LValue) @@ -1071,81 +1102,23 @@ void TypeChecker::endVisit(EmitStatement const& _emit) m_errorReporter.typeError(9292_error, _emit.eventCall().expression().location(), "Expression has to be an event invocation."); } -namespace -{ -/** - * @returns a suggested left-hand-side of a multi-variable declaration contairing - * the variable declarations given in @a _decls. - */ -string createTupleDecl(vector> const& _decls) -{ - vector components; - for (ASTPointer const& decl: _decls) - if (decl) - { - solAssert(decl->annotation().type, ""); - 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> const& decls) -{ - for (ASTPointer const& decl: decls) - { - // skip empty tuples (they can be expressed of course) - if (!decl) - continue; - - if (!decl->annotation().type) - return false; - - if (auto functionType = dynamic_cast(decl->annotation().type)) - if ( - functionType->kind() != FunctionType::Kind::Internal && - functionType->kind() != FunctionType::Kind::External - ) - return false; - } - - return true; -} -} - bool TypeChecker::visit(VariableDeclarationStatement const& _statement) { if (!_statement.initialValue()) { // No initial value is only permitted for single variables with specified type. + // This usually already results in a parser error. if (_statement.declarations().size() != 1 || !_statement.declarations().front()) { - if (std::all_of( - _statement.declarations().begin(), - _statement.declarations().end(), - [](ASTPointer const& declaration) { return declaration == nullptr; } - )) - { - // The syntax checker has already generated an error for this case (empty LHS tuple). - solAssert(m_errorReporter.hasErrors(), ""); + solAssert(m_errorReporter.hasErrors(), ""); - // It is okay to return here, as there are no named components on the - // left-hand-side that could cause any damage later. - return false; - } - else - // Bailing out *fatal* here, as those (untyped) vars may be used later, and diagnostics wouldn't be helpful then. - m_errorReporter.fatalTypeError(4626_error, _statement.location(), "Use of the \"var\" keyword is disallowed."); + // It is okay to return here, as there are no named components on the + // left-hand-side that could cause any damage later. + return false; } VariableDeclaration const& varDecl = *_statement.declarations().front(); - if (!varDecl.annotation().type) - m_errorReporter.fatalTypeError(6983_error, _statement.location(), "Use of the \"var\" keyword is disallowed."); + solAssert(varDecl.annotation().type, ""); if (dynamic_cast(type(varDecl))) m_errorReporter.typeError( @@ -1182,8 +1155,6 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement) ")." ); - bool autoTypeDeductionNeeded = false; - for (size_t i = 0; i < min(variables.size(), valueTypes.size()); ++i) { if (!variables[i]) @@ -1192,95 +1163,45 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement) solAssert(!var.value(), "Value has to be tied to statement."); TypePointer const& valueComponentType = valueTypes[i]; solAssert(!!valueComponentType, ""); - if (!var.annotation().type) - { - autoTypeDeductionNeeded = true; + solAssert(var.annotation().type, ""); - // Infer type from value. - solAssert(!var.typeName(), ""); - var.annotation().type = valueComponentType->mobileType(); - if (!var.annotation().type) - { - if (valueComponentType->category() == Type::Category::RationalNumber) - m_errorReporter.fatalTypeError( - 6963_error, - _statement.initialValue()->location(), - "Invalid rational " + - valueComponentType->toString() + - " (absolute value too large or division by zero)." - ); - else - solAssert(false, ""); - } - else if (*var.annotation().type == *TypeProvider::emptyTuple()) - solAssert(false, "Cannot declare variable with void (empty tuple) type."); - else if (valueComponentType->category() == Type::Category::RationalNumber) - { - string typeName = var.annotation().type->toString(true); - string extension; - if (auto type = dynamic_cast(var.annotation().type)) - { - unsigned numBits = type->numBits(); - bool isSigned = type->isSigned(); - solAssert(numBits > 0, ""); - string minValue; - string maxValue; - if (isSigned) - { - numBits--; - minValue = "-" + bigint(bigint(1) << numBits).str(); - } - else - minValue = "0"; - maxValue = bigint((bigint(1) << numBits) - 1).str(); - extension = ", which can hold values between " + minValue + " and " + maxValue; - } - else - solAssert(dynamic_cast(var.annotation().type), "Unknown type."); - } - - var.accept(*this); - } - else + var.accept(*this); + BoolResult result = valueComponentType->isImplicitlyConvertibleTo(*var.annotation().type); + if (!result) { - var.accept(*this); - BoolResult result = valueComponentType->isImplicitlyConvertibleTo(*var.annotation().type); - if (!result) + auto errorMsg = "Type " + + valueComponentType->toString() + + " is not implicitly convertible to expected type " + + var.annotation().type->toString(); + if ( + valueComponentType->category() == Type::Category::RationalNumber && + dynamic_cast(*valueComponentType).isFractional() && + valueComponentType->mobileType() + ) { - auto errorMsg = "Type " + - valueComponentType->toString() + - " is not implicitly convertible to expected type " + - var.annotation().type->toString(); - if ( - valueComponentType->category() == Type::Category::RationalNumber && - dynamic_cast(*valueComponentType).isFractional() && - valueComponentType->mobileType() - ) - { - if (var.annotation().type->operator==(*valueComponentType->mobileType())) - m_errorReporter.typeError( - 5107_error, - _statement.location(), - errorMsg + ", but it can be explicitly converted." - ); - else - m_errorReporter.typeError( - 4486_error, - _statement.location(), - errorMsg + - ". Try converting to type " + - valueComponentType->mobileType()->toString() + - " or use an explicit conversion." - ); - } - else - m_errorReporter.typeErrorConcatenateDescriptions( - 9574_error, + if (var.annotation().type->operator==(*valueComponentType->mobileType())) + m_errorReporter.typeError( + 5107_error, _statement.location(), - errorMsg + ".", - result.message() + errorMsg + ", but it can be explicitly converted." + ); + else + m_errorReporter.typeError( + 4486_error, + _statement.location(), + errorMsg + + ". Try converting to type " + + valueComponentType->mobileType()->toString() + + " or use an explicit conversion." ); } + else + m_errorReporter.typeErrorConcatenateDescriptions( + 9574_error, + _statement.location(), + errorMsg + ".", + result.message() + ); } } @@ -1292,24 +1213,6 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement) BOOST_THROW_EXCEPTION(FatalError()); } - if (autoTypeDeductionNeeded) - { - if (!typeCanBeExpressed(variables)) - m_errorReporter.syntaxError( - 3478_error, - _statement.location(), - "Use of the \"var\" keyword is disallowed. " - "Type cannot be expressed in syntax." - ); - else - m_errorReporter.syntaxError( - 1719_error, - _statement.location(), - "Use of the \"var\" keyword is disallowed. " - "Use explicit declaration `" + createTupleDecl(variables) + " = ...` instead." - ); - } - return false; } @@ -1420,7 +1323,7 @@ void TypeChecker::checkExpressionAssignment(Type const& _type, Expression const& checkExpressionAssignment(*types[i], *tupleExpression->components()[i]); } } - else if (_type.category() == Type::Category::Mapping) + else if (_type.nameable() && _type.containsNestedMapping()) { bool isLocalOrReturn = false; if (auto const* identifier = dynamic_cast(&_expression)) @@ -1428,7 +1331,7 @@ void TypeChecker::checkExpressionAssignment(Type const& _type, Expression const& if (variableDeclaration->isLocalOrReturn()) isLocalOrReturn = true; if (!isLocalOrReturn) - m_errorReporter.typeError(9214_error, _expression.location(), "Mappings cannot be assigned to."); + m_errorReporter.typeError(9214_error, _expression.location(), "Types in storage containing (nested) mappings cannot be assigned to."); } } @@ -1564,8 +1467,12 @@ bool TypeChecker::visit(TupleExpression const& _tuple) _tuple.location(), "Unable to deduce nameable type for array elements. Try adding explicit type conversion for the first element." ); - else if (!inlineArrayType->canLiveOutsideStorage()) - m_errorReporter.fatalTypeError(1545_error, _tuple.location(), "Type " + inlineArrayType->toString() + " is only valid in storage."); + else if (inlineArrayType->containsNestedMapping()) + m_errorReporter.fatalTypeError( + 1545_error, + _tuple.location(), + "Type " + inlineArrayType->toString(true) + " is only valid in storage." + ); _tuple.annotation().type = TypeProvider::array(DataLocation::Memory, inlineArrayType, types.size()); } @@ -1906,8 +1813,6 @@ void TypeChecker::typeCheckReceiveFunction(FunctionDefinition const& _function) void TypeChecker::typeCheckConstructor(FunctionDefinition const& _function) { solAssert(_function.isConstructor(), ""); - if (_function.markedVirtual()) - m_errorReporter.typeError(7001_error, _function.location(), "Constructors cannot be virtual."); if (_function.overrides()) m_errorReporter.typeError(1209_error, _function.location(), "Constructors cannot override."); if (!_function.returnParameters().empty()) @@ -1920,8 +1825,30 @@ void TypeChecker::typeCheckConstructor(FunctionDefinition const& _function) stateMutabilityToString(_function.stateMutability()) + "\"." ); - if (_function.visibility() != Visibility::Public && _function.visibility() != Visibility::Internal) - m_errorReporter.typeError(9239_error, _function.location(), "Constructor must be public or internal."); + if (!_function.noVisibilitySpecified()) + { + auto const& contract = dynamic_cast(*_function.scope()); + if (_function.visibility() != Visibility::Public && _function.visibility() != Visibility::Internal) + m_errorReporter.typeError(9239_error, _function.location(), "Constructor cannot have visibility."); + else if (_function.isPublic() && contract.abstract()) + m_errorReporter.declarationError( + 8295_error, + _function.location(), + "Abstract contracts cannot have public constructors. Remove the \"public\" keyword to fix this." + ); + else if (!_function.isPublic() && !contract.abstract()) + m_errorReporter.declarationError( + 1845_error, + _function.location(), + "Non-abstract contracts cannot have internal constructors. Remove the \"internal\" keyword and make the contract abstract to fix this." + ); + else + m_errorReporter.warning( + 2462_error, + _function.location(), + "Visibility for constructor is ignored. If you want the contract to be non-deployable, making it \"abstract\" is sufficient." + ); + } } void TypeChecker::typeCheckABIEncodeFunctions( @@ -2066,24 +1993,8 @@ void TypeChecker::typeCheckFunctionGeneralChecks( toString(parameterTypes.size()) + "."; - // Extend error message in case we try to construct a struct with mapping member. if (isStructConstructorCall) - { - /// For error message: Struct members that were removed during conversion to memory. - TypePointer const expressionType = type(_functionCall.expression()); - auto const& t = dynamic_cast(*expressionType); - auto const& structType = dynamic_cast(*t.actualType()); - set membersRemovedForStructConstructor = structType.membersMissingInMemory(); - - if (!membersRemovedForStructConstructor.empty()) - { - msg += " Members that have to be skipped in memory:"; - for (auto const& member: membersRemovedForStructConstructor) - msg += " " + member; - } - return { isVariadic ? 1123_error : 9755_error, msg }; - } else if ( _functionType->kind() == FunctionType::Kind::BareCall || _functionType->kind() == FunctionType::Kind::BareCallCode || @@ -2303,6 +2214,12 @@ bool TypeChecker::visit(FunctionCall const& _functionCall) if (actualType->category() == Type::Category::Struct) { + if (actualType->containsNestedMapping()) + m_errorReporter.fatalTypeError( + 9515_error, + _functionCall.location(), + "Struct containing a (nested) mapping cannot be constructed." + ); functionType = dynamic_cast(*actualType).constructorType(); funcCallAnno.kind = FunctionCallKind::StructConstructorCall; funcCallAnno.isPure = argumentsArePure; @@ -2532,8 +2449,6 @@ void TypeChecker::endVisit(NewExpression const& _newExpression) m_errorReporter.fatalTypeError(5540_error, _newExpression.location(), "Identifier is not a contract."); if (contract->isInterface()) m_errorReporter.fatalTypeError(2971_error, _newExpression.location(), "Cannot instantiate an interface."); - if (!contract->constructorIsPublic()) - m_errorReporter.typeError(9054_error, _newExpression.location(), "Contract with internal constructor cannot be created directly."); if (contract->abstract()) m_errorReporter.typeError(4614_error, _newExpression.location(), "Cannot instantiate an abstract contract."); @@ -2554,11 +2469,11 @@ void TypeChecker::endVisit(NewExpression const& _newExpression) } else if (type->category() == Type::Category::Array) { - if (!type->canLiveOutsideStorage()) + if (type->containsNestedMapping()) m_errorReporter.fatalTypeError( 1164_error, _newExpression.typeName().location(), - "Type cannot live outside storage." + "Array containing a (nested) mapping cannot be constructed in memory." ); if (!type->isDynamicallySized()) m_errorReporter.typeError( @@ -2716,7 +2631,7 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) !annotation.referencedDeclaration && (memberName == "value" || memberName == "gas") ) - m_errorReporter.warning( + m_errorReporter.typeError( 1621_error, _memberAccess.location(), "Using \"." + memberName + "(...)\" is deprecated. Use \"{" + memberName + ": ...}\" instead." @@ -3114,6 +3029,20 @@ bool TypeChecker::visit(Identifier const& _identifier) ); } + if ( + MagicVariableDeclaration const* magicVar = + dynamic_cast(annotation.referencedDeclaration) + ) + if (magicVar->type()->category() == Type::Category::Integer) + { + solAssert(_identifier.name() == "now", ""); + m_errorReporter.typeError( + 7359_error, + _identifier.location(), + "\"now\" has been deprecated. Use \"block.timestamp\" instead." + ); + } + return false; } diff --git a/libsolidity/analysis/ViewPureChecker.cpp b/libsolidity/analysis/ViewPureChecker.cpp index d2e1b3e43..469d399b1 100644 --- a/libsolidity/analysis/ViewPureChecker.cpp +++ b/libsolidity/analysis/ViewPureChecker.cpp @@ -169,7 +169,7 @@ void ViewPureChecker::endVisit(FunctionDefinition const& _funDef) !_funDef.isConstructor() && !_funDef.isFallback() && !_funDef.isReceive() && - !_funDef.overrides() + !_funDef.virtualSemantics() ) m_errorReporter.warning( 2018_error, diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 7c1ed2aa8..662ea81d3 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -123,15 +123,9 @@ FunctionDefinition const* ContractDefinition::constructor() const return nullptr; } -bool ContractDefinition::constructorIsPublic() const -{ - FunctionDefinition const* f = constructor(); - return !f || f->isPublic(); -} - bool ContractDefinition::canBeDeployed() const { - return constructorIsPublic() && !abstract() && !isInterface(); + return !abstract() && !isInterface(); } FunctionDefinition const* ContractDefinition::fallbackFunction() const @@ -295,6 +289,12 @@ bool FunctionDefinition::libraryFunction() const return false; } +Visibility FunctionDefinition::defaultVisibility() const +{ + solAssert(!isConstructor(), ""); + return Declaration::defaultVisibility(); +} + FunctionTypePointer FunctionDefinition::functionType(bool _internal) const { if (_internal) @@ -615,9 +615,8 @@ bool VariableDeclaration::isEventParameter() const bool VariableDeclaration::hasReferenceOrMappingType() const { - solAssert(typeName(), ""); - solAssert(typeName()->annotation().type, "Can only be called after reference resolution"); - Type const* type = typeName()->annotation().type; + solAssert(typeName().annotation().type, "Can only be called after reference resolution"); + Type const* type = typeName().annotation().type; return type->category() == Type::Category::Mapping || dynamic_cast(type); } @@ -630,7 +629,12 @@ set VariableDeclaration::allowedDataLocations() c else if (isCallableOrCatchParameter()) { set locations{ Location::Memory }; - if (isInternalCallableParameter() || isLibraryFunctionParameter() || isTryCatchParameter()) + if ( + isConstructorParameter() || + isInternalCallableParameter() || + isLibraryFunctionParameter() || + isTryCatchParameter() + ) locations.insert(Location::Storage); if (!isTryCatchParameter() && !isConstructorParameter()) locations.insert(Location::CallData); @@ -638,22 +642,8 @@ set VariableDeclaration::allowedDataLocations() c return locations; } else if (isLocalVariable()) - { - solAssert(typeName(), ""); - auto dataLocations = [](TypePointer _type, auto&& _recursion) -> set { - solAssert(_type, "Can only be called after reference resolution"); - switch (_type->category()) - { - case Type::Category::Array: - return _recursion(dynamic_cast(_type)->baseType(), _recursion); - case Type::Category::Mapping: - return set{ Location::Storage }; - default: - return set{ Location::Memory, Location::Storage, Location::CallData }; - } - }; - return dataLocations(typeName()->annotation().type, dataLocations); - } + // Further restrictions will be imposed later on. + return set{ Location::Memory, Location::Storage, Location::CallData }; else // Struct members etc. return set{ Location::Unspecified }; diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index eb2b4f87d..de358a9e7 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -506,8 +506,6 @@ public: /// Returns the constructor or nullptr if no constructor was specified. FunctionDefinition const* constructor() const; - /// @returns true iff the constructor of this contract is public (or non-existing). - bool constructorIsPublic() const; /// @returns true iff the contract can be deployed, i.e. is not abstract and has a /// public constructor. /// Should only be called after the type checker has run. @@ -809,15 +807,16 @@ public: bool isPayable() const { return m_stateMutability == StateMutability::Payable; } std::vector> const& modifiers() const { return m_functionModifiers; } Block const& body() const { solAssert(m_body, ""); return *m_body; } + Visibility defaultVisibility() const override; bool isVisibleInContract() const override { - return Declaration::isVisibleInContract() && isOrdinary(); + return isOrdinary() && Declaration::isVisibleInContract(); } bool isVisibleViaContractTypeAccess() const override { - return visibility() >= Visibility::Public; + return isOrdinary() && visibility() >= Visibility::Public; } - bool isPartOfExternalInterface() const override { return isPublic() && isOrdinary(); } + bool isPartOfExternalInterface() const override { return isOrdinary() && isPublic(); } /// @returns the external signature of the function /// That consists of the name of the function followed by the types of the @@ -897,13 +896,16 @@ public: m_isIndexed(_isIndexed), m_mutability(_mutability), m_overrides(std::move(_overrides)), - m_location(_referenceLocation) {} + m_location(_referenceLocation) + { + solAssert(m_typeName, ""); + } void accept(ASTVisitor& _visitor) override; void accept(ASTConstVisitor& _visitor) const override; - TypeName* typeName() const { return m_typeName.get(); } + TypeName const& typeName() const { return *m_typeName; } ASTPointer const& value() const { return m_value; } bool isLValue() const override; @@ -929,6 +931,7 @@ public: /// @returns true if this variable is a parameter or return parameter of an internal function /// or a function type of internal visibility. bool isInternalCallableParameter() const; + /// @returns true if this variable is the parameter of a constructor. bool isConstructorParameter() const; /// @returns true iff this variable is a parameter(or return parameter of a library function bool isLibraryFunctionParameter() const; @@ -965,7 +968,7 @@ protected: Visibility defaultVisibility() const override { return Visibility::Internal; } private: - ASTPointer m_typeName; ///< can be empty ("var") + ASTPointer m_typeName; /// Initially assigned value, can be missing. For local variables, this is stored inside /// VariableDeclarationStatement and not here. ASTPointer m_value; @@ -2087,8 +2090,6 @@ public: None = static_cast(Token::Illegal), Wei = static_cast(Token::SubWei), Gwei = static_cast(Token::SubGwei), - Szabo = static_cast(Token::SubSzabo), - Finney = static_cast(Token::SubFinney), Ether = static_cast(Token::SubEther), Second = static_cast(Token::SubSecond), Minute = static_cast(Token::SubMinute), diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h index 272bf6440..04f661020 100644 --- a/libsolidity/ast/ASTAnnotations.h +++ b/libsolidity/ast/ASTAnnotations.h @@ -139,6 +139,9 @@ struct StructDeclarationAnnotation: TypeDeclarationAnnotation /// recursion immediately raises an error. /// Will be filled in by the DeclarationTypeChecker. std::optional recursive; + /// Whether the struct contains a mapping type, either directly or, indirectly inside another + /// struct or an array. + std::optional containsNestedMapping; }; struct ContractDefinitionAnnotation: TypeDeclarationAnnotation, StructurallyDocumentedAnnotation diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp index 39b92bbb4..d04fcbe0b 100644 --- a/libsolidity/ast/ASTJsonConverter.cpp +++ b/libsolidity/ast/ASTJsonConverter.cpp @@ -203,7 +203,7 @@ Json::Value ASTJsonConverter::inlineAssemblyIdentifierToJson(pairabstract() ? Visibility::Internal : Visibility::Public; + else + visibility = _node.visibility(); + std::vector> attributes = { make_pair("name", _node.name()), make_pair("documentation", _node.documentation() ? toJson(*_node.documentation()) : Json::nullValue), make_pair("kind", TokenTraits::toString(_node.kind())), make_pair("stateMutability", stateMutabilityToString(_node.stateMutability())), - make_pair("visibility", Declaration::visibilityToString(_node.visibility())), + make_pair("visibility", Declaration::visibilityToString(visibility)), make_pair("virtual", _node.markedVirtual()), make_pair("overrides", _node.overrides() ? toJson(*_node.overrides()) : Json::nullValue), make_pair("parameters", toJson(_node.parameterList())), @@ -366,6 +372,7 @@ bool ASTJsonConverter::visit(FunctionDefinition const& _node) make_pair("implemented", _node.isImplemented()), make_pair("scope", idOrNull(_node.scope())) }; + if (_node.isPartOfExternalInterface()) attributes.emplace_back("functionSelector", _node.externalIdentifierHex()); if (!_node.annotation().baseFunctions.empty()) @@ -380,7 +387,7 @@ bool ASTJsonConverter::visit(VariableDeclaration const& _node) { std::vector> attributes = { make_pair("name", _node.name()), - make_pair("typeName", toJsonOrNull(_node.typeName())), + make_pair("typeName", toJson(_node.typeName())), make_pair("constant", _node.isConstant()), make_pair("mutability", VariableDeclaration::mutabilityToString(_node.mutability())), make_pair("stateVariable", _node.isStateVariable()), diff --git a/libsolidity/ast/ASTJsonImporter.cpp b/libsolidity/ast/ASTJsonImporter.cpp index 33975d8ca..e3cb8c6fa 100644 --- a/libsolidity/ast/ASTJsonImporter.cpp +++ b/libsolidity/ast/ASTJsonImporter.cpp @@ -400,7 +400,7 @@ ASTPointer ASTJsonImporter::createFunctionDefinition(Json::V return createASTNode( _node, memberAsASTString(_node, "name"), - visibility(_node), + kind == Token::Constructor ? Visibility::Default : visibility(_node), stateMutability(_node), kind, memberAsBool(_node, "virtual"), @@ -886,7 +886,8 @@ ASTPointer ASTJsonImporter::createDocumentation(Json::V Json::Value ASTJsonImporter::member(Json::Value const& _node, string const& _name) { - astAssert(_node.isMember(_name), "Node '" + _node["nodeType"].asString() + "' (id " + _node["id"].asString() + ") is missing field '" + _name + "'."); + if (!_node.isMember(_name)) + return Json::nullValue; return _node[_name]; } @@ -1004,10 +1005,6 @@ Literal::SubDenomination ASTJsonImporter::subdenomination(Json::Value const& _no return Literal::SubDenomination::Wei; else if (subDenStr == "gwei") return Literal::SubDenomination::Gwei; - else if (subDenStr == "szabo") - return Literal::SubDenomination::Szabo; - else if (subDenStr == "finney") - return Literal::SubDenomination::Finney; else if (subDenStr == "ether") return Literal::SubDenomination::Ether; else if (subDenStr == "seconds") diff --git a/libsolidity/ast/AsmJsonImporter.cpp b/libsolidity/ast/AsmJsonImporter.cpp index 3ff280f54..ec5a50e1c 100644 --- a/libsolidity/ast/AsmJsonImporter.cpp +++ b/libsolidity/ast/AsmJsonImporter.cpp @@ -64,7 +64,8 @@ T AsmJsonImporter::createAsmNode(Json::Value const& _node) Json::Value AsmJsonImporter::member(Json::Value const& _node, string const& _name) { - astAssert(_node.isMember(_name), "Node is missing field '" + _name + "'."); + if (!_node.isMember(_name)) + return Json::nullValue; return _node[_name]; } diff --git a/libsolidity/ast/TypeProvider.h b/libsolidity/ast/TypeProvider.h index 1f9ba4329..911eb7b31 100644 --- a/libsolidity/ast/TypeProvider.h +++ b/libsolidity/ast/TypeProvider.h @@ -97,6 +97,7 @@ public: static IntegerType const* uint(unsigned _bits) { return integer(_bits, IntegerType::Modifier::Unsigned); } static IntegerType const* uint256() { return uint(256); } + static IntegerType const* int256() { return integer(256, IntegerType::Modifier::Signed); } static FixedPointType const* fixedPoint(unsigned m, unsigned n, FixedPointType::Modifier _modifier); diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index b382e9803..2c0889dfa 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -417,11 +417,9 @@ MemberList::MemberMap Type::boundFunctions(Type const& _type, ASTNode const& _sc if (auto const* sourceUnit = dynamic_cast(&_scope)) usingForDirectives += ASTNode::filteredNodes(sourceUnit->nodes()); else if (auto const* contract = dynamic_cast(&_scope)) - { - for (ContractDefinition const* contract: contract->annotation().linearizedBaseContracts) - usingForDirectives += contract->usingForDirectives(); - usingForDirectives += ASTNode::filteredNodes(contract->sourceUnit().nodes()); - } + usingForDirectives += + contract->usingForDirectives() + + ASTNode::filteredNodes(contract->sourceUnit().nodes()); else solAssert(false, ""); @@ -570,7 +568,7 @@ bool isValidShiftAndAmountType(Token _operator, Type const& _shiftAmountType) if (_operator == Token::SHR) return false; else if (IntegerType const* otherInt = dynamic_cast(&_shiftAmountType)) - return true; + return !otherInt->isSigned(); else if (RationalNumberType const* otherRat = dynamic_cast(&_shiftAmountType)) return !otherRat->isFractional() && otherRat->integerType() && !otherRat->integerType()->isSigned(); else @@ -954,12 +952,6 @@ tuple RationalNumberType::isValidLiteral(Literal const& _literal case Literal::SubDenomination::Gwei: value *= bigint("1000000000"); break; - case Literal::SubDenomination::Szabo: - value *= bigint("1000000000000"); - break; - case Literal::SubDenomination::Finney: - value *= bigint("1000000000000000"); - break; case Literal::SubDenomination::Ether: value *= bigint("1000000000000000000"); break; @@ -1057,10 +1049,38 @@ TypeResult RationalNumberType::binaryOperatorResult(Token _operator, Type const* { if (_other->category() == Category::Integer || _other->category() == Category::FixedPoint) { - auto commonType = Type::commonType(this, _other); - if (!commonType) - return nullptr; - return commonType->binaryOperatorResult(_operator, _other); + if (isFractional()) + return TypeResult::err("Fractional literals not supported."); + else if (!integerType()) + return TypeResult::err("Literal too large."); + + // Shift and exp are not symmetric, so it does not make sense to swap + // the types as below. As an exception, we always use uint here. + if (TokenTraits::isShiftOp(_operator)) + { + if (!isValidShiftAndAmountType(_operator, *_other)) + return nullptr; + return isNegative() ? TypeProvider::int256() : TypeProvider::uint256(); + } + else if (Token::Exp == _operator) + { + if (auto const* otherIntType = dynamic_cast(_other)) + { + if (otherIntType->isSigned()) + return TypeResult::err("Exponentiation power is not allowed to be a signed integer type."); + } + else if (dynamic_cast(_other)) + return TypeResult::err("Exponent is fractional."); + + return isNegative() ? TypeProvider::int256() : TypeProvider::uint256(); + } + else + { + auto commonType = Type::commonType(this, _other); + if (!commonType) + return nullptr; + return commonType->binaryOperatorResult(_operator, _other); + } } else if (_other->category() != category()) return nullptr; @@ -2032,6 +2052,20 @@ TypeResult ArrayType::interfaceType(bool _inLibrary) const return result; } +Type const* ArrayType::finalBaseType(bool _breakIfDynamicArrayType) const +{ + Type const* finalBaseType = this; + + while (auto arrayType = dynamic_cast(finalBaseType)) + { + if (_breakIfDynamicArrayType && arrayType->isDynamicallySized()) + break; + finalBaseType = arrayType->baseType(); + } + + return finalBaseType; +} + u256 ArrayType::memoryDataSize() const { solAssert(!isDynamicallySized(), ""); @@ -2260,7 +2294,7 @@ unsigned StructType::calldataEncodedSize(bool) const unsigned size = 0; for (auto const& member: members(nullptr)) { - solAssert(member.type->canLiveOutsideStorage(), ""); + solAssert(!member.type->containsNestedMapping(), ""); // Struct members are always padded. size += member.type->calldataEncodedSize(); } @@ -2275,7 +2309,7 @@ unsigned StructType::calldataEncodedTailSize() const unsigned size = 0; for (auto const& member: members(nullptr)) { - solAssert(member.type->canLiveOutsideStorage(), ""); + solAssert(!member.type->containsNestedMapping(), ""); // Struct members are always padded. size += member.type->calldataHeadSize(); } @@ -2287,7 +2321,7 @@ unsigned StructType::calldataOffsetOfMember(std::string const& _member) const unsigned offset = 0; for (auto const& member: members(nullptr)) { - solAssert(member.type->canLiveOutsideStorage(), ""); + solAssert(!member.type->containsNestedMapping(), ""); if (member.name == _member) return offset; // Struct members are always padded. @@ -2332,6 +2366,42 @@ u256 StructType::storageSize() const return max(1, members(nullptr).storageSize()); } +bool StructType::containsNestedMapping() const +{ + if (!m_struct.annotation().containsNestedMapping.has_value()) + { + bool hasNestedMapping = false; + + util::BreadthFirstSearch breadthFirstSearch{{&m_struct}}; + + breadthFirstSearch.run( + [&](StructDefinition const* _struct, auto&& _addChild) + { + for (auto const& member: _struct->members()) + { + TypePointer memberType = member->annotation().type; + solAssert(memberType, ""); + + if (auto arrayType = dynamic_cast(memberType)) + memberType = arrayType->finalBaseType(false); + + if (dynamic_cast(memberType)) + { + hasNestedMapping = true; + breadthFirstSearch.abort(); + } + else if (auto structType = dynamic_cast(memberType)) + _addChild(&structType->structDefinition()); + } + + }); + + m_struct.annotation().containsNestedMapping = hasNestedMapping; + } + + return m_struct.annotation().containsNestedMapping.value(); +} + string StructType::toString(bool _short) const { string ret = "struct " + m_struct.annotation().canonicalName; @@ -2347,10 +2417,7 @@ MemberList::MemberMap StructType::nativeMembers(ASTNode const*) const { TypePointer type = variable->annotation().type; solAssert(type, ""); - // If we are not in storage, skip all members that cannot live outside of storage, - // ex. mappings and array of mappings - if (location() != DataLocation::Storage && !type->canLiveOutsideStorage()) - continue; + solAssert(!(location() != DataLocation::Storage && type->containsNestedMapping()), ""); members.emplace_back( variable->name(), copyForLocationIfReference(type), @@ -2519,10 +2586,9 @@ FunctionTypePointer StructType::constructorType() const { TypePointers paramTypes; strings paramNames; + solAssert(!containsNestedMapping(), ""); for (auto const& member: members(nullptr)) { - if (!member.type->canLiveOutsideStorage()) - continue; paramNames.push_back(member.name); paramTypes.push_back(TypeProvider::withLocationIfReference(DataLocation::Memory, member.type)); } @@ -2556,20 +2622,12 @@ u256 StructType::memoryOffsetOfMember(string const& _name) const TypePointers StructType::memoryMemberTypes() const { + solAssert(!containsNestedMapping(), ""); TypePointers types; for (ASTPointer const& variable: m_struct.members()) - if (variable->annotation().type->canLiveOutsideStorage()) - types.push_back(TypeProvider::withLocationIfReference(DataLocation::Memory, variable->annotation().type)); - return types; -} + types.push_back(TypeProvider::withLocationIfReference(DataLocation::Memory, variable->annotation().type)); -set StructType::membersMissingInMemory() const -{ - set missing; - for (ASTPointer const& variable: m_struct.members()) - if (!variable->annotation().type->canLiveOutsideStorage()) - missing.insert(variable->name()); - return missing; + return types; } vector> StructType::makeStackItems() const @@ -3716,7 +3774,10 @@ TypeResult MappingType::interfaceType(bool _inLibrary) const } } else - return TypeResult::err("Only libraries are allowed to use the mapping type in public or external functions."); + return TypeResult::err( + "Types containing (nested) mappings can only be parameters or " + "return variables of internal or library functions." + ); return this; } diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index 02f5c9f5f..5983fe941 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -271,7 +271,11 @@ public: /// Returns true if the type can be stored in storage. virtual bool canBeStored() const { return true; } /// Returns false if the type cannot live outside the storage, i.e. if it includes some mapping. - virtual bool canLiveOutsideStorage() const { return true; } + virtual bool containsNestedMapping() const + { + solAssert(nameable(), "Called for a non nameable type."); + return false; + } /// Returns true if the type can be stored as a value (as opposed to a reference) on the stack, /// i.e. it behaves differently in lvalue context and in value context. virtual bool isValueType() const { return false; } @@ -561,7 +565,6 @@ public: bool operator==(Type const& _other) const override; bool canBeStored() const override { return false; } - bool canLiveOutsideStorage() const override { return false; } std::string toString(bool _short) const override; u256 literalValue(Literal const* _literal) const override; @@ -622,7 +625,6 @@ public: bool operator==(Type const& _other) const override; bool canBeStored() const override { return false; } - bool canLiveOutsideStorage() const override { return false; } std::string toString(bool) const override; TypePointer mobileType() const override; @@ -794,8 +796,9 @@ public: bool isDynamicallyEncoded() const override; bigint storageSizeUpperBound() const override; u256 storageSize() const override; - bool canLiveOutsideStorage() const override { return m_baseType->canLiveOutsideStorage(); } + bool containsNestedMapping() const override { return m_baseType->containsNestedMapping(); } bool nameable() const override { return true; } + std::string toString(bool _short) const override; std::string canonicalName() const override; std::string signatureInExternalFunction(bool _structsByName) const override; @@ -811,6 +814,7 @@ public: /// @returns true if this is a string bool isString() const { return m_arrayKind == ArrayKind::String; } Type const* baseType() const { solAssert(!!m_baseType, ""); return m_baseType; } + Type const* finalBaseType(bool breakIfDynamicArrayType) const; u256 const& length() const { return m_length; } u256 memoryDataSize() const override; @@ -855,7 +859,6 @@ public: unsigned calldataEncodedTailSize() const override { return 32; } bool isDynamicallySized() const override { return true; } bool isDynamicallyEncoded() const override { return true; } - bool canLiveOutsideStorage() const override { return m_arrayType.canLiveOutsideStorage(); } std::string toString(bool _short) const override; TypePointer mobileType() const override; @@ -896,7 +899,6 @@ public: } unsigned storageBytes() const override { solAssert(!isSuper(), ""); return 20; } bool leftAligned() const override { solAssert(!isSuper(), ""); return false; } - bool canLiveOutsideStorage() const override { return !isSuper(); } bool isValueType() const override { return !isSuper(); } bool nameable() const override { return !isSuper(); } std::string toString(bool _short) const override; @@ -959,7 +961,7 @@ public: u256 memoryDataSize() const override; bigint storageSizeUpperBound() const override; u256 storageSize() const override; - bool canLiveOutsideStorage() const override { return true; } + bool containsNestedMapping() const override; bool nameable() const override { return true; } std::string toString(bool _short) const override; @@ -989,8 +991,6 @@ public: /// @returns the vector of types of members available in memory. TypePointers memoryMemberTypes() const; - /// @returns the set of all members that are removed in the memory version (typically mappings). - std::set membersMissingInMemory() const; void clearCache() const override; @@ -1021,7 +1021,6 @@ public: } unsigned storageBytes() const override; bool leftAligned() const override { return false; } - bool canLiveOutsideStorage() const override { return true; } std::string toString(bool _short) const override; std::string canonicalName() const override; bool isValueType() const override { return true; } @@ -1061,7 +1060,6 @@ public: std::string toString(bool) const override; bool canBeStored() const override { return false; } u256 storageSize() const override; - bool canLiveOutsideStorage() const override { return false; } bool hasSimpleZeroValueInMemory() const override { return false; } TypePointer mobileType() const override; /// Converts components to their temporary types and performs some wildcard matching. @@ -1232,7 +1230,6 @@ public: unsigned storageBytes() const override; bool isValueType() const override { return true; } bool nameable() const override; - bool canLiveOutsideStorage() const override { return m_kind == Kind::Internal || m_kind == Kind::External; } bool hasSimpleZeroValueInMemory() const override { return false; } MemberList::MemberMap nativeMembers(ASTNode const* _currentScope) const override; TypePointer encodingType() const override; @@ -1365,7 +1362,7 @@ public: bool operator==(Type const& _other) const override; std::string toString(bool _short) const override; std::string canonicalName() const override; - bool canLiveOutsideStorage() const override { return false; } + bool containsNestedMapping() const override { return true; } TypeResult binaryOperatorResult(Token, Type const*) const override { return nullptr; } Type const* encodingType() const override; TypeResult interfaceType(bool _inLibrary) const override; @@ -1400,7 +1397,6 @@ public: bool operator==(Type const& _other) const override; bool canBeStored() const override { return false; } u256 storageSize() const override; - bool canLiveOutsideStorage() const override { return false; } bool hasSimpleZeroValueInMemory() const override { solAssert(false, ""); } std::string toString(bool _short) const override { return "type(" + m_actualType->toString(_short) + ")"; } MemberList::MemberMap nativeMembers(ASTNode const* _currentScope) const override; @@ -1426,7 +1422,6 @@ public: TypeResult binaryOperatorResult(Token, Type const*) const override { return nullptr; } bool canBeStored() const override { return false; } u256 storageSize() const override; - bool canLiveOutsideStorage() const override { return false; } bool hasSimpleZeroValueInMemory() const override { solAssert(false, ""); } std::string richIdentifier() const override; bool operator==(Type const& _other) const override; @@ -1453,7 +1448,6 @@ public: std::string richIdentifier() const override; bool operator==(Type const& _other) const override; bool canBeStored() const override { return false; } - bool canLiveOutsideStorage() const override { return true; } bool hasSimpleZeroValueInMemory() const override { solAssert(false, ""); } MemberList::MemberMap nativeMembers(ASTNode const*) const override; @@ -1493,7 +1487,6 @@ public: std::string richIdentifier() const override; bool operator==(Type const& _other) const override; bool canBeStored() const override { return false; } - bool canLiveOutsideStorage() const override { return true; } bool hasSimpleZeroValueInMemory() const override { solAssert(false, ""); } MemberList::MemberMap nativeMembers(ASTNode const*) const override; @@ -1526,7 +1519,6 @@ public: TypeResult binaryOperatorResult(Token, Type const*) const override { return nullptr; } unsigned calldataEncodedSize(bool) const override { return 32; } bool canBeStored() const override { return false; } - bool canLiveOutsideStorage() const override { return false; } bool isValueType() const override { return true; } bool hasSimpleZeroValueInMemory() const override { solAssert(false, ""); } std::string toString(bool) const override { return "inaccessible dynamic type"; } diff --git a/libsolidity/codegen/ABIFunctions.cpp b/libsolidity/codegen/ABIFunctions.cpp index ef5948069..f640c2180 100644 --- a/libsolidity/codegen/ABIFunctions.cpp +++ b/libsolidity/codegen/ABIFunctions.cpp @@ -861,8 +861,7 @@ string ABIFunctions::abiEncodingFunctionStruct( for (auto const& member: _to.members(nullptr)) { solAssert(member.type, ""); - if (!member.type->canLiveOutsideStorage()) - continue; + solAssert(!member.type->containsNestedMapping(), ""); TypePointer memberTypeTo = member.type->fullEncodingType(_options.encodeAsLibraryTypes, true, false); solUnimplementedAssert(memberTypeTo, "Encoding type \"" + member.type->toString() + "\" not yet implemented."); auto memberTypeFrom = _from.memberType(member.name); @@ -1341,7 +1340,7 @@ string ABIFunctions::abiDecodingFunctionStruct(StructType const& _type, bool _fr for (auto const& member: _type.members(nullptr)) { solAssert(member.type, ""); - solAssert(member.type->canLiveOutsideStorage(), ""); + solAssert(!member.type->containsNestedMapping(), ""); auto decodingType = member.type->decodingType(); solAssert(decodingType, ""); bool dynamic = decodingType->isDynamicallyEncoded(); diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index f2db90569..dfc7cd233 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -1080,8 +1080,7 @@ void CompilerUtils::convertType( // stack: for (auto const& member: typeOnStack->members(nullptr)) { - if (!member.type->canLiveOutsideStorage()) - continue; + solAssert(!member.type->containsNestedMapping(), ""); pair const& offsets = typeOnStack->storageOffsetsOfMember(member.name); _context << offsets.first << Instruction::DUP3 << Instruction::ADD; _context << u256(offsets.second); diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 566db8517..428f59993 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -1915,10 +1915,6 @@ void ExpressionCompiler::endVisit(Identifier const& _identifier) if (!dynamic_cast(*magicVar->type()).isSuper()) m_context << Instruction::ADDRESS; break; - case Type::Category::Integer: - // "now" - m_context << Instruction::TIMESTAMP; - break; default: break; } diff --git a/libsolidity/codegen/LValue.cpp b/libsolidity/codegen/LValue.cpp index 777196767..f4fdd0cbb 100644 --- a/libsolidity/codegen/LValue.cpp +++ b/libsolidity/codegen/LValue.cpp @@ -356,13 +356,13 @@ void StorageItem::storeValue(Type const& _sourceType, SourceLocation const& _loc structType.structDefinition() == sourceType.structDefinition(), "Struct assignment with conversion." ); + solAssert(!structType.containsNestedMapping(), ""); solAssert(sourceType.location() != DataLocation::CallData, "Structs in calldata not supported."); for (auto const& member: structType.members(nullptr)) { // assign each member that can live outside of storage TypePointer const& memberType = member.type; - if (!memberType->canLiveOutsideStorage()) - continue; + solAssert(memberType->nameable(), ""); TypePointer sourceMemberType = sourceType.memberType(member.name); if (sourceType.location() == DataLocation::Storage) { diff --git a/libsolidity/interface/ABI.cpp b/libsolidity/interface/ABI.cpp index 512bf9b13..bed432cd6 100644 --- a/libsolidity/interface/ABI.cpp +++ b/libsolidity/interface/ABI.cpp @@ -75,7 +75,7 @@ Json::Value ABI::generate(ContractDefinition const& _contractDef) abi.emplace(std::move(method)); } FunctionDefinition const* constructor = _contractDef.constructor(); - if (constructor && constructor->visibility() >= Visibility::Public) + if (constructor && !_contractDef.abstract()) { FunctionType constrType(*constructor); FunctionType const* externalFunctionType = constrType.interfaceFunctionType(); diff --git a/libsolidity/interface/Natspec.cpp b/libsolidity/interface/Natspec.cpp index 67ef6f17f..618dda363 100644 --- a/libsolidity/interface/Natspec.cpp +++ b/libsolidity/interface/Natspec.cpp @@ -47,8 +47,12 @@ Json::Value Natspec::userDocumentation(ContractDefinition const& _contractDef) { string const value = extractDoc(constructorDefinition->annotation().docTags, "notice"); if (!value.empty()) + { // add the constructor, only if we have any documentation to add - methods["constructor"] = Json::Value(value); + Json::Value user; + user["notice"] = Json::Value(value); + methods["constructor"] = user; + } } string notice = extractDoc(_contractDef.annotation().docTags, "notice"); diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index ce08bef60..16ed2ae37 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -465,14 +465,6 @@ StateMutability Parser::parseStateMutability() case Token::Pure: stateMutability = StateMutability::Pure; break; - case Token::Constant: - stateMutability = StateMutability::View; - parserError( - 7698_error, - "The state mutability modifier \"constant\" was removed in version 0.5.0. " - "Use \"view\" or \"pure\" instead." - ); - break; default: solAssert(false, "Invalid state mutability specifier."); } @@ -686,19 +678,13 @@ ASTPointer Parser::parseVariableDeclaration( RecursionGuard recursionGuard(*this); ASTNodeFactory nodeFactory = _lookAheadArrayType ? ASTNodeFactory(*this, _lookAheadArrayType) : ASTNodeFactory(*this); - ASTPointer type; + ASTPointer const documentation = parseStructuredDocumentation(); - if (_lookAheadArrayType) - type = _lookAheadArrayType; - else - { - type = parseTypeName(_options.allowVar); - if (type != nullptr) - nodeFactory.setEndPositionFromNode(type); - } + ASTPointer type = _lookAheadArrayType ? _lookAheadArrayType : parseTypeName(); + nodeFactory.setEndPositionFromNode(type); if (!_options.isStateVariable && documentation != nullptr) - parserWarning(2837_error, "Only state variables can have a docstring. This will be disallowed in 0.7.0."); + parserError(2837_error, "Only state variables can have a docstring."); if (dynamic_cast(type.get()) && _options.isStateVariable && m_scanner->currentToken() == Token::LBrace) fatalParserError( @@ -762,8 +748,6 @@ ASTPointer Parser::parseVariableDeclaration( { if (location != VariableDeclaration::Location::Unspecified) parserError(3548_error, "Location already specified."); - else if (!type) - parserError(7439_error, "Location specifier needs explicit type name."); else { switch (token) @@ -790,10 +774,7 @@ ASTPointer Parser::parseVariableDeclaration( } if (_options.allowEmptyName && m_scanner->currentToken() != Token::Identifier) - { identifier = make_shared(""); - solAssert(!_options.allowVar, ""); // allowEmptyName && allowVar makes no sense - } else { nodeFactory.markEndPosition(); @@ -917,7 +898,7 @@ ASTPointer Parser::parseUsingDirective() if (m_scanner->currentToken() == Token::Mul) m_scanner->next(); else - typeName = parseTypeName(false); + typeName = parseTypeName(); nodeFactory.markEndPosition(); expectToken(Token::Semicolon); return nodeFactory.createNode(library, typeName); @@ -980,7 +961,7 @@ ASTPointer Parser::parseTypeNameSuffix(ASTPointer type, ASTN return type; } -ASTPointer Parser::parseTypeName(bool _allowVar) +ASTPointer Parser::parseTypeName() { RecursionGuard recursionGuard(*this); ASTNodeFactory nodeFactory(*this); @@ -998,7 +979,7 @@ ASTPointer Parser::parseTypeName(bool _allowVar) auto stateMutability = elemTypeName.token() == Token::Address ? optional{StateMutability::NonPayable} : nullopt; - if (TokenTraits::isStateMutabilitySpecifier(m_scanner->currentToken(), false)) + if (TokenTraits::isStateMutabilitySpecifier(m_scanner->currentToken())) { if (elemTypeName.token() == Token::Address) { @@ -1013,12 +994,6 @@ ASTPointer Parser::parseTypeName(bool _allowVar) } type = nodeFactory.createNode(elemTypeName, stateMutability); } - else if (token == Token::Var) - { - if (!_allowVar) - parserError(7059_error, "Expected explicit type name."); - m_scanner->next(); - } else if (token == Token::Function) type = parseFunctionType(); else if (token == Token::Mapping) @@ -1028,9 +1003,10 @@ ASTPointer Parser::parseTypeName(bool _allowVar) else fatalParserError(3546_error, "Expected type name"); - if (type) - // Parse "[...]" postfixes for arrays. - type = parseTypeNameSuffix(type, nodeFactory); + solAssert(type, ""); + // Parse "[...]" postfixes for arrays. + type = parseTypeNameSuffix(type, nodeFactory); + return type; } @@ -1071,8 +1047,7 @@ ASTPointer Parser::parseMapping() else fatalParserError(1005_error, "Expected elementary type name or identifier for mapping key type"); expectToken(Token::Arrow); - bool const allowVar = false; - ASTPointer valueType = parseTypeName(allowVar); + ASTPointer valueType = parseTypeName(); nodeFactory.markEndPosition(); expectToken(Token::RParen); return nodeFactory.createNode(keyType, valueType); @@ -1553,53 +1528,14 @@ ASTPointer Parser::parseVariableDeclarationStateme ASTNodeFactory nodeFactory(*this); if (_lookAheadArrayType) nodeFactory.setLocation(_lookAheadArrayType->location()); + + VarDeclParserOptions options; + options.allowLocationSpecifier = true; vector> variables; + variables.emplace_back(parseVariableDeclaration(options, _lookAheadArrayType)); + nodeFactory.setEndPositionFromNode(variables.back()); + ASTPointer value; - if ( - !_lookAheadArrayType && - m_scanner->currentToken() == Token::Var && - m_scanner->peekNextToken() == Token::LParen - ) - { - // Parse `var (a, b, ,, c) = ...` into a single VariableDeclarationStatement with multiple variables. - m_scanner->next(); - m_scanner->next(); - if (m_scanner->currentToken() != Token::RParen) - while (true) - { - ASTPointer var; - if ( - m_scanner->currentToken() != Token::Comma && - m_scanner->currentToken() != Token::RParen - ) - { - ASTNodeFactory varDeclNodeFactory(*this); - varDeclNodeFactory.markEndPosition(); - ASTPointer name = expectIdentifierToken(); - var = varDeclNodeFactory.createNode( - ASTPointer(), - name, - ASTPointer(), - Visibility::Default - ); - } - variables.push_back(var); - if (m_scanner->currentToken() == Token::RParen) - break; - else - expectToken(Token::Comma); - } - nodeFactory.markEndPosition(); - m_scanner->next(); - } - else - { - VarDeclParserOptions options; - options.allowVar = true; - options.allowLocationSpecifier = true; - variables.push_back(parseVariableDeclaration(options, _lookAheadArrayType)); - nodeFactory.setEndPositionFromNode(variables.back()); - } if (m_scanner->currentToken() == Token::Assign) { m_scanner->next(); @@ -1713,11 +1649,8 @@ ASTPointer Parser::parseLeftHandSideExpression( else if (m_scanner->currentToken() == Token::New) { expectToken(Token::New); - ASTPointer typeName(parseTypeName(false)); - if (typeName) - nodeFactory.setEndPositionFromNode(typeName); - else - nodeFactory.markEndPosition(); + ASTPointer typeName(parseTypeName()); + nodeFactory.setEndPositionFromNode(typeName); expression = nodeFactory.createNode(typeName); } else if (m_scanner->currentToken() == Token::Payable) @@ -1826,16 +1759,11 @@ ASTPointer Parser::parsePrimaryExpression() expression = nodeFactory.createNode(token, getLiteralAndAdvance()); break; case Token::Number: - if ( - (m_scanner->peekNextToken() == Token::Identifier && m_scanner->peekLiteral() == "gwei") || - TokenTraits::isEtherSubdenomination(m_scanner->peekNextToken()) - ) + if (TokenTraits::isEtherSubdenomination(m_scanner->peekNextToken())) { ASTPointer literal = getLiteralAndAdvance(); nodeFactory.markEndPosition(); - Token actualToken = m_scanner->currentToken() == Token::Identifier ? Token::SubGwei : m_scanner->currentToken(); - - Literal::SubDenomination subdenomination = static_cast(actualToken); + Literal::SubDenomination subdenomination = static_cast(m_scanner->currentToken()); m_scanner->next(); expression = nodeFactory.createNode(token, literal, subdenomination); } @@ -2062,7 +1990,7 @@ Parser::LookAheadInfo Parser::peekStatementType() const Token token(m_scanner->currentToken()); bool mightBeTypeName = (TokenTraits::isElementaryTypeName(token) || token == Token::Identifier); - if (token == Token::Mapping || token == Token::Function || token == Token::Var) + if (token == Token::Mapping || token == Token::Function) return LookAheadInfo::VariableDeclaration; if (mightBeTypeName) { @@ -2071,7 +1999,7 @@ Parser::LookAheadInfo Parser::peekStatementType() const // kind of statement. This means, for example, that we do not allow type expressions of the form // ``address payable;``. // If we want to change this in the future, we need to consider another scanner token here. - if (TokenTraits::isElementaryTypeName(token) && TokenTraits::isStateMutabilitySpecifier(next, false)) + if (TokenTraits::isElementaryTypeName(token) && TokenTraits::isStateMutabilitySpecifier(next)) return LookAheadInfo::VariableDeclaration; if (next == Token::Identifier || TokenTraits::isLocationSpecifier(next)) return LookAheadInfo::VariableDeclaration; diff --git a/libsolidity/parsing/Parser.h b/libsolidity/parsing/Parser.h index f84cb7041..b769545da 100644 --- a/libsolidity/parsing/Parser.h +++ b/libsolidity/parsing/Parser.h @@ -58,7 +58,6 @@ private: // https://stackoverflow.com/questions/17430377 VarDeclParserOptions() {} - bool allowVar = false; bool isStateVariable = false; bool allowIndexed = false; bool allowEmptyName = false; @@ -108,7 +107,7 @@ private: ASTPointer parseIdentifier(); ASTPointer parseUserDefinedTypeName(); ASTPointer parseTypeNameSuffix(ASTPointer type, ASTNodeFactory& nodeFactory); - ASTPointer parseTypeName(bool _allowVar); + ASTPointer parseTypeName(); ASTPointer parseFunctionType(); ASTPointer parseMapping(); ASTPointer parseParameterList( diff --git a/libsolutil/JSON.cpp b/libsolutil/JSON.cpp index b3635c877..81ef7f76b 100644 --- a/libsolutil/JSON.cpp +++ b/libsolutil/JSON.cpp @@ -88,8 +88,31 @@ bool parse(Json::CharReaderBuilder& _builder, string const& _input, Json::Value& return reader->parse(_input.c_str(), _input.c_str() + _input.length(), &_json, _errs); } +/// Takes a JSON value (@ _json) and removes all its members with value 'null' recursively. +void removeNullMembersHelper(Json::Value& _json) +{ + if (_json.type() == Json::ValueType::arrayValue) + for (auto& child: _json) + removeNullMembersHelper(child); + else if (_json.type() == Json::ValueType::objectValue) + for (auto const& key: _json.getMemberNames()) + { + Json::Value& value = _json[key]; + if (value.isNull()) + _json.removeMember(key); + else + removeNullMembersHelper(value); + } +} + } // end anonymous namespace +Json::Value removeNullMembers(Json::Value _json) +{ + removeNullMembersHelper(_json); + return _json; +} + string jsonPrettyPrint(Json::Value const& _input) { static map settings{{"indentation", " "}, {"enableYAMLCompatibility", true}}; diff --git a/libsolutil/JSON.h b/libsolutil/JSON.h index 5328a3faf..485aa600e 100644 --- a/libsolutil/JSON.h +++ b/libsolutil/JSON.h @@ -29,6 +29,9 @@ namespace solidity::util { +/// Removes members with null value recursively from (@a _json). +Json::Value removeNullMembers(Json::Value _json); + /// Serialise the JSON object (@a _input) with indentation std::string jsonPrettyPrint(Json::Value const& _input); diff --git a/libyul/AsmAnalysis.cpp b/libyul/AsmAnalysis.cpp index 934cff0a4..2c7a4b940 100644 --- a/libyul/AsmAnalysis.cpp +++ b/libyul/AsmAnalysis.cpp @@ -209,7 +209,10 @@ void AsmAnalyzer::operator()(VariableDeclaration const& _varDecl) m_currentScope->insideFunction() ); for (auto const& variable: _varDecl.variables) + { + expectValidIdentifier(variable.name, variable.location); expectValidType(variable.type, variable.location); + } if (_varDecl.value) { @@ -249,11 +252,13 @@ void AsmAnalyzer::operator()(VariableDeclaration const& _varDecl) void AsmAnalyzer::operator()(FunctionDefinition const& _funDef) { yulAssert(!_funDef.name.empty(), ""); + expectValidIdentifier(_funDef.name, _funDef.location); Block const* virtualBlock = m_info.virtualBlocks.at(&_funDef).get(); yulAssert(virtualBlock, ""); Scope& varScope = scope(virtualBlock); for (auto const& var: _funDef.parameters + _funDef.returnVariables) { + expectValidIdentifier(var.name, var.location); expectValidType(var.type, var.location); m_activeVariables.insert(&std::get(varScope.identifiers.at(var.name))); } @@ -529,6 +534,26 @@ Scope& AsmAnalyzer::scope(Block const* _block) return *scopePtr; } +void AsmAnalyzer::expectValidIdentifier(YulString _identifier, SourceLocation const& _location) +{ + // NOTE: the leading dot case is handled by the parser not allowing it. + + if (boost::ends_with(_identifier.str(), ".")) + m_errorReporter.syntaxError( + 3384_error, + _location, + "\"" + _identifier.str() + "\" is not a valid identifier (ends with a dot)." + ); + + if (_identifier.str().find("..") != std::string::npos) + m_errorReporter.syntaxError( + 7771_error, + _location, + "\"" + _identifier.str() + "\" is not a valid identifier (contains consecutive dots)." + ); + +} + void AsmAnalyzer::expectValidType(YulString _type, SourceLocation const& _location) { if (!m_dialect.types.count(_type)) @@ -611,13 +636,15 @@ bool AsmAnalyzer::validateInstructions(evmasm::Instruction _instr, SourceLocatio errorForVM(7110_error, "only available for Constantinople-compatible"); else if (_instr == evmasm::Instruction::CHAINID && !m_evmVersion.hasChainID()) errorForVM(1561_error, "only available for Istanbul-compatible"); + else if (_instr == evmasm::Instruction::SELFBALANCE && !m_evmVersion.hasSelfBalance()) + errorForVM(7721_error, "only available for Istanbul-compatible"); else if (_instr == evmasm::Instruction::PC) - m_errorReporter.warning( + m_errorReporter.error( 2450_error, + Error::Type::SyntaxError, _location, - "The \"" + - boost::to_lower_copy(instructionInfo(_instr).name) + - "\" instruction is deprecated and will be removed in the next breaking release." + "PC instruction is a low-level EVM feature. " + "Because of that PC is disallowed in strict assembly." ); else if (_instr == evmasm::Instruction::SELFBALANCE && !m_evmVersion.hasSelfBalance()) errorForVM(3672_error, "only available for Istanbul-compatible"); diff --git a/libyul/AsmAnalysis.h b/libyul/AsmAnalysis.h index 552191c4d..9906c66e2 100644 --- a/libyul/AsmAnalysis.h +++ b/libyul/AsmAnalysis.h @@ -108,6 +108,7 @@ private: void checkAssignment(Identifier const& _variable, YulString _valueType); Scope& scope(Block const* _block); + void expectValidIdentifier(YulString _identifier, langutil::SourceLocation const& _location); void expectValidType(YulString _type, langutil::SourceLocation const& _location); void expectType(YulString _expectedType, YulString _givenType, langutil::SourceLocation const& _location); diff --git a/libyul/backends/wasm/EVMToEwasmTranslator.cpp b/libyul/backends/wasm/EVMToEwasmTranslator.cpp index dc180b240..4495ea13b 100644 --- a/libyul/backends/wasm/EVMToEwasmTranslator.cpp +++ b/libyul/backends/wasm/EVMToEwasmTranslator.cpp @@ -1024,11 +1024,6 @@ function sstore(x1, x2, x3, x4, y1, y2, y3, y4) { eth.storageStore(0:i32, 32:i32) } -// Needed? -function pc() -> z1, z2, z3, z4 { - // TODO implement - unreachable() -} function gas() -> z1, z2, z3, z4 { z4 := eth.getGasLeft() } diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 412d7f094..8e8abf4e5 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -442,7 +442,7 @@ void CommandLineInterface::handleABI(string const& _contract) if (!m_args.count(g_argAbi)) return; - string data = jsonCompactPrint(m_compiler->contractABI(_contract)); + string data = jsonCompactPrint(removeNullMembers(m_compiler->contractABI(_contract))); if (m_args.count(g_argOutputDir)) createFile(m_compiler->filesystemFriendlyName(_contract) + ".abi", data); else @@ -454,7 +454,7 @@ void CommandLineInterface::handleStorageLayout(string const& _contract) if (!m_args.count(g_argStorageLayout)) return; - string data = jsonCompactPrint(m_compiler->storageLayout(_contract)); + string data = jsonCompactPrint(removeNullMembers(m_compiler->storageLayout(_contract))); if (m_args.count(g_argOutputDir)) createFile(m_compiler->filesystemFriendlyName(_contract) + "_storage.json", data); else @@ -483,9 +483,11 @@ void CommandLineInterface::handleNatspec(bool _natspecDev, string const& _contra if (m_args.count(argName)) { std::string output = jsonPrettyPrint( - _natspecDev ? - m_compiler->natspecDev(_contract) : - m_compiler->natspecUser(_contract) + removeNullMembers( + _natspecDev ? + m_compiler->natspecDev(_contract) : + m_compiler->natspecUser(_contract) + ) ); if (m_args.count(g_argOutputDir)) @@ -1561,7 +1563,8 @@ void CommandLineInterface::handleCombinedJSON() } } - string json = m_args.count(g_argPrettyJson) ? jsonPrettyPrint(output) : jsonCompactPrint(output); + string json = m_args.count(g_argPrettyJson) ? jsonPrettyPrint(removeNullMembers(std::move(output))) : + jsonCompactPrint(removeNullMembers(std::move(output))); if (m_args.count(g_argOutputDir)) createJson("combined", json); @@ -1877,7 +1880,7 @@ void CommandLineInterface::outputCompilationResults() { string ret; if (m_args.count(g_argAsmJson)) - ret = jsonPrettyPrint(m_compiler->assemblyJSON(contract)); + ret = jsonPrettyPrint(removeNullMembers(m_compiler->assemblyJSON(contract))); else ret = m_compiler->assemblyString(contract, m_sourceCodes); diff --git a/test/ExecutionFramework.h b/test/ExecutionFramework.h index 56321a119..69fd93a1c 100644 --- a/test/ExecutionFramework.h +++ b/test/ExecutionFramework.h @@ -46,13 +46,9 @@ using rational = boost::rational; /// @NOTE This is not endian-specific; it's just a bunch of bytes. using Address = util::h160; -// The various denominations; here for ease of use where needed within code. -static const u256 wei = 1; -static const u256 shannon = u256("1000000000"); -static const u256 gwei = shannon; -static const u256 szabo = shannon * 1000; -static const u256 finney = szabo * 1000; -static const u256 ether = finney * 1000; +// The ether and gwei denominations; here for ease of use where needed within code. +static const u256 gwei = u256(1) << 9; +static const u256 ether = u256(1) << 18; class ExecutionFramework { @@ -288,7 +284,7 @@ protected: bool m_transactionSuccessful = true; Address m_sender = account(0); Address m_contractAddress; - u256 const m_gasPrice = 100 * szabo; + u256 const m_gasPrice = 10 * gwei; u256 const m_gas = 100000000; bytes m_output; u256 m_gasUsed; diff --git a/test/cmdlineTests/ir_compiler_inheritance_nosubobjects/input.sol b/test/cmdlineTests/ir_compiler_inheritance_nosubobjects/input.sol index 160c4cd1d..8d523bd4d 100644 --- a/test/cmdlineTests/ir_compiler_inheritance_nosubobjects/input.sol +++ b/test/cmdlineTests/ir_compiler_inheritance_nosubobjects/input.sol @@ -2,7 +2,7 @@ pragma solidity >=0.6.0; contract C { - constructor() public {} + constructor() {} } contract D is C { } \ No newline at end of file diff --git a/test/cmdlineTests/message_format_utf8/err b/test/cmdlineTests/message_format_utf8/err index fcd1717b8..c73ed714f 100644 --- a/test/cmdlineTests/message_format_utf8/err +++ b/test/cmdlineTests/message_format_utf8/err @@ -5,10 +5,10 @@ Warning: Source file does not specify required compiler version! --> message_format_utf8/input.sol Warning: Statement has no effect. - --> message_format_utf8/input.sol:2:58: + --> message_format_utf8/input.sol:2:51: | -2 | /* ©©©©ᄅ©©©©© 2017 */ constructor () public { "©©©©ᄅ©©©©©" ; } - | ^^^^^^^^^^^^ +2 | /* ©©©©ᄅ©©©©© 2017 */ constructor () { "©©©©ᄅ©©©©©" ; } + | ^^^^^^^^^^^^ Warning: Statement has no effect. --> message_format_utf8/input.sol:6:25: diff --git a/test/cmdlineTests/message_format_utf8/input.sol b/test/cmdlineTests/message_format_utf8/input.sol index 51585efde..dbeddfa01 100644 --- a/test/cmdlineTests/message_format_utf8/input.sol +++ b/test/cmdlineTests/message_format_utf8/input.sol @@ -1,5 +1,5 @@ contract Foo { -/* ©©©©ᄅ©©©©© 2017 */ constructor () public { "©©©©ᄅ©©©©©" ; } +/* ©©©©ᄅ©©©©© 2017 */ constructor () { "©©©©ᄅ©©©©©" ; } function f() public pure { diff --git a/test/cmdlineTests/optimizer_user_yul/input.sol b/test/cmdlineTests/optimizer_user_yul/input.sol index e61b132e4..f43ccc755 100644 --- a/test/cmdlineTests/optimizer_user_yul/input.sol +++ b/test/cmdlineTests/optimizer_user_yul/input.sol @@ -3,7 +3,7 @@ pragma solidity >=0.0; contract C { - constructor() public payable + constructor() payable { int a; diff --git a/test/cmdlineTests/optimizer_user_yul/output b/test/cmdlineTests/optimizer_user_yul/output index 340d70914..34f35c643 100644 --- a/test/cmdlineTests/optimizer_user_yul/output +++ b/test/cmdlineTests/optimizer_user_yul/output @@ -1,69 +1,69 @@ ======= optimizer_user_yul/input.sol:C ======= EVM assembly: - /* "optimizer_user_yul/input.sol":60:525 contract C... */ + /* "optimizer_user_yul/input.sol":60:518 contract C... */ mstore(0x40, 0x80) - /* "optimizer_user_yul/input.sol":108:113 int a */ + /* "optimizer_user_yul/input.sol":101:106 int a */ 0x00 - /* "optimizer_user_yul/input.sol":188:197 let x,y,z */ + /* "optimizer_user_yul/input.sol":181:190 let x,y,z */ dup1 0x00 dup1 - /* "optimizer_user_yul/input.sol":212:213 1 */ + /* "optimizer_user_yul/input.sol":205:206 1 */ 0x01 - /* "optimizer_user_yul/input.sol":209:210 0 */ + /* "optimizer_user_yul/input.sol":202:203 0 */ 0x00 - /* "optimizer_user_yul/input.sol":202:214 sstore(0, 1) */ + /* "optimizer_user_yul/input.sol":195:207 sstore(0, 1) */ sstore - /* "optimizer_user_yul/input.sol":219:265 for { } sload(4) { } {... */ + /* "optimizer_user_yul/input.sol":212:258 for { } sload(4) { } {... */ tag_3: - /* "optimizer_user_yul/input.sol":233:234 4 */ + /* "optimizer_user_yul/input.sol":226:227 4 */ 0x04 - /* "optimizer_user_yul/input.sol":227:235 sload(4) */ + /* "optimizer_user_yul/input.sol":220:228 sload(4) */ sload - /* "optimizer_user_yul/input.sol":219:265 for { } sload(4) { } {... */ + /* "optimizer_user_yul/input.sol":212:258 for { } sload(4) { } {... */ iszero tag_5 jumpi pop - /* "optimizer_user_yul/input.sol":251:260 exp(x, y) */ + /* "optimizer_user_yul/input.sol":244:253 exp(x, y) */ dup1 dup3 exp - /* "optimizer_user_yul/input.sol":219:265 for { } sload(4) { } {... */ + /* "optimizer_user_yul/input.sol":212:258 for { } sload(4) { } {... */ jump(tag_3) tag_5: - /* "optimizer_user_yul/input.sol":223:226 { } */ + /* "optimizer_user_yul/input.sol":216:219 { } */ pop pop pop - /* "optimizer_user_yul/input.sol":275:276 2 */ + /* "optimizer_user_yul/input.sol":268:269 2 */ 0x02 - /* "optimizer_user_yul/input.sol":270:276 a := 2 */ + /* "optimizer_user_yul/input.sol":263:269 a := 2 */ swap1 pop - /* "optimizer_user_yul/input.sol":376:377 3 */ + /* "optimizer_user_yul/input.sol":369:370 3 */ 0x03 - /* "optimizer_user_yul/input.sol":373:374 2 */ + /* "optimizer_user_yul/input.sol":366:367 2 */ 0x02 - /* "optimizer_user_yul/input.sol":366:378 sstore(2, 3) */ + /* "optimizer_user_yul/input.sol":359:371 sstore(2, 3) */ sstore - /* "optimizer_user_yul/input.sol":383:516 for { } sload(5) { } {... */ + /* "optimizer_user_yul/input.sol":376:509 for { } sload(5) { } {... */ tag_6: - /* "optimizer_user_yul/input.sol":397:398 5 */ + /* "optimizer_user_yul/input.sol":390:391 5 */ 0x05 - /* "optimizer_user_yul/input.sol":391:399 sload(5) */ + /* "optimizer_user_yul/input.sol":384:392 sload(5) */ sload tag_9 jumpi jump(tag_8) tag_9: - /* "optimizer_user_yul/input.sol":383:516 for { } sload(5) { } {... */ + /* "optimizer_user_yul/input.sol":376:509 for { } sload(5) { } {... */ jump(tag_6) tag_8: - /* "optimizer_user_yul/input.sol":347:520 {... */ + /* "optimizer_user_yul/input.sol":340:513 {... */ pop - /* "optimizer_user_yul/input.sol":60:525 contract C... */ + /* "optimizer_user_yul/input.sol":60:518 contract C... */ dataSize(sub_0) dup1 dataOffset(sub_0) @@ -74,7 +74,7 @@ tag_8: stop sub_0: assembly { - /* "optimizer_user_yul/input.sol":60:525 contract C... */ + /* "optimizer_user_yul/input.sol":60:518 contract C... */ mstore(0x40, 0x80) 0x00 dup1 diff --git a/test/cmdlineTests/recovery_ast_constructor/input.sol b/test/cmdlineTests/recovery_ast_constructor/input.sol index 9035590d9..8da09638a 100644 --- a/test/cmdlineTests/recovery_ast_constructor/input.sol +++ b/test/cmdlineTests/recovery_ast_constructor/input.sol @@ -2,7 +2,7 @@ pragma solidity >=0.0.0; contract Error1 { - constructor() public { + constructor() { balances[tx.origin] = ; // missing RHS. } diff --git a/test/cmdlineTests/recovery_ast_constructor/output b/test/cmdlineTests/recovery_ast_constructor/output index 06d7bb95c..d4a7d0288 100644 --- a/test/cmdlineTests/recovery_ast_constructor/output +++ b/test/cmdlineTests/recovery_ast_constructor/output @@ -45,7 +45,6 @@ JSON AST: null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -59,7 +58,6 @@ JSON AST: { "attributes": { - "documentation": null, "implemented": true, "isConstructor": true, "kind": "constructor", @@ -68,7 +66,6 @@ JSON AST: null ], "name": "", - "overrides": null, "scope": 18, "stateMutability": "nonpayable", "virtual": false, @@ -100,7 +97,7 @@ JSON AST: "children": [], "id": 3, "name": "ParameterList", - "src": "103:0:0" + "src": "96:0:0" }, { "attributes": @@ -113,17 +110,16 @@ JSON AST: "children": [], "id": 8, "name": "Block", - "src": "103:49:0" + "src": "96:49:0" } ], "id": 9, "name": "FunctionDefinition", - "src": "82:70:0" + "src": "82:63:0" }, { "attributes": { - "documentation": null, "functionSelector": "af11c34c", "implemented": true, "isConstructor": false, @@ -133,7 +129,6 @@ JSON AST: null ], "name": "five", - "overrides": null, "scope": 18, "stateMutability": "view", "virtual": false, @@ -152,7 +147,7 @@ JSON AST: "children": [], "id": 10, "name": "ParameterList", - "src": "418:2:0" + "src": "411:2:0" }, { "children": @@ -163,12 +158,10 @@ JSON AST: "constant": false, "mutability": "mutable", "name": "", - "overrides": null, "scope": 17, "stateVariable": false, "storageLocation": "default", "type": "uint256", - "value": null, "visibility": "internal" }, "children": @@ -181,17 +174,17 @@ JSON AST: }, "id": 11, "name": "ElementaryTypeName", - "src": "441:4:0" + "src": "434:4:0" } ], "id": 12, "name": "VariableDeclaration", - "src": "441:4:0" + "src": "434:4:0" } ], "id": 13, "name": "ParameterList", - "src": "440:6:0" + "src": "433:6:0" }, { "children": @@ -206,43 +199,41 @@ JSON AST: { "attributes": { - "argumentTypes": null, "hexvalue": "35", "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, - "subdenomination": null, "token": "number", "type": "int_const 5", "value": "5" }, "id": 14, "name": "Literal", - "src": "460:1:0" + "src": "453:1:0" } ], "id": 15, "name": "Return", - "src": "453:8:0" + "src": "446:8:0" } ], "id": 16, "name": "Block", - "src": "447:19:0" + "src": "440:19:0" } ], "id": 17, "name": "FunctionDefinition", - "src": "405:61:0" + "src": "398:61:0" } ], "id": 18, "name": "ContractDefinition", - "src": "62:406:0" + "src": "62:399:0" } ], "id": 19, "name": "SourceUnit", - "src": "36:433:0" + "src": "36:426:0" } diff --git a/test/cmdlineTests/standard_secondary_source_location/input.json b/test/cmdlineTests/standard_secondary_source_location/input.json index 0cd6a6126..e429265b4 100644 --- a/test/cmdlineTests/standard_secondary_source_location/input.json +++ b/test/cmdlineTests/standard_secondary_source_location/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract A { constructor(uint) public {} } contract B is A(2) { } contract C is A(3) {} contract D is B, C {}" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract A { constructor(uint) {} } contract B is A(2) { } contract C is A(3) {} contract D is B, C {}" } } } diff --git a/test/cmdlineTests/standard_secondary_source_location/output.json b/test/cmdlineTests/standard_secondary_source_location/output.json index b32b00028..45874df27 100644 --- a/test/cmdlineTests/standard_secondary_source_location/output.json +++ b/test/cmdlineTests/standard_secondary_source_location/output.json @@ -1,10 +1,10 @@ -{"errors":[{"component":"general","errorCode":"3364","formattedMessage":"A:2:112: DeclarationError: Base constructor arguments given twice. -pragma solidity >=0.0; contract A { constructor(uint) public {} } contract B is A(2) { } contract C is A(3) {} contract D is B, C {} - ^-------------------^ -A:2:81: First constructor call is here: -pragma solidity >=0.0; contract A { constructor(uint) public {} } contract B is A(2) { } contract C is A(3) {} contract D is B, C {} - ^--^ -A:2:104: Second constructor call is here: -pragma solidity >=0.0; contract A { constructor(uint) public {} } contract B is A(2) { } contract C is A(3) {} contract D is B, C {} - ^--^ -","message":"Base constructor arguments given twice.","secondarySourceLocations":[{"end":119,"file":"A","message":"First constructor call is here:","start":115},{"end":142,"file":"A","message":"Second constructor call is here:","start":138}],"severity":"error","sourceLocation":{"end":167,"file":"A","start":146},"type":"DeclarationError"}],"sources":{}} +{"errors":[{"component":"general","errorCode":"3364","formattedMessage":"A:2:105: DeclarationError: Base constructor arguments given twice. +pragma solidity >=0.0; contract A { constructor(uint) {} } contract B is A(2) { } contract C is A(3) {} contract D is B, C {} + ^-------------------^ +A:2:74: First constructor call is here: +pragma solidity >=0.0; contract A { constructor(uint) {} } contract B is A(2) { } contract C is A(3) {} contract D is B, C {} + ^--^ +A:2:97: Second constructor call is here: +pragma solidity >=0.0; contract A { constructor(uint) {} } contract B is A(2) { } contract C is A(3) {} contract D is B, C {} + ^--^ +","message":"Base constructor arguments given twice.","secondarySourceLocations":[{"end":112,"file":"A","message":"First constructor call is here:","start":108},{"end":135,"file":"A","message":"Second constructor call is here:","start":131}],"severity":"error","sourceLocation":{"end":160,"file":"A","start":139},"type":"DeclarationError"}],"sources":{}} diff --git a/test/cmdlineTests/yul_optimizer_steps/input.sol b/test/cmdlineTests/yul_optimizer_steps/input.sol index a75662b25..c93363e41 100644 --- a/test/cmdlineTests/yul_optimizer_steps/input.sol +++ b/test/cmdlineTests/yul_optimizer_steps/input.sol @@ -3,5 +3,5 @@ pragma solidity >=0.0; contract C { - constructor() public {} + constructor() {} } diff --git a/test/compilationTests/MultiSigWallet/MultiSigWallet.sol b/test/compilationTests/MultiSigWallet/MultiSigWallet.sol index 8bf4ebe4b..b4594344c 100644 --- a/test/compilationTests/MultiSigWallet/MultiSigWallet.sol +++ b/test/compilationTests/MultiSigWallet/MultiSigWallet.sol @@ -104,7 +104,6 @@ contract MultiSigWallet { /// @param _owners List of initial owners. /// @param _required Number of required confirmations. constructor(address[] memory _owners, uint _required) - public validRequirement(_owners.length, _required) { for (uint i=0; i<_owners.length; i++) { @@ -227,7 +226,7 @@ contract MultiSigWallet { { if (isConfirmed(transactionId)) { Transaction storage tx = transactions[transactionId]; - (tx.executed,) = tx.destination.call.value(tx.value)(tx.data); + (tx.executed,) = tx.destination.call{value: tx.value}(tx.data); if (tx.executed) emit Execution(transactionId); else diff --git a/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol b/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol index 65116d9f0..6207f9764 100644 --- a/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol +++ b/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol @@ -20,7 +20,6 @@ contract MultiSigWalletWithDailyLimit is MultiSigWallet { /// @param _required Number of required confirmations. /// @param _dailyLimit Amount in wei, which can be withdrawn without confirmations on a daily basis. constructor(address[] memory _owners, uint _required, uint _dailyLimit) - public MultiSigWallet(_owners, _required) { dailyLimit = _dailyLimit; @@ -48,7 +47,7 @@ contract MultiSigWalletWithDailyLimit is MultiSigWallet { if (confirmed || tx.data.length == 0 && isUnderLimit(tx.value)) { if (!confirmed) spentToday += tx.value; - (tx.executed,) = tx.destination.call.value(tx.value)(tx.data); + (tx.executed,) = tx.destination.call{value: tx.value}(tx.data); if (tx.executed) emit Execution(transactionId); else { @@ -69,8 +68,8 @@ contract MultiSigWalletWithDailyLimit is MultiSigWallet { internal returns (bool) { - if (now > lastDay + 24 hours) { - lastDay = now; + if (block.timestamp > lastDay + 24 hours) { + lastDay = block.timestamp; spentToday = 0; } if (spentToday + amount > dailyLimit || spentToday + amount < spentToday) @@ -88,7 +87,7 @@ contract MultiSigWalletWithDailyLimit is MultiSigWallet { view returns (uint) { - if (now > lastDay + 24 hours) + if (block.timestamp > lastDay + 24 hours) return dailyLimit; if (dailyLimit < spentToday) return 0; diff --git a/test/compilationTests/corion/ico.sol b/test/compilationTests/corion/ico.sol index a8804fd4c..a0c31cbc3 100644 --- a/test/compilationTests/corion/ico.sol +++ b/test/compilationTests/corion/ico.sol @@ -50,7 +50,7 @@ contract ico is safeMath { uint256 public totalMint; uint256 public totalPremiumMint; - constructor(address payable foundation, address priceSet, uint256 exchangeRate, uint256 startBlockNum, address[] memory genesisAddr, uint256[] memory genesisValue) public { + constructor(address payable foundation, address priceSet, uint256 exchangeRate, uint256 startBlockNum, address[] memory genesisAddr, uint256[] memory genesisValue) { /* Installation function. diff --git a/test/compilationTests/corion/moduleHandler.sol b/test/compilationTests/corion/moduleHandler.sol index ccbe5ac92..e8e65760c 100644 --- a/test/compilationTests/corion/moduleHandler.sol +++ b/test/compilationTests/corion/moduleHandler.sol @@ -36,7 +36,7 @@ contract moduleHandler is multiOwner, announcementTypes { uint256 debugModeUntil = block.number + 1000000; - constructor(address[] memory newOwners) multiOwner(newOwners) public {} + constructor(address[] memory newOwners) multiOwner(newOwners) {} function load(address payable foundation, bool forReplace, address payable Token, address payable Premium, address payable Publisher, address payable Schelling, address payable Provider) public { /* Loading modulest to ModuleHandler. diff --git a/test/compilationTests/corion/multiOwner.sol b/test/compilationTests/corion/multiOwner.sol index b61289dd2..cad0ce7a8 100644 --- a/test/compilationTests/corion/multiOwner.sol +++ b/test/compilationTests/corion/multiOwner.sol @@ -12,7 +12,7 @@ contract multiOwner is safeMath { /* Constructor */ - constructor(address[] memory newOwners) public { + constructor(address[] memory newOwners) { for ( uint256 a=0 ; a bool) public genesis; - constructor(bool forReplace, address payable moduleHandler, address dbAddress, address icoContractAddr, address[] memory genesisAddr, uint256[] memory genesisValue) public { + constructor(bool forReplace, address payable moduleHandler, address dbAddress, address icoContractAddr, address[] memory genesisAddr, uint256[] memory genesisValue) { /* Setup function. If an ICOaddress is defined then the balance of the genesis addresses will be set as well. diff --git a/test/compilationTests/corion/provider.sol b/test/compilationTests/corion/provider.sol index 0b9f4ac1c..1e2d308a1 100644 --- a/test/compilationTests/corion/provider.sol +++ b/test/compilationTests/corion/provider.sol @@ -118,7 +118,7 @@ contract provider is module, safeMath, announcementTypes { uint256 private currentSchellingRound = 1; - constructor(address payable _moduleHandler) public { + constructor(address payable _moduleHandler) { /* Install function. @@ -256,7 +256,7 @@ contract provider is module, safeMath, announcementTypes { providers[msg.sender].data[currHeight].country = country; providers[msg.sender].data[currHeight].info = info; providers[msg.sender].data[currHeight].currentRate = rate; - providers[msg.sender].data[currHeight].create = now; + providers[msg.sender].data[currHeight].create = block.timestamp; providers[msg.sender].data[currHeight].lastPaidRate = rate; providers[msg.sender].data[currHeight].priv = priv; providers[msg.sender].data[currHeight].lastSupplyID = currentSchellingRound; @@ -436,7 +436,7 @@ contract provider is module, safeMath, announcementTypes { clients[msg.sender].lastSupplyID = currentSchellingRound; clients[msg.sender].paidUpTo = currentSchellingRound; clients[msg.sender].lastRate = providers[provider].data[currHeight].currentRate; - clients[msg.sender].providerConnected = now; + clients[msg.sender].providerConnected = block.timestamp; emit ENewClient(msg.sender, provider, currHeight, bal); } function partProvider() isReady external { diff --git a/test/compilationTests/corion/publisher.sol b/test/compilationTests/corion/publisher.sol index 19746ec57..ec8ce33bc 100644 --- a/test/compilationTests/corion/publisher.sol +++ b/test/compilationTests/corion/publisher.sol @@ -61,7 +61,7 @@ contract publisher is announcementTypes, module, safeMath { mapping (address => uint256[]) public opponents; - constructor(address payable moduleHandler) public { + constructor(address payable moduleHandler) { /* Installation function. The installer will be registered in the admin list automatically diff --git a/test/compilationTests/corion/schelling.sol b/test/compilationTests/corion/schelling.sol index 51f4727ef..bbb16e250 100644 --- a/test/compilationTests/corion/schelling.sol +++ b/test/compilationTests/corion/schelling.sol @@ -45,7 +45,7 @@ contract schellingDB is safeMath, schellingVars { /* Constructor */ - constructor() public { + constructor() { rounds.push(); rounds.push(); rounds[0].blockHeight = block.number; @@ -249,7 +249,7 @@ contract schelling is module, announcementTypes, schellingVars { bytes1 public belowChar = 0x30; schellingDB private db; - constructor(address payable _moduleHandler, address _db, bool _forReplace) public { + constructor(address payable _moduleHandler, address _db, bool _forReplace) { /* Installation function. diff --git a/test/compilationTests/corion/token.sol b/test/compilationTests/corion/token.sol index 0d67feaa9..865372d5f 100644 --- a/test/compilationTests/corion/token.sol +++ b/test/compilationTests/corion/token.sol @@ -11,6 +11,12 @@ contract thirdPartyContractAbstract { function approvedCorionToken(address, uint256, bytes calldata) external returns (bool) {} } +/** + * + * @title Corion Platform Token + * @author iFA @ Corion Platform + * + */ contract token is safeMath, module, announcementTypes { /* module callbacks @@ -26,12 +32,7 @@ contract token is safeMath, module, announcementTypes { require( _success && _active ); _; } - /** - * - * @title Corion Platform Token - * @author iFA @ Corion Platform - * - */ + string public name = "Corion"; string public symbol = "COR"; uint8 public decimals = 6; @@ -48,7 +49,7 @@ contract token is safeMath, module, announcementTypes { mapping(address => bool) public genesis; - constructor(bool forReplace, address payable moduleHandler, address dbAddr, address payable icoContractAddr, address payable exchangeContractAddress, address payable[] memory genesisAddr, uint256[] memory genesisValue) public payable { + constructor(bool forReplace, address payable moduleHandler, address dbAddr, address payable icoContractAddr, address payable exchangeContractAddress, address payable[] memory genesisAddr, uint256[] memory genesisValue) payable { /* Installation function diff --git a/test/compilationTests/gnosis/Events/CategoricalEvent.sol b/test/compilationTests/gnosis/Events/CategoricalEvent.sol index 6b04b73d9..e3cd0edc7 100644 --- a/test/compilationTests/gnosis/Events/CategoricalEvent.sol +++ b/test/compilationTests/gnosis/Events/CategoricalEvent.sol @@ -18,7 +18,6 @@ contract CategoricalEvent is Event { Oracle _oracle, uint8 outcomeCount ) - public Event(_collateralToken, _oracle, outcomeCount) { diff --git a/test/compilationTests/gnosis/Events/Event.sol b/test/compilationTests/gnosis/Events/Event.sol index 8f48d4ac2..4b5bb24d0 100644 --- a/test/compilationTests/gnosis/Events/Event.sol +++ b/test/compilationTests/gnosis/Events/Event.sol @@ -34,7 +34,6 @@ abstract contract Event { /// @param _oracle Oracle contract used to resolve the event /// @param outcomeCount Number of event outcomes constructor(Token _collateralToken, Oracle _oracle, uint8 outcomeCount) - public { // Validate input require(address(_collateralToken) != address(0) && address(_oracle) != address(0) && outcomeCount >= 2); diff --git a/test/compilationTests/gnosis/Events/ScalarEvent.sol b/test/compilationTests/gnosis/Events/ScalarEvent.sol index 6df1dc072..c2b0a90a2 100644 --- a/test/compilationTests/gnosis/Events/ScalarEvent.sol +++ b/test/compilationTests/gnosis/Events/ScalarEvent.sol @@ -34,7 +34,6 @@ contract ScalarEvent is Event { int _lowerBound, int _upperBound ) - public Event(_collateralToken, _oracle, 2) { // Validate bounds diff --git a/test/compilationTests/gnosis/Markets/Campaign.sol b/test/compilationTests/gnosis/Markets/Campaign.sol index 451eef9ed..450a38170 100644 --- a/test/compilationTests/gnosis/Markets/Campaign.sol +++ b/test/compilationTests/gnosis/Markets/Campaign.sol @@ -55,7 +55,7 @@ contract Campaign { } modifier timedTransitions() { - if (stage == Stages.AuctionStarted && deadline < now) + if (stage == Stages.AuctionStarted && deadline < block.timestamp) stage = Stages.AuctionFailed; _; } @@ -78,7 +78,6 @@ contract Campaign { uint _funding, uint _deadline ) - public { // Validate input require( address(_eventContract) != address(0) @@ -86,7 +85,7 @@ contract Campaign { && address(_marketMaker) != address(0) && _fee < FEE_RANGE && _funding > 0 - && now < _deadline); + && block.timestamp < _deadline); eventContract = _eventContract; marketFactory = _marketFactory; marketMaker = _marketMaker; diff --git a/test/compilationTests/gnosis/Markets/StandardMarket.sol b/test/compilationTests/gnosis/Markets/StandardMarket.sol index d77fadaca..5e476a86f 100644 --- a/test/compilationTests/gnosis/Markets/StandardMarket.sol +++ b/test/compilationTests/gnosis/Markets/StandardMarket.sol @@ -39,7 +39,6 @@ contract StandardMarket is Market { /// @param _marketMaker Market maker contract /// @param _fee Market fee constructor(address _creator, Event _eventContract, MarketMaker _marketMaker, uint24 _fee) - public { // Validate inputs require(address(_eventContract) != address(0) && address(_marketMaker) != address(0) && _fee < FEE_RANGE); diff --git a/test/compilationTests/gnosis/Migrations.sol b/test/compilationTests/gnosis/Migrations.sol index 396e36494..9d37ef688 100644 --- a/test/compilationTests/gnosis/Migrations.sol +++ b/test/compilationTests/gnosis/Migrations.sol @@ -8,7 +8,7 @@ contract Migrations { if (msg.sender == owner) _; } - constructor() public { + constructor() { owner = msg.sender; } diff --git a/test/compilationTests/gnosis/Oracles/CentralizedOracle.sol b/test/compilationTests/gnosis/Oracles/CentralizedOracle.sol index 97253229c..08df08305 100644 --- a/test/compilationTests/gnosis/Oracles/CentralizedOracle.sol +++ b/test/compilationTests/gnosis/Oracles/CentralizedOracle.sol @@ -35,7 +35,6 @@ contract CentralizedOracle is Oracle { /// @dev Constructor sets owner address and IPFS hash /// @param _ipfsHash Hash identifying off chain event description constructor(address _owner, bytes memory _ipfsHash) - public { // Description hash cannot be null require(_ipfsHash.length == 46); diff --git a/test/compilationTests/gnosis/Oracles/DifficultyOracle.sol b/test/compilationTests/gnosis/Oracles/DifficultyOracle.sol index a42f2ba66..b94f5b64b 100644 --- a/test/compilationTests/gnosis/Oracles/DifficultyOracle.sol +++ b/test/compilationTests/gnosis/Oracles/DifficultyOracle.sol @@ -23,7 +23,6 @@ contract DifficultyOracle is Oracle { /// @dev Contract constructor validates and sets target block number /// @param _blockNumber Target block number constructor(uint _blockNumber) - public { // Block has to be in the future require(_blockNumber > block.number); diff --git a/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol b/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol index 84675ba96..89b418b73 100644 --- a/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol +++ b/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol @@ -68,10 +68,9 @@ contract FutarchyOracle is Oracle { uint24 fee, uint _deadline ) - public { // Deadline is in the future - require(_deadline > now); + require(_deadline > block.timestamp); // Create decision event categoricalEvent = eventFactory.createCategoricalEvent(collateralToken, this, outcomeCount); // Create outcome events @@ -131,7 +130,7 @@ contract FutarchyOracle is Oracle { public { // Outcome is not set yet and deadline has passed - require(!isSet && deadline <= now); + require(!isSet && deadline <= block.timestamp); // Find market with highest marginal price for long outcome tokens uint highestMarginalPrice = markets[0].marketMaker().calcMarginalPrice(markets[0], LONG); uint highestIndex = 0; diff --git a/test/compilationTests/gnosis/Oracles/FutarchyOracleFactory.sol b/test/compilationTests/gnosis/Oracles/FutarchyOracleFactory.sol index 4a440c58c..a6438379b 100644 --- a/test/compilationTests/gnosis/Oracles/FutarchyOracleFactory.sol +++ b/test/compilationTests/gnosis/Oracles/FutarchyOracleFactory.sol @@ -34,7 +34,6 @@ contract FutarchyOracleFactory { /// @dev Constructor sets event factory contract /// @param _eventFactory Event factory contract constructor(EventFactory _eventFactory) - public { require(address(_eventFactory) != address(0)); eventFactory = _eventFactory; diff --git a/test/compilationTests/gnosis/Oracles/MajorityOracle.sol b/test/compilationTests/gnosis/Oracles/MajorityOracle.sol index d57c89429..854088fa4 100644 --- a/test/compilationTests/gnosis/Oracles/MajorityOracle.sol +++ b/test/compilationTests/gnosis/Oracles/MajorityOracle.sol @@ -17,7 +17,6 @@ contract MajorityOracle is Oracle { /// @dev Allows to create an oracle for a majority vote based on other oracles /// @param _oracles List of oracles taking part in the majority vote constructor(Oracle[] memory _oracles) - public { // At least 2 oracles should be defined require(_oracles.length > 2); diff --git a/test/compilationTests/gnosis/Oracles/SignedMessageOracle.sol b/test/compilationTests/gnosis/Oracles/SignedMessageOracle.sol index 694b73742..7b56a107e 100644 --- a/test/compilationTests/gnosis/Oracles/SignedMessageOracle.sol +++ b/test/compilationTests/gnosis/Oracles/SignedMessageOracle.sol @@ -39,7 +39,6 @@ contract SignedMessageOracle is Oracle { /// @param r Signature parameter /// @param s Signature parameter constructor(bytes32 _descriptionHash, uint8 v, bytes32 r, bytes32 s) - public { signer = ecrecover(_descriptionHash, v, r, s); descriptionHash = _descriptionHash; diff --git a/test/compilationTests/gnosis/Oracles/UltimateOracle.sol b/test/compilationTests/gnosis/Oracles/UltimateOracle.sol index 94b57ca81..9fc7a0cc9 100644 --- a/test/compilationTests/gnosis/Oracles/UltimateOracle.sol +++ b/test/compilationTests/gnosis/Oracles/UltimateOracle.sol @@ -54,7 +54,6 @@ contract UltimateOracle is Oracle { uint _challengeAmount, uint _frontRunnerPeriod ) - public { // Validate inputs require( address(_forwardedOracle) != address(0) @@ -80,7 +79,7 @@ contract UltimateOracle is Oracle { && forwardedOutcomeSetTimestamp == 0 && forwardedOracle.isOutcomeSet()); forwardedOutcome = forwardedOracle.getOutcome(); - forwardedOutcomeSetTimestamp = now; + forwardedOutcomeSetTimestamp = block.timestamp; emit ForwardedOracleOutcomeAssignment(forwardedOutcome); } @@ -97,7 +96,7 @@ contract UltimateOracle is Oracle { totalOutcomeAmounts[_outcome] = challengeAmount; totalAmount = challengeAmount; frontRunner = _outcome; - frontRunnerSetTimestamp = now; + frontRunnerSetTimestamp = block.timestamp; emit OutcomeChallenge(msg.sender, _outcome); } @@ -120,7 +119,7 @@ contract UltimateOracle is Oracle { if (_outcome != frontRunner && totalOutcomeAmounts[_outcome] > totalOutcomeAmounts[frontRunner]) { frontRunner = _outcome; - frontRunnerSetTimestamp = now; + frontRunnerSetTimestamp = block.timestamp; } emit OutcomeVote(msg.sender, _outcome, amount); } @@ -147,7 +146,7 @@ contract UltimateOracle is Oracle { view returns (bool) { - return forwardedOutcomeSetTimestamp != 0 && now.sub(forwardedOutcomeSetTimestamp) > challengePeriod; + return forwardedOutcomeSetTimestamp != 0 && (block.timestamp).sub(forwardedOutcomeSetTimestamp) > challengePeriod; } /// @dev Checks if time to overbid the front runner is over @@ -157,7 +156,7 @@ contract UltimateOracle is Oracle { view returns (bool) { - return frontRunnerSetTimestamp != 0 && now.sub(frontRunnerSetTimestamp) > frontRunnerPeriod; + return frontRunnerSetTimestamp != 0 && (block.timestamp).sub(frontRunnerSetTimestamp) > frontRunnerPeriod; } /// @dev Checks if outcome was challenged diff --git a/test/compilationTests/gnosis/Tokens/OutcomeToken.sol b/test/compilationTests/gnosis/Tokens/OutcomeToken.sol index 11f4ece14..ed63541db 100644 --- a/test/compilationTests/gnosis/Tokens/OutcomeToken.sol +++ b/test/compilationTests/gnosis/Tokens/OutcomeToken.sol @@ -32,7 +32,6 @@ contract OutcomeToken is StandardToken { */ /// @dev Constructor sets events contract address constructor() - public { eventContract = msg.sender; } diff --git a/test/compilationTests/gnosis/Utils/Math.sol b/test/compilationTests/gnosis/Utils/Math.sol index 93e2375c2..bcae29b6a 100644 --- a/test/compilationTests/gnosis/Utils/Math.sol +++ b/test/compilationTests/gnosis/Utils/Math.sol @@ -94,12 +94,12 @@ library Math { zpow = zpow * z / ONE; result += 0x9c7 * zpow / ONE; if (shift >= 0) { - if (result >> (256-shift) > 0) - return (2**256-1); - return result << shift; + if (result >> uint(256 - shift) > 0) + return (2 ** 256 - 1); + return result << uint(shift); } else - return result >> (-shift); + return result >> uint(-shift); } /// @dev Returns natural logarithm value of given x @@ -177,7 +177,6 @@ library Math { /// @param nums Numbers to look through /// @return max Maximum number function max(int[] memory nums) - virtual public pure returns (int max) diff --git a/test/compilationTests/milestonetracker/MilestoneTracker.sol b/test/compilationTests/milestonetracker/MilestoneTracker.sol index c222d0a9d..2aee9f4cf 100644 --- a/test/compilationTests/milestonetracker/MilestoneTracker.sol +++ b/test/compilationTests/milestonetracker/MilestoneTracker.sol @@ -112,7 +112,7 @@ contract MilestoneTracker { address _arbitrator, address _donor, address _recipient - ) public { + ) { arbitrator = _arbitrator; donor = _donor; recipient = _recipient; @@ -264,10 +264,10 @@ contract MilestoneTracker { &&(msg.sender != recipient)) revert(); if (milestone.status != MilestoneStatus.AcceptedAndInProgress) revert(); - if (now < milestone.minCompletionDate) revert(); - if (now > milestone.maxCompletionDate) revert(); + if (block.timestamp < milestone.minCompletionDate) revert(); + if (block.timestamp > milestone.maxCompletionDate) revert(); milestone.status = MilestoneStatus.Completed; - milestone.doneTime = now; + milestone.doneTime = block.timestamp; emit ProposalStatusChanged(_idMilestone, milestone.status); } @@ -312,7 +312,7 @@ contract MilestoneTracker { &&(msg.sender != recipient)) revert(); if ((milestone.status != MilestoneStatus.Completed) || - (now < milestone.doneTime + milestone.reviewTime)) + (block.timestamp < milestone.doneTime + milestone.reviewTime)) revert(); authorizePayment(_idMilestone); @@ -360,7 +360,7 @@ contract MilestoneTracker { // Recheck again to not pay twice if (milestone.status == MilestoneStatus.AuthorizedForPayment) revert(); milestone.status = MilestoneStatus.AuthorizedForPayment; - (bool success,) = milestone.paymentSource.call.value(0)(milestone.payData); + (bool success,) = milestone.paymentSource.call{value: 0}(milestone.payData); require(success); emit ProposalStatusChanged(_idMilestone, milestone.status); } diff --git a/test/contracts/AuctionRegistrar.cpp b/test/contracts/AuctionRegistrar.cpp index b3621238b..ce99fd585 100644 --- a/test/contracts/AuctionRegistrar.cpp +++ b/test/contracts/AuctionRegistrar.cpp @@ -42,9 +42,8 @@ namespace solidity::frontend::test namespace { - static char const* registrarCode = R"DELIMITER( -pragma solidity >=0.4.0 <0.7.0; +pragma solidity >=0.4.0 <0.8.0; abstract contract NameRegister { function addr(string memory _name) public virtual view returns (address o_owner); @@ -72,7 +71,7 @@ abstract contract AuctionSystem { function bid(string memory _name, address payable _bidder, uint _value) internal { Auction storage auction = m_auctions[_name]; - if (auction.endDate > 0 && now > auction.endDate) + if (auction.endDate > 0 && block.timestamp > auction.endDate) { emit AuctionEnded(_name, auction.highestBidder); onAuctionEnd(_name); @@ -86,7 +85,7 @@ abstract contract AuctionSystem { auction.sumOfBids += _value; auction.highestBid = _value; auction.highestBidder = _bidder; - auction.endDate = now + c_biddingTime; + auction.endDate = block.timestamp + c_biddingTime; emit NewBid(_name, _bidder, _value); } @@ -116,7 +115,7 @@ contract GlobalRegistrar is Registrar, AuctionSystem { uint constant c_renewalInterval = 365 days; uint constant c_freeBytes = 12; - constructor() public { + constructor() { // TODO: Populate with hall-of-fame. } @@ -124,7 +123,7 @@ contract GlobalRegistrar is Registrar, AuctionSystem { Auction storage auction = m_auctions[_name]; Record storage record = m_toRecord[_name]; address previousOwner = record.owner; - record.renewalDate = now + c_renewalInterval; + record.renewalDate = block.timestamp + c_renewalInterval; record.owner = auction.highestBidder; emit Changed(_name); if (previousOwner != 0x0000000000000000000000000000000000000000) { @@ -142,7 +141,7 @@ contract GlobalRegistrar is Registrar, AuctionSystem { bool needAuction = requiresAuction(_name); if (needAuction) { - if (now < m_toRecord[_name].renewalDate) + if (block.timestamp < m_toRecord[_name].renewalDate) revert(); bid(_name, msg.sender, msg.value); } else { diff --git a/test/contracts/FixedFeeRegistrar.cpp b/test/contracts/FixedFeeRegistrar.cpp index f953cda9a..f88bb0b6f 100644 --- a/test/contracts/FixedFeeRegistrar.cpp +++ b/test/contracts/FixedFeeRegistrar.cpp @@ -55,7 +55,7 @@ static char const* registrarCode = R"DELIMITER( // @authors: // Gav Wood -pragma solidity >=0.4.0 <0.7.0; +pragma solidity >=0.4.0 <0.8.0; abstract contract Registrar { event Changed(string indexed name); diff --git a/test/contracts/Wallet.cpp b/test/contracts/Wallet.cpp index 503282094..e3352ac0b 100644 --- a/test/contracts/Wallet.cpp +++ b/test/contracts/Wallet.cpp @@ -44,7 +44,6 @@ using namespace solidity::util; namespace solidity::frontend::test { - static char const* walletCode = R"DELIMITER( //sol Wallet // Multi-sig, daily-limited account proxy/wallet. @@ -57,7 +56,7 @@ static char const* walletCode = R"DELIMITER( // some number (specified in constructor) of the set of owners (specified in the constructor, modifiable) before the // interior is executed. -pragma solidity >=0.4.0 <0.7.0; +pragma solidity >=0.4.0 <0.8.0; contract multiowned { @@ -102,7 +101,7 @@ contract multiowned { // constructor is given number of sigs required to do protected "onlymanyowners" transactions // as well as the selection of addresses capable of confirming them. - constructor(address[] memory _owners, uint _required) public { + constructor(address[] memory _owners, uint _required) { m_numOwners = _owners.length + 1; m_owners[1] = uint(msg.sender); m_ownerIndex[uint(msg.sender)] = 1; @@ -290,7 +289,7 @@ abstract contract daylimit is multiowned { // METHODS // constructor - stores initial daily limit and records the present day's index. - constructor(uint _limit) public { + constructor(uint _limit) { m_dailyLimit = _limit; m_lastDay = today(); } @@ -321,7 +320,7 @@ abstract contract daylimit is multiowned { return false; } // determines today's index. - function today() private view returns (uint) { return now / 1 days; } + function today() private view returns (uint) { return block.timestamp / 1 days; } // FIELDS @@ -371,7 +370,7 @@ contract Wallet is multisig, multiowned, daylimit { // constructor - just pass on the owner array to the multiowned and // the limit to daylimit - constructor(address[] memory _owners, uint _required, uint _daylimit) public payable + constructor(address[] memory _owners, uint _required, uint _daylimit) payable multiowned(_owners, _required) daylimit(_daylimit) { } @@ -399,7 +398,7 @@ contract Wallet is multisig, multiowned, daylimit { if (underLimit(_value)) { emit SingleTransact(msg.sender, _value, _to, _data); // yes - just execute the call. - _to.call.value(_value)(_data); + _to.call{value: _value}(_data); return 0; } // determine our operation hash. @@ -416,7 +415,7 @@ contract Wallet is multisig, multiowned, daylimit { // to determine the body of the transaction from the hash provided. function confirm(bytes32 _h) onlymanyowners(_h) public override returns (bool) { if (m_txs[_h].to != 0x0000000000000000000000000000000000000000) { - m_txs[_h].to.call.value(m_txs[_h].value)(m_txs[_h].data); + m_txs[_h].to.call{value: m_txs[_h].value}(m_txs[_h].data); emit MultiTransact(msg.sender, _h, m_txs[_h].value, m_txs[_h].to, m_txs[_h].data); delete m_txs[_h]; return true; diff --git a/test/externalTests/colony.sh b/test/externalTests/colony.sh index 559703ae7..6a246b2b9 100755 --- a/test/externalTests/colony.sh +++ b/test/externalTests/colony.sh @@ -34,7 +34,7 @@ function colony_test FORCE_ABIv2=false CONFIG="truffle.js" - truffle_setup https://github.com/solidity-external-tests/colonyNetwork.git develop_060 + truffle_setup https://github.com/solidity-external-tests/colonyNetwork.git develop_070 run_install install_fn cd lib diff --git a/test/externalTests/gnosis.sh b/test/externalTests/gnosis.sh index b78877211..436942d2d 100755 --- a/test/externalTests/gnosis.sh +++ b/test/externalTests/gnosis.sh @@ -33,10 +33,10 @@ function gnosis_safe_test OPTIMIZER_LEVEL=1 CONFIG="truffle.js" - truffle_setup https://github.com/solidity-external-tests/safe-contracts.git development_060 + truffle_setup https://github.com/solidity-external-tests/safe-contracts.git development_070 force_truffle_version - sed -i 's|github:gnosis/mock-contract#sol_0_5_0|github:solidity-external-tests/mock-contract#master_060|g' package.json + sed -i 's|github:gnosis/mock-contract#sol_0_5_0|github:solidity-external-tests/mock-contract#master_070|g' package.json run_install install_fn replace_libsolc_call diff --git a/test/externalTests/solc-js/DAO/DAO.sol b/test/externalTests/solc-js/DAO/DAO.sol index 46b68bf2a..56e50d23d 100644 --- a/test/externalTests/solc-js/DAO/DAO.sol +++ b/test/externalTests/solc-js/DAO/DAO.sol @@ -381,7 +381,7 @@ contract DAO is DAOInterface, Token, TokenCreation { revert(); if (address(DAOrewardAccount) == 0x0000000000000000000000000000000000000000) revert(); - lastTimeMinQuorumMet = now; + lastTimeMinQuorumMet = block.timestamp; minQuorumDivisor = 5; // sets the minimal quorum to 20% proposals.push(); // avoids a proposal with ID 0 because it is used @@ -390,7 +390,7 @@ contract DAO is DAOInterface, Token, TokenCreation { } receive() external payable override(DAOInterface, TokenCreation) { - if (now < closingTime + creationGracePeriod && msg.sender != address(extraBalance)) + if (block.timestamp < closingTime + creationGracePeriod && msg.sender != address(extraBalance)) createTokenProxy(msg.sender); else receiveEther(); @@ -430,13 +430,13 @@ contract DAO is DAOInterface, Token, TokenCreation { revert(); if (!isFueled - || now < closingTime + || block.timestamp < closingTime || (msg.value < proposalDeposit && !_newCurator)) { revert(); } - if (now + _debatingPeriod < now) // prevents overflow + if (block.timestamp + _debatingPeriod < block.timestamp) // prevents overflow revert(); // to prevent a 51% attacker to convert the ether into deposit @@ -445,7 +445,7 @@ contract DAO is DAOInterface, Token, TokenCreation { // to prevent curator from halving quorum before first proposal if (proposals.length == 1) // initial length is 1 (see constructor) - lastTimeMinQuorumMet = now; + lastTimeMinQuorumMet = block.timestamp; Proposal storage p = proposals.push(); _proposalID = proposals.length - 1; @@ -453,7 +453,7 @@ contract DAO is DAOInterface, Token, TokenCreation { p.amount = _amount; p.description = _description; p.proposalHash = keccak256(abi.encodePacked(_recipient, _amount, _transactionData)); - p.votingDeadline = now + _debatingPeriod; + p.votingDeadline = block.timestamp + _debatingPeriod; p.open = true; //p.proposalPassed = False; // that's default p.newCurator = _newCurator; @@ -493,7 +493,7 @@ contract DAO is DAOInterface, Token, TokenCreation { Proposal storage p = proposals[_proposalID]; if (p.votedYes[msg.sender] || p.votedNo[msg.sender] - || now >= p.votingDeadline) { + || block.timestamp >= p.votingDeadline) { revert(); } @@ -529,13 +529,13 @@ contract DAO is DAOInterface, Token, TokenCreation { ? splitExecutionPeriod : executeProposalPeriod; // If we are over deadline and waiting period, assert proposal is closed - if (p.open && now > p.votingDeadline + waitPeriod) { + if (p.open && block.timestamp > p.votingDeadline + waitPeriod) { closeProposal(_proposalID); return false; } // Check if the proposal can be executed - if (now < p.votingDeadline // has the voting deadline arrived? + if (block.timestamp < p.votingDeadline // has the voting deadline arrived? // Have the votes been counted? || !p.open || p.proposalPassed // anyone trying to call us recursively? @@ -573,7 +573,7 @@ contract DAO is DAOInterface, Token, TokenCreation { if (!p.creator.send(p.proposalDeposit)) revert(); - lastTimeMinQuorumMet = now; + lastTimeMinQuorumMet = block.timestamp; // set the minQuorum to 20% again, in the case it has been reached if (quorum > totalSupply / 5) minQuorumDivisor = 5; @@ -587,7 +587,7 @@ contract DAO is DAOInterface, Token, TokenCreation { // multiple times out of the DAO p.proposalPassed = true; - (bool success,) = p.recipient.call.value(p.amount)(_transactionData); + (bool success,) = p.recipient.call{value: p.amount}(_transactionData); if (!success) revert(); @@ -628,9 +628,9 @@ contract DAO is DAOInterface, Token, TokenCreation { // Sanity check - if (now < p.votingDeadline // has the voting deadline arrived? + if (block.timestamp < p.votingDeadline // has the voting deadline arrived? //The request for a split expires XX days after the voting deadline - || now > p.votingDeadline + splitExecutionPeriod + || block.timestamp > p.votingDeadline + splitExecutionPeriod // Does the new Curator address match? || p.recipient != _newCurator // Is it a new curator proposal? @@ -663,7 +663,7 @@ contract DAO is DAOInterface, Token, TokenCreation { uint fundsToBeMoved = (balances[msg.sender] * p.splitData[0].splitBalance) / p.splitData[0].totalSupply; - if (p.splitData[0].newDAO.createTokenProxy.value(fundsToBeMoved)(msg.sender) == false) + if (p.splitData[0].newDAO.createTokenProxy{value: fundsToBeMoved}(msg.sender) == false) revert(); @@ -697,7 +697,7 @@ contract DAO is DAOInterface, Token, TokenCreation { function newContract(address payable _newContract) public override { if (msg.sender != address(this) || !allowedRecipients[_newContract]) return; // move all ether - (bool success,) = _newContract.call.value(address(this).balance)(""); + (bool success,) = _newContract.call{value: address(this).balance}(""); if (!success) { revert(); } @@ -759,7 +759,7 @@ override returns (bool _success) { function transfer(address _to, uint256 _value) public override returns (bool success) { if (isFueled - && now > closingTime + && block.timestamp > closingTime && !isBlocked(msg.sender) && _to != address(this) && transferPaidOut(msg.sender, _to, _value) @@ -782,7 +782,7 @@ override returns (bool _success) { function transferFrom(address _from, address _to, uint256 _value) public override returns (bool success) { if (isFueled - && now > closingTime + && block.timestamp > closingTime && !isBlocked(_from) && _to != address(this) && transferPaidOut(_from, _to, _value) @@ -869,11 +869,11 @@ override returns (bool _success) { // this can only be called after `quorumHalvingPeriod` has passed or at anytime after // fueling by the curator with a delay of at least `minProposalDebatePeriod` // between the calls - if ((lastTimeMinQuorumMet < (now - quorumHalvingPeriod) || msg.sender == curator) - && lastTimeMinQuorumMet < (now - minProposalDebatePeriod) - && now >= closingTime + if ((lastTimeMinQuorumMet < (block.timestamp - quorumHalvingPeriod) || msg.sender == curator) + && lastTimeMinQuorumMet < (block.timestamp - minProposalDebatePeriod) + && block.timestamp >= closingTime && proposals.length > 1) { - lastTimeMinQuorumMet = now; + lastTimeMinQuorumMet = block.timestamp; minQuorumDivisor *= 2; return true; } else { @@ -887,7 +887,7 @@ override returns (bool _success) { _newCurator, 0, 0, - now + splitExecutionPeriod, + block.timestamp + splitExecutionPeriod, name, symbol, decimals @@ -907,7 +907,7 @@ override returns (bool _success) { if (blocked[_account] == 0) return false; Proposal storage p = proposals[blocked[_account]]; - if (now > p.votingDeadline) { + if (block.timestamp > p.votingDeadline) { blocked[_account] = 0; return false; } else { diff --git a/test/externalTests/solc-js/DAO/ManagedAccount.sol b/test/externalTests/solc-js/DAO/ManagedAccount.sol index 0b334d2aa..879de9587 100644 --- a/test/externalTests/solc-js/DAO/ManagedAccount.sol +++ b/test/externalTests/solc-js/DAO/ManagedAccount.sol @@ -42,7 +42,7 @@ abstract contract ManagedAccountInterface { contract ManagedAccount is ManagedAccountInterface{ // The constructor sets the owner of the account - constructor(address _owner, bool _payOwnerOnly) public { + constructor(address _owner, bool _payOwnerOnly) { owner = _owner; payOwnerOnly = _payOwnerOnly; } @@ -57,7 +57,7 @@ contract ManagedAccount is ManagedAccountInterface{ function payOut(address payable _recipient, uint _amount) public override returns (bool) { if (msg.sender != owner || (payOwnerOnly && _recipient != owner)) revert(); - (bool success,) = _recipient.call.value(_amount)(""); + (bool success,) = _recipient.call{value: _amount}(""); if (success) { emit PayOut(_recipient, _amount); return true; diff --git a/test/externalTests/solc-js/DAO/TokenCreation.sol b/test/externalTests/solc-js/DAO/TokenCreation.sol index d85cb50b9..cf0d27a53 100644 --- a/test/externalTests/solc-js/DAO/TokenCreation.sol +++ b/test/externalTests/solc-js/DAO/TokenCreation.sol @@ -102,11 +102,11 @@ contract TokenCreation is TokenCreationInterface, Token { function createTokenProxy(address payable _tokenHolder) payable public override returns (bool success) { - if (now < closingTime && msg.value > 0 + if (block.timestamp < closingTime && msg.value > 0 && (privateCreation == 0x0000000000000000000000000000000000000000 || privateCreation == msg.sender)) { uint token = (msg.value * 20) / divisor(); - address(extraBalance).call.value(msg.value - token)(""); + address(extraBalance).call{value: msg.value - token}(""); balances[_tokenHolder] += token; totalSupply += token; weiGiven[_tokenHolder] += msg.value; @@ -121,13 +121,13 @@ override returns (bool success) { } function refund() public override { - if (now > closingTime && !isFueled) { + if (block.timestamp > closingTime && !isFueled) { // Get extraBalance - will only succeed when called for the first time if (address(extraBalance).balance >= extraBalance.accumulatedInput()) extraBalance.payOut(address(this), extraBalance.accumulatedInput()); // Execute refund - (bool success,) = msg.sender.call.value(weiGiven[msg.sender])(""); + (bool success,) = msg.sender.call{value: weiGiven[msg.sender]}(""); if (success) { emit Refund(msg.sender, weiGiven[msg.sender]); totalSupply -= balances[msg.sender]; @@ -141,11 +141,11 @@ override returns (bool success) { // The number of (base unit) tokens per wei is calculated // as `msg.value` * 20 / `divisor` // The fueling period starts with a 1:1 ratio - if (closingTime - 2 weeks > now) { + if (closingTime - 2 weeks > block.timestamp) { return 20; // Followed by 10 days with a daily creation rate increase of 5% - } else if (closingTime - 4 days > now) { - return (20 + (now - (closingTime - 2 weeks)) / (1 days)); + } else if (closingTime - 4 days > block.timestamp) { + return (20 + (block.timestamp - (closingTime - 2 weeks)) / (1 days)); // The last 4 days there is a constant creation rate ratio of 1:1.5 } else { return 30; diff --git a/test/externalTests/zeppelin.sh b/test/externalTests/zeppelin.sh index 7c82cd281..51051f334 100755 --- a/test/externalTests/zeppelin.sh +++ b/test/externalTests/zeppelin.sh @@ -33,7 +33,7 @@ function zeppelin_test OPTIMIZER_LEVEL=1 CONFIG="truffle-config.js" - truffle_setup https://github.com/OpenZeppelin/openzeppelin-contracts.git master + truffle_setup https://github.com/solidity-external-tests/openzeppelin-contracts.git upgrade-0.7.0 run_install install_fn truffle_run_test compile_fn test_fn diff --git a/test/libsolidity/ABIDecoderTests.cpp b/test/libsolidity/ABIDecoderTests.cpp index 2c3711ea3..611bc7cd3 100644 --- a/test/libsolidity/ABIDecoderTests.cpp +++ b/test/libsolidity/ABIDecoderTests.cpp @@ -319,7 +319,7 @@ BOOST_AUTO_TEST_CASE(decode_from_memory_simple) contract C { uint public _a; uint[] public _b; - constructor(uint a, uint[] memory b) public { + constructor(uint a, uint[] memory b) { _a = a; _b = b; } @@ -344,7 +344,7 @@ BOOST_AUTO_TEST_CASE(decode_function_type) string sourceCode = R"( contract D { function () external returns (uint) public _a; - constructor(function () external returns (uint) a) public { + constructor(function () external returns (uint) a) { _a = a; } } @@ -378,13 +378,13 @@ BOOST_AUTO_TEST_CASE(decode_function_type_array) string sourceCode = R"( contract D { function () external returns (uint)[] public _a; - constructor(function () external returns (uint)[] memory a) public { + constructor(function () external returns (uint)[] memory a) { _a = a; } } contract E { function () external returns (uint)[3] public _a; - constructor(function () external returns (uint)[3] memory a) public { + constructor(function () external returns (uint)[3] memory a) { _a = a; } } @@ -446,7 +446,7 @@ BOOST_AUTO_TEST_CASE(decode_from_memory_complex) uint public _a; uint[] public _b; bytes[2] public _c; - constructor(uint a, uint[] memory b, bytes[2] memory c) public { + constructor(uint a, uint[] memory b, bytes[2] memory c) { _a = a; _b = b; _c = c; diff --git a/test/libsolidity/ABIEncoderTests.cpp b/test/libsolidity/ABIEncoderTests.cpp index b804a458d..6c614e75b 100644 --- a/test/libsolidity/ABIEncoderTests.cpp +++ b/test/libsolidity/ABIEncoderTests.cpp @@ -719,7 +719,7 @@ BOOST_AUTO_TEST_CASE(struct_in_constructor) string c; } S public x; - constructor(S memory s) public { x = s; } + constructor(S memory s) { x = s; } } )"; @@ -739,7 +739,7 @@ BOOST_AUTO_TEST_CASE(struct_in_constructor_indirect) string c; } S public x; - constructor(S memory s) public { x = s; } + constructor(S memory s) { x = s; } } contract D { @@ -772,7 +772,7 @@ BOOST_AUTO_TEST_CASE(struct_in_constructor_data_short) string c; } S public x; - constructor(S memory s) public { x = s; } + constructor(S memory s) { x = s; } } )"; diff --git a/test/libsolidity/ABIJson/constructor_abi.sol b/test/libsolidity/ABIJson/constructor_abi.sol index d6cb1d495..ae07c9401 100644 --- a/test/libsolidity/ABIJson/constructor_abi.sol +++ b/test/libsolidity/ABIJson/constructor_abi.sol @@ -1,5 +1,5 @@ contract test { - constructor(uint param1, test param2, bool param3) public {} + constructor(uint param1, test param2, bool param3) {} } // ---- // :test diff --git a/test/libsolidity/ABIJson/internal_constructor.sol b/test/libsolidity/ABIJson/internal_constructor.sol index 7f8ea5ed2..47c783b5d 100644 --- a/test/libsolidity/ABIJson/internal_constructor.sol +++ b/test/libsolidity/ABIJson/internal_constructor.sol @@ -1,7 +1,7 @@ // bug #8712 -contract B { +abstract contract B { uint immutable x; - constructor(function() internal returns(uint) fp) internal { + constructor(function() internal returns(uint) fp) { x = fp(); } } // ---- diff --git a/test/libsolidity/ABIJson/payable_constructor_abi.sol b/test/libsolidity/ABIJson/payable_constructor_abi.sol index e9497b248..579e83efb 100644 --- a/test/libsolidity/ABIJson/payable_constructor_abi.sol +++ b/test/libsolidity/ABIJson/payable_constructor_abi.sol @@ -1,5 +1,5 @@ contract test { - constructor(uint param1, test param2, bool param3) public payable {} + constructor(uint param1, test param2, bool param3) payable {} } // ---- // :test diff --git a/test/libsolidity/ABIJson/return_param_in_abi.sol b/test/libsolidity/ABIJson/return_param_in_abi.sol index 92782a73d..23995d62a 100644 --- a/test/libsolidity/ABIJson/return_param_in_abi.sol +++ b/test/libsolidity/ABIJson/return_param_in_abi.sol @@ -1,7 +1,7 @@ // bug #1801 contract test { enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } - constructor(ActionChoices param) public {} + constructor(ActionChoices param) {} function ret() public returns (ActionChoices) { ActionChoices action = ActionChoices.GoLeft; return action; diff --git a/test/libsolidity/ASTJSON/abstract_contract.json b/test/libsolidity/ASTJSON/abstract_contract.json index 32b414e8a..08b1e6d95 100644 --- a/test/libsolidity/ASTJSON/abstract_contract.json +++ b/test/libsolidity/ASTJSON/abstract_contract.json @@ -8,7 +8,6 @@ ] }, "id": 6, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 5, "linearizedBaseContracts": @@ -33,17 +31,15 @@ { "id": 3, "nodeType": "Block", - "src": "44:4:1", + "src": "37:4:1", "statements": [] }, - "documentation": null, "id": 4, "implemented": true, "kind": "constructor", "modifiers": [], "name": "", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, @@ -56,18 +52,18 @@ "id": 2, "nodeType": "ParameterList", "parameters": [], - "src": "44:0:1" + "src": "37:0:1" }, "scope": 5, - "src": "23:25:1", + "src": "23:18:1", "stateMutability": "nonpayable", "virtual": false, - "visibility": "public" + "visibility": "internal" } ], "scope": 6, - "src": "0:50:1" + "src": "0:43:1" } ], - "src": "0:51:1" + "src": "0:44:1" } diff --git a/test/libsolidity/ASTJSON/abstract_contract.sol b/test/libsolidity/ASTJSON/abstract_contract.sol index 8ff9955c2..bddbc1779 100644 --- a/test/libsolidity/ASTJSON/abstract_contract.sol +++ b/test/libsolidity/ASTJSON/abstract_contract.sol @@ -1,5 +1,5 @@ abstract contract C { - constructor() public { + constructor() { } } diff --git a/test/libsolidity/ASTJSON/abstract_contract_legacy.json b/test/libsolidity/ASTJSON/abstract_contract_legacy.json index 13f046eec..c13abca7f 100644 --- a/test/libsolidity/ASTJSON/abstract_contract_legacy.json +++ b/test/libsolidity/ASTJSON/abstract_contract_legacy.json @@ -8,8 +8,7 @@ [ 5 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,7 +38,6 @@ { "attributes": { - "documentation": null, "implemented": true, "isConstructor": true, "kind": "constructor", @@ -49,11 +46,10 @@ null ], "name": "", - "overrides": null, "scope": 5, "stateMutability": "nonpayable", "virtual": false, - "visibility": "public" + "visibility": "internal" }, "children": [ @@ -81,7 +77,7 @@ "children": [], "id": 2, "name": "ParameterList", - "src": "44:0:1" + "src": "37:0:1" }, { "attributes": @@ -94,20 +90,20 @@ "children": [], "id": 3, "name": "Block", - "src": "44:4:1" + "src": "37:4:1" } ], "id": 4, "name": "FunctionDefinition", - "src": "23:25:1" + "src": "23:18:1" } ], "id": 5, "name": "ContractDefinition", - "src": "0:50:1" + "src": "0:43:1" } ], "id": 6, "name": "SourceUnit", - "src": "0:51:1" + "src": "0:44:1" } diff --git a/test/libsolidity/ASTJSON/address_payable.json b/test/libsolidity/ASTJSON/address_payable.json index a82fa0b82..3365ec436 100644 --- a/test/libsolidity/ASTJSON/address_payable.json +++ b/test/libsolidity/ASTJSON/address_payable.json @@ -8,7 +8,6 @@ ] }, "id": 40, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 39, "linearizedBaseContracts": @@ -35,7 +33,6 @@ "mutability": "mutable", "name": "m", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 39, "src": "17:44:1", "stateVariable": true, @@ -81,7 +78,6 @@ } } }, - "value": null, "visibility": "public" }, { @@ -105,7 +101,6 @@ "mutability": "mutable", "name": "a", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 37, "src": "144:17:1", "stateVariable": false, @@ -128,17 +123,14 @@ "typeString": "address payable" } }, - "value": null, "visibility": "internal" } ], "id": 16, "initialValue": { - "argumentTypes": null, "baseExpression": { - "argumentTypes": null, "id": 13, "name": "m", "nodeType": "Identifier", @@ -154,7 +146,6 @@ "id": 15, "indexExpression": { - "argumentTypes": null, "id": 14, "name": "arg", "nodeType": "Identifier", @@ -185,7 +176,6 @@ { "expression": { - "argumentTypes": null, "id": 19, "isConstant": false, "isLValue": false, @@ -193,7 +183,6 @@ "lValueRequested": false, "leftHandSide": { - "argumentTypes": null, "id": 17, "name": "r", "nodeType": "Identifier", @@ -210,7 +199,6 @@ "operator": "=", "rightHandSide": { - "argumentTypes": null, "id": 18, "name": "arg", "nodeType": "Identifier", @@ -247,7 +235,6 @@ "mutability": "mutable", "name": "c", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 37, "src": "197:9:1", "stateVariable": false, @@ -270,18 +257,15 @@ "typeString": "address" } }, - "value": null, "visibility": "internal" } ], "id": 27, "initialValue": { - "argumentTypes": null, "arguments": [ { - "argumentTypes": null, "id": 25, "name": "this", "nodeType": "Identifier", @@ -322,11 +306,7 @@ "name": "address", "nodeType": "ElementaryTypeName", "src": "209:7:1", - "typeDescriptions": - { - "typeIdentifier": null, - "typeString": null - } + "typeDescriptions": {} } }, "id": 26, @@ -351,7 +331,6 @@ { "expression": { - "argumentTypes": null, "id": 35, "isConstant": false, "isLValue": false, @@ -359,10 +338,8 @@ "lValueRequested": false, "leftHandSide": { - "argumentTypes": null, "baseExpression": { - "argumentTypes": null, "id": 28, "name": "m", "nodeType": "Identifier", @@ -378,7 +355,6 @@ "id": 30, "indexExpression": { - "argumentTypes": null, "id": 29, "name": "c", "nodeType": "Identifier", @@ -407,11 +383,9 @@ "operator": "=", "rightHandSide": { - "argumentTypes": null, "arguments": [ { - "argumentTypes": null, "hexValue": "30", "id": 33, "isConstant": false, @@ -421,7 +395,6 @@ "lValueRequested": false, "nodeType": "Literal", "src": "247:1:1", - "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", @@ -457,11 +430,7 @@ "name": "address", "nodeType": "ElementaryTypeName", "src": "239:7:1", - "typeDescriptions": - { - "typeIdentifier": null, - "typeString": null - } + "typeDescriptions": {} } }, "id": 34, @@ -493,7 +462,6 @@ } ] }, - "documentation": null, "functionSelector": "fc68521a", "id": 38, "implemented": true, @@ -501,7 +469,6 @@ "modifiers": [], "name": "f", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 7, @@ -514,7 +481,6 @@ "mutability": "mutable", "name": "arg", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 38, "src": "78:19:1", "stateVariable": false, @@ -537,7 +503,6 @@ "typeString": "address payable" } }, - "value": null, "visibility": "internal" } ], @@ -555,7 +520,6 @@ "mutability": "mutable", "name": "r", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 38, "src": "115:17:1", "stateVariable": false, @@ -578,7 +542,6 @@ "typeString": "address payable" } }, - "value": null, "visibility": "internal" } ], diff --git a/test/libsolidity/ASTJSON/address_payable_legacy.json b/test/libsolidity/ASTJSON/address_payable_legacy.json index 7fe404f3e..bda50fc57 100644 --- a/test/libsolidity/ASTJSON/address_payable_legacy.json +++ b/test/libsolidity/ASTJSON/address_payable_legacy.json @@ -8,8 +8,7 @@ [ 39 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -44,12 +42,10 @@ "functionSelector": "97682884", "mutability": "mutable", "name": "m", - "overrides": null, "scope": 39, "stateVariable": true, "storageLocation": "default", "type": "mapping(address => address payable)", - "value": null, "visibility": "public" }, "children": @@ -95,7 +91,6 @@ { "attributes": { - "documentation": null, "functionSelector": "fc68521a", "implemented": true, "isConstructor": false, @@ -105,7 +100,6 @@ null ], "name": "f", - "overrides": null, "scope": 39, "stateMutability": "nonpayable", "virtual": false, @@ -122,12 +116,10 @@ "constant": false, "mutability": "mutable", "name": "arg", - "overrides": null, "scope": 38, "stateVariable": false, "storageLocation": "default", "type": "address payable", - "value": null, "visibility": "internal" }, "children": @@ -162,12 +154,10 @@ "constant": false, "mutability": "mutable", "name": "r", - "overrides": null, "scope": 38, "stateVariable": false, "storageLocation": "default", "type": "address payable", - "value": null, "visibility": "internal" }, "children": @@ -212,12 +202,10 @@ "constant": false, "mutability": "mutable", "name": "a", - "overrides": null, "scope": 37, "stateVariable": false, "storageLocation": "default", "type": "address payable", - "value": null, "visibility": "internal" }, "children": @@ -241,7 +229,6 @@ { "attributes": { - "argumentTypes": null, "isConstant": false, "isLValue": true, "isPure": false, @@ -253,7 +240,6 @@ { "attributes": { - "argumentTypes": null, "overloadedDeclarations": [ null @@ -269,7 +255,6 @@ { "attributes": { - "argumentTypes": null, "overloadedDeclarations": [ null @@ -298,7 +283,6 @@ { "attributes": { - "argumentTypes": null, "isConstant": false, "isLValue": false, "isPure": false, @@ -311,7 +295,6 @@ { "attributes": { - "argumentTypes": null, "overloadedDeclarations": [ null @@ -327,7 +310,6 @@ { "attributes": { - "argumentTypes": null, "overloadedDeclarations": [ null @@ -366,12 +348,10 @@ "constant": false, "mutability": "mutable", "name": "c", - "overrides": null, "scope": 37, "stateVariable": false, "storageLocation": "default", "type": "address", - "value": null, "visibility": "internal" }, "children": @@ -395,7 +375,6 @@ { "attributes": { - "argumentTypes": null, "isConstant": false, "isLValue": false, "isPure": false, @@ -432,8 +411,7 @@ { "attributes": { - "name": "address", - "type": null + "name": "address" }, "id": 23, "name": "ElementaryTypeName", @@ -447,7 +425,6 @@ { "attributes": { - "argumentTypes": null, "overloadedDeclarations": [ null @@ -476,7 +453,6 @@ { "attributes": { - "argumentTypes": null, "isConstant": false, "isLValue": false, "isPure": false, @@ -489,7 +465,6 @@ { "attributes": { - "argumentTypes": null, "isConstant": false, "isLValue": true, "isPure": false, @@ -501,7 +476,6 @@ { "attributes": { - "argumentTypes": null, "overloadedDeclarations": [ null @@ -517,7 +491,6 @@ { "attributes": { - "argumentTypes": null, "overloadedDeclarations": [ null @@ -538,7 +511,6 @@ { "attributes": { - "argumentTypes": null, "isConstant": false, "isLValue": false, "isPure": true, @@ -575,8 +547,7 @@ { "attributes": { - "name": "address", - "type": null + "name": "address" }, "id": 31, "name": "ElementaryTypeName", @@ -590,13 +561,11 @@ { "attributes": { - "argumentTypes": null, "hexvalue": "30", "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, - "subdenomination": null, "token": "number", "type": "int_const 0", "value": "0" diff --git a/test/libsolidity/ASTJSON/array_type_name.json b/test/libsolidity/ASTJSON/array_type_name.json index a09bc306a..90649b501 100644 --- a/test/libsolidity/ASTJSON/array_type_name.json +++ b/test/libsolidity/ASTJSON/array_type_name.json @@ -8,7 +8,6 @@ ] }, "id": 5, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 4, "linearizedBaseContracts": @@ -34,7 +32,6 @@ "mutability": "mutable", "name": "i", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 4, "src": "13:8:1", "stateVariable": true, @@ -59,7 +56,6 @@ } }, "id": 2, - "length": null, "nodeType": "ArrayTypeName", "src": "13:6:1", "typeDescriptions": @@ -68,7 +64,6 @@ "typeString": "uint256[]" } }, - "value": null, "visibility": "internal" } ], diff --git a/test/libsolidity/ASTJSON/array_type_name_legacy.json b/test/libsolidity/ASTJSON/array_type_name_legacy.json index cc1c7a77a..304d59da8 100644 --- a/test/libsolidity/ASTJSON/array_type_name_legacy.json +++ b/test/libsolidity/ASTJSON/array_type_name_legacy.json @@ -8,8 +8,7 @@ [ 4 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -43,12 +41,10 @@ "constant": false, "mutability": "mutable", "name": "i", - "overrides": null, "scope": 4, "stateVariable": true, "storageLocation": "default", "type": "uint256[]", - "value": null, "visibility": "internal" }, "children": @@ -56,7 +52,6 @@ { "attributes": { - "length": null, "type": "uint256[]" }, "children": diff --git a/test/libsolidity/ASTJSON/assembly/call.json b/test/libsolidity/ASTJSON/assembly/call.json index ad81c1094..9538fe5cc 100644 --- a/test/libsolidity/ASTJSON/assembly/call.json +++ b/test/libsolidity/ASTJSON/assembly/call.json @@ -8,7 +8,6 @@ ] }, "id": 7, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 6, "linearizedBaseContracts": @@ -133,7 +131,6 @@ } ] }, - "documentation": null, "functionSelector": "b582ec5f", "id": 5, "implemented": true, @@ -141,7 +138,6 @@ "modifiers": [], "name": "j", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, diff --git a/test/libsolidity/ASTJSON/assembly/call_legacy.json b/test/libsolidity/ASTJSON/assembly/call_legacy.json index 93ad1b956..2902873fa 100644 --- a/test/libsolidity/ASTJSON/assembly/call_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/call_legacy.json @@ -8,8 +8,7 @@ [ 6 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,7 +38,6 @@ { "attributes": { - "documentation": null, "functionSelector": "b582ec5f", "implemented": true, "isConstructor": false, @@ -50,7 +47,6 @@ null ], "name": "j", - "overrides": null, "scope": 6, "stateMutability": "nonpayable", "virtual": false, diff --git a/test/libsolidity/ASTJSON/assembly/empty_block.json b/test/libsolidity/ASTJSON/assembly/empty_block.json index 847fd4085..2d22cc035 100644 --- a/test/libsolidity/ASTJSON/assembly/empty_block.json +++ b/test/libsolidity/ASTJSON/assembly/empty_block.json @@ -8,7 +8,6 @@ ] }, "id": 7, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 6, "linearizedBaseContracts": @@ -58,7 +56,6 @@ } ] }, - "documentation": null, "functionSelector": "e2179b8e", "id": 5, "implemented": true, @@ -66,7 +63,6 @@ "modifiers": [], "name": "g", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, diff --git a/test/libsolidity/ASTJSON/assembly/empty_block_legacy.json b/test/libsolidity/ASTJSON/assembly/empty_block_legacy.json index 74d24d5e1..54811bf1a 100644 --- a/test/libsolidity/ASTJSON/assembly/empty_block_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/empty_block_legacy.json @@ -8,8 +8,7 @@ [ 6 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,7 +38,6 @@ { "attributes": { - "documentation": null, "functionSelector": "e2179b8e", "implemented": true, "isConstructor": false, @@ -50,7 +47,6 @@ null ], "name": "g", - "overrides": null, "scope": 6, "stateMutability": "view", "virtual": false, diff --git a/test/libsolidity/ASTJSON/assembly/function.json b/test/libsolidity/ASTJSON/assembly/function.json index 6bd37162d..ccbf3d853 100644 --- a/test/libsolidity/ASTJSON/assembly/function.json +++ b/test/libsolidity/ASTJSON/assembly/function.json @@ -8,7 +8,6 @@ ] }, "id": 7, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 6, "linearizedBaseContracts": @@ -120,7 +118,6 @@ } ] }, - "documentation": null, "functionSelector": "b8c9d365", "id": 5, "implemented": true, @@ -128,7 +125,6 @@ "modifiers": [], "name": "h", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, diff --git a/test/libsolidity/ASTJSON/assembly/function_legacy.json b/test/libsolidity/ASTJSON/assembly/function_legacy.json index ee6918d25..940a4b6ac 100644 --- a/test/libsolidity/ASTJSON/assembly/function_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/function_legacy.json @@ -8,8 +8,7 @@ [ 6 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,7 +38,6 @@ { "attributes": { - "documentation": null, "functionSelector": "b8c9d365", "implemented": true, "isConstructor": false, @@ -50,7 +47,6 @@ null ], "name": "h", - "overrides": null, "scope": 6, "stateMutability": "view", "virtual": false, diff --git a/test/libsolidity/ASTJSON/assembly/leave.json b/test/libsolidity/ASTJSON/assembly/leave.json index 5868c1acb..ba765146f 100644 --- a/test/libsolidity/ASTJSON/assembly/leave.json +++ b/test/libsolidity/ASTJSON/assembly/leave.json @@ -8,7 +8,6 @@ ] }, "id": 7, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 6, "linearizedBaseContracts": @@ -70,7 +68,6 @@ } ] }, - "documentation": null, "functionSelector": "ece866b9", "id": 5, "implemented": true, @@ -78,7 +75,6 @@ "modifiers": [], "name": "l", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, diff --git a/test/libsolidity/ASTJSON/assembly/leave_legacy.json b/test/libsolidity/ASTJSON/assembly/leave_legacy.json index 2c39fba37..fa71bcba0 100644 --- a/test/libsolidity/ASTJSON/assembly/leave_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/leave_legacy.json @@ -8,8 +8,7 @@ [ 6 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,7 +38,6 @@ { "attributes": { - "documentation": null, "functionSelector": "ece866b9", "implemented": true, "isConstructor": false, @@ -50,7 +47,6 @@ null ], "name": "l", - "overrides": null, "scope": 6, "stateMutability": "nonpayable", "virtual": false, diff --git a/test/libsolidity/ASTJSON/assembly/loop.json b/test/libsolidity/ASTJSON/assembly/loop.json index 263db400d..9c99cf491 100644 --- a/test/libsolidity/ASTJSON/assembly/loop.json +++ b/test/libsolidity/ASTJSON/assembly/loop.json @@ -8,7 +8,6 @@ ] }, "id": 7, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 6, "linearizedBaseContracts": @@ -133,7 +131,6 @@ } ] }, - "documentation": null, "functionSelector": "e2179b8e", "id": 5, "implemented": true, @@ -141,7 +138,6 @@ "modifiers": [], "name": "g", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, diff --git a/test/libsolidity/ASTJSON/assembly/loop_legacy.json b/test/libsolidity/ASTJSON/assembly/loop_legacy.json index 5085e4c50..84890475f 100644 --- a/test/libsolidity/ASTJSON/assembly/loop_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/loop_legacy.json @@ -8,8 +8,7 @@ [ 6 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,7 +38,6 @@ { "attributes": { - "documentation": null, "functionSelector": "e2179b8e", "implemented": true, "isConstructor": false, @@ -50,7 +47,6 @@ null ], "name": "g", - "overrides": null, "scope": 6, "stateMutability": "view", "virtual": false, diff --git a/test/libsolidity/ASTJSON/assembly/nested_functions.json b/test/libsolidity/ASTJSON/assembly/nested_functions.json index 5abb7fce4..f945494ba 100644 --- a/test/libsolidity/ASTJSON/assembly/nested_functions.json +++ b/test/libsolidity/ASTJSON/assembly/nested_functions.json @@ -8,7 +8,6 @@ ] }, "id": 9, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 8, "linearizedBaseContracts": @@ -97,7 +95,6 @@ } ] }, - "documentation": null, "functionSelector": "26121ff0", "id": 7, "implemented": true, @@ -105,7 +102,6 @@ "modifiers": [], "name": "f", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, @@ -125,29 +121,19 @@ "mutability": "mutable", "name": "x", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 7, "src": "49:6:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { - "typeIdentifier": null, - "typeString": null - }, + "typeDescriptions": {}, "typeName": { "id": 2, "name": "uint", "nodeType": "ElementaryTypeName", "src": "49:4:1", - "typeDescriptions": - { - "typeIdentifier": null, - "typeString": null - } + "typeDescriptions": {} }, - "value": null, "visibility": "internal" } ], diff --git a/test/libsolidity/ASTJSON/assembly/nested_functions_legacy.json b/test/libsolidity/ASTJSON/assembly/nested_functions_legacy.json index 0ccfcf85a..393646221 100644 --- a/test/libsolidity/ASTJSON/assembly/nested_functions_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/nested_functions_legacy.json @@ -8,8 +8,7 @@ [ 8 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,7 +38,6 @@ { "attributes": { - "documentation": null, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, @@ -50,7 +47,6 @@ null ], "name": "f", - "overrides": null, "scope": 8, "stateMutability": "pure", "virtual": false, @@ -80,12 +76,9 @@ "constant": false, "mutability": "mutable", "name": "x", - "overrides": null, "scope": 7, "stateVariable": false, "storageLocation": "default", - "type": null, - "value": null, "visibility": "internal" }, "children": @@ -93,8 +86,7 @@ { "attributes": { - "name": "uint", - "type": null + "name": "uint" }, "id": 2, "name": "ElementaryTypeName", diff --git a/test/libsolidity/ASTJSON/assembly/slot_offset.json b/test/libsolidity/ASTJSON/assembly/slot_offset.json index 7231747c4..0858fe617 100644 --- a/test/libsolidity/ASTJSON/assembly/slot_offset.json +++ b/test/libsolidity/ASTJSON/assembly/slot_offset.json @@ -8,7 +8,6 @@ ] }, "id": 12, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 11, "linearizedBaseContracts": @@ -39,7 +37,6 @@ "mutability": "mutable", "name": "x", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 3, "src": "28:6:1", "stateVariable": false, @@ -61,7 +58,6 @@ "typeString": "uint256" } }, - "value": null, "visibility": "internal" } ], @@ -77,7 +73,6 @@ "mutability": "mutable", "name": "s", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 11, "src": "42:3:1", "stateVariable": true, @@ -89,7 +84,6 @@ }, "typeName": { - "contractScope": null, "id": 4, "name": "S", "nodeType": "UserDefinedTypeName", @@ -101,7 +95,6 @@ "typeString": "struct C.S" } }, - "value": null, "visibility": "internal" }, { @@ -124,7 +117,7 @@ "src": "97:17:1", "value": { - "name": "s_offset", + "name": "s.offset", "nodeType": "YulIdentifier", "src": "106:8:1" }, @@ -146,7 +139,7 @@ "arguments": [ { - "name": "s_slot", + "name": "s.slot", "nodeType": "YulIdentifier", "src": "128:6:1" }, @@ -203,7 +196,6 @@ } ] }, - "documentation": null, "functionSelector": "ffae15ba", "id": 10, "implemented": true, @@ -211,7 +203,6 @@ "modifiers": [], "name": "e", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 6, diff --git a/test/libsolidity/ASTJSON/assembly/slot_offset.sol b/test/libsolidity/ASTJSON/assembly/slot_offset.sol index 367d66179..d3c8f7554 100644 --- a/test/libsolidity/ASTJSON/assembly/slot_offset.sol +++ b/test/libsolidity/ASTJSON/assembly/slot_offset.sol @@ -2,7 +2,7 @@ contract C { struct S { uint x; } S s; function e() pure public { - assembly { let x := s_offset let y := mul(s_slot, 2) } + assembly { let x := s.offset let y := mul(s.slot, 2) } } } diff --git a/test/libsolidity/ASTJSON/assembly/slot_offset_legacy.json b/test/libsolidity/ASTJSON/assembly/slot_offset_legacy.json index 574c7ad75..50747baaa 100644 --- a/test/libsolidity/ASTJSON/assembly/slot_offset_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/slot_offset_legacy.json @@ -8,8 +8,7 @@ [ 11 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -53,12 +51,10 @@ "constant": false, "mutability": "mutable", "name": "x", - "overrides": null, "scope": 3, "stateVariable": false, "storageLocation": "default", "type": "uint256", - "value": null, "visibility": "internal" }, "children": @@ -89,12 +85,10 @@ "constant": false, "mutability": "mutable", "name": "s", - "overrides": null, "scope": 11, "stateVariable": true, "storageLocation": "default", "type": "struct C.S", - "value": null, "visibility": "internal" }, "children": @@ -102,7 +96,6 @@ { "attributes": { - "contractScope": null, "name": "S", "referencedDeclaration": 3, "type": "struct C.S" @@ -119,7 +112,6 @@ { "attributes": { - "documentation": null, "functionSelector": "ffae15ba", "implemented": true, "isConstructor": false, @@ -129,7 +121,6 @@ null ], "name": "e", - "overrides": null, "scope": 11, "stateMutability": "pure", "virtual": false, @@ -187,7 +178,7 @@ "valueSize": 1 } ], - "operations": "{\n let x := s_offset\n let y := mul(s_slot, 2)\n}" + "operations": "{\n let x := s.offset\n let y := mul(s.slot, 2)\n}" }, "children": [], "id": 8, diff --git a/test/libsolidity/ASTJSON/assembly/stringlit.json b/test/libsolidity/ASTJSON/assembly/stringlit.json index 7fd0b9b84..08e0ea4f6 100644 --- a/test/libsolidity/ASTJSON/assembly/stringlit.json +++ b/test/libsolidity/ASTJSON/assembly/stringlit.json @@ -8,7 +8,6 @@ ] }, "id": 7, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 6, "linearizedBaseContracts": @@ -74,7 +72,6 @@ } ] }, - "documentation": null, "functionSelector": "5a2ee019", "id": 5, "implemented": true, @@ -82,7 +79,6 @@ "modifiers": [], "name": "m", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, diff --git a/test/libsolidity/ASTJSON/assembly/stringlit_legacy.json b/test/libsolidity/ASTJSON/assembly/stringlit_legacy.json index 76c503925..325d25274 100644 --- a/test/libsolidity/ASTJSON/assembly/stringlit_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/stringlit_legacy.json @@ -8,8 +8,7 @@ [ 6 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,7 +38,6 @@ { "attributes": { - "documentation": null, "functionSelector": "5a2ee019", "implemented": true, "isConstructor": false, @@ -50,7 +47,6 @@ null ], "name": "m", - "overrides": null, "scope": 6, "stateMutability": "nonpayable", "virtual": false, diff --git a/test/libsolidity/ASTJSON/assembly/switch.json b/test/libsolidity/ASTJSON/assembly/switch.json index 61b462f1e..9ae71f15c 100644 --- a/test/libsolidity/ASTJSON/assembly/switch.json +++ b/test/libsolidity/ASTJSON/assembly/switch.json @@ -8,7 +8,6 @@ ] }, "id": 7, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 6, "linearizedBaseContracts": @@ -182,7 +180,6 @@ } ] }, - "documentation": null, "functionSelector": "26121ff0", "id": 5, "implemented": true, @@ -190,7 +187,6 @@ "modifiers": [], "name": "f", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, diff --git a/test/libsolidity/ASTJSON/assembly/switch_default.json b/test/libsolidity/ASTJSON/assembly/switch_default.json index 3a6c71864..4226a8ea3 100644 --- a/test/libsolidity/ASTJSON/assembly/switch_default.json +++ b/test/libsolidity/ASTJSON/assembly/switch_default.json @@ -8,7 +8,6 @@ ] }, "id": 7, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 6, "linearizedBaseContracts": @@ -97,7 +95,6 @@ } ] }, - "documentation": null, "functionSelector": "e2179b8e", "id": 5, "implemented": true, @@ -105,7 +102,6 @@ "modifiers": [], "name": "g", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, diff --git a/test/libsolidity/ASTJSON/assembly/switch_default_legacy.json b/test/libsolidity/ASTJSON/assembly/switch_default_legacy.json index 3b79ccf44..324330f86 100644 --- a/test/libsolidity/ASTJSON/assembly/switch_default_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/switch_default_legacy.json @@ -8,8 +8,7 @@ [ 6 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,7 +38,6 @@ { "attributes": { - "documentation": null, "functionSelector": "e2179b8e", "implemented": true, "isConstructor": false, @@ -50,7 +47,6 @@ null ], "name": "g", - "overrides": null, "scope": 6, "stateMutability": "view", "virtual": false, diff --git a/test/libsolidity/ASTJSON/assembly/switch_legacy.json b/test/libsolidity/ASTJSON/assembly/switch_legacy.json index dab33b305..92e2e2c61 100644 --- a/test/libsolidity/ASTJSON/assembly/switch_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/switch_legacy.json @@ -8,8 +8,7 @@ [ 6 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,7 +38,6 @@ { "attributes": { - "documentation": null, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, @@ -50,7 +47,6 @@ null ], "name": "f", - "overrides": null, "scope": 6, "stateMutability": "pure", "virtual": false, diff --git a/test/libsolidity/ASTJSON/assembly/var_access.json b/test/libsolidity/ASTJSON/assembly/var_access.json index c44940a28..f10c45cc4 100644 --- a/test/libsolidity/ASTJSON/assembly/var_access.json +++ b/test/libsolidity/ASTJSON/assembly/var_access.json @@ -8,7 +8,6 @@ ] }, "id": 10, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 9, "linearizedBaseContracts": @@ -49,7 +47,6 @@ "mutability": "mutable", "name": "x", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 7, "src": "52:6:1", "stateVariable": false, @@ -71,12 +68,10 @@ "typeString": "uint256" } }, - "value": null, "visibility": "internal" } ], "id": 5, - "initialValue": null, "nodeType": "VariableDeclarationStatement", "src": "52:6:1" }, @@ -126,7 +121,6 @@ } ] }, - "documentation": null, "functionSelector": "26121ff0", "id": 8, "implemented": true, @@ -134,7 +128,6 @@ "modifiers": [], "name": "f", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, diff --git a/test/libsolidity/ASTJSON/assembly/var_access_legacy.json b/test/libsolidity/ASTJSON/assembly/var_access_legacy.json index a80a24613..fcd798ad9 100644 --- a/test/libsolidity/ASTJSON/assembly/var_access_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/var_access_legacy.json @@ -8,8 +8,7 @@ [ 9 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,7 +38,6 @@ { "attributes": { - "documentation": null, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, @@ -50,7 +47,6 @@ null ], "name": "f", - "overrides": null, "scope": 9, "stateMutability": "pure", "virtual": false, @@ -93,8 +89,7 @@ "assignments": [ 4 - ], - "initialValue": null + ] }, "children": [ @@ -104,12 +99,10 @@ "constant": false, "mutability": "mutable", "name": "x", - "overrides": null, "scope": 7, "stateVariable": false, "storageLocation": "default", "type": "uint256", - "value": null, "visibility": "internal" }, "children": diff --git a/test/libsolidity/ASTJSON/constructor.json b/test/libsolidity/ASTJSON/constructor.json index 321d93471..31747901e 100644 --- a/test/libsolidity/ASTJSON/constructor.json +++ b/test/libsolidity/ASTJSON/constructor.json @@ -8,7 +8,6 @@ ] }, "id": 6, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 5, "linearizedBaseContracts": @@ -33,17 +31,15 @@ { "id": 3, "nodeType": "Block", - "src": "35:4:1", + "src": "28:4:1", "statements": [] }, - "documentation": null, "id": 4, "implemented": true, "kind": "constructor", "modifiers": [], "name": "", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, @@ -56,18 +52,18 @@ "id": 2, "nodeType": "ParameterList", "parameters": [], - "src": "35:0:1" + "src": "28:0:1" }, "scope": 5, - "src": "14:25:1", + "src": "14:18:1", "stateMutability": "nonpayable", "virtual": false, "visibility": "public" } ], "scope": 6, - "src": "0:41:1" + "src": "0:34:1" } ], - "src": "0:42:1" + "src": "0:35:1" } diff --git a/test/libsolidity/ASTJSON/constructor.sol b/test/libsolidity/ASTJSON/constructor.sol index f89ac45b4..b2b1c6460 100644 --- a/test/libsolidity/ASTJSON/constructor.sol +++ b/test/libsolidity/ASTJSON/constructor.sol @@ -1,5 +1,5 @@ contract C { - constructor() public { + constructor() { } } diff --git a/test/libsolidity/ASTJSON/constructor_legacy.json b/test/libsolidity/ASTJSON/constructor_legacy.json index 9417561a7..68a648bc9 100644 --- a/test/libsolidity/ASTJSON/constructor_legacy.json +++ b/test/libsolidity/ASTJSON/constructor_legacy.json @@ -8,8 +8,7 @@ [ 5 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,7 +38,6 @@ { "attributes": { - "documentation": null, "implemented": true, "isConstructor": true, "kind": "constructor", @@ -49,7 +46,6 @@ null ], "name": "", - "overrides": null, "scope": 5, "stateMutability": "nonpayable", "virtual": false, @@ -81,7 +77,7 @@ "children": [], "id": 2, "name": "ParameterList", - "src": "35:0:1" + "src": "28:0:1" }, { "attributes": @@ -94,20 +90,20 @@ "children": [], "id": 3, "name": "Block", - "src": "35:4:1" + "src": "28:4:1" } ], "id": 4, "name": "FunctionDefinition", - "src": "14:25:1" + "src": "14:18:1" } ], "id": 5, "name": "ContractDefinition", - "src": "0:41:1" + "src": "0:34:1" } ], "id": 6, "name": "SourceUnit", - "src": "0:42:1" + "src": "0:35:1" } diff --git a/test/libsolidity/ASTJSON/contract_dep_order.json b/test/libsolidity/ASTJSON/contract_dep_order.json index b4a93ff75..ff1247548 100644 --- a/test/libsolidity/ASTJSON/contract_dep_order.json +++ b/test/libsolidity/ASTJSON/contract_dep_order.json @@ -24,7 +24,6 @@ ] }, "id": 14, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -33,7 +32,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 1, "linearizedBaseContracts": @@ -51,10 +49,8 @@ "baseContracts": [ { - "arguments": null, "baseName": { - "contractScope": null, "id": 2, "name": "A", "nodeType": "UserDefinedTypeName", @@ -76,7 +72,6 @@ 1 ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 4, "linearizedBaseContracts": @@ -95,10 +90,8 @@ "baseContracts": [ { - "arguments": null, "baseName": { - "contractScope": null, "id": 5, "name": "B", "nodeType": "UserDefinedTypeName", @@ -121,7 +114,6 @@ 4 ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 7, "linearizedBaseContracts": @@ -141,10 +133,8 @@ "baseContracts": [ { - "arguments": null, "baseName": { - "contractScope": null, "id": 8, "name": "C", "nodeType": "UserDefinedTypeName", @@ -168,7 +158,6 @@ 7 ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 10, "linearizedBaseContracts": @@ -189,10 +178,8 @@ "baseContracts": [ { - "arguments": null, "baseName": { - "contractScope": null, "id": 11, "name": "D", "nodeType": "UserDefinedTypeName", @@ -217,7 +204,6 @@ 10 ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 13, "linearizedBaseContracts": diff --git a/test/libsolidity/ASTJSON/contract_dep_order_legacy.json b/test/libsolidity/ASTJSON/contract_dep_order_legacy.json index 75ac151e8..20f40cb90 100644 --- a/test/libsolidity/ASTJSON/contract_dep_order_legacy.json +++ b/test/libsolidity/ASTJSON/contract_dep_order_legacy.json @@ -24,8 +24,7 @@ [ 13 ] - }, - "license": null + } }, "children": [ @@ -42,7 +41,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -68,7 +66,6 @@ 1 ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -85,16 +82,12 @@ "children": [ { - "attributes": - { - "arguments": null - }, + "attributes": {}, "children": [ { "attributes": { - "contractScope": null, "name": "A", "referencedDeclaration": 1, "type": "contract A" @@ -123,7 +116,6 @@ 4 ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -141,16 +133,12 @@ "children": [ { - "attributes": - { - "arguments": null - }, + "attributes": {}, "children": [ { "attributes": { - "contractScope": null, "name": "B", "referencedDeclaration": 4, "type": "contract B" @@ -180,7 +168,6 @@ 7 ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -199,16 +186,12 @@ "children": [ { - "attributes": - { - "arguments": null - }, + "attributes": {}, "children": [ { "attributes": { - "contractScope": null, "name": "C", "referencedDeclaration": 7, "type": "contract C" @@ -239,7 +222,6 @@ 10 ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -259,16 +241,12 @@ "children": [ { - "attributes": - { - "arguments": null - }, + "attributes": {}, "children": [ { "attributes": { - "contractScope": null, "name": "D", "referencedDeclaration": 10, "type": "contract D" diff --git a/test/libsolidity/ASTJSON/documentation.json b/test/libsolidity/ASTJSON/documentation.json index 29e0b17b9..f0beba98f 100644 --- a/test/libsolidity/ASTJSON/documentation.json +++ b/test/libsolidity/ASTJSON/documentation.json @@ -9,7 +9,6 @@ ] }, "id": 3, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -50,7 +49,6 @@ ] }, "id": 6, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -91,7 +89,6 @@ ] }, "id": 24, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -100,7 +97,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 23, "linearizedBaseContracts": @@ -125,7 +121,6 @@ "mutability": "mutable", "name": "state", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 23, "src": "48:17:3", "stateVariable": true, @@ -147,7 +142,6 @@ "typeString": "uint256" } }, - "value": null, "visibility": "public" }, { @@ -196,7 +190,6 @@ "id": 17, "name": "mod", "nodeType": "ModifierDefinition", - "overrides": null, "parameters": { "id": 14, @@ -230,7 +223,6 @@ "modifiers": [], "name": "fn", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 19, diff --git a/test/libsolidity/ASTJSON/documentation_legacy.json b/test/libsolidity/ASTJSON/documentation_legacy.json index bf085443c..4284c4f8f 100644 --- a/test/libsolidity/ASTJSON/documentation_legacy.json +++ b/test/libsolidity/ASTJSON/documentation_legacy.json @@ -8,8 +8,7 @@ [ 23 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -44,12 +42,10 @@ "functionSelector": "c19d93fb", "mutability": "mutable", "name": "state", - "overrides": null, "scope": 23, "stateVariable": true, "storageLocation": "default", "type": "uint256", - "value": null, "visibility": "public" }, "children": @@ -117,7 +113,6 @@ "attributes": { "name": "mod", - "overrides": null, "virtual": false, "visibility": "internal" }, @@ -175,7 +170,6 @@ null ], "name": "fn", - "overrides": null, "scope": 23, "stateMutability": "nonpayable", "virtual": false, diff --git a/test/libsolidity/ASTJSON/enum_value.json b/test/libsolidity/ASTJSON/enum_value.json index bb8e1289b..533e7b9e6 100644 --- a/test/libsolidity/ASTJSON/enum_value.json +++ b/test/libsolidity/ASTJSON/enum_value.json @@ -8,7 +8,6 @@ ] }, "id": 5, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 4, "linearizedBaseContracts": diff --git a/test/libsolidity/ASTJSON/enum_value_legacy.json b/test/libsolidity/ASTJSON/enum_value_legacy.json index eeff347d7..9ae5e1dad 100644 --- a/test/libsolidity/ASTJSON/enum_value_legacy.json +++ b/test/libsolidity/ASTJSON/enum_value_legacy.json @@ -8,8 +8,7 @@ [ 4 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ diff --git a/test/libsolidity/ASTJSON/event_definition.json b/test/libsolidity/ASTJSON/event_definition.json index e5c574973..61a1f46d4 100644 --- a/test/libsolidity/ASTJSON/event_definition.json +++ b/test/libsolidity/ASTJSON/event_definition.json @@ -8,7 +8,6 @@ ] }, "id": 4, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 3, "linearizedBaseContracts": @@ -30,7 +28,6 @@ [ { "anonymous": false, - "documentation": null, "id": 2, "name": "E", "nodeType": "EventDefinition", diff --git a/test/libsolidity/ASTJSON/event_definition_legacy.json b/test/libsolidity/ASTJSON/event_definition_legacy.json index 330f586ae..7adf0d038 100644 --- a/test/libsolidity/ASTJSON/event_definition_legacy.json +++ b/test/libsolidity/ASTJSON/event_definition_legacy.json @@ -8,8 +8,7 @@ [ 3 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -41,7 +39,6 @@ "attributes": { "anonymous": false, - "documentation": null, "name": "E" }, "children": diff --git a/test/libsolidity/ASTJSON/fallback.json b/test/libsolidity/ASTJSON/fallback.json index 7c83f871f..7037b960a 100644 --- a/test/libsolidity/ASTJSON/fallback.json +++ b/test/libsolidity/ASTJSON/fallback.json @@ -8,7 +8,6 @@ ] }, "id": 6, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 5, "linearizedBaseContracts": @@ -36,14 +34,12 @@ "src": "43:5:1", "statements": [] }, - "documentation": null, "id": 4, "implemented": true, "kind": "fallback", "modifiers": [], "name": "", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, diff --git a/test/libsolidity/ASTJSON/fallback_and_reveice_ether.json b/test/libsolidity/ASTJSON/fallback_and_reveice_ether.json index 801a4e148..009363e98 100644 --- a/test/libsolidity/ASTJSON/fallback_and_reveice_ether.json +++ b/test/libsolidity/ASTJSON/fallback_and_reveice_ether.json @@ -8,7 +8,6 @@ ] }, "id": 10, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 9, "linearizedBaseContracts": @@ -36,14 +34,12 @@ "src": "42:5:1", "statements": [] }, - "documentation": null, "id": 4, "implemented": true, "kind": "receive", "modifiers": [], "name": "", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, @@ -72,14 +68,12 @@ "src": "78:5:1", "statements": [] }, - "documentation": null, "id": 8, "implemented": true, "kind": "fallback", "modifiers": [], "name": "", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 5, diff --git a/test/libsolidity/ASTJSON/fallback_and_reveice_ether_legacy.json b/test/libsolidity/ASTJSON/fallback_and_reveice_ether_legacy.json index 44e02c42d..8ac17607e 100644 --- a/test/libsolidity/ASTJSON/fallback_and_reveice_ether_legacy.json +++ b/test/libsolidity/ASTJSON/fallback_and_reveice_ether_legacy.json @@ -8,8 +8,7 @@ [ 9 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,7 +38,6 @@ { "attributes": { - "documentation": null, "implemented": true, "isConstructor": false, "kind": "receive", @@ -49,7 +46,6 @@ null ], "name": "", - "overrides": null, "scope": 9, "stateMutability": "payable", "virtual": false, @@ -104,7 +100,6 @@ { "attributes": { - "documentation": null, "implemented": true, "isConstructor": false, "kind": "fallback", @@ -113,7 +108,6 @@ null ], "name": "", - "overrides": null, "scope": 9, "stateMutability": "payable", "virtual": false, diff --git a/test/libsolidity/ASTJSON/fallback_legacy.json b/test/libsolidity/ASTJSON/fallback_legacy.json index 8c81e87d8..1ee8bf6b3 100644 --- a/test/libsolidity/ASTJSON/fallback_legacy.json +++ b/test/libsolidity/ASTJSON/fallback_legacy.json @@ -8,8 +8,7 @@ [ 5 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,7 +38,6 @@ { "attributes": { - "documentation": null, "implemented": true, "isConstructor": false, "kind": "fallback", @@ -49,7 +46,6 @@ null ], "name": "", - "overrides": null, "scope": 5, "stateMutability": "payable", "virtual": false, diff --git a/test/libsolidity/ASTJSON/fallback_payable.json b/test/libsolidity/ASTJSON/fallback_payable.json index fb55b6077..2391f57bb 100644 --- a/test/libsolidity/ASTJSON/fallback_payable.json +++ b/test/libsolidity/ASTJSON/fallback_payable.json @@ -8,7 +8,6 @@ ] }, "id": 6, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 5, "linearizedBaseContracts": @@ -36,14 +34,12 @@ "src": "34:2:1", "statements": [] }, - "documentation": null, "id": 4, "implemented": true, "kind": "fallback", "modifiers": [], "name": "", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, diff --git a/test/libsolidity/ASTJSON/fallback_payable_legacy.json b/test/libsolidity/ASTJSON/fallback_payable_legacy.json index 2bc5a9659..69e25ab6e 100644 --- a/test/libsolidity/ASTJSON/fallback_payable_legacy.json +++ b/test/libsolidity/ASTJSON/fallback_payable_legacy.json @@ -8,8 +8,7 @@ [ 5 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,7 +38,6 @@ { "attributes": { - "documentation": null, "implemented": true, "isConstructor": false, "kind": "fallback", @@ -49,7 +46,6 @@ null ], "name": "", - "overrides": null, "scope": 5, "stateMutability": "nonpayable", "virtual": false, diff --git a/test/libsolidity/ASTJSON/function_type.json b/test/libsolidity/ASTJSON/function_type.json index 57f061b39..c0d2efc68 100644 --- a/test/libsolidity/ASTJSON/function_type.json +++ b/test/libsolidity/ASTJSON/function_type.json @@ -8,7 +8,6 @@ ] }, "id": 18, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 17, "linearizedBaseContracts": @@ -36,7 +34,6 @@ "src": "120:2:1", "statements": [] }, - "documentation": null, "functionSelector": "d6cd4974", "id": 16, "implemented": true, @@ -44,7 +41,6 @@ "modifiers": [], "name": "f", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 7, @@ -57,7 +53,6 @@ "mutability": "mutable", "name": "x", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 16, "src": "24:44:1", "stateVariable": false, @@ -90,7 +85,6 @@ "mutability": "mutable", "name": "", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 5, "src": "61:4:1", "stateVariable": false, @@ -112,7 +106,6 @@ "typeString": "uint256" } }, - "value": null, "visibility": "internal" } ], @@ -127,7 +120,6 @@ }, "visibility": "external" }, - "value": null, "visibility": "internal" } ], @@ -145,7 +137,6 @@ "mutability": "mutable", "name": "", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 16, "src": "79:40:1", "stateVariable": false, @@ -178,7 +169,6 @@ "mutability": "mutable", "name": "", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 12, "src": "113:4:1", "stateVariable": false, @@ -200,7 +190,6 @@ "typeString": "uint256" } }, - "value": null, "visibility": "internal" } ], @@ -215,7 +204,6 @@ }, "visibility": "external" }, - "value": null, "visibility": "internal" } ], diff --git a/test/libsolidity/ASTJSON/function_type_legacy.json b/test/libsolidity/ASTJSON/function_type_legacy.json index 799e94bf9..627ce45f0 100644 --- a/test/libsolidity/ASTJSON/function_type_legacy.json +++ b/test/libsolidity/ASTJSON/function_type_legacy.json @@ -8,8 +8,7 @@ [ 17 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,7 +38,6 @@ { "attributes": { - "documentation": null, "functionSelector": "d6cd4974", "implemented": true, "isConstructor": false, @@ -50,7 +47,6 @@ null ], "name": "f", - "overrides": null, "scope": 17, "stateMutability": "nonpayable", "virtual": false, @@ -67,12 +63,10 @@ "constant": false, "mutability": "mutable", "name": "x", - "overrides": null, "scope": 16, "stateVariable": false, "storageLocation": "default", "type": "function () payable external returns (uint256)", - "value": null, "visibility": "internal" }, "children": @@ -108,12 +102,10 @@ "constant": false, "mutability": "mutable", "name": "", - "overrides": null, "scope": 5, "stateVariable": false, "storageLocation": "default", "type": "uint256", - "value": null, "visibility": "internal" }, "children": @@ -162,12 +154,10 @@ "constant": false, "mutability": "mutable", "name": "", - "overrides": null, "scope": 16, "stateVariable": false, "storageLocation": "default", "type": "function () view external returns (uint256)", - "value": null, "visibility": "internal" }, "children": @@ -203,12 +193,10 @@ "constant": false, "mutability": "mutable", "name": "", - "overrides": null, "scope": 12, "stateVariable": false, "storageLocation": "default", "type": "uint256", - "value": null, "visibility": "internal" }, "children": diff --git a/test/libsolidity/ASTJSON/global_enum.json b/test/libsolidity/ASTJSON/global_enum.json index 876b55ddf..1b0ffe377 100644 --- a/test/libsolidity/ASTJSON/global_enum.json +++ b/test/libsolidity/ASTJSON/global_enum.json @@ -8,7 +8,6 @@ ] }, "id": 3, - "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/global_enum_legacy.json b/test/libsolidity/ASTJSON/global_enum_legacy.json index aea058345..f29649018 100644 --- a/test/libsolidity/ASTJSON/global_enum_legacy.json +++ b/test/libsolidity/ASTJSON/global_enum_legacy.json @@ -8,8 +8,7 @@ [ 2 ] - }, - "license": null + } }, "children": [ diff --git a/test/libsolidity/ASTJSON/global_struct.json b/test/libsolidity/ASTJSON/global_struct.json index e1802e03b..2d1d42bdc 100644 --- a/test/libsolidity/ASTJSON/global_struct.json +++ b/test/libsolidity/ASTJSON/global_struct.json @@ -8,7 +8,6 @@ ] }, "id": 4, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -23,7 +22,6 @@ "mutability": "mutable", "name": "a", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 3, "src": "11:9:1", "stateVariable": false, @@ -45,7 +43,6 @@ "typeString": "uint256" } }, - "value": null, "visibility": "internal" } ], diff --git a/test/libsolidity/ASTJSON/global_struct_legacy.json b/test/libsolidity/ASTJSON/global_struct_legacy.json index 2670ea5ea..09f5d2de6 100644 --- a/test/libsolidity/ASTJSON/global_struct_legacy.json +++ b/test/libsolidity/ASTJSON/global_struct_legacy.json @@ -8,8 +8,7 @@ [ 3 ] - }, - "license": null + } }, "children": [ @@ -29,12 +28,10 @@ "constant": false, "mutability": "mutable", "name": "a", - "overrides": null, "scope": 3, "stateVariable": false, "storageLocation": "default", "type": "uint256", - "value": null, "visibility": "internal" }, "children": diff --git a/test/libsolidity/ASTJSON/inheritance_specifier.json b/test/libsolidity/ASTJSON/inheritance_specifier.json index 20da9e31c..40acc5d2a 100644 --- a/test/libsolidity/ASTJSON/inheritance_specifier.json +++ b/test/libsolidity/ASTJSON/inheritance_specifier.json @@ -12,7 +12,6 @@ ] }, "id": 5, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -21,7 +20,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 1, "linearizedBaseContracts": @@ -39,10 +37,8 @@ "baseContracts": [ { - "arguments": null, "baseName": { - "contractScope": null, "id": 2, "name": "C1", "nodeType": "UserDefinedTypeName", @@ -64,7 +60,6 @@ 1 ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 4, "linearizedBaseContracts": diff --git a/test/libsolidity/ASTJSON/inheritance_specifier_legacy.json b/test/libsolidity/ASTJSON/inheritance_specifier_legacy.json index b8de3a97b..4d6f0ffec 100644 --- a/test/libsolidity/ASTJSON/inheritance_specifier_legacy.json +++ b/test/libsolidity/ASTJSON/inheritance_specifier_legacy.json @@ -12,8 +12,7 @@ [ 4 ] - }, - "license": null + } }, "children": [ @@ -30,7 +29,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -56,7 +54,6 @@ 1 ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -73,16 +70,12 @@ "children": [ { - "attributes": - { - "arguments": null - }, + "attributes": {}, "children": [ { "attributes": { - "contractScope": null, "name": "C1", "referencedDeclaration": 1, "type": "contract C1" diff --git a/test/libsolidity/ASTJSON/license.json b/test/libsolidity/ASTJSON/license.json index e8c6616a3..c365c072a 100644 --- a/test/libsolidity/ASTJSON/license.json +++ b/test/libsolidity/ASTJSON/license.json @@ -17,7 +17,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 1, "linearizedBaseContracts": diff --git a/test/libsolidity/ASTJSON/license_legacy.json b/test/libsolidity/ASTJSON/license_legacy.json index 2f1405b62..03e6b6056 100644 --- a/test/libsolidity/ASTJSON/license_legacy.json +++ b/test/libsolidity/ASTJSON/license_legacy.json @@ -26,7 +26,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation.json b/test/libsolidity/ASTJSON/long_type_name_binary_operation.json index 5e13c2bfb..7b598093b 100644 --- a/test/libsolidity/ASTJSON/long_type_name_binary_operation.json +++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation.json @@ -8,7 +8,6 @@ ] }, "id": 12, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 11, "linearizedBaseContracts": @@ -49,7 +47,6 @@ "mutability": "mutable", "name": "a", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 9, "src": "35:6:1", "stateVariable": false, @@ -71,14 +68,12 @@ "typeString": "uint256" } }, - "value": null, "visibility": "internal" } ], "id": 8, "initialValue": { - "argumentTypes": null, "commonType": { "typeIdentifier": "t_rational_5_by_1", @@ -91,7 +86,6 @@ "lValueRequested": false, "leftExpression": { - "argumentTypes": null, "hexValue": "32", "id": 5, "isConstant": false, @@ -101,7 +95,6 @@ "lValueRequested": false, "nodeType": "Literal", "src": "44:1:1", - "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_2_by_1", @@ -113,7 +106,6 @@ "operator": "+", "rightExpression": { - "argumentTypes": null, "hexValue": "33", "id": 6, "isConstant": false, @@ -123,7 +115,6 @@ "lValueRequested": false, "nodeType": "Literal", "src": "48:1:1", - "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_3_by_1", @@ -143,7 +134,6 @@ } ] }, - "documentation": null, "functionSelector": "26121ff0", "id": 10, "implemented": true, @@ -151,7 +141,6 @@ "modifiers": [], "name": "f", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json b/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json index c6f7662ea..46e5b0417 100644 --- a/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json +++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json @@ -8,8 +8,7 @@ [ 11 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,7 +38,6 @@ { "attributes": { - "documentation": null, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, @@ -50,7 +47,6 @@ null ], "name": "f", - "overrides": null, "scope": 11, "stateMutability": "nonpayable", "virtual": false, @@ -103,12 +99,10 @@ "constant": false, "mutability": "mutable", "name": "a", - "overrides": null, "scope": 9, "stateVariable": false, "storageLocation": "default", "type": "uint256", - "value": null, "visibility": "internal" }, "children": @@ -131,7 +125,6 @@ { "attributes": { - "argumentTypes": null, "commonType": { "typeIdentifier": "t_rational_5_by_1", @@ -149,13 +142,11 @@ { "attributes": { - "argumentTypes": null, "hexvalue": "32", "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, - "subdenomination": null, "token": "number", "type": "int_const 2", "value": "2" @@ -167,13 +158,11 @@ { "attributes": { - "argumentTypes": null, "hexvalue": "33", "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, - "subdenomination": null, "token": "number", "type": "int_const 3", "value": "3" diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier.json b/test/libsolidity/ASTJSON/long_type_name_identifier.json index 417972b45..4293f6df4 100644 --- a/test/libsolidity/ASTJSON/long_type_name_identifier.json +++ b/test/libsolidity/ASTJSON/long_type_name_identifier.json @@ -8,7 +8,6 @@ ] }, "id": 16, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 15, "linearizedBaseContracts": @@ -34,7 +32,6 @@ "mutability": "mutable", "name": "a", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 15, "src": "13:8:1", "stateVariable": true, @@ -59,7 +56,6 @@ } }, "id": 2, - "length": null, "nodeType": "ArrayTypeName", "src": "13:6:1", "typeDescriptions": @@ -68,7 +64,6 @@ "typeString": "uint256[]" } }, - "value": null, "visibility": "internal" }, { @@ -92,7 +87,6 @@ "mutability": "mutable", "name": "b", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 13, "src": "45:16:1", "stateVariable": false, @@ -117,7 +111,6 @@ } }, "id": 9, - "length": null, "nodeType": "ArrayTypeName", "src": "45:6:1", "typeDescriptions": @@ -126,14 +119,12 @@ "typeString": "uint256[]" } }, - "value": null, "visibility": "internal" } ], "id": 12, "initialValue": { - "argumentTypes": null, "id": 11, "name": "a", "nodeType": "Identifier", @@ -151,7 +142,6 @@ } ] }, - "documentation": null, "functionSelector": "26121ff0", "id": 14, "implemented": true, @@ -159,7 +149,6 @@ "modifiers": [], "name": "f", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 4, diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json b/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json index 537746abd..ced331a6d 100644 --- a/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json +++ b/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json @@ -8,8 +8,7 @@ [ 15 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -43,12 +41,10 @@ "constant": false, "mutability": "mutable", "name": "a", - "overrides": null, "scope": 15, "stateVariable": true, "storageLocation": "default", "type": "uint256[]", - "value": null, "visibility": "internal" }, "children": @@ -56,7 +52,6 @@ { "attributes": { - "length": null, "type": "uint256[]" }, "children": @@ -84,7 +79,6 @@ { "attributes": { - "documentation": null, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, @@ -94,7 +88,6 @@ null ], "name": "f", - "overrides": null, "scope": 15, "stateMutability": "nonpayable", "virtual": false, @@ -147,12 +140,10 @@ "constant": false, "mutability": "mutable", "name": "b", - "overrides": null, "scope": 13, "stateVariable": false, "storageLocation": "storage", "type": "uint256[]", - "value": null, "visibility": "internal" }, "children": @@ -160,7 +151,6 @@ { "attributes": { - "length": null, "type": "uint256[]" }, "children": @@ -188,7 +178,6 @@ { "attributes": { - "argumentTypes": null, "overloadedDeclarations": [ null diff --git a/test/libsolidity/ASTJSON/mappings.json b/test/libsolidity/ASTJSON/mappings.json index 8df004d4b..b1f150f10 100644 --- a/test/libsolidity/ASTJSON/mappings.json +++ b/test/libsolidity/ASTJSON/mappings.json @@ -8,7 +8,6 @@ ] }, "id": 18, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 17, "linearizedBaseContracts": @@ -62,7 +60,6 @@ "mutability": "mutable", "name": "a", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 17, "src": "40:20:1", "stateVariable": true, @@ -77,7 +74,6 @@ "id": 7, "keyType": { - "contractScope": null, "id": 5, "name": "C", "nodeType": "UserDefinedTypeName", @@ -109,7 +105,6 @@ } } }, - "value": null, "visibility": "internal" }, { @@ -118,7 +113,6 @@ "mutability": "mutable", "name": "b", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 17, "src": "66:26:1", "stateVariable": true, @@ -163,7 +157,6 @@ } } }, - "value": null, "visibility": "internal" }, { @@ -172,7 +165,6 @@ "mutability": "mutable", "name": "c", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 17, "src": "98:20:1", "stateVariable": true, @@ -187,7 +179,6 @@ "id": 15, "keyType": { - "contractScope": null, "id": 13, "name": "E", "nodeType": "UserDefinedTypeName", @@ -219,7 +210,6 @@ } } }, - "value": null, "visibility": "internal" } ], diff --git a/test/libsolidity/ASTJSON/mappings_legacy.json b/test/libsolidity/ASTJSON/mappings_legacy.json index 49737edee..a44eea0eb 100644 --- a/test/libsolidity/ASTJSON/mappings_legacy.json +++ b/test/libsolidity/ASTJSON/mappings_legacy.json @@ -8,8 +8,7 @@ [ 17 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -83,12 +81,10 @@ "constant": false, "mutability": "mutable", "name": "a", - "overrides": null, "scope": 17, "stateVariable": true, "storageLocation": "default", "type": "mapping(contract C => bool)", - "value": null, "visibility": "internal" }, "children": @@ -103,7 +99,6 @@ { "attributes": { - "contractScope": null, "name": "C", "referencedDeclaration": 17, "type": "contract C" @@ -138,12 +133,10 @@ "constant": false, "mutability": "mutable", "name": "b", - "overrides": null, "scope": 17, "stateVariable": true, "storageLocation": "default", "type": "mapping(address => bool)", - "value": null, "visibility": "internal" }, "children": @@ -191,12 +184,10 @@ "constant": false, "mutability": "mutable", "name": "c", - "overrides": null, "scope": 17, "stateVariable": true, "storageLocation": "default", "type": "mapping(enum C.E => bool)", - "value": null, "visibility": "internal" }, "children": @@ -211,7 +202,6 @@ { "attributes": { - "contractScope": null, "name": "E", "referencedDeclaration": 4, "type": "enum C.E" diff --git a/test/libsolidity/ASTJSON/modifier_definition.json b/test/libsolidity/ASTJSON/modifier_definition.json index c5070f1da..198afe454 100644 --- a/test/libsolidity/ASTJSON/modifier_definition.json +++ b/test/libsolidity/ASTJSON/modifier_definition.json @@ -8,7 +8,6 @@ ] }, "id": 15, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 14, "linearizedBaseContracts": @@ -43,11 +41,9 @@ } ] }, - "documentation": null, "id": 6, "name": "M", "nodeType": "ModifierDefinition", - "overrides": null, "parameters": { "id": 3, @@ -60,7 +56,6 @@ "mutability": "mutable", "name": "i", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 6, "src": "24:6:1", "stateVariable": false, @@ -82,7 +77,6 @@ "typeString": "uint256" } }, - "value": null, "visibility": "internal" } ], @@ -100,7 +94,6 @@ "src": "64:2:1", "statements": [] }, - "documentation": null, "functionSelector": "28811f59", "id": 13, "implemented": true, @@ -111,7 +104,6 @@ "arguments": [ { - "argumentTypes": null, "hexValue": "31", "id": 9, "isConstant": false, @@ -121,7 +113,6 @@ "lValueRequested": false, "nodeType": "Literal", "src": "54:1:1", - "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_1_by_1", @@ -133,7 +124,6 @@ "id": 10, "modifierName": { - "argumentTypes": null, "id": 8, "name": "M", "nodeType": "Identifier", @@ -152,7 +142,6 @@ ], "name": "F", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 7, diff --git a/test/libsolidity/ASTJSON/modifier_definition_legacy.json b/test/libsolidity/ASTJSON/modifier_definition_legacy.json index 05876ae3e..cc3089395 100644 --- a/test/libsolidity/ASTJSON/modifier_definition_legacy.json +++ b/test/libsolidity/ASTJSON/modifier_definition_legacy.json @@ -8,8 +8,7 @@ [ 14 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,9 +38,7 @@ { "attributes": { - "documentation": null, "name": "M", - "overrides": null, "virtual": false, "visibility": "internal" }, @@ -57,12 +53,10 @@ "constant": false, "mutability": "mutable", "name": "i", - "overrides": null, "scope": 6, "stateVariable": false, "storageLocation": "default", "type": "uint256", - "value": null, "visibility": "internal" }, "children": @@ -108,13 +102,11 @@ { "attributes": { - "documentation": null, "functionSelector": "28811f59", "implemented": true, "isConstructor": false, "kind": "function", "name": "F", - "overrides": null, "scope": 14, "stateMutability": "nonpayable", "virtual": false, @@ -154,7 +146,6 @@ { "attributes": { - "argumentTypes": null, "overloadedDeclarations": [ null @@ -170,13 +161,11 @@ { "attributes": { - "argumentTypes": null, "hexvalue": "31", "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, - "subdenomination": null, "token": "number", "type": "int_const 1", "value": "1" diff --git a/test/libsolidity/ASTJSON/modifier_invocation.json b/test/libsolidity/ASTJSON/modifier_invocation.json index c5070f1da..198afe454 100644 --- a/test/libsolidity/ASTJSON/modifier_invocation.json +++ b/test/libsolidity/ASTJSON/modifier_invocation.json @@ -8,7 +8,6 @@ ] }, "id": 15, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 14, "linearizedBaseContracts": @@ -43,11 +41,9 @@ } ] }, - "documentation": null, "id": 6, "name": "M", "nodeType": "ModifierDefinition", - "overrides": null, "parameters": { "id": 3, @@ -60,7 +56,6 @@ "mutability": "mutable", "name": "i", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 6, "src": "24:6:1", "stateVariable": false, @@ -82,7 +77,6 @@ "typeString": "uint256" } }, - "value": null, "visibility": "internal" } ], @@ -100,7 +94,6 @@ "src": "64:2:1", "statements": [] }, - "documentation": null, "functionSelector": "28811f59", "id": 13, "implemented": true, @@ -111,7 +104,6 @@ "arguments": [ { - "argumentTypes": null, "hexValue": "31", "id": 9, "isConstant": false, @@ -121,7 +113,6 @@ "lValueRequested": false, "nodeType": "Literal", "src": "54:1:1", - "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_1_by_1", @@ -133,7 +124,6 @@ "id": 10, "modifierName": { - "argumentTypes": null, "id": 8, "name": "M", "nodeType": "Identifier", @@ -152,7 +142,6 @@ ], "name": "F", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 7, diff --git a/test/libsolidity/ASTJSON/modifier_invocation_legacy.json b/test/libsolidity/ASTJSON/modifier_invocation_legacy.json index 05876ae3e..cc3089395 100644 --- a/test/libsolidity/ASTJSON/modifier_invocation_legacy.json +++ b/test/libsolidity/ASTJSON/modifier_invocation_legacy.json @@ -8,8 +8,7 @@ [ 14 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,9 +38,7 @@ { "attributes": { - "documentation": null, "name": "M", - "overrides": null, "virtual": false, "visibility": "internal" }, @@ -57,12 +53,10 @@ "constant": false, "mutability": "mutable", "name": "i", - "overrides": null, "scope": 6, "stateVariable": false, "storageLocation": "default", "type": "uint256", - "value": null, "visibility": "internal" }, "children": @@ -108,13 +102,11 @@ { "attributes": { - "documentation": null, "functionSelector": "28811f59", "implemented": true, "isConstructor": false, "kind": "function", "name": "F", - "overrides": null, "scope": 14, "stateMutability": "nonpayable", "virtual": false, @@ -154,7 +146,6 @@ { "attributes": { - "argumentTypes": null, "overloadedDeclarations": [ null @@ -170,13 +161,11 @@ { "attributes": { - "argumentTypes": null, "hexvalue": "31", "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, - "subdenomination": null, "token": "number", "type": "int_const 1", "value": "1" diff --git a/test/libsolidity/ASTJSON/mutability.json b/test/libsolidity/ASTJSON/mutability.json index 3f5d610ed..f93bbb87f 100644 --- a/test/libsolidity/ASTJSON/mutability.json +++ b/test/libsolidity/ASTJSON/mutability.json @@ -8,7 +8,6 @@ ] }, "id": 11, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 10, "linearizedBaseContracts": @@ -35,7 +33,6 @@ "mutability": "immutable", "name": "a", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 10, "src": "17:27:1", "stateVariable": true, @@ -59,7 +56,6 @@ }, "value": { - "argumentTypes": null, "hexValue": "34", "id": 2, "isConstant": false, @@ -69,7 +65,6 @@ "lValueRequested": false, "nodeType": "Literal", "src": "43:1:1", - "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_4_by_1", @@ -86,7 +81,6 @@ "mutability": "constant", "name": "b", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 10, "src": "50:26:1", "stateVariable": true, @@ -110,7 +104,6 @@ }, "value": { - "argumentTypes": null, "hexValue": "32", "id": 5, "isConstant": false, @@ -120,7 +113,6 @@ "lValueRequested": false, "nodeType": "Literal", "src": "75:1:1", - "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_2_by_1", @@ -137,7 +129,6 @@ "mutability": "mutable", "name": "c", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 10, "src": "82:17:1", "stateVariable": true, @@ -161,7 +152,6 @@ }, "value": { - "argumentTypes": null, "hexValue": "33", "id": 8, "isConstant": false, @@ -171,7 +161,6 @@ "lValueRequested": false, "nodeType": "Literal", "src": "98:1:1", - "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_3_by_1", diff --git a/test/libsolidity/ASTJSON/mutability_legacy.json b/test/libsolidity/ASTJSON/mutability_legacy.json index 387ebc267..f4eb7e0c5 100644 --- a/test/libsolidity/ASTJSON/mutability_legacy.json +++ b/test/libsolidity/ASTJSON/mutability_legacy.json @@ -8,8 +8,7 @@ [ 10 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -44,7 +42,6 @@ "functionSelector": "0dbe671f", "mutability": "immutable", "name": "a", - "overrides": null, "scope": 10, "stateVariable": true, "storageLocation": "default", @@ -66,13 +63,11 @@ { "attributes": { - "argumentTypes": null, "hexvalue": "34", "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, - "subdenomination": null, "token": "number", "type": "int_const 4", "value": "4" @@ -93,7 +88,6 @@ "functionSelector": "4df7e3d0", "mutability": "constant", "name": "b", - "overrides": null, "scope": 10, "stateVariable": true, "storageLocation": "default", @@ -115,13 +109,11 @@ { "attributes": { - "argumentTypes": null, "hexvalue": "32", "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, - "subdenomination": null, "token": "number", "type": "int_const 2", "value": "2" @@ -142,7 +134,6 @@ "functionSelector": "c3da42b8", "mutability": "mutable", "name": "c", - "overrides": null, "scope": 10, "stateVariable": true, "storageLocation": "default", @@ -164,13 +155,11 @@ { "attributes": { - "argumentTypes": null, "hexvalue": "33", "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, - "subdenomination": null, "token": "number", "type": "int_const 3", "value": "3" diff --git a/test/libsolidity/ASTJSON/non_utf8.json b/test/libsolidity/ASTJSON/non_utf8.json index d716d91c2..5fff32417 100644 --- a/test/libsolidity/ASTJSON/non_utf8.json +++ b/test/libsolidity/ASTJSON/non_utf8.json @@ -4,11 +4,10 @@ { "C": [ - 8 + 9 ] }, - "id": 9, - "license": null, + "id": 10, "nodeType": "SourceUnit", "nodes": [ @@ -17,12 +16,11 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, - "id": 8, + "id": 9, "linearizedBaseContracts": [ - 8 + 9 ], "name": "C", "nodeType": "ContractDefinition", @@ -31,74 +29,78 @@ { "body": { - "id": 6, + "id": 7, "nodeType": "Block", - "src": "33:20:1", + "src": "33:30:1", "statements": [ { "assignments": [ - 3 + 4 ], "declarations": [ { "constant": false, - "id": 3, + "id": 4, "mutability": "mutable", "name": "x", "nodeType": "VariableDeclaration", - "overrides": null, - "scope": 6, - "src": "35:5:1", + "scope": 7, + "src": "35:15:1", "stateVariable": false, - "storageLocation": "default", + "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_string_memory_ptr", "typeString": "string" }, - "typeName": null, - "value": null, + "typeName": + { + "id": 3, + "name": "string", + "nodeType": "ElementaryTypeName", + "src": "35:6:1", + "typeDescriptions": + { + "typeIdentifier": "t_string_storage_ptr", + "typeString": "string" + } + }, "visibility": "internal" } ], - "id": 5, + "id": 6, "initialValue": { - "argumentTypes": null, "hexValue": "ff", - "id": 4, + "id": 5, "isConstant": false, "isLValue": false, "isPure": true, "kind": "string", "lValueRequested": false, "nodeType": "Literal", - "src": "43:7:1", - "subdenomination": null, + "src": "53:7:1", "typeDescriptions": { "typeIdentifier": "t_stringliteral_8b1a944cf13a9a1c08facb2c9e98623ef3254d2ddb48113885c3e8e97fec8db9", "typeString": "literal_string (contains invalid UTF-8 sequence at position 0)" - }, - "value": null + } }, "nodeType": "VariableDeclarationStatement", - "src": "35:15:1" + "src": "35:25:1" } ] }, - "documentation": null, "functionSelector": "26121ff0", - "id": 7, + "id": 8, "implemented": true, "kind": "function", "modifiers": [], "name": "f", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, @@ -113,16 +115,16 @@ "parameters": [], "src": "33:0:1" }, - "scope": 8, - "src": "13:40:1", + "scope": 9, + "src": "13:50:1", "stateMutability": "nonpayable", "virtual": false, "visibility": "public" } ], - "scope": 9, - "src": "0:55:1" + "scope": 10, + "src": "0:65:1" } ], - "src": "0:56:1" + "src": "0:66:1" } diff --git a/test/libsolidity/ASTJSON/non_utf8.sol b/test/libsolidity/ASTJSON/non_utf8.sol index f9a79d2fa..3651a05fd 100644 --- a/test/libsolidity/ASTJSON/non_utf8.sol +++ b/test/libsolidity/ASTJSON/non_utf8.sol @@ -1,3 +1,3 @@ -contract C { function f() public { var x = hex"ff"; } } +contract C { function f() public { string memory x = hex"ff"; } } // ---- diff --git a/test/libsolidity/ASTJSON/non_utf8_legacy.json b/test/libsolidity/ASTJSON/non_utf8_legacy.json index d49d2013d..e8d795efd 100644 --- a/test/libsolidity/ASTJSON/non_utf8_legacy.json +++ b/test/libsolidity/ASTJSON/non_utf8_legacy.json @@ -6,10 +6,9 @@ { "C": [ - 8 + 9 ] - }, - "license": null + } }, "children": [ @@ -26,21 +25,19 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ - 8 + 9 ], "name": "C", - "scope": 9 + "scope": 10 }, "children": [ { "attributes": { - "documentation": null, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, @@ -50,8 +47,7 @@ null ], "name": "f", - "overrides": null, - "scope": 8, + "scope": 9, "stateMutability": "nonpayable", "virtual": false, "visibility": "public" @@ -92,7 +88,7 @@ { "assignments": [ - 3 + 4 ] }, "children": @@ -103,60 +99,66 @@ "constant": false, "mutability": "mutable", "name": "x", - "overrides": null, - "scope": 6, + "scope": 7, "stateVariable": false, - "storageLocation": "default", + "storageLocation": "memory", "type": "string", - "typeName": null, - "value": null, "visibility": "internal" }, - "children": [], - "id": 3, + "children": + [ + { + "attributes": + { + "name": "string", + "type": "string" + }, + "id": 3, + "name": "ElementaryTypeName", + "src": "35:6:1" + } + ], + "id": 4, "name": "VariableDeclaration", - "src": "35:5:1" + "src": "35:15:1" }, { "attributes": { - "argumentTypes": null, "hexvalue": "ff", "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, - "subdenomination": null, "token": "string", - "type": "literal_string (contains invalid UTF-8 sequence at position 0)", - "value": null + "type": "literal_string (contains invalid UTF-8 sequence at position 0)" }, - "id": 4, + "id": 5, "name": "Literal", - "src": "43:7:1" + "src": "53:7:1" } ], - "id": 5, + "id": 6, "name": "VariableDeclarationStatement", - "src": "35:15:1" + "src": "35:25:1" } ], - "id": 6, + "id": 7, "name": "Block", - "src": "33:20:1" + "src": "33:30:1" } ], - "id": 7, + "id": 8, "name": "FunctionDefinition", - "src": "13:40:1" + "src": "13:50:1" } ], - "id": 8, + "id": 9, "name": "ContractDefinition", - "src": "0:55:1" + "src": "0:65:1" } ], - "id": 9, + "id": 10, "name": "SourceUnit", - "src": "0:56:1" + "src": "0:66:1" } diff --git a/test/libsolidity/ASTJSON/override.json b/test/libsolidity/ASTJSON/override.json index 3e5a8c9da..49f85144e 100644 --- a/test/libsolidity/ASTJSON/override.json +++ b/test/libsolidity/ASTJSON/override.json @@ -16,7 +16,6 @@ ] }, "id": 32, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -25,7 +24,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 5, "linearizedBaseContracts": @@ -44,7 +42,6 @@ "src": "36:2:1", "statements": [] }, - "documentation": null, "functionSelector": "a399b6a2", "id": 4, "implemented": true, @@ -52,7 +49,6 @@ "modifiers": [], "name": "faa", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, @@ -82,10 +78,8 @@ "baseContracts": [ { - "arguments": null, "baseName": { - "contractScope": null, "id": 6, "name": "A", "nodeType": "UserDefinedTypeName", @@ -107,7 +101,6 @@ 5 ], "contractKind": "contract", - "documentation": null, "fullyImplemented": false, "id": 16, "linearizedBaseContracts": @@ -120,8 +113,6 @@ "nodes": [ { - "body": null, - "documentation": null, "functionSelector": "c2985578", "id": 10, "implemented": false, @@ -129,7 +120,6 @@ "modifiers": [], "name": "foo", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 8, @@ -162,7 +152,6 @@ "src": "115:2:1", "statements": [] }, - "documentation": null, "functionSelector": "a399b6a2", "id": 15, "implemented": true, @@ -206,10 +195,8 @@ "baseContracts": [ { - "arguments": null, "baseName": { - "contractScope": null, "id": 17, "name": "B", "nodeType": "UserDefinedTypeName", @@ -232,7 +219,6 @@ 16 ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 31, "linearizedBaseContracts": @@ -257,7 +243,6 @@ "src": "170:3:1", "statements": [] }, - "documentation": null, "functionSelector": "c2985578", "id": 23, "implemented": true, @@ -304,7 +289,6 @@ "src": "212:2:1", "statements": [] }, - "documentation": null, "functionSelector": "a399b6a2", "id": 30, "implemented": true, @@ -319,7 +303,6 @@ "overrides": [ { - "contractScope": null, "id": 25, "name": "A", "nodeType": "UserDefinedTypeName", @@ -332,7 +315,6 @@ } }, { - "contractScope": null, "id": 26, "name": "B", "nodeType": "UserDefinedTypeName", diff --git a/test/libsolidity/ASTJSON/override_legacy.json b/test/libsolidity/ASTJSON/override_legacy.json index 23cf18b2b..5cdc2f364 100644 --- a/test/libsolidity/ASTJSON/override_legacy.json +++ b/test/libsolidity/ASTJSON/override_legacy.json @@ -16,8 +16,7 @@ [ 31 ] - }, - "license": null + } }, "children": [ @@ -34,7 +33,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -48,7 +46,6 @@ { "attributes": { - "documentation": null, "functionSelector": "a399b6a2", "implemented": true, "isConstructor": false, @@ -58,7 +55,6 @@ null ], "name": "faa", - "overrides": null, "scope": 5, "stateMutability": "nonpayable", "virtual": false, @@ -124,7 +120,6 @@ 5 ], "contractKind": "contract", - "documentation": null, "fullyImplemented": false, "linearizedBaseContracts": [ @@ -137,16 +132,12 @@ "children": [ { - "attributes": - { - "arguments": null - }, + "attributes": {}, "children": [ { "attributes": { - "contractScope": null, "name": "A", "referencedDeclaration": 5, "type": "contract A" @@ -163,8 +154,6 @@ { "attributes": { - "body": null, - "documentation": null, "functionSelector": "c2985578", "implemented": false, "isConstructor": false, @@ -174,7 +163,6 @@ null ], "name": "foo", - "overrides": null, "scope": 16, "stateMutability": "nonpayable", "virtual": false, @@ -220,7 +208,6 @@ [ 4 ], - "documentation": null, "functionSelector": "a399b6a2", "implemented": true, "isConstructor": false, @@ -308,7 +295,6 @@ 16 ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -322,16 +308,12 @@ "children": [ { - "attributes": - { - "arguments": null - }, + "attributes": {}, "children": [ { "attributes": { - "contractScope": null, "name": "B", "referencedDeclaration": 16, "type": "contract B" @@ -352,7 +334,6 @@ [ 10 ], - "documentation": null, "functionSelector": "c2985578", "implemented": true, "isConstructor": false, @@ -432,7 +413,6 @@ [ 15 ], - "documentation": null, "functionSelector": "a399b6a2", "implemented": true, "isConstructor": false, @@ -455,7 +435,6 @@ { "attributes": { - "contractScope": null, "name": "A", "referencedDeclaration": 5, "type": "contract A" @@ -467,7 +446,6 @@ { "attributes": { - "contractScope": null, "name": "B", "referencedDeclaration": 16, "type": "contract B" diff --git a/test/libsolidity/ASTJSON/placeholder_statement.json b/test/libsolidity/ASTJSON/placeholder_statement.json index 3be70c463..4f9bbbdce 100644 --- a/test/libsolidity/ASTJSON/placeholder_statement.json +++ b/test/libsolidity/ASTJSON/placeholder_statement.json @@ -8,7 +8,6 @@ ] }, "id": 6, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 5, "linearizedBaseContracts": @@ -43,11 +41,9 @@ } ] }, - "documentation": null, "id": 4, "name": "M", "nodeType": "ModifierDefinition", - "overrides": null, "parameters": { "id": 1, diff --git a/test/libsolidity/ASTJSON/placeholder_statement_legacy.json b/test/libsolidity/ASTJSON/placeholder_statement_legacy.json index 7ab1f4879..661feb13e 100644 --- a/test/libsolidity/ASTJSON/placeholder_statement_legacy.json +++ b/test/libsolidity/ASTJSON/placeholder_statement_legacy.json @@ -8,8 +8,7 @@ [ 5 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,9 +38,7 @@ { "attributes": { - "documentation": null, "name": "M", - "overrides": null, "virtual": false, "visibility": "internal" }, diff --git a/test/libsolidity/ASTJSON/receive_ether.json b/test/libsolidity/ASTJSON/receive_ether.json index a837dae15..8a1f0ac9a 100644 --- a/test/libsolidity/ASTJSON/receive_ether.json +++ b/test/libsolidity/ASTJSON/receive_ether.json @@ -8,7 +8,6 @@ ] }, "id": 6, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 5, "linearizedBaseContracts": @@ -36,14 +34,12 @@ "src": "42:5:1", "statements": [] }, - "documentation": null, "id": 4, "implemented": true, "kind": "receive", "modifiers": [], "name": "", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, diff --git a/test/libsolidity/ASTJSON/receive_ether_legacy.json b/test/libsolidity/ASTJSON/receive_ether_legacy.json index 964bd991b..d9544f138 100644 --- a/test/libsolidity/ASTJSON/receive_ether_legacy.json +++ b/test/libsolidity/ASTJSON/receive_ether_legacy.json @@ -8,8 +8,7 @@ [ 5 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,7 +38,6 @@ { "attributes": { - "documentation": null, "implemented": true, "isConstructor": false, "kind": "receive", @@ -49,7 +46,6 @@ null ], "name": "", - "overrides": null, "scope": 5, "stateMutability": "payable", "virtual": false, diff --git a/test/libsolidity/ASTJSON/short_type_name.json b/test/libsolidity/ASTJSON/short_type_name.json index 54c9b99ea..882fcfe24 100644 --- a/test/libsolidity/ASTJSON/short_type_name.json +++ b/test/libsolidity/ASTJSON/short_type_name.json @@ -8,7 +8,6 @@ ] }, "id": 12, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 11, "linearizedBaseContracts": @@ -49,7 +47,6 @@ "mutability": "mutable", "name": "x", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 9, "src": "35:15:1", "stateVariable": false, @@ -74,7 +71,6 @@ } }, "id": 6, - "length": null, "nodeType": "ArrayTypeName", "src": "35:6:1", "typeDescriptions": @@ -83,18 +79,15 @@ "typeString": "uint256[]" } }, - "value": null, "visibility": "internal" } ], "id": 8, - "initialValue": null, "nodeType": "VariableDeclarationStatement", "src": "35:15:1" } ] }, - "documentation": null, "functionSelector": "26121ff0", "id": 10, "implemented": true, @@ -102,7 +95,6 @@ "modifiers": [], "name": "f", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, diff --git a/test/libsolidity/ASTJSON/short_type_name_legacy.json b/test/libsolidity/ASTJSON/short_type_name_legacy.json index c813bcdf4..8e255954d 100644 --- a/test/libsolidity/ASTJSON/short_type_name_legacy.json +++ b/test/libsolidity/ASTJSON/short_type_name_legacy.json @@ -8,8 +8,7 @@ [ 11 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,7 +38,6 @@ { "attributes": { - "documentation": null, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, @@ -50,7 +47,6 @@ null ], "name": "f", - "overrides": null, "scope": 11, "stateMutability": "nonpayable", "virtual": false, @@ -93,8 +89,7 @@ "assignments": [ 7 - ], - "initialValue": null + ] }, "children": [ @@ -104,12 +99,10 @@ "constant": false, "mutability": "mutable", "name": "x", - "overrides": null, "scope": 9, "stateVariable": false, "storageLocation": "memory", "type": "uint256[]", - "value": null, "visibility": "internal" }, "children": @@ -117,7 +110,6 @@ { "attributes": { - "length": null, "type": "uint256[]" }, "children": diff --git a/test/libsolidity/ASTJSON/short_type_name_ref.json b/test/libsolidity/ASTJSON/short_type_name_ref.json index 1a22f1f24..2d07a9c60 100644 --- a/test/libsolidity/ASTJSON/short_type_name_ref.json +++ b/test/libsolidity/ASTJSON/short_type_name_ref.json @@ -8,7 +8,6 @@ ] }, "id": 13, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 12, "linearizedBaseContracts": @@ -49,7 +47,6 @@ "mutability": "mutable", "name": "rows", "nodeType": "VariableDeclaration", - "overrides": null, "scope": 10, "src": "35:20:1", "stateVariable": false, @@ -76,7 +73,6 @@ } }, "id": 6, - "length": null, "nodeType": "ArrayTypeName", "src": "35:6:1", "typeDescriptions": @@ -86,7 +82,6 @@ } }, "id": 7, - "length": null, "nodeType": "ArrayTypeName", "src": "35:8:1", "typeDescriptions": @@ -95,18 +90,15 @@ "typeString": "uint256[][]" } }, - "value": null, "visibility": "internal" } ], "id": 9, - "initialValue": null, "nodeType": "VariableDeclarationStatement", "src": "35:20:1" } ] }, - "documentation": null, "functionSelector": "26121ff0", "id": 11, "implemented": true, @@ -114,7 +106,6 @@ "modifiers": [], "name": "f", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, diff --git a/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json b/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json index 086a21584..5316c56ac 100644 --- a/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json +++ b/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json @@ -8,8 +8,7 @@ [ 12 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -40,7 +38,6 @@ { "attributes": { - "documentation": null, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, @@ -50,7 +47,6 @@ null ], "name": "f", - "overrides": null, "scope": 12, "stateMutability": "nonpayable", "virtual": false, @@ -93,8 +89,7 @@ "assignments": [ 8 - ], - "initialValue": null + ] }, "children": [ @@ -104,12 +99,10 @@ "constant": false, "mutability": "mutable", "name": "rows", - "overrides": null, "scope": 10, "stateVariable": false, "storageLocation": "memory", "type": "uint256[][]", - "value": null, "visibility": "internal" }, "children": @@ -117,7 +110,6 @@ { "attributes": { - "length": null, "type": "uint256[][]" }, "children": @@ -125,7 +117,6 @@ { "attributes": { - "length": null, "type": "uint256[]" }, "children": diff --git a/test/libsolidity/ASTJSON/smoke.json b/test/libsolidity/ASTJSON/smoke.json index d72018e09..dede1661c 100644 --- a/test/libsolidity/ASTJSON/smoke.json +++ b/test/libsolidity/ASTJSON/smoke.json @@ -8,7 +8,6 @@ ] }, "id": 2, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -17,7 +16,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 1, "linearizedBaseContracts": diff --git a/test/libsolidity/ASTJSON/smoke_legacy.json b/test/libsolidity/ASTJSON/smoke_legacy.json index da56b0e77..6097976e9 100644 --- a/test/libsolidity/ASTJSON/smoke_legacy.json +++ b/test/libsolidity/ASTJSON/smoke_legacy.json @@ -8,8 +8,7 @@ [ 1 ] - }, - "license": null + } }, "children": [ @@ -26,7 +25,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ diff --git a/test/libsolidity/ASTJSON/source_location.json b/test/libsolidity/ASTJSON/source_location.json index b0b81d8f8..f56231ed7 100644 --- a/test/libsolidity/ASTJSON/source_location.json +++ b/test/libsolidity/ASTJSON/source_location.json @@ -4,11 +4,10 @@ { "C": [ - 11 + 12 ] }, - "id": 12, - "license": null, + "id": 13, "nodeType": "SourceUnit", "nodes": [ @@ -17,12 +16,11 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, - "id": 11, + "id": 12, "linearizedBaseContracts": [ - 11 + 12 ], "name": "C", "nodeType": "ContractDefinition", @@ -31,53 +29,60 @@ { "body": { - "id": 9, + "id": 10, "nodeType": "Block", - "src": "26:19:1", + "src": "26:20:1", "statements": [ { "assignments": [ - 3 + 4 ], "declarations": [ { "constant": false, - "id": 3, + "id": 4, "mutability": "mutable", "name": "x", "nodeType": "VariableDeclaration", - "overrides": null, - "scope": 9, - "src": "28:5:1", + "scope": 10, + "src": "28:6:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { - "typeIdentifier": "t_uint8", - "typeString": "uint8" + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": + { + "id": 3, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "28:4:1", + "typeDescriptions": + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } }, - "typeName": null, - "value": null, "visibility": "internal" } ], - "id": 5, + "id": 6, "initialValue": { - "argumentTypes": null, "hexValue": "32", - "id": 4, + "id": 5, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", - "src": "36:1:1", - "subdenomination": null, + "src": "37:1:1", "typeDescriptions": { "typeIdentifier": "t_rational_2_by_1", @@ -86,13 +91,12 @@ "value": "2" }, "nodeType": "VariableDeclarationStatement", - "src": "28:9:1" + "src": "28:10:1" }, { "expression": { - "argumentTypes": null, - "id": 7, + "id": 8, "isConstant": false, "isLValue": false, "isPure": false, @@ -100,43 +104,40 @@ "nodeType": "UnaryOperation", "operator": "++", "prefix": false, - "src": "39:3:1", + "src": "40:3:1", "subExpression": { - "argumentTypes": null, - "id": 6, + "id": 7, "name": "x", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 3, - "src": "39:1:1", + "referencedDeclaration": 4, + "src": "40:1:1", "typeDescriptions": { - "typeIdentifier": "t_uint8", - "typeString": "uint8" + "typeIdentifier": "t_uint256", + "typeString": "uint256" } }, "typeDescriptions": { - "typeIdentifier": "t_uint8", - "typeString": "uint8" + "typeIdentifier": "t_uint256", + "typeString": "uint256" } }, - "id": 8, + "id": 9, "nodeType": "ExpressionStatement", - "src": "39:3:1" + "src": "40:3:1" } ] }, - "documentation": null, "functionSelector": "26121ff0", - "id": 10, + "id": 11, "implemented": true, "kind": "function", "modifiers": [], "name": "f", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, @@ -151,16 +152,16 @@ "parameters": [], "src": "26:0:1" }, - "scope": 11, - "src": "13:32:1", + "scope": 12, + "src": "13:33:1", "stateMutability": "nonpayable", "virtual": false, "visibility": "public" } ], - "scope": 12, - "src": "0:47:1" + "scope": 13, + "src": "0:48:1" } ], - "src": "0:48:1" + "src": "0:49:1" } diff --git a/test/libsolidity/ASTJSON/source_location.sol b/test/libsolidity/ASTJSON/source_location.sol index 1b763646d..0960bcde6 100644 --- a/test/libsolidity/ASTJSON/source_location.sol +++ b/test/libsolidity/ASTJSON/source_location.sol @@ -1,3 +1,3 @@ -contract C { function f() { var x = 2; x++; } } +contract C { function f() { uint x = 2; x++; } } // ---- diff --git a/test/libsolidity/ASTJSON/source_location_legacy.json b/test/libsolidity/ASTJSON/source_location_legacy.json index 42f81ad16..bf3dfaedd 100644 --- a/test/libsolidity/ASTJSON/source_location_legacy.json +++ b/test/libsolidity/ASTJSON/source_location_legacy.json @@ -6,10 +6,9 @@ { "C": [ - 11 + 12 ] - }, - "license": null + } }, "children": [ @@ -26,21 +25,19 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ - 11 + 12 ], "name": "C", - "scope": 12 + "scope": 13 }, "children": [ { "attributes": { - "documentation": null, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, @@ -50,8 +47,7 @@ null ], "name": "f", - "overrides": null, - "scope": 11, + "scope": 12, "stateMutability": "nonpayable", "virtual": false, "visibility": "public" @@ -92,7 +88,7 @@ { "assignments": [ - 3 + 4 ] }, "children": @@ -103,42 +99,49 @@ "constant": false, "mutability": "mutable", "name": "x", - "overrides": null, - "scope": 9, + "scope": 10, "stateVariable": false, "storageLocation": "default", - "type": "uint8", - "typeName": null, - "value": null, + "type": "uint256", "visibility": "internal" }, - "children": [], - "id": 3, + "children": + [ + { + "attributes": + { + "name": "uint", + "type": "uint256" + }, + "id": 3, + "name": "ElementaryTypeName", + "src": "28:4:1" + } + ], + "id": 4, "name": "VariableDeclaration", - "src": "28:5:1" + "src": "28:6:1" }, { "attributes": { - "argumentTypes": null, "hexvalue": "32", "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, - "subdenomination": null, "token": "number", "type": "int_const 2", "value": "2" }, - "id": 4, + "id": 5, "name": "Literal", - "src": "36:1:1" + "src": "37:1:1" } ], - "id": 5, + "id": 6, "name": "VariableDeclarationStatement", - "src": "28:9:1" + "src": "28:10:1" }, { "children": @@ -146,60 +149,58 @@ { "attributes": { - "argumentTypes": null, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "operator": "++", "prefix": false, - "type": "uint8" + "type": "uint256" }, "children": [ { "attributes": { - "argumentTypes": null, "overloadedDeclarations": [ null ], - "referencedDeclaration": 3, - "type": "uint8", + "referencedDeclaration": 4, + "type": "uint256", "value": "x" }, - "id": 6, + "id": 7, "name": "Identifier", - "src": "39:1:1" + "src": "40:1:1" } ], - "id": 7, + "id": 8, "name": "UnaryOperation", - "src": "39:3:1" + "src": "40:3:1" } ], - "id": 8, + "id": 9, "name": "ExpressionStatement", - "src": "39:3:1" + "src": "40:3:1" } ], - "id": 9, + "id": 10, "name": "Block", - "src": "26:19:1" + "src": "26:20:1" } ], - "id": 10, + "id": 11, "name": "FunctionDefinition", - "src": "13:32:1" + "src": "13:33:1" } ], - "id": 11, + "id": 12, "name": "ContractDefinition", - "src": "0:47:1" + "src": "0:48:1" } ], - "id": 12, + "id": 13, "name": "SourceUnit", - "src": "0:48:1" + "src": "0:49:1" } diff --git a/test/libsolidity/ASTJSON/two_base_functions.json b/test/libsolidity/ASTJSON/two_base_functions.json index 18412bbc7..769e5c3f8 100644 --- a/test/libsolidity/ASTJSON/two_base_functions.json +++ b/test/libsolidity/ASTJSON/two_base_functions.json @@ -16,7 +16,6 @@ ] }, "id": 23, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -25,7 +24,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 5, "linearizedBaseContracts": @@ -44,7 +42,6 @@ "src": "45:2:1", "statements": [] }, - "documentation": null, "functionSelector": "26121ff0", "id": 4, "implemented": true, @@ -52,7 +49,6 @@ "modifiers": [], "name": "f", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 1, @@ -82,7 +78,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 10, "linearizedBaseContracts": @@ -101,7 +96,6 @@ "src": "95:2:1", "statements": [] }, - "documentation": null, "functionSelector": "26121ff0", "id": 9, "implemented": true, @@ -109,7 +103,6 @@ "modifiers": [], "name": "f", "nodeType": "FunctionDefinition", - "overrides": null, "parameters": { "id": 6, @@ -139,10 +132,8 @@ "baseContracts": [ { - "arguments": null, "baseName": { - "contractScope": null, "id": 11, "name": "A", "nodeType": "UserDefinedTypeName", @@ -159,10 +150,8 @@ "src": "114:1:1" }, { - "arguments": null, "baseName": { - "contractScope": null, "id": 13, "name": "B", "nodeType": "UserDefinedTypeName", @@ -185,7 +174,6 @@ 10 ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 22, "linearizedBaseContracts": @@ -211,7 +199,6 @@ "src": "160:2:1", "statements": [] }, - "documentation": null, "functionSelector": "26121ff0", "id": 21, "implemented": true, @@ -226,7 +213,6 @@ "overrides": [ { - "contractScope": null, "id": 16, "name": "A", "nodeType": "UserDefinedTypeName", @@ -239,7 +225,6 @@ } }, { - "contractScope": null, "id": 17, "name": "B", "nodeType": "UserDefinedTypeName", diff --git a/test/libsolidity/ASTJSON/two_base_functions_legacy.json b/test/libsolidity/ASTJSON/two_base_functions_legacy.json index b58008b75..a5bd2d725 100644 --- a/test/libsolidity/ASTJSON/two_base_functions_legacy.json +++ b/test/libsolidity/ASTJSON/two_base_functions_legacy.json @@ -16,8 +16,7 @@ [ 22 ] - }, - "license": null + } }, "children": [ @@ -34,7 +33,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -48,7 +46,6 @@ { "attributes": { - "documentation": null, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, @@ -58,7 +55,6 @@ null ], "name": "f", - "overrides": null, "scope": 5, "stateMutability": "nonpayable", "virtual": true, @@ -128,7 +124,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -142,7 +137,6 @@ { "attributes": { - "documentation": null, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, @@ -152,7 +146,6 @@ null ], "name": "f", - "overrides": null, "scope": 10, "stateMutability": "nonpayable", "virtual": true, @@ -219,7 +212,6 @@ 10 ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -233,16 +225,12 @@ "children": [ { - "attributes": - { - "arguments": null - }, + "attributes": {}, "children": [ { "attributes": { - "contractScope": null, "name": "A", "referencedDeclaration": 5, "type": "contract A" @@ -257,16 +245,12 @@ "src": "114:1:1" }, { - "attributes": - { - "arguments": null - }, + "attributes": {}, "children": [ { "attributes": { - "contractScope": null, "name": "B", "referencedDeclaration": 10, "type": "contract B" @@ -288,7 +272,6 @@ 4, 9 ], - "documentation": null, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, @@ -311,7 +294,6 @@ { "attributes": { - "contractScope": null, "name": "A", "referencedDeclaration": 5, "type": "contract A" @@ -323,7 +305,6 @@ { "attributes": { - "contractScope": null, "name": "B", "referencedDeclaration": 10, "type": "contract B" diff --git a/test/libsolidity/ASTJSON/using_for_directive.json b/test/libsolidity/ASTJSON/using_for_directive.json index 66674f589..d26922262 100644 --- a/test/libsolidity/ASTJSON/using_for_directive.json +++ b/test/libsolidity/ASTJSON/using_for_directive.json @@ -12,7 +12,6 @@ ] }, "id": 6, - "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -21,7 +20,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "library", - "documentation": null, "fullyImplemented": true, "id": 1, "linearizedBaseContracts": @@ -39,7 +37,6 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "id": 5, "linearizedBaseContracts": @@ -54,7 +51,6 @@ "id": 4, "libraryName": { - "contractScope": null, "id": 2, "name": "L", "nodeType": "UserDefinedTypeName", diff --git a/test/libsolidity/ASTJSON/using_for_directive_legacy.json b/test/libsolidity/ASTJSON/using_for_directive_legacy.json index 280e9be4a..bdd92fcba 100644 --- a/test/libsolidity/ASTJSON/using_for_directive_legacy.json +++ b/test/libsolidity/ASTJSON/using_for_directive_legacy.json @@ -12,8 +12,7 @@ [ 1 ] - }, - "license": null + } }, "children": [ @@ -30,7 +29,6 @@ null ], "contractKind": "library", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -60,7 +58,6 @@ null ], "contractKind": "contract", - "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ @@ -77,7 +74,6 @@ { "attributes": { - "contractScope": null, "name": "L", "referencedDeclaration": 1, "type": "library L" diff --git a/test/libsolidity/GasCosts.cpp b/test/libsolidity/GasCosts.cpp index 2ad1368a6..bb86aaa83 100644 --- a/test/libsolidity/GasCosts.cpp +++ b/test/libsolidity/GasCosts.cpp @@ -97,7 +97,7 @@ BOOST_AUTO_TEST_CASE(string_storage) auto evmVersion = solidity::test::CommonOptions::get().evmVersion(); if (evmVersion <= EVMVersion::byzantium()) - CHECK_DEPLOY_GAS(134209, 130895, evmVersion); + CHECK_DEPLOY_GAS(134145, 130831, evmVersion); // This is only correct on >=Constantinople. else if (CommonOptions::get().useABIEncoderV2) { @@ -105,22 +105,22 @@ BOOST_AUTO_TEST_CASE(string_storage) { // Costs with 0 are cases which cannot be triggered in tests. if (evmVersion < EVMVersion::istanbul()) - CHECK_DEPLOY_GAS(0, 124033, evmVersion); + CHECK_DEPLOY_GAS(0, 123969, evmVersion); else - CHECK_DEPLOY_GAS(0, 110981, evmVersion); + CHECK_DEPLOY_GAS(0, 110969, evmVersion); } else { if (evmVersion < EVMVersion::istanbul()) - CHECK_DEPLOY_GAS(147835, 131687, evmVersion); + CHECK_DEPLOY_GAS(147835, 123969, evmVersion); else - CHECK_DEPLOY_GAS(131871, 117231, evmVersion); + CHECK_DEPLOY_GAS(131871, 110969, evmVersion); } } else if (evmVersion < EVMVersion::istanbul()) - CHECK_DEPLOY_GAS(126993, 119723, evmVersion); + CHECK_DEPLOY_GAS(126929, 119659, evmVersion); else - CHECK_DEPLOY_GAS(114357, 107347, evmVersion); + CHECK_DEPLOY_GAS(114345, 107335, evmVersion); if (evmVersion >= EVMVersion::byzantium()) { @@ -140,9 +140,9 @@ BOOST_AUTO_TEST_CASE(string_storage) else { if (evmVersion < EVMVersion::istanbul()) - CHECK_GAS(21707, 21635, 20); + CHECK_GAS(21707, 21559, 20); else - CHECK_GAS(21499, 21431, 20); + CHECK_GAS(21499, 21351, 20); } } else if (evmVersion < EVMVersion::istanbul()) diff --git a/test/libsolidity/GasMeter.cpp b/test/libsolidity/GasMeter.cpp index c8296beb1..412dfb9d7 100644 --- a/test/libsolidity/GasMeter.cpp +++ b/test/libsolidity/GasMeter.cpp @@ -174,7 +174,7 @@ BOOST_AUTO_TEST_CASE(store_keccak256) char const* sourceCode = R"( contract test { bytes32 public shaValue; - constructor() public { + constructor() { shaValue = keccak256(abi.encodePacked(this)); } } @@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE(updating_store) contract test { uint data; uint data2; - constructor() public { + constructor() { data = 1; data = 2; data2 = 0; diff --git a/test/libsolidity/SolidityCompiler.cpp b/test/libsolidity/SolidityCompiler.cpp index 971a74a75..13f714e5e 100644 --- a/test/libsolidity/SolidityCompiler.cpp +++ b/test/libsolidity/SolidityCompiler.cpp @@ -36,7 +36,7 @@ BOOST_AUTO_TEST_CASE(does_not_include_creation_time_only_internal_functions) char const* sourceCode = R"( contract C { uint x; - constructor() public { f(); } + constructor() { f(); } function f() internal { for (uint i = 0; i < 10; ++i) x += 3 + i; } } )"; diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 59f01096d..d3398f510 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -981,7 +981,7 @@ BOOST_AUTO_TEST_CASE(constructor) char const* sourceCode = R"( contract test { mapping(uint => uint) data; - constructor() public { + constructor() { data[7] = 8; } function get(uint key) public returns (uint value) { @@ -1008,7 +1008,7 @@ BOOST_AUTO_TEST_CASE(blockchain) { char const* sourceCode = R"( contract test { - constructor() public payable {} + constructor() payable {} function someInfo() public payable returns (uint256 value, address coinbase, uint256 blockNumber) { value = msg.value; coinbase = block.coinbase; @@ -1026,34 +1026,11 @@ BOOST_AUTO_TEST_CASE(blockchain) ABI_CHECK(callContractFunctionWithValue("someInfo()", 28), encodeArgs(28, u256("0x1212121212121212121212121212121212121212"), 7)); } -BOOST_AUTO_TEST_CASE(now) -{ - char const* sourceCode = R"( - contract test { - function someInfo() public returns (bool equal, uint val) { - equal = block.timestamp == now; - val = now; - } - } - )"; - ALSO_VIA_YUL( - compileAndRun(sourceCode); - u256 startBlock = blockNumber(); - size_t startTime = blockTimestamp(startBlock); - auto ret = callContractFunction("someInfo()"); - u256 endBlock = blockNumber(); - size_t endTime = blockTimestamp(endBlock); - BOOST_CHECK(startBlock != endBlock); - BOOST_CHECK(startTime != endTime); - ABI_CHECK(ret, encodeArgs(true, endTime)); - ) -} - BOOST_AUTO_TEST_CASE(send_ether) { char const* sourceCode = R"( contract test { - constructor() payable public {} + constructor() payable {} function a(address payable addr, uint amount) public returns (uint ret) { addr.send(amount); return address(this).balance; @@ -1073,7 +1050,7 @@ BOOST_AUTO_TEST_CASE(transfer_ether) { char const* sourceCode = R"( contract A { - constructor() public payable {} + constructor() payable {} function a(address payable addr, uint amount) public returns (uint) { addr.transfer(amount); return address(this).balance; @@ -1229,7 +1206,7 @@ BOOST_AUTO_TEST_CASE(log_in_constructor) { char const* sourceCode = R"( contract test { - constructor() public { + constructor() { log1(bytes32(uint256(1)), bytes32(uint256(2))); } } @@ -1248,7 +1225,7 @@ BOOST_AUTO_TEST_CASE(selfdestruct) { char const* sourceCode = R"( contract test { - constructor() public payable {} + constructor() payable {} function a(address payable receiver) public returns (uint ret) { selfdestruct(receiver); return 10; @@ -1637,7 +1614,7 @@ BOOST_AUTO_TEST_CASE(constructor_with_long_arguments) string public a; string public b; - constructor(string memory _a, string memory _b) public { + constructor(string memory _a, string memory _b) { a = _a; b = _b; } @@ -1666,7 +1643,7 @@ BOOST_AUTO_TEST_CASE(contracts_as_addresses) } contract test { helper h; - constructor() public payable { h = new helper(); address(h).send(5); } + constructor() payable { h = new helper(); address(h).send(5); } function getBalance() public returns (uint256 myBalance, uint256 helperBalance) { myBalance = address(this).balance; helperBalance = address(h).balance; @@ -1743,8 +1720,8 @@ BOOST_AUTO_TEST_CASE(blockhash) BOOST_AUTO_TEST_CASE(internal_constructor) { char const* sourceCode = R"( - contract C { - constructor() internal {} + abstract contract C { + constructor() {} } )"; BOOST_CHECK(compileAndRunWithoutCheck({{"", sourceCode}}, 0, "C").empty()); @@ -2402,11 +2379,11 @@ BOOST_AUTO_TEST_CASE(generic_call) function recv(uint256 x) public payable { received = x; } } contract sender { - constructor() public payable {} + constructor() payable {} function doSend(address rec) public returns (uint d) { bytes4 signature = bytes4(bytes32(keccak256("recv(uint256)"))); - rec.call.value(2)(abi.encodeWithSelector(signature, 23)); + rec.call{value: 2}(abi.encodeWithSelector(signature, 23)); return receiver(rec).received(); } } @@ -2425,14 +2402,14 @@ BOOST_AUTO_TEST_CASE(generic_delegatecall) uint public received; address public sender; uint public value; - constructor() public payable {} + constructor() payable {} function recv(uint256 x) public payable { received = x; sender = msg.sender; value = msg.value; } } contract Sender { uint public received; address public sender; uint public value; - constructor() public payable {} + constructor() payable {} function doSend(address rec) public payable { bytes4 signature = bytes4(bytes32(keccak256("recv(uint256)"))); @@ -2473,7 +2450,7 @@ BOOST_AUTO_TEST_CASE(generic_staticcall) char const* sourceCode = R"**( contract A { uint public x; - constructor() public { x = 42; } + constructor() { x = 42; } function pureFunction(uint256 p) public pure returns (uint256) { return p; } function viewFunction(uint256 p) public view returns (uint256) { return p + x; } function nonpayableFunction(uint256 p) public returns (uint256) { x = p; return x; } @@ -2608,7 +2585,7 @@ BOOST_AUTO_TEST_CASE(call_forward_bytes) fallback() external { received = 0x80; } } contract sender { - constructor() public { rec = new receiver(); } + constructor() { rec = new receiver(); } fallback() external { savedData = msg.data; } function forward() public returns (bool) { address(rec).call(savedData); return true; } function clear() public returns (bool) { delete savedData; return true; } @@ -2637,7 +2614,7 @@ BOOST_AUTO_TEST_CASE(call_forward_bytes_length) } contract sender { receiver rec; - constructor() public { rec = new receiver(); } + constructor() { rec = new receiver(); } function viaCalldata() public returns (uint) { (bool success,) = address(rec).call(msg.data); require(success); @@ -2681,7 +2658,7 @@ BOOST_AUTO_TEST_CASE(copying_bytes_multiassign) fallback() external { received = 0x80; } } contract sender { - constructor() public { rec = new receiver(); } + constructor() { rec = new receiver(); } fallback() external { savedData1 = savedData2 = msg.data; } function forward(bool selector) public returns (bool) { if (selector) { address(rec).call(savedData1); delete savedData1; } @@ -3489,12 +3466,12 @@ BOOST_AUTO_TEST_CASE(array_copy_calldata_storage) ABI_CHECK(callContractFunction("retrieve()"), encodeArgs(9, 28, 9, 28, 4, 3, 32)); } -BOOST_AUTO_TEST_CASE(array_copy_including_mapping) +BOOST_AUTO_TEST_CASE(array_copy_including_array) { char const* sourceCode = R"( contract c { - mapping(uint=>uint)[90][] large; - mapping(uint=>uint)[3][] small; + uint[3][90][] large; + uint[3][3][] small; function test() public returns (uint r) { for (uint i = 0; i < 7; i++) { large.push(); @@ -3529,9 +3506,8 @@ BOOST_AUTO_TEST_CASE(array_copy_including_mapping) } )"; compileAndRun(sourceCode); - ABI_CHECK(callContractFunction("test()"), encodeArgs(0x02000200)); - // storage is not empty because we cannot delete the mappings - BOOST_CHECK(!storageEmpty(m_contractAddress)); + ABI_CHECK(callContractFunction("test()"), encodeArgs(0x02000202)); + BOOST_CHECK(storageEmpty(m_contractAddress)); ABI_CHECK(callContractFunction("clear()"), encodeArgs(0, 0)); BOOST_CHECK(storageEmpty(m_contractAddress)); } @@ -3634,7 +3610,7 @@ BOOST_AUTO_TEST_CASE(evm_exceptions_in_constructor_out_of_baund) contract A { uint public test = 1; uint[3] arr; - constructor() public + constructor() { uint index = 5; test = arr[index]; @@ -3656,7 +3632,7 @@ BOOST_AUTO_TEST_CASE(failing_send) } } contract Main { - constructor() public payable {} + constructor() payable {} function callHelper(address payable _a) public returns (bool r, uint bal) { r = !_a.send(5); bal = address(this).balance; @@ -3881,7 +3857,7 @@ BOOST_AUTO_TEST_CASE(bytes_in_constructors_unpacker) contract Test { uint public m_x; bytes public m_s; - constructor(uint x, bytes memory s) public { + constructor(uint x, bytes memory s) { m_x = x; m_s = s; } @@ -3902,7 +3878,7 @@ BOOST_AUTO_TEST_CASE(bytes_in_constructors_packer) contract Base { uint public m_x; bytes m_s; - constructor(uint x, bytes memory s) public { + constructor(uint x, bytes memory s) { m_x = x; m_s = s; } @@ -3911,7 +3887,7 @@ BOOST_AUTO_TEST_CASE(bytes_in_constructors_packer) } } contract Main is Base { - constructor(bytes memory s, uint x) Base(x, f(s)) public {} + constructor(bytes memory s, uint x) Base(x, f(s)) {} function f(bytes memory s) public returns (bytes memory) { return s; } @@ -3941,7 +3917,7 @@ BOOST_AUTO_TEST_CASE(arrays_in_constructors) contract Base { uint public m_x; address[] m_s; - constructor(uint x, address[] memory s) public { + constructor(uint x, address[] memory s) { m_x = x; m_s = s; } @@ -3950,7 +3926,7 @@ BOOST_AUTO_TEST_CASE(arrays_in_constructors) } } contract Main is Base { - constructor(address[] memory s, uint x) Base(x, f(s)) public {} + constructor(address[] memory s, uint x) Base(x, f(s)) {} function f(address[] memory s) public returns (address[] memory) { return s; } @@ -4493,7 +4469,7 @@ BOOST_AUTO_TEST_CASE(constant_string_literal) bytes32 constant public b = "abcdefghijklmnopq"; string constant public x = "abefghijklmnopqabcdefghijklmnopqabcdefghijklmnopqabca"; - constructor() public { + constructor() { string memory xx = x; bytes32 bb = b; } @@ -4994,7 +4970,7 @@ BOOST_AUTO_TEST_CASE(calldata_offset) { address[] _arr; string public last = "nd"; - constructor(address[] memory guardians) public + constructor(address[] memory guardians) { _arr = guardians; } @@ -5009,7 +4985,7 @@ BOOST_AUTO_TEST_CASE(reject_ether_sent_to_library) char const* sourceCode = R"( library lib {} contract c { - constructor() public payable {} + constructor() payable {} function f(address payable x) public returns (bool) { return x.send(1); } @@ -5228,13 +5204,13 @@ BOOST_AUTO_TEST_CASE(index_access_with_type_conversion) BOOST_AUTO_TEST_CASE(failed_create) { char const* sourceCode = R"( - contract D { constructor() public payable {} } + contract D { constructor() payable {} } contract C { uint public x; - constructor() public payable {} + constructor() payable {} function f(uint amount) public returns (D) { x++; - return (new D).value(amount)(); + return (new D){value: amount}(); } function stack(uint depth) public returns (address) { if (depth < 1024) @@ -5260,7 +5236,7 @@ BOOST_AUTO_TEST_CASE(correctly_initialize_memory_array_in_constructor) char const* sourceCode = R"( contract C { bool public success; - constructor() public { + constructor() { // Make memory dirty. assembly { for { let i := 0 } lt(i, 64) { i := add(i, 1) } { @@ -5297,12 +5273,12 @@ BOOST_AUTO_TEST_CASE(mutex) } contract Fund is mutexed { uint shares; - constructor() public payable { shares = msg.value; } + constructor() payable { shares = msg.value; } function withdraw(uint amount) public protected returns (uint) { // NOTE: It is very bad practice to write this function this way. // Please refer to the documentation of how to do this properly. if (amount > shares) revert(); - (bool success,) = msg.sender.call.value(amount)(""); + (bool success,) = msg.sender.call{value: amount}(""); require(success); shares -= amount; return shares; @@ -5311,7 +5287,7 @@ BOOST_AUTO_TEST_CASE(mutex) // NOTE: It is very bad practice to write this function this way. // Please refer to the documentation of how to do this properly. if (amount > shares) revert(); - (bool success,) = msg.sender.call.value(amount)(""); + (bool success,) = msg.sender.call{value: amount}(""); require(success); shares -= amount; return shares; @@ -5322,7 +5298,7 @@ BOOST_AUTO_TEST_CASE(mutex) uint callDepth; bool protected; function setProtected(bool _protected) public { protected = _protected; } - constructor(Fund _fund) public { fund = _fund; } + constructor(Fund _fund) { fund = _fund; } function attack() public returns (uint) { callDepth = 0; return attackInternal(); @@ -5562,7 +5538,7 @@ BOOST_AUTO_TEST_CASE(include_creation_bytecode_only_once) contract D { bytes a = hex"1237651237125387136581271652831736512837126583171583712358126123765123712538713658127165283173651283712658317158371235812612376512371253871365812716528317365128371265831715837123581261237651237125387136581271652831736512837126583171583712358126"; bytes b = hex"1237651237125327136581271252831736512837126583171383712358126123765125712538713658127165253173651283712658357158371235812612376512371a5387136581271652a317365128371265a317158371235812612a765123712538a13658127165a83173651283712a58317158371235a126"; - constructor(uint) public {} + constructor(uint) {} } contract Double { function f() public { @@ -5808,7 +5784,7 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages_through_create) { char const* sourceCode = R"( contract E { - constructor() public { + constructor() { revert("message"); } } @@ -5922,7 +5898,7 @@ BOOST_AUTO_TEST_CASE(bare_call_return_data) { string sourceCode = R"DELIMITER( contract A { - constructor() public { + constructor() { } function return_bool() public pure returns(bool) { return true; @@ -5953,7 +5929,7 @@ BOOST_AUTO_TEST_CASE(bare_call_return_data) } contract C { A addr; - constructor() public { + constructor() { addr = new A(); } function f(string memory signature) public returns (bool, bytes memory) { @@ -6284,7 +6260,7 @@ BOOST_AUTO_TEST_CASE(abi_encodePackedV2_structs) } S s; event E(S indexed); - constructor() public { + constructor() { s.a = 0x12; s.b = -7; s.c[0] = 2; @@ -6349,7 +6325,7 @@ BOOST_AUTO_TEST_CASE(abi_encodePackedV2_arrayOfStrings) contract C { string[] x; event E(string[] indexed); - constructor() public { + constructor() { x.push("abc"); x.push("0123456789012345678901234567890123456789"); } @@ -6392,7 +6368,7 @@ BOOST_AUTO_TEST_CASE(event_signature_in_library) } } contract C { - constructor() public { + constructor() { L.f(); } } @@ -6720,7 +6696,7 @@ BOOST_AUTO_TEST_CASE(dirty_scratch_space_prior_to_constant_optimiser) char const* sourceCode = R"( contract C { event X(uint); - constructor() public { + constructor() { assembly { // make scratch space dirty mstore(0, 0x4242424242424242424242424242424242424242424242424242424242424242) diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index a1db40747..91a41a65b 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -237,37 +237,6 @@ BOOST_AUTO_TEST_CASE(int_with_gwei_ether_subdenomination) BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } -BOOST_AUTO_TEST_CASE(int_with_szabo_ether_subdenomination) -{ - char const* sourceCode = R"( - contract test { - function test () { - uint x = 1 szabo; - } - } - )"; - bytes code = compileFirstExpression(sourceCode); - - bytes expectation({uint8_t(Instruction::PUSH5), 0xe8, 0xd4, 0xa5, 0x10, 0x00}); - BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); -} - -BOOST_AUTO_TEST_CASE(int_with_finney_ether_subdenomination) -{ - char const* sourceCode = R"( - contract test { - constructor() - { - uint x = 1 finney; - } - } - )"; - bytes code = compileFirstExpression(sourceCode); - - bytes expectation({uint8_t(Instruction::PUSH7), 0x3, 0x8d, 0x7e, 0xa4, 0xc6, 0x80, 0x00}); - BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); -} - BOOST_AUTO_TEST_CASE(int_with_ether_ether_subdenomination) { char const* sourceCode = R"( diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index b97d7bd4d..65a8026a4 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -97,7 +97,7 @@ BOOST_AUTO_TEST_CASE(implement_abstract_via_constructor) SourceUnit const* sourceUnit = nullptr; char const* text = R"( abstract contract base { function foo() public virtual; } - abstract contract foo is base { constructor() public {} } + abstract contract foo is base { constructor() {} } )"; sourceUnit = parseAndAnalyse(text); std::vector> nodes = sourceUnit->nodes(); diff --git a/test/libsolidity/SolidityNatspecJSON.cpp b/test/libsolidity/SolidityNatspecJSON.cpp index 26e293b68..fa1e7903d 100644 --- a/test/libsolidity/SolidityNatspecJSON.cpp +++ b/test/libsolidity/SolidityNatspecJSON.cpp @@ -918,18 +918,7 @@ BOOST_AUTO_TEST_CASE(dev_author_at_function) } )"; - char const* natspec = "{" - " \"author\": \"Lefteris\"," - " \"title\": \"Just a test contract\"," - " \"methods\":{" - " \"mul(uint256,uint256)\":{ \n" - " \"details\": \"Mul function\",\n" - " \"author\": \"John Doe\",\n" - " }\n" - " }\n" - "}"; - - checkNatspec(sourceCode, "test", natspec, false); + expectNatspecError(sourceCode); } BOOST_AUTO_TEST_CASE(natspec_notice_without_tag) @@ -1067,16 +1056,18 @@ BOOST_AUTO_TEST_CASE(dev_documenting_no_param_description) BOOST_AUTO_TEST_CASE(user_constructor) { - char const *sourceCode = R"( + char const* sourceCode = R"( contract test { /// @notice this is a really nice constructor - constructor(uint a, uint second) public { } + constructor(uint a, uint second) { } } )"; - char const *natspec = R"ABCDEF({ - "methods" : { - "constructor" : "this is a really nice constructor" + char const* natspec = R"ABCDEF({ + "methods": { + "constructor" : { + "notice": "this is a really nice constructor" + } } })ABCDEF"; @@ -1085,21 +1076,23 @@ BOOST_AUTO_TEST_CASE(user_constructor) BOOST_AUTO_TEST_CASE(user_constructor_and_function) { - char const *sourceCode = R"( + char const* sourceCode = R"( contract test { /// @notice this is a really nice constructor - constructor(uint a, uint second) public { } + constructor(uint a, uint second) { } /// another multiplier function mul(uint a, uint second) public returns(uint d) { return a * 7 + second; } } )"; - char const *natspec = R"ABCDEF({ + char const* natspec = R"ABCDEF({ "methods" : { "mul(uint256,uint256)" : { "notice" : "another multiplier" }, - "constructor" : "this is a really nice constructor" + "constructor" : { + "notice" : "this is a really nice constructor" + } } })ABCDEF"; @@ -1110,17 +1103,15 @@ BOOST_AUTO_TEST_CASE(dev_constructor) { char const *sourceCode = R"( contract test { - /// @author Alex /// @param a the parameter a is really nice and very useful /// @param second the second parameter is not very useful, it just provides additional confusion - constructor(uint a, uint second) public { } + constructor(uint a, uint second) { } } )"; char const *natspec = R"ABCDEF({ "methods" : { "constructor" : { - "author" : "Alex", "params" : { "a" : "the parameter a is really nice and very useful", "second" : "the second parameter is not very useful, it just provides additional confusion" @@ -1136,11 +1127,10 @@ BOOST_AUTO_TEST_CASE(dev_constructor_return) { char const* sourceCode = R"( contract test { - /// @author Alex /// @param a the parameter a is really nice and very useful /// @param second the second parameter is not very useful, it just provides additional confusion /// @return return should not work within constructors - constructor(uint a, uint second) public { } + constructor(uint a, uint second) { } } )"; @@ -1151,10 +1141,9 @@ BOOST_AUTO_TEST_CASE(dev_constructor_and_function) { char const *sourceCode = R"( contract test { - /// @author Alex /// @param a the parameter a is really nice and very useful /// @param second the second parameter is not very useful, it just provides additional confusion - constructor(uint a, uint second) public { } + constructor(uint a, uint second) { } /// @dev Multiplies a number by 7 and adds second parameter /// @param a Documentation for the first parameter starts here. /// Since it's a really complicated parameter we need 2 lines @@ -1180,7 +1169,6 @@ BOOST_AUTO_TEST_CASE(dev_constructor_and_function) } }, "constructor" : { - "author" : "Alex", "params" : { "a" : "the parameter a is really nice and very useful", "second" : "the second parameter is not very useful, it just provides additional confusion" @@ -1398,7 +1386,6 @@ BOOST_AUTO_TEST_CASE(dev_default_inherit) interface ERC20 { /// Transfer ``amount`` from ``msg.sender`` to ``to``. /// Second line. - /// @author Programmer /// @dev test /// @param to address to transfer to /// @param amount amount to transfer @@ -1425,7 +1412,6 @@ BOOST_AUTO_TEST_CASE(dev_default_inherit) { "transfer(address,uint256)": { - "author": "Programmer", "details": "test", "params": { @@ -1447,7 +1433,6 @@ BOOST_AUTO_TEST_CASE(user_default_inherit) interface ERC20 { /// Transfer ``amount`` from ``msg.sender`` to ``to``. /// Second line. - /// @author Programmer /// @dev test /// @param to address to transfer to /// @param amount amount to transfer @@ -1489,7 +1474,6 @@ BOOST_AUTO_TEST_CASE(dev_explicit_inherit) char const *sourceCode = R"( interface ERC20 { /// Transfer ``amount`` from ``msg.sender`` to ``to``. - /// @author Programmer /// @dev test /// @param to address to transfer to /// @param amount amount to transfer @@ -1515,7 +1499,6 @@ BOOST_AUTO_TEST_CASE(dev_explicit_inherit) { "transfer(address,uint256)": { - "author": "Programmer", "details": "test", "params": { @@ -1535,7 +1518,6 @@ BOOST_AUTO_TEST_CASE(user_explicit_inherit) char const *sourceCode = R"( interface ERC20 { /// Transfer ``amount`` from ``msg.sender`` to ``to``. - /// @author Programmer /// @dev test /// @param to address to transfer to /// @param amount amount to transfer @@ -1575,7 +1557,6 @@ BOOST_AUTO_TEST_CASE(dev_explicit_inherit2) char const *sourceCode = R"( interface ERC20 { /// Transfer ``amount`` from ``msg.sender`` to ``to``. - /// @author Programmer /// @dev test /// @param to address to transfer to /// @param amount amount to transfer @@ -1601,7 +1582,6 @@ BOOST_AUTO_TEST_CASE(dev_explicit_inherit2) { "transfer(address,uint256)": { - "author": "Programmer", "details": "test", "params": { @@ -1622,7 +1602,6 @@ BOOST_AUTO_TEST_CASE(user_explicit_inherit2) char const *sourceCode = R"( interface ERC20 { /// Transfer ``amount`` from ``msg.sender`` to ``to``. - /// @author Programmer /// @dev test /// @param to address to transfer to /// @param amount amount to transfer @@ -1663,7 +1642,6 @@ BOOST_AUTO_TEST_CASE(dev_explicit_inherit_partial2) char const *sourceCode = R"( interface ERC20 { /// Transfer ``amount`` from ``msg.sender`` to ``to``. - /// @author Programmer /// @dev test /// @param to address to transfer to /// @param amount amount to transfer @@ -1691,7 +1669,6 @@ BOOST_AUTO_TEST_CASE(dev_explicit_inherit_partial2) { "transfer(address,uint256)": { - "author": "Programmer", "details": "test", "params": { @@ -1707,7 +1684,6 @@ BOOST_AUTO_TEST_CASE(dev_explicit_inherit_partial2) { "transfer(address,uint256)": { - "author": "Programmer", "details": "override dev comment", "params": { @@ -1727,7 +1703,6 @@ BOOST_AUTO_TEST_CASE(user_explicit_inherit_partial2) char const *sourceCode = R"( interface ERC20 { /// Transfer ``amount`` from ``msg.sender`` to ``to``. - /// @author Programmer /// @dev test /// @param to address to transfer to /// @param amount amount to transfer @@ -1778,7 +1753,6 @@ BOOST_AUTO_TEST_CASE(dev_explicit_inherit_partial) char const *sourceCode = R"( interface ERC20 { /// Transfer ``amount`` from ``msg.sender`` to ``to``. - /// @author Programmer /// @dev test /// @param to address to transfer to /// @param amount amount to transfer @@ -1806,7 +1780,6 @@ BOOST_AUTO_TEST_CASE(dev_explicit_inherit_partial) { "transfer(address,uint256)": { - "author": "Programmer", "details": "test", "params": { @@ -1822,7 +1795,6 @@ BOOST_AUTO_TEST_CASE(dev_explicit_inherit_partial) { "transfer(address,uint256)": { - "author": "Programmer", "details": "override dev comment", "params": { @@ -1842,7 +1814,6 @@ BOOST_AUTO_TEST_CASE(user_explicit_inherit_partial) char const *sourceCode = R"( interface ERC20 { /// Transfer ``amount`` from ``msg.sender`` to ``to``. - /// @author Programmer /// @dev test /// @param to address to transfer to /// @param amount amount to transfer @@ -1894,7 +1865,6 @@ BOOST_AUTO_TEST_CASE(dev_inherit_parameter_mismatch) char const *sourceCode = R"( interface ERC20 { /// Transfer ``amount`` from ``msg.sender`` to ``to``. - /// @author Programmer /// @dev test /// @param to address to transfer to /// @param amount amount to transfer @@ -1919,7 +1889,6 @@ BOOST_AUTO_TEST_CASE(dev_inherit_parameter_mismatch) { "transfer(address,uint256)": { - "author": "Programmer", "details": "test", "params": { @@ -1944,7 +1913,6 @@ BOOST_AUTO_TEST_CASE(user_inherit_parameter_mismatch) char const *sourceCode = R"( interface ERC20 { /// Transfer ``amount`` from ``msg.sender`` to ``to``. - /// @author Programmer /// @dev test /// @param to address to transfer to /// @param amount amount to transfer @@ -1988,7 +1956,6 @@ BOOST_AUTO_TEST_CASE(dev_explicit_inehrit_complex) char const *sourceCode1 = R"( interface ERC20 { /// Transfer ``amount`` from ``msg.sender`` to ``to``. - /// @author Programmer /// @dev test /// @param to address to transfer to /// @param amount amount to transfer @@ -1997,7 +1964,6 @@ BOOST_AUTO_TEST_CASE(dev_explicit_inehrit_complex) interface ERC21 { /// Transfer ``amount`` from ``msg.sender`` to ``to``. - /// @author Programmer2 /// @dev test2 /// @param to address to transfer to /// @param amount amount to transfer @@ -2022,7 +1988,6 @@ BOOST_AUTO_TEST_CASE(dev_explicit_inehrit_complex) { "transfer(address,uint256)": { - "author": "Programmer", "details": "test", "params": { diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp index 952eac940..24428c5ad 100644 --- a/test/libsolidity/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -347,9 +347,9 @@ BOOST_AUTO_TEST_CASE(incorrect_storage_access_bug) mapping(uint => uint) data; function f() public returns (uint) { - if (data[now] == 0) + if (data[block.timestamp] == 0) data[uint(-7)] = 5; - return data[now]; + return data[block.timestamp]; } } )"; @@ -379,7 +379,7 @@ BOOST_AUTO_TEST_CASE(computing_constants) uint m_b; uint m_c; uint m_d; - constructor() public { + constructor() { set(); } function set() public returns (uint) { @@ -563,7 +563,7 @@ BOOST_AUTO_TEST_CASE(dead_code_elimination_across_assemblies) char const* sourceCode = R"( contract DCE { function () internal returns (uint) stored; - constructor() public { + constructor() { stored = f; } function f() internal returns (uint) { return 7; } diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp index 364c0e2d5..1aea3bf96 100644 --- a/test/libsolidity/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -253,8 +253,8 @@ BOOST_AUTO_TEST_CASE(natspec_comment_in_function_body) contract test { /// fun1 description function fun1(uint256 a) { - var b; - /// I should not interfere with actual natspec comments + uint b; + // I should not interfere with actual natspec comments (natspec comments on local variables not allowed anymore) uint256 c; mapping(address=>bytes32) d; bytes7 name = "Solidity"; @@ -285,8 +285,8 @@ BOOST_AUTO_TEST_CASE(natspec_docstring_between_keyword_and_signature) uint256 stateVar; function ///I am in the wrong place fun1(uint256 a) { - var b; - /// I should not interfere with actual natspec comments + uint b; + // I should not interfere with actual natspec comments (natspec comments on local variables not allowed anymore) uint256 c; mapping(address=>bytes32) d; bytes7 name = "Solidity"; @@ -310,9 +310,9 @@ BOOST_AUTO_TEST_CASE(natspec_docstring_after_signature) contract test { uint256 stateVar; function fun1(uint256 a) { - /// I should have been above the function signature - var b; - /// I should not interfere with actual natspec comments + // I should have been above the function signature (natspec comments on local variables not allowed anymore) + uint b; + // I should not interfere with actual natspec comments (natspec comments on local variables not allowed anymore) uint256 c; mapping(address=>bytes32) d; bytes7 name = "Solidity"; @@ -334,7 +334,7 @@ BOOST_AUTO_TEST_CASE(variable_definition) char const* text = R"( contract test { function fun(uint256 a) { - var b; + uint b; uint256 c; mapping(address=>bytes32) d; customtype varname; @@ -349,7 +349,7 @@ BOOST_AUTO_TEST_CASE(variable_definition_with_initialization) char const* text = R"( contract test { function fun(uint256 a) { - var b = 2; + uint b = 2; uint256 c = 0x87; mapping(address=>bytes32) d; bytes7 name = "Solidity"; @@ -403,7 +403,7 @@ BOOST_AUTO_TEST_CASE(type_conversion_to_dynamic_array) char const* text = R"( contract test { function fun() { - var x = uint64[](3); + uint x = uint64[](3); } } )"; diff --git a/test/libsolidity/SolidityScanner.cpp b/test/libsolidity/SolidityScanner.cpp index b02a910a5..5b83778ba 100644 --- a/test/libsolidity/SolidityScanner.cpp +++ b/test/libsolidity/SolidityScanner.cpp @@ -428,11 +428,9 @@ BOOST_AUTO_TEST_CASE(comments_mixed_in_sequence) BOOST_AUTO_TEST_CASE(ether_subdenominations) { - Scanner scanner(CharStream("wei gwei szabo finney ether", "")); + Scanner scanner(CharStream("wei gwei ether", "")); BOOST_CHECK_EQUAL(scanner.currentToken(), Token::SubWei); - BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier); - BOOST_CHECK_EQUAL(scanner.next(), Token::SubSzabo); - BOOST_CHECK_EQUAL(scanner.next(), Token::SubFinney); + BOOST_CHECK_EQUAL(scanner.next(), Token::SubGwei); BOOST_CHECK_EQUAL(scanner.next(), Token::SubEther); } diff --git a/test/libsolidity/errorRecoveryTests/constructor_recovers.sol b/test/libsolidity/errorRecoveryTests/constructor_recovers.sol index 393a638ca..cc03f1e89 100644 --- a/test/libsolidity/errorRecoveryTests/constructor_recovers.sol +++ b/test/libsolidity/errorRecoveryTests/constructor_recovers.sol @@ -1,7 +1,7 @@ pragma solidity >=0.0.0; contract Error1 { - constructor() public { + constructor() { balances[tx.origin] = ; // missing RHS. } @@ -16,5 +16,5 @@ contract Error1 { } } // ---- -// ParserError 6933: (95-96): Expected primary expression. -// Warning 3347: (95-96): Recovered in Statement at ';'. +// ParserError 6933: (88-89): Expected primary expression. +// Warning 3347: (88-89): Recovered in Statement at ';'. diff --git a/test/libsolidity/errorRecoveryTests/missing_rhs.sol b/test/libsolidity/errorRecoveryTests/missing_rhs.sol index 6cd99f76a..aaf7a7509 100644 --- a/test/libsolidity/errorRecoveryTests/missing_rhs.sol +++ b/test/libsolidity/errorRecoveryTests/missing_rhs.sol @@ -1,11 +1,11 @@ pragma solidity >=0.0.0; contract Error3 { - constructor() public { + constructor() { balances[tx.origin] = ; // missing RHS. } } // ---- -// ParserError 6933: (95-96): Expected primary expression. -// Warning 3347: (95-96): Recovered in Statement at ';'. +// ParserError 6933: (88-89): Expected primary expression. +// Warning 3347: (88-89): Recovered in Statement at ';'. diff --git a/test/libsolidity/errorRecoveryTests/multiple_errors.sol b/test/libsolidity/errorRecoveryTests/multiple_errors.sol index 2beccac72..c0a0bd32c 100644 --- a/test/libsolidity/errorRecoveryTests/multiple_errors.sol +++ b/test/libsolidity/errorRecoveryTests/multiple_errors.sol @@ -6,7 +6,7 @@ pragma solidity >=0.0.0; contract Error4 { - constructor() public { + constructor() { balances[tx.origin] = 1 2; // missing operator } @@ -21,9 +21,9 @@ contract Error4 { } // ---- -// ParserError 6635: (249-250): Expected ';' but got 'Number' -// ParserError 6635: (471-479): Expected ';' but got identifier -// ParserError 6635: (529-533): Expected ';' but got 'emit' -// ParserError 6635: (577-583): Expected ',' but got 'return' -// ParserError 6933: (577-583): Expected primary expression. -// Warning 3796: (588-589): Recovered in Statement at ';'. +// ParserError 6635: (242-243): Expected ';' but got 'Number' +// ParserError 6635: (464-472): Expected ';' but got identifier +// ParserError 6635: (522-526): Expected ';' but got 'emit' +// ParserError 6635: (570-576): Expected ',' but got 'return' +// ParserError 6933: (570-576): Expected primary expression. +// Warning 3796: (581-582): Recovered in Statement at ';'. diff --git a/test/libsolidity/semanticTests/array/byte_array_storage_layout.sol b/test/libsolidity/semanticTests/array/byte_array_storage_layout.sol index b04ad9e46..7277e8502 100644 --- a/test/libsolidity/semanticTests/array/byte_array_storage_layout.sol +++ b/test/libsolidity/semanticTests/array/byte_array_storage_layout.sol @@ -2,38 +2,38 @@ contract c { bytes data; function test_short() public returns (uint256 r) { assembly { - sstore(data_slot, 0) + sstore(data.slot, 0) } for (uint8 i = 0; i < 15; i++) { data.push(bytes1(i)); } assembly { - r := sload(data_slot) + r := sload(data.slot) } } function test_long() public returns (uint256 r) { assembly { - sstore(data_slot, 0) + sstore(data.slot, 0) } for (uint8 i = 0; i < 33; i++) { data.push(bytes1(i)); } assembly { - r := sload(data_slot) + r := sload(data.slot) } } function test_pop() public returns (uint256 r) { assembly { - sstore(data_slot, 0) + sstore(data.slot, 0) } for (uint8 i = 0; i < 32; i++) { data.push(bytes1(i)); } data.pop(); assembly { - r := sload(data_slot) + r := sload(data.slot) } } } diff --git a/test/libsolidity/semanticTests/array/constant_var_as_array_length.sol b/test/libsolidity/semanticTests/array/constant_var_as_array_length.sol index 017de5d7b..6a34670ff 100644 --- a/test/libsolidity/semanticTests/array/constant_var_as_array_length.sol +++ b/test/libsolidity/semanticTests/array/constant_var_as_array_length.sol @@ -2,7 +2,7 @@ contract C { uint256 constant LEN = 3; uint256[LEN] public a; - constructor(uint256[LEN] memory _a) public { + constructor(uint256[LEN] memory _a) { a = _a; } } diff --git a/test/libsolidity/semanticTests/array/delete_storage_array.sol b/test/libsolidity/semanticTests/array/delete_storage_array.sol index f0bb76978..d8bf81d8a 100644 --- a/test/libsolidity/semanticTests/array/delete_storage_array.sol +++ b/test/libsolidity/semanticTests/array/delete_storage_array.sol @@ -6,7 +6,7 @@ contract C { data.push(123); delete data; assembly { - ret := sload(data_slot) + ret := sload(data.slot) } } diff --git a/test/libsolidity/semanticTests/array/fixed_arrays_in_constructors.sol b/test/libsolidity/semanticTests/array/fixed_arrays_in_constructors.sol index e85cb599e..c6e46a7fa 100644 --- a/test/libsolidity/semanticTests/array/fixed_arrays_in_constructors.sol +++ b/test/libsolidity/semanticTests/array/fixed_arrays_in_constructors.sol @@ -2,7 +2,7 @@ contract Creator { uint256 public r; address public ch; - constructor(address[3] memory s, uint256 x) public { + constructor(address[3] memory s, uint256 x) { r = x; ch = s[2]; } diff --git a/test/libsolidity/semanticTests/array/reusing_memory.sol b/test/libsolidity/semanticTests/array/reusing_memory.sol index 994a31db9..32f21b675 100644 --- a/test/libsolidity/semanticTests/array/reusing_memory.sol +++ b/test/libsolidity/semanticTests/array/reusing_memory.sol @@ -2,7 +2,7 @@ contract Helper { uint256 public flag; - constructor(uint256 x) public { + constructor(uint256 x) { flag = x; } } diff --git a/test/libsolidity/semanticTests/array/string_allocation_bug.sol b/test/libsolidity/semanticTests/array/string_allocation_bug.sol index 9c2ec2e53..d6dadb78a 100644 --- a/test/libsolidity/semanticTests/array/string_allocation_bug.sol +++ b/test/libsolidity/semanticTests/array/string_allocation_bug.sol @@ -7,7 +7,7 @@ contract Sample { } s[2] public p; - constructor() public { + constructor() { s memory m; m.x = 0xbbbb; m.y = 0xcccc; diff --git a/test/libsolidity/semanticTests/array/strings_in_struct.sol b/test/libsolidity/semanticTests/array/strings_in_struct.sol index a6ec607f4..bacf8dec7 100644 --- a/test/libsolidity/semanticTests/array/strings_in_struct.sol +++ b/test/libsolidity/semanticTests/array/strings_in_struct.sol @@ -8,7 +8,7 @@ contract buggystruct { string last; } - constructor() public { + constructor() { bug = Buggy(10, 20, 30, "asdfghjkl"); } diff --git a/test/libsolidity/semanticTests/calldata/calldata_internal_function_pointer.sol b/test/libsolidity/semanticTests/calldata/calldata_internal_function_pointer.sol index 539653219..1c900b497 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_internal_function_pointer.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_internal_function_pointer.sol @@ -1,6 +1,6 @@ contract C { function(bytes calldata) returns (byte) x; - constructor() public { x = f; } + constructor() { x = f; } function f(bytes calldata b) internal pure returns (byte) { return b[2]; } diff --git a/test/libsolidity/semanticTests/cleanup/exp_cleanup.sol b/test/libsolidity/semanticTests/cleanup/exp_cleanup.sol index a81e2755e..e6bd08b8f 100644 --- a/test/libsolidity/semanticTests/cleanup/exp_cleanup.sol +++ b/test/libsolidity/semanticTests/cleanup/exp_cleanup.sol @@ -1,5 +1,5 @@ contract C { - function f() public pure returns (uint8 x) { + function f() public pure returns (uint x) { uint8 y = uint8(2)**uint8(8); return 0**y; } diff --git a/test/libsolidity/semanticTests/constructor/base_constructor_arguments.sol b/test/libsolidity/semanticTests/constructor/base_constructor_arguments.sol index ffb98ada1..76c18244e 100644 --- a/test/libsolidity/semanticTests/constructor/base_constructor_arguments.sol +++ b/test/libsolidity/semanticTests/constructor/base_constructor_arguments.sol @@ -1,14 +1,14 @@ contract BaseBase { uint256 m_a; - constructor(uint256 a) public { + constructor(uint256 a) { m_a = a; } } contract Base is BaseBase(7) { - constructor() public { + constructor() { m_a *= m_a; } } diff --git a/test/libsolidity/semanticTests/constructor/callvalue_check.sol b/test/libsolidity/semanticTests/constructor/callvalue_check.sol index c096382d0..3b7c63a9d 100644 --- a/test/libsolidity/semanticTests/constructor/callvalue_check.sol +++ b/test/libsolidity/semanticTests/constructor/callvalue_check.sol @@ -1,12 +1,12 @@ -contract A1 { constructor() public {} } +contract A1 { constructor() {} } contract B1 is A1 {} -contract A2 { constructor() public payable {} } +contract A2 { constructor() payable {} } contract B2 is A2 {} contract B3 {} -contract B4 { constructor() public {} } +contract B4 { constructor() {} } contract C { function createWithValue(bytes memory c, uint256 value) public payable returns (bool) { diff --git a/test/libsolidity/semanticTests/constructor/constructor_arguments_external.sol b/test/libsolidity/semanticTests/constructor/constructor_arguments_external.sol index fe6a4c59b..bb271ec17 100644 --- a/test/libsolidity/semanticTests/constructor/constructor_arguments_external.sol +++ b/test/libsolidity/semanticTests/constructor/constructor_arguments_external.sol @@ -2,7 +2,7 @@ contract Main { bytes3 name; bool flag; - constructor(bytes3 x, bool f) public { + constructor(bytes3 x, bool f) { name = x; flag = f; } diff --git a/test/libsolidity/semanticTests/constructor/constructor_arguments_internal.sol b/test/libsolidity/semanticTests/constructor/constructor_arguments_internal.sol index b29498083..c7534faaf 100644 --- a/test/libsolidity/semanticTests/constructor/constructor_arguments_internal.sol +++ b/test/libsolidity/semanticTests/constructor/constructor_arguments_internal.sol @@ -2,7 +2,7 @@ contract Helper { bytes3 name; bool flag; - constructor(bytes3 x, bool f) public { + constructor(bytes3 x, bool f) { name = x; flag = f; } @@ -20,7 +20,7 @@ contract Helper { contract Main { Helper h; - constructor() public { + constructor() { h = new Helper("abc", true); } diff --git a/test/libsolidity/semanticTests/constructor/constructor_static_array_argument.sol b/test/libsolidity/semanticTests/constructor/constructor_static_array_argument.sol index 10243f897..d59f2cd19 100644 --- a/test/libsolidity/semanticTests/constructor/constructor_static_array_argument.sol +++ b/test/libsolidity/semanticTests/constructor/constructor_static_array_argument.sol @@ -2,7 +2,7 @@ contract C { uint256 public a; uint256[3] public b; - constructor(uint256 _a, uint256[3] memory _b) public { + constructor(uint256 _a, uint256[3] memory _b) { a = _a; b = _b; } diff --git a/test/libsolidity/semanticTests/constructor/evm_exceptions_in_constructor_call_fail.sol b/test/libsolidity/semanticTests/constructor/evm_exceptions_in_constructor_call_fail.sol index 4517c9702..5310d097b 100644 --- a/test/libsolidity/semanticTests/constructor/evm_exceptions_in_constructor_call_fail.sol +++ b/test/libsolidity/semanticTests/constructor/evm_exceptions_in_constructor_call_fail.sol @@ -1,5 +1,5 @@ contract A { - constructor() public { + constructor() { address(this).call("123"); } } diff --git a/test/libsolidity/semanticTests/constructor/function_usage_in_constructor_arguments.sol b/test/libsolidity/semanticTests/constructor/function_usage_in_constructor_arguments.sol index 6f2f41428..44d376cb6 100644 --- a/test/libsolidity/semanticTests/constructor/function_usage_in_constructor_arguments.sol +++ b/test/libsolidity/semanticTests/constructor/function_usage_in_constructor_arguments.sol @@ -1,7 +1,7 @@ contract BaseBase { uint256 m_a; - constructor(uint256 a) public { + constructor(uint256 a) { m_a = a; } diff --git a/test/libsolidity/semanticTests/constructor/functions_called_by_constructor.sol b/test/libsolidity/semanticTests/constructor/functions_called_by_constructor.sol index 42db8582a..9eb3754ff 100644 --- a/test/libsolidity/semanticTests/constructor/functions_called_by_constructor.sol +++ b/test/libsolidity/semanticTests/constructor/functions_called_by_constructor.sol @@ -2,7 +2,7 @@ contract Test { bytes3 name; bool flag; - constructor() public { + constructor() { setName("abc"); } diff --git a/test/libsolidity/semanticTests/constructor/functions_called_by_constructor_through_dispatch.sol b/test/libsolidity/semanticTests/constructor/functions_called_by_constructor_through_dispatch.sol index 56f92cd50..7549f1387 100644 --- a/test/libsolidity/semanticTests/constructor/functions_called_by_constructor_through_dispatch.sol +++ b/test/libsolidity/semanticTests/constructor/functions_called_by_constructor_through_dispatch.sol @@ -1,7 +1,7 @@ contract Test { bytes6 name; - constructor() public { + constructor() { function (bytes6 _name) internal setter = setName; setter("abcdef"); diff --git a/test/libsolidity/semanticTests/constructor/no_callvalue_check.sol b/test/libsolidity/semanticTests/constructor/no_callvalue_check.sol index 9744aa3ce..0da5f49b7 100644 --- a/test/libsolidity/semanticTests/constructor/no_callvalue_check.sol +++ b/test/libsolidity/semanticTests/constructor/no_callvalue_check.sol @@ -1,10 +1,10 @@ contract A1 {} -contract B1 is A1 { constructor() public payable {} } +contract B1 is A1 { constructor() payable {} } -contract A2 { constructor() public {} } -contract B2 is A2 { constructor() public payable {} } +contract A2 { constructor() {} } +contract B2 is A2 { constructor() payable {} } -contract B3 { constructor() public payable {} } +contract B3 { constructor() payable {} } contract C { function f() public payable returns (bool) { diff --git a/test/libsolidity/semanticTests/constructor/payable_constructor.sol b/test/libsolidity/semanticTests/constructor/payable_constructor.sol index 9a3c56ebe..143212cba 100644 --- a/test/libsolidity/semanticTests/constructor/payable_constructor.sol +++ b/test/libsolidity/semanticTests/constructor/payable_constructor.sol @@ -1,5 +1,5 @@ contract C { - constructor() public payable {} + constructor() payable {} } // ==== diff --git a/test/libsolidity/semanticTests/constructor/store_function_in_constructor.sol b/test/libsolidity/semanticTests/constructor/store_function_in_constructor.sol index ab8ad47f9..72833717d 100644 --- a/test/libsolidity/semanticTests/constructor/store_function_in_constructor.sol +++ b/test/libsolidity/semanticTests/constructor/store_function_in_constructor.sol @@ -2,7 +2,7 @@ contract C { uint256 public result_in_constructor; function(uint256) returns (uint256) internal x; - constructor() public { + constructor() { x = double; result_in_constructor = use(2); } diff --git a/test/libsolidity/semanticTests/constructor/store_internal_unused_function_in_constructor.sol b/test/libsolidity/semanticTests/constructor/store_internal_unused_function_in_constructor.sol index 7492a4281..04be9f8ed 100644 --- a/test/libsolidity/semanticTests/constructor/store_internal_unused_function_in_constructor.sol +++ b/test/libsolidity/semanticTests/constructor/store_internal_unused_function_in_constructor.sol @@ -1,7 +1,7 @@ contract C { function() returns (uint256) internal x; - constructor() public { + constructor() { x = unused; } diff --git a/test/libsolidity/semanticTests/constructor/store_internal_unused_library_function_in_constructor.sol b/test/libsolidity/semanticTests/constructor/store_internal_unused_library_function_in_constructor.sol index 0a4295114..7b166489f 100644 --- a/test/libsolidity/semanticTests/constructor/store_internal_unused_library_function_in_constructor.sol +++ b/test/libsolidity/semanticTests/constructor/store_internal_unused_library_function_in_constructor.sol @@ -8,7 +8,7 @@ library L { contract C { function() returns (uint256) internal x; - constructor() public { + constructor() { x = L.x; } diff --git a/test/libsolidity/semanticTests/constructor_inheritance_init_order.sol b/test/libsolidity/semanticTests/constructor_inheritance_init_order.sol index 898edf6ad..61d801631 100644 --- a/test/libsolidity/semanticTests/constructor_inheritance_init_order.sol +++ b/test/libsolidity/semanticTests/constructor_inheritance_init_order.sol @@ -1,6 +1,6 @@ contract A { uint x; - constructor() public { + constructor() { x = 42; } function f() public returns(uint256) { diff --git a/test/libsolidity/semanticTests/constructor_with_params.sol b/test/libsolidity/semanticTests/constructor_with_params.sol index 19f0bdb57..e3ac5b386 100644 --- a/test/libsolidity/semanticTests/constructor_with_params.sol +++ b/test/libsolidity/semanticTests/constructor_with_params.sol @@ -2,7 +2,7 @@ contract C { uint public i; uint public k; - constructor(uint newI, uint newK) public { + constructor(uint newI, uint newK) { i = newI; k = newK; } diff --git a/test/libsolidity/semanticTests/constructor_with_params_diamond_inheritance.sol b/test/libsolidity/semanticTests/constructor_with_params_diamond_inheritance.sol index 0ec347963..89cb202c6 100644 --- a/test/libsolidity/semanticTests/constructor_with_params_diamond_inheritance.sol +++ b/test/libsolidity/semanticTests/constructor_with_params_diamond_inheritance.sol @@ -2,22 +2,22 @@ contract A { uint public i; uint public k; - constructor(uint newI, uint newK) public { + constructor(uint newI, uint newK) { i = newI; k = newK; } } abstract contract B is A { uint public j; - constructor(uint newJ) public { + constructor(uint newJ) { j = newJ; } } contract C is A { - constructor(uint newI, uint newK) A(newI, newK) public {} + constructor(uint newI, uint newK) A(newI, newK) {} } contract D is B, C { - constructor(uint newI, uint newK) B(newI) C(newI, newK + 1) public {} + constructor(uint newI, uint newK) B(newI) C(newI, newK + 1) {} } // ==== // compileViaYul: also diff --git a/test/libsolidity/semanticTests/constructor_with_params_inheritance.sol b/test/libsolidity/semanticTests/constructor_with_params_inheritance.sol index 3419a9c25..d477bbc0d 100644 --- a/test/libsolidity/semanticTests/constructor_with_params_inheritance.sol +++ b/test/libsolidity/semanticTests/constructor_with_params_inheritance.sol @@ -2,13 +2,13 @@ contract C { uint public i; uint public k; - constructor(uint newI, uint newK) public { + constructor(uint newI, uint newK) { i = newI; k = newK; } } contract D is C { - constructor(uint newI, uint newK) C(newI, newK + 1) public {} + constructor(uint newI, uint newK) C(newI, newK + 1) {} } // ==== // compileViaYul: also diff --git a/test/libsolidity/semanticTests/constructor_with_params_inheritance_2.sol b/test/libsolidity/semanticTests/constructor_with_params_inheritance_2.sol index f2c39e75e..e00969726 100644 --- a/test/libsolidity/semanticTests/constructor_with_params_inheritance_2.sol +++ b/test/libsolidity/semanticTests/constructor_with_params_inheritance_2.sol @@ -2,7 +2,7 @@ contract C { uint public i; uint public k; - constructor(uint newI, uint newK) public { + constructor(uint newI, uint newK) { i = newI; k = newK; } diff --git a/test/libsolidity/semanticTests/dirty_memory_bytes_to_storgage_copy.sol b/test/libsolidity/semanticTests/dirty_memory_bytes_to_storgage_copy.sol index 8fc6c33ec..bdb1a7c64 100644 --- a/test/libsolidity/semanticTests/dirty_memory_bytes_to_storgage_copy.sol +++ b/test/libsolidity/semanticTests/dirty_memory_bytes_to_storgage_copy.sol @@ -8,7 +8,7 @@ contract C { } x = m; assembly { - r := sload(x_slot) + r := sload(x.slot) } } } diff --git a/test/libsolidity/semanticTests/enums/enum_explicit_overflow.sol b/test/libsolidity/semanticTests/enums/enum_explicit_overflow.sol index fd4c96ce7..9d5492d1e 100644 --- a/test/libsolidity/semanticTests/enums/enum_explicit_overflow.sol +++ b/test/libsolidity/semanticTests/enums/enum_explicit_overflow.sol @@ -1,7 +1,7 @@ contract test { enum ActionChoices {GoLeft, GoRight, GoStraight} - constructor() public {} + constructor() {} function getChoiceExp(uint256 x) public returns (uint256 d) { choice = ActionChoices(x); diff --git a/test/libsolidity/semanticTests/enums/using_enums.sol b/test/libsolidity/semanticTests/enums/using_enums.sol index 883726f7c..b903e5182 100644 --- a/test/libsolidity/semanticTests/enums/using_enums.sol +++ b/test/libsolidity/semanticTests/enums/using_enums.sol @@ -1,7 +1,7 @@ contract test { enum ActionChoices {GoLeft, GoRight, GoStraight, Sit} - constructor() public { + constructor() { choices = ActionChoices.GoStraight; } diff --git a/test/libsolidity/semanticTests/exponentiation/literal_base.sol b/test/libsolidity/semanticTests/exponentiation/literal_base.sol new file mode 100644 index 000000000..2c11519d0 --- /dev/null +++ b/test/libsolidity/semanticTests/exponentiation/literal_base.sol @@ -0,0 +1,16 @@ +contract test { + function f(uint x) public pure returns (uint, int) { + uint a = 2 ** x; + int b = -2 ** x; + return (a, b); + } +} +// ---- +// f(uint256): 0 -> 1, 1 +// f(uint256): 1 -> 2, -2 +// f(uint256): 2 -> 4, 4 +// f(uint256): 13 -> 0x2000, -8192 +// f(uint256): 113 -> 0x020000000000000000000000000000, -10384593717069655257060992658440192 +// f(uint256): 114 -> 0x040000000000000000000000000000, 20769187434139310514121985316880384 +// f(uint256): 1113 -> 0x00, 0 +// f(uint256): 1114 -> 0x00, 0 diff --git a/test/libsolidity/semanticTests/functionCall/calling_nonexisting_contract_throws.sol b/test/libsolidity/semanticTests/functionCall/calling_nonexisting_contract_throws.sol index 2ccfc064c..171779444 100644 --- a/test/libsolidity/semanticTests/functionCall/calling_nonexisting_contract_throws.sol +++ b/test/libsolidity/semanticTests/functionCall/calling_nonexisting_contract_throws.sol @@ -12,7 +12,7 @@ contract C { } function g() public returns (uint256) { - d.g.gas(200)(); + d.g{gas: 200}(); return 7; } @@ -22,6 +22,8 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f() -> FAILURE // g() -> FAILURE diff --git a/test/libsolidity/semanticTests/functionCall/creation_function_call_no_args.sol b/test/libsolidity/semanticTests/functionCall/creation_function_call_no_args.sol index eac910f05..f60827738 100644 --- a/test/libsolidity/semanticTests/functionCall/creation_function_call_no_args.sol +++ b/test/libsolidity/semanticTests/functionCall/creation_function_call_no_args.sol @@ -1,6 +1,6 @@ contract C { uint public i; - constructor() public { + constructor() { i = 2; } } diff --git a/test/libsolidity/semanticTests/functionCall/creation_function_call_with_args.sol b/test/libsolidity/semanticTests/functionCall/creation_function_call_with_args.sol index 32c2910e2..56e458110 100644 --- a/test/libsolidity/semanticTests/functionCall/creation_function_call_with_args.sol +++ b/test/libsolidity/semanticTests/functionCall/creation_function_call_with_args.sol @@ -1,12 +1,12 @@ contract C { uint public i; - constructor(uint newI) public { + constructor(uint newI) { i = newI; } } contract D { C c; - constructor(uint v) public { + constructor(uint v) { c = new C(v); } function f() public returns (uint r) { diff --git a/test/libsolidity/semanticTests/functionCall/creation_function_call_with_salt.sol b/test/libsolidity/semanticTests/functionCall/creation_function_call_with_salt.sol index 3bb9765a9..725a54b54 100644 --- a/test/libsolidity/semanticTests/functionCall/creation_function_call_with_salt.sol +++ b/test/libsolidity/semanticTests/functionCall/creation_function_call_with_salt.sol @@ -1,12 +1,12 @@ contract C { uint public i; - constructor(uint newI) public { + constructor(uint newI) { i = newI; } } contract D { C c; - constructor(uint v) public { + constructor(uint v) { c = new C{salt: "abc"}(v); } function f() public returns (uint r) { diff --git a/test/libsolidity/semanticTests/functionCall/gas_and_value_basic.sol b/test/libsolidity/semanticTests/functionCall/gas_and_value_basic.sol index aaafb6f28..5ca46b4e1 100644 --- a/test/libsolidity/semanticTests/functionCall/gas_and_value_basic.sol +++ b/test/libsolidity/semanticTests/functionCall/gas_and_value_basic.sol @@ -18,16 +18,16 @@ contract helper { contract test { helper h; - constructor() public payable { + constructor() payable { h = new helper(); } function sendAmount(uint256 amount) public payable returns (uint256 bal) { - return h.getBalance.value(amount)(); + return h.getBalance{value: amount}(); } function outOfGas() public returns (bool ret) { - h.setFlag.gas(2)(); // should fail due to OOG + h.setFlag{gas: 2}(); // should fail due to OOG return true; } @@ -37,6 +37,8 @@ contract test { } } +// ==== +// compileViaYul: also // ---- // constructor(), 20 wei -> // sendAmount(uint256): 5 -> 5 diff --git a/test/libsolidity/semanticTests/functionCall/gas_and_value_brace_syntax.sol b/test/libsolidity/semanticTests/functionCall/gas_and_value_brace_syntax.sol index 46c922a9c..3da540807 100644 --- a/test/libsolidity/semanticTests/functionCall/gas_and_value_brace_syntax.sol +++ b/test/libsolidity/semanticTests/functionCall/gas_and_value_brace_syntax.sol @@ -15,7 +15,7 @@ contract helper { } contract test { helper h; - constructor() public payable { + constructor() payable { h = new helper(); } diff --git a/test/libsolidity/semanticTests/functionCall/member_accessors.sol b/test/libsolidity/semanticTests/functionCall/member_accessors.sol index 238d99a61..d7b2b3284 100644 --- a/test/libsolidity/semanticTests/functionCall/member_accessors.sol +++ b/test/libsolidity/semanticTests/functionCall/member_accessors.sol @@ -3,7 +3,7 @@ contract test { bytes6 public name; bytes32 public a_hash; address public an_address; - constructor() public { + constructor() { data = 8; name = "Celina"; a_hash = keccak256("\x7b"); diff --git a/test/libsolidity/semanticTests/functionCall/send_zero_ether.sol b/test/libsolidity/semanticTests/functionCall/send_zero_ether.sol index 07f6ff51d..bb1b28b3e 100644 --- a/test/libsolidity/semanticTests/functionCall/send_zero_ether.sol +++ b/test/libsolidity/semanticTests/functionCall/send_zero_ether.sol @@ -6,7 +6,7 @@ contract Receiver { contract Main { - constructor() public payable {} + constructor() payable {} function s() public returns (bool) { Receiver r = new Receiver(); diff --git a/test/libsolidity/semanticTests/functionTypes/mapping_of_functions.sol b/test/libsolidity/semanticTests/functionTypes/mapping_of_functions.sol index ac802ee9e..353844723 100644 --- a/test/libsolidity/semanticTests/functionTypes/mapping_of_functions.sol +++ b/test/libsolidity/semanticTests/functionTypes/mapping_of_functions.sol @@ -15,7 +15,7 @@ contract Flow { success = true; } - constructor() public { + constructor() { stages[msg.sender] = stage0; } diff --git a/test/libsolidity/semanticTests/functionTypes/same_function_in_construction_and_runtime.sol b/test/libsolidity/semanticTests/functionTypes/same_function_in_construction_and_runtime.sol index d829c1554..dc0731485 100644 --- a/test/libsolidity/semanticTests/functionTypes/same_function_in_construction_and_runtime.sol +++ b/test/libsolidity/semanticTests/functionTypes/same_function_in_construction_and_runtime.sol @@ -1,7 +1,7 @@ contract C { uint256 public initial; - constructor() public { + constructor() { initial = double(2); } diff --git a/test/libsolidity/semanticTests/functionTypes/same_function_in_construction_and_runtime_equality_check.sol b/test/libsolidity/semanticTests/functionTypes/same_function_in_construction_and_runtime_equality_check.sol index f8230b21a..a778589ab 100644 --- a/test/libsolidity/semanticTests/functionTypes/same_function_in_construction_and_runtime_equality_check.sol +++ b/test/libsolidity/semanticTests/functionTypes/same_function_in_construction_and_runtime_equality_check.sol @@ -1,7 +1,7 @@ contract C { function(uint256) returns (uint256) internal x; - constructor() public { + constructor() { x = double; } diff --git a/test/libsolidity/semanticTests/getters/array_mapping_struct.sol b/test/libsolidity/semanticTests/getters/array_mapping_struct.sol index 534dcd8a6..d824897e8 100644 --- a/test/libsolidity/semanticTests/getters/array_mapping_struct.sol +++ b/test/libsolidity/semanticTests/getters/array_mapping_struct.sol @@ -5,7 +5,7 @@ contract C { } mapping(uint256 => Y)[] public m; mapping(uint256 => Y)[3] public n; - constructor() public { + constructor() { m.push(); m.push(); m[1][0].a = 1; diff --git a/test/libsolidity/semanticTests/getters/arrays.sol b/test/libsolidity/semanticTests/getters/arrays.sol index 2a8641a9b..184d6ce7f 100644 --- a/test/libsolidity/semanticTests/getters/arrays.sol +++ b/test/libsolidity/semanticTests/getters/arrays.sol @@ -1,6 +1,6 @@ contract C { uint8[][2] public a; - constructor() public { + constructor() { a[1].push(3); a[1].push(4); } diff --git a/test/libsolidity/semanticTests/getters/mapping.sol b/test/libsolidity/semanticTests/getters/mapping.sol index 5b28a0f06..194e44792 100644 --- a/test/libsolidity/semanticTests/getters/mapping.sol +++ b/test/libsolidity/semanticTests/getters/mapping.sol @@ -1,6 +1,6 @@ contract C { mapping(uint => mapping(uint => uint)) public x; - constructor() public { + constructor() { x[1][2] = 3; } } diff --git a/test/libsolidity/semanticTests/getters/mapping_array_struct.sol b/test/libsolidity/semanticTests/getters/mapping_array_struct.sol index 2b237c4df..60683dfc0 100644 --- a/test/libsolidity/semanticTests/getters/mapping_array_struct.sol +++ b/test/libsolidity/semanticTests/getters/mapping_array_struct.sol @@ -5,7 +5,7 @@ contract C { } mapping(uint256 => Y[]) public m; mapping(uint256 => Y[3]) public n; - constructor() public { + constructor() { m[1].push().a = 1; m[1][0].b = 2; m[1].push().a = 3; diff --git a/test/libsolidity/semanticTests/getters/mapping_of_string.sol b/test/libsolidity/semanticTests/getters/mapping_of_string.sol index ea0a8b8f8..319f0a655 100644 --- a/test/libsolidity/semanticTests/getters/mapping_of_string.sol +++ b/test/libsolidity/semanticTests/getters/mapping_of_string.sol @@ -1,6 +1,6 @@ contract C { mapping(string => uint8[3]) public x; - constructor() public { + constructor() { x["abc"][0] = 1; x["abc"][2] = 3; x["abc"][1] = 2; diff --git a/test/libsolidity/semanticTests/getters/mapping_to_struct.sol b/test/libsolidity/semanticTests/getters/mapping_to_struct.sol index fed9f6ec5..c2d70a35a 100644 --- a/test/libsolidity/semanticTests/getters/mapping_to_struct.sol +++ b/test/libsolidity/semanticTests/getters/mapping_to_struct.sol @@ -6,7 +6,7 @@ contract C { uint d; } mapping(uint => mapping(uint => S)) public x; - constructor() public { + constructor() { x[1][2].a = 3; x[1][2].b = 4; x[1][2].c = 5; diff --git a/test/libsolidity/semanticTests/getters/small_types.sol b/test/libsolidity/semanticTests/getters/small_types.sol index d970f9138..a26eba785 100644 --- a/test/libsolidity/semanticTests/getters/small_types.sol +++ b/test/libsolidity/semanticTests/getters/small_types.sol @@ -3,7 +3,7 @@ contract C { uint16 public b; uint128 public c; uint public d; - constructor() public { + constructor() { a = 3; b = 4; c = 5; diff --git a/test/libsolidity/semanticTests/getters/struct_with_bytes.sol b/test/libsolidity/semanticTests/getters/struct_with_bytes.sol index 2bbd7e8b8..477a1297f 100644 --- a/test/libsolidity/semanticTests/getters/struct_with_bytes.sol +++ b/test/libsolidity/semanticTests/getters/struct_with_bytes.sol @@ -7,7 +7,7 @@ contract C { } uint shifter; S public s; - constructor() public { + constructor() { s.a = 7; s.b = "abc"; s.c[0] = 9; diff --git a/test/libsolidity/semanticTests/getters/struct_with_bytes_simple.sol b/test/libsolidity/semanticTests/getters/struct_with_bytes_simple.sol index 974ca9e80..281b29c87 100644 --- a/test/libsolidity/semanticTests/getters/struct_with_bytes_simple.sol +++ b/test/libsolidity/semanticTests/getters/struct_with_bytes_simple.sol @@ -7,7 +7,7 @@ contract C { } uint shifter; S public s; - constructor() public { + constructor() { s.a = 7; s.b = "abc"; s.c[0] = 9; diff --git a/test/libsolidity/semanticTests/immutable/getter_call_in_constructor.sol b/test/libsolidity/semanticTests/immutable/getter_call_in_constructor.sol index e4aa474f2..2ef12c04a 100644 --- a/test/libsolidity/semanticTests/immutable/getter_call_in_constructor.sol +++ b/test/libsolidity/semanticTests/immutable/getter_call_in_constructor.sol @@ -1,7 +1,7 @@ contract A { uint immutable public x = 1; uint public y; - constructor() public { + constructor() { y = this.x(); } } diff --git a/test/libsolidity/semanticTests/immutable/inheritance.sol b/test/libsolidity/semanticTests/immutable/inheritance.sol index bca0ee889..0e131535e 100644 --- a/test/libsolidity/semanticTests/immutable/inheritance.sol +++ b/test/libsolidity/semanticTests/immutable/inheritance.sol @@ -1,25 +1,25 @@ contract A { uint8 immutable a; - constructor() public { + constructor() { a = 4; } } contract B is A { uint8 immutable b; - constructor() public { + constructor() { b = 3; } } contract C is A { uint8 immutable c; - constructor() public { + constructor() { c = 2; } } contract D is B, C { uint8 immutable d; - constructor() public { + constructor() { d = 1; } function f() public view returns (uint256, uint256, uint, uint) { diff --git a/test/libsolidity/semanticTests/immutable/internal_function_pointer.sol b/test/libsolidity/semanticTests/immutable/internal_function_pointer.sol index 0119a90a2..f046395d2 100644 --- a/test/libsolidity/semanticTests/immutable/internal_function_pointer.sol +++ b/test/libsolidity/semanticTests/immutable/internal_function_pointer.sol @@ -1,6 +1,6 @@ contract C { function() internal view returns(uint256) immutable z; - constructor() public { + constructor() { z = f; } function f() public view returns (uint256) { diff --git a/test/libsolidity/semanticTests/immutable/multi_creation.sol b/test/libsolidity/semanticTests/immutable/multi_creation.sol index 970ea9155..33820b18b 100644 --- a/test/libsolidity/semanticTests/immutable/multi_creation.sol +++ b/test/libsolidity/semanticTests/immutable/multi_creation.sol @@ -1,13 +1,13 @@ contract A { uint immutable a; - constructor() public { + constructor() { a = 7; } function f() public view returns (uint) { return a; } } contract B { uint immutable a; - constructor() public { + constructor() { a = 5; } function f() public view returns (uint) { return a; } @@ -16,7 +16,7 @@ contract C { uint immutable a; uint public x; uint public y; - constructor() public { + constructor() { a = 3; x = (new A()).f(); y = (new B()).f(); diff --git a/test/libsolidity/semanticTests/immutable/stub.sol b/test/libsolidity/semanticTests/immutable/stub.sol index a800ab904..eda441c75 100644 --- a/test/libsolidity/semanticTests/immutable/stub.sol +++ b/test/libsolidity/semanticTests/immutable/stub.sol @@ -1,7 +1,7 @@ contract C { uint256 immutable x; uint256 immutable y; - constructor() public { + constructor() { x = 42; y = 23; } diff --git a/test/libsolidity/semanticTests/immutable/use_scratch.sol b/test/libsolidity/semanticTests/immutable/use_scratch.sol index 442ef5636..71381fc9b 100644 --- a/test/libsolidity/semanticTests/immutable/use_scratch.sol +++ b/test/libsolidity/semanticTests/immutable/use_scratch.sol @@ -2,7 +2,7 @@ contract C { uint256 immutable x; uint256 immutable y; mapping(uint => uint) public m; - constructor(uint _a) public { + constructor(uint _a) { x = 42; y = 23; m[_a] = 7; diff --git a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access.sol b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access.sol index 8e42595d4..3dfdcbc66 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access.sol @@ -7,9 +7,9 @@ contract C { uint256 off1; uint256 off2; assembly { - sstore(z_slot, 7) - off1 := z_offset - off2 := y_offset + sstore(z.slot, 7) + off1 := z.offset + off2 := y.offset } assert(off1 == 0); assert(off2 == 2); diff --git a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access_inside_function.sol b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access_inside_function.sol index 8f48f2f52..c7707aebe 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access_inside_function.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access_inside_function.sol @@ -8,8 +8,8 @@ contract C { uint256 off2; assembly { function f() -> o1 { - sstore(z_slot, 7) - o1 := y_offset + sstore(z.slot, 7) + o1 := y.offset } off2 := f() } diff --git a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access_via_pointer.sol b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access_via_pointer.sol index 3893c8e89..183709835 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access_via_pointer.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access_via_pointer.sol @@ -10,8 +10,8 @@ contract C { Data storage x = a; uint256 off; assembly { - sstore(x_slot, 7) - off := x_offset + sstore(x.slot, 7) + off := x.offset } assert(off == 0); return true; diff --git a/test/libsolidity/semanticTests/inlineAssembly/slot_access.sol b/test/libsolidity/semanticTests/inlineAssembly/slot_access.sol index 4f3be7489..abfc6d09b 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/slot_access.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/slot_access.sol @@ -13,7 +13,7 @@ contract C { bytes32 slot = keccak256(abi.encode(uint(1), uint(0))); assembly { - _data_slot := slot + _data.slot := slot } } diff --git a/test/libsolidity/semanticTests/interfaceID/lisa.sol b/test/libsolidity/semanticTests/interfaceID/lisa.sol index ea844dd81..885cf9b24 100644 --- a/test/libsolidity/semanticTests/interfaceID/lisa.sol +++ b/test/libsolidity/semanticTests/interfaceID/lisa.sol @@ -8,11 +8,11 @@ interface ERC165 { function supportsInterface(bytes4 interfaceID) external view returns (bool); } -contract ERC165MappingImplementation is ERC165 { +abstract contract ERC165MappingImplementation is ERC165 { /// @dev You must not set element 0xffffffff to true mapping(bytes4 => bool) internal supportedInterfaces; - constructor() internal { + constructor() { supportedInterfaces[this.supportsInterface.selector] = true; } @@ -27,7 +27,7 @@ interface Simpson { } contract Lisa is ERC165MappingImplementation, Simpson { - constructor() public { + constructor() { supportedInterfaces[this.is2D.selector ^ this.skinColor.selector] = true; } diff --git a/test/libsolidity/semanticTests/interfaceID/lisa_interfaceId.sol b/test/libsolidity/semanticTests/interfaceID/lisa_interfaceId.sol index 96f1a4742..c535df528 100644 --- a/test/libsolidity/semanticTests/interfaceID/lisa_interfaceId.sol +++ b/test/libsolidity/semanticTests/interfaceID/lisa_interfaceId.sol @@ -8,11 +8,11 @@ interface ERC165 { function supportsInterface(bytes4 interfaceID) external view returns (bool); } -contract ERC165MappingImplementation is ERC165 { +abstract contract ERC165MappingImplementation is ERC165 { /// @dev You must not set element 0xffffffff to true mapping(bytes4 => bool) internal supportedInterfaces; - constructor() internal { + constructor() { supportedInterfaces[this.supportsInterface.selector] = true; } @@ -27,7 +27,7 @@ interface Simpson { } contract Lisa is ERC165MappingImplementation, Simpson { - constructor() public { + constructor() { supportedInterfaces[type(Simpson).interfaceId] = true; } diff --git a/test/libsolidity/semanticTests/intheritance/pass_dynamic_arguments_to_the_base.sol b/test/libsolidity/semanticTests/intheritance/pass_dynamic_arguments_to_the_base.sol index 98922c389..e564c560c 100644 --- a/test/libsolidity/semanticTests/intheritance/pass_dynamic_arguments_to_the_base.sol +++ b/test/libsolidity/semanticTests/intheritance/pass_dynamic_arguments_to_the_base.sol @@ -1,5 +1,5 @@ contract Base { - constructor(uint256 i) public { + constructor(uint256 i) { m_i = i; } @@ -8,7 +8,7 @@ contract Base { contract Derived is Base { - constructor(uint256 i) public Base(i) {} + constructor(uint256 i) Base(i) {} } diff --git a/test/libsolidity/semanticTests/intheritance/pass_dynamic_arguments_to_the_base_base.sol b/test/libsolidity/semanticTests/intheritance/pass_dynamic_arguments_to_the_base_base.sol index cab918567..0ae3e1ce4 100644 --- a/test/libsolidity/semanticTests/intheritance/pass_dynamic_arguments_to_the_base_base.sol +++ b/test/libsolidity/semanticTests/intheritance/pass_dynamic_arguments_to_the_base_base.sol @@ -1,5 +1,5 @@ contract Base { - constructor(uint256 j) public { + constructor(uint256 j) { m_i = j; } @@ -8,12 +8,12 @@ contract Base { contract Base1 is Base { - constructor(uint256 k) public Base(k) {} + constructor(uint256 k) Base(k) {} } contract Derived is Base, Base1 { - constructor(uint256 i) public Base1(i) {} + constructor(uint256 i) Base1(i) {} } diff --git a/test/libsolidity/semanticTests/intheritance/pass_dynamic_arguments_to_the_base_base_with_gap.sol b/test/libsolidity/semanticTests/intheritance/pass_dynamic_arguments_to_the_base_base_with_gap.sol index ab7bada38..def996344 100644 --- a/test/libsolidity/semanticTests/intheritance/pass_dynamic_arguments_to_the_base_base_with_gap.sol +++ b/test/libsolidity/semanticTests/intheritance/pass_dynamic_arguments_to_the_base_base_with_gap.sol @@ -1,5 +1,5 @@ contract Base { - constructor(uint256 i) public { + constructor(uint256 i) { m_i = i; } @@ -8,12 +8,12 @@ contract Base { abstract contract Base1 is Base { - constructor(uint256 k) public {} + constructor(uint256 k) {} } contract Derived is Base, Base1 { - constructor(uint256 i) public Base(i) Base1(7) {} + constructor(uint256 i) Base(i) Base1(7) {} } diff --git a/test/libsolidity/semanticTests/intheritance/super_in_constructor.sol b/test/libsolidity/semanticTests/intheritance/super_in_constructor.sol index 33e270c9e..5be2158a2 100644 --- a/test/libsolidity/semanticTests/intheritance/super_in_constructor.sol +++ b/test/libsolidity/semanticTests/intheritance/super_in_constructor.sol @@ -22,7 +22,7 @@ contract C is A { contract D is B, C { uint256 data; - constructor() public { + constructor() { data = super.f() | 8; } diff --git a/test/libsolidity/semanticTests/intheritance/value_for_constructor.sol b/test/libsolidity/semanticTests/intheritance/value_for_constructor.sol index 5cd0bc177..057b3b8e4 100644 --- a/test/libsolidity/semanticTests/intheritance/value_for_constructor.sol +++ b/test/libsolidity/semanticTests/intheritance/value_for_constructor.sol @@ -2,7 +2,7 @@ contract Helper { bytes3 name; bool flag; - constructor(bytes3 x, bool f) public payable { + constructor(bytes3 x, bool f) payable { name = x; flag = f; } @@ -20,8 +20,8 @@ contract Helper { contract Main { Helper h; - constructor() public payable { - h = (new Helper).value(10)("abc", true); + constructor() payable { + h = (new Helper){value: 10}("abc", true); } function getFlag() public returns (bool ret) { @@ -38,6 +38,8 @@ contract Main { } } +// ==== +// compileViaYul: also // ---- // constructor(), 22 wei -> // getFlag() -> true diff --git a/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_pure.sol b/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_pure.sol index 902ca66c1..b540e9a63 100644 --- a/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_pure.sol +++ b/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_pure.sol @@ -6,19 +6,19 @@ library L { contract C { uint256[] y; string x; - constructor() public { y.push(42); } + constructor() { y.push(42); } function f() public view returns (uint256) { return L.f(y); } function g() public returns (bool, uint256) { uint256 ys; - assembly { ys := y_slot } + assembly { ys := y.slot } (bool success, bytes memory data) = address(L).delegatecall(abi.encodeWithSelector(L.f.selector, ys)); return (success, success ? abi.decode(data,(uint256)) : 0); } function h() public returns (bool, uint256) { uint256 ys; - assembly { ys := y_slot } + assembly { ys := y.slot } (bool success, bytes memory data) = address(L).call(abi.encodeWithSelector(L.f.selector, ys)); return (success, success ? abi.decode(data,(uint256)) : 0); } diff --git a/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_needed.sol b/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_needed.sol index b9254c811..3c5274990 100644 --- a/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_needed.sol +++ b/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_needed.sol @@ -6,19 +6,19 @@ library L { contract C { uint256[] y; string x; - constructor() public { y.push(42); } + constructor() { y.push(42); } function f() public view returns (uint256) { return L.f(y); } function g() public returns (bool, uint256) { uint256 ys; - assembly { ys := y_slot } + assembly { ys := y.slot } (bool success, bytes memory data) = address(L).delegatecall(abi.encodeWithSelector(L.f.selector, ys)); return (success, success ? abi.decode(data,(uint256)) : 0); } function h() public returns (bool, uint256) { uint256 ys; - assembly { ys := y_slot } + assembly { ys := y.slot } (bool success, bytes memory data) = address(L).call(abi.encodeWithSelector(L.f.selector, ys)); return (success, success ? abi.decode(data,(uint256)) : 0); } diff --git a/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_not_needed.sol b/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_not_needed.sol index 450f74f1d..2d4e6468e 100644 --- a/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_not_needed.sol +++ b/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_not_needed.sol @@ -5,19 +5,19 @@ library L { } contract C { uint256[] y; - constructor() public { y.push(42); } + constructor() { y.push(42); } function f() public view returns (uint256) { return L.f(y); } function g() public returns (bool, uint256) { uint256 ys; - assembly { ys := y_slot } + assembly { ys := y.slot } (bool success, bytes memory data) = address(L).delegatecall(abi.encodeWithSelector(L.f.selector, ys)); return (success, success ? abi.decode(data,(uint256)) : 0); } function h() public returns (bool, uint256) { uint256 ys; - assembly { ys := y_slot } + assembly { ys := y.slot } (bool success, bytes memory data) = address(L).call(abi.encodeWithSelector(L.f.selector, ys)); return (success, success ? abi.decode(data,(uint256)) : 0); } diff --git a/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_staticcall.sol b/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_staticcall.sol index dc394f7fa..d8cdb9a4d 100644 --- a/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_staticcall.sol +++ b/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_staticcall.sol @@ -1,6 +1,6 @@ contract D { uint public x; - constructor() public { x = 42; } + constructor() { x = 42; } } library L { function f(D d) public view returns (uint256) { @@ -9,7 +9,7 @@ library L { } contract C { D d; - constructor() public { d = new D(); } + constructor() { d = new D(); } function f() public view returns (uint256) { return L.f(d); } diff --git a/test/libsolidity/semanticTests/libraries/library_function_selectors.sol b/test/libsolidity/semanticTests/libraries/library_function_selectors.sol index 305ccf39b..baeb5cedd 100644 --- a/test/libsolidity/semanticTests/libraries/library_function_selectors.sol +++ b/test/libsolidity/semanticTests/libraries/library_function_selectors.sol @@ -5,14 +5,14 @@ library L { } contract C { uint256[] s; - constructor() public { while (s.length < 42) s.push(0); } + constructor() { while (s.length < 42) s.push(0); } function f() public returns (bool, bool, uint256) { (bool success, bytes memory data) = address(L).delegatecall(abi.encodeWithSelector(L.f.selector, 7)); return (L.f.selector == bytes4(keccak256("f(uint256)")), success, abi.decode(data, (uint256))); } function g() public returns (bool, bool, uint256) { uint256 s_ptr; - assembly { s_ptr := s_slot } + assembly { s_ptr := s.slot } (bool success, bytes memory data) = address(L).delegatecall(abi.encodeWithSelector(L.g.selector, s_ptr)); return (L.g.selector == bytes4(keccak256("g(uint256[] storage)")), success, abi.decode(data, (uint256))); } diff --git a/test/libsolidity/semanticTests/libraries/library_function_selectors_struct.sol b/test/libsolidity/semanticTests/libraries/library_function_selectors_struct.sol index f0c71dec7..8081b0e24 100644 --- a/test/libsolidity/semanticTests/libraries/library_function_selectors_struct.sol +++ b/test/libsolidity/semanticTests/libraries/library_function_selectors_struct.sol @@ -6,11 +6,11 @@ library L { } contract C { L.S s; - constructor() public { s.a = 42; } + constructor() { s.a = 42; } function f() public returns (bool, bool, uint256) { uint256 s_ptr; - assembly { s_ptr := s_slot } + assembly { s_ptr := s.slot } (bool success, bytes memory data) = address(L).delegatecall(abi.encodeWithSelector(L.f.selector, s_ptr)); return (L.f.selector == bytes4(keccak256("f(L.S storage)")), success, abi.decode(data, (uint256))); } diff --git a/test/libsolidity/semanticTests/literals/denominations.sol b/test/libsolidity/semanticTests/literals/denominations.sol new file mode 100644 index 000000000..256525cb9 --- /dev/null +++ b/test/libsolidity/semanticTests/literals/denominations.sol @@ -0,0 +1,9 @@ +contract C { + uint constant x = 1 ether + 1 gwei + 1 wei; + + function f() public view returns(uint) { return x; } +} +// ==== +// compileViaYul: also +// ---- +// f() -> 1000000001000000001 diff --git a/test/libsolidity/semanticTests/literals/ether.sol b/test/libsolidity/semanticTests/literals/ether.sol new file mode 100644 index 000000000..f03171796 --- /dev/null +++ b/test/libsolidity/semanticTests/literals/ether.sol @@ -0,0 +1,9 @@ +contract C { + uint constant x = 1 ether; + + function f() public view returns(uint) { return x; } +} +// ==== +// compileViaYul: also +// ---- +// f() -> 1000000000000000000 diff --git a/test/libsolidity/semanticTests/literals/gwei.sol b/test/libsolidity/semanticTests/literals/gwei.sol index 7762021dc..54870040f 100644 --- a/test/libsolidity/semanticTests/literals/gwei.sol +++ b/test/libsolidity/semanticTests/literals/gwei.sol @@ -1,7 +1,7 @@ contract C { - uint constant gwei = 1 gwei; + uint constant x = 1 gwei; - function f() public view returns(uint) { return gwei; } + function f() public view returns(uint) { return x; } } // ==== // compileViaYul: also diff --git a/test/libsolidity/semanticTests/literals/wei.sol b/test/libsolidity/semanticTests/literals/wei.sol new file mode 100644 index 000000000..59af2a3d7 --- /dev/null +++ b/test/libsolidity/semanticTests/literals/wei.sol @@ -0,0 +1,9 @@ +contract C { + uint constant x = 1 wei; + + function f() public view returns(uint) { return x; } +} +// ==== +// compileViaYul: also +// ---- +// f() -> 1 diff --git a/test/libsolidity/semanticTests/modifiers/function_modifier_calling_functions_in_creation_context.sol b/test/libsolidity/semanticTests/modifiers/function_modifier_calling_functions_in_creation_context.sol index f4a73ebeb..ebe8d6086 100644 --- a/test/libsolidity/semanticTests/modifiers/function_modifier_calling_functions_in_creation_context.sol +++ b/test/libsolidity/semanticTests/modifiers/function_modifier_calling_functions_in_creation_context.sol @@ -1,7 +1,7 @@ contract A { uint256 data; - constructor() public mod1 { + constructor() mod1 { f1(); } diff --git a/test/libsolidity/semanticTests/modifiers/function_modifier_for_constructor.sol b/test/libsolidity/semanticTests/modifiers/function_modifier_for_constructor.sol index ac99b0cf7..c05f7e202 100644 --- a/test/libsolidity/semanticTests/modifiers/function_modifier_for_constructor.sol +++ b/test/libsolidity/semanticTests/modifiers/function_modifier_for_constructor.sol @@ -1,7 +1,7 @@ contract A { uint256 data; - constructor() public mod1 { + constructor() mod1 { data |= 2; } diff --git a/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol b/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol index 4e62acc5e..16383f8b9 100644 --- a/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol +++ b/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol @@ -4,7 +4,7 @@ contract B function getBalance() public view returns (uint) { return address(this).balance * 1000 + x; } - constructor(uint _x) public payable { + constructor(uint _x) payable { x = _x; } } diff --git a/test/libsolidity/semanticTests/shifts/shift_negative_rvalue.sol b/test/libsolidity/semanticTests/shifts/shift_negative_rvalue.sol deleted file mode 100644 index 611458246..000000000 --- a/test/libsolidity/semanticTests/shifts/shift_negative_rvalue.sol +++ /dev/null @@ -1,15 +0,0 @@ -contract C { - function f(int256 a, int256 b) public returns (int256) { - return a << b; - } - - function g(int256 a, int256 b) public returns (int256) { - return a >> b; - } -} - -// ==== -// compileViaYul: also -// ---- -// f(int256,int256): 1, -1 -> FAILURE -// g(int256,int256): 1, -1 -> FAILURE diff --git a/test/libsolidity/semanticTests/shifts/shift_negative_rvalue_assignment.sol b/test/libsolidity/semanticTests/shifts/shift_negative_rvalue_assignment.sol deleted file mode 100644 index 623a715ec..000000000 --- a/test/libsolidity/semanticTests/shifts/shift_negative_rvalue_assignment.sol +++ /dev/null @@ -1,17 +0,0 @@ -contract C { - function f(int256 a, int256 b) public returns (int256) { - a <<= b; - return a; - } - - function g(int256 a, int256 b) public returns (int256) { - a >>= b; - return a; - } -} - -// ==== -// compileViaYul: also -// ---- -// f(int256,int256): 1, -1 -> FAILURE -// g(int256,int256): 1, -1 -> FAILURE diff --git a/test/libsolidity/semanticTests/shifts/shift_overflow.sol b/test/libsolidity/semanticTests/shifts/shift_overflow.sol index 54f5fcc2b..c303d449e 100644 --- a/test/libsolidity/semanticTests/shifts/shift_overflow.sol +++ b/test/libsolidity/semanticTests/shifts/shift_overflow.sol @@ -3,7 +3,7 @@ contract C { return x << y; } - function leftS(int8 x, int8 y) public returns (int8) { + function leftS(int8 x, uint8 y) public returns (int8) { return x << y; } } @@ -14,5 +14,5 @@ contract C { // leftU(uint8,uint8): 255, 8 -> 0 // leftU(uint8,uint8): 255, 1 -> 254 // leftU(uint8,uint8): 255, 0 -> 255 -// leftS(int8,int8): 1, 7 -> -128 # Result is -128 and output is sign-extended, not zero-padded. # -// leftS(int8,int8): 1, 6 -> 64 +// leftS(int8,uint8): 1, 7 -> -128 # Result is -128 and output is sign-extended, not zero-padded. # +// leftS(int8,uint8): 1, 6 -> 64 diff --git a/test/libsolidity/semanticTests/shifts/shift_right_assignment_signed.sol b/test/libsolidity/semanticTests/shifts/shift_right_assignment_signed.sol deleted file mode 100644 index 5b8494167..000000000 --- a/test/libsolidity/semanticTests/shifts/shift_right_assignment_signed.sol +++ /dev/null @@ -1,14 +0,0 @@ -contract C { - function f(int256 a, int256 b) public returns (int256) { - a >>= b; - return a; - } -} - -// ==== -// compileViaYul: also -// ---- -// f(int256,int256): 0x4266, 0x0 -> 0x4266 -// f(int256,int256): 0x4266, 0x8 -> 0x42 -// f(int256,int256): 0x4266, 0x10 -> 0 -// f(int256,int256): 0x4266, 0x11 -> 0 diff --git a/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue.sol b/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue.sol index 2bac06e6e..013379d97 100644 --- a/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue.sol +++ b/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue.sol @@ -1,5 +1,5 @@ contract C { - function f(int256 a, int256 b) public returns (int256) { + function f(int256 a, uint256 b) public returns (int256) { return a >> b; } } @@ -7,15 +7,15 @@ contract C { // ==== // compileViaYul: also // ---- -// f(int256,int256): -4266, 0 -> -4266 -// f(int256,int256): -4266, 1 -> -2133 -// f(int256,int256): -4266, 4 -> -267 -// f(int256,int256): -4266, 8 -> -17 -// f(int256,int256): -4266, 16 -> -1 -// f(int256,int256): -4266, 17 -> -1 -// f(int256,int256): -4267, 0 -> -4267 -// f(int256,int256): -4267, 1 -> -2134 -// f(int256,int256): -4267, 4 -> -267 -// f(int256,int256): -4267, 8 -> -17 -// f(int256,int256): -4267, 16 -> -1 -// f(int256,int256): -4267, 17 -> -1 +// f(int256,uint256): -4266, 0 -> -4266 +// f(int256,uint256): -4266, 1 -> -2133 +// f(int256,uint256): -4266, 4 -> -267 +// f(int256,uint256): -4266, 8 -> -17 +// f(int256,uint256): -4266, 16 -> -1 +// f(int256,uint256): -4266, 17 -> -1 +// f(int256,uint256): -4267, 0 -> -4267 +// f(int256,uint256): -4267, 1 -> -2134 +// f(int256,uint256): -4267, 4 -> -267 +// f(int256,uint256): -4267, 8 -> -17 +// f(int256,uint256): -4267, 16 -> -1 +// f(int256,uint256): -4267, 17 -> -1 diff --git a/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_assignment.sol b/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_assignment.sol index 4fecffda4..2109f47d3 100644 --- a/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_assignment.sol +++ b/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_assignment.sol @@ -1,5 +1,5 @@ contract C { - function f(int256 a, int256 b) public returns (int256) { + function f(int256 a, uint256 b) public returns (int256) { a >>= b; return a; } @@ -8,15 +8,15 @@ contract C { // ==== // compileViaYul: also // ---- -// f(int256,int256): -4266, 0 -> -4266 -// f(int256,int256): -4266, 1 -> -2133 -// f(int256,int256): -4266, 4 -> -267 -// f(int256,int256): -4266, 8 -> -17 -// f(int256,int256): -4266, 16 -> -1 -// f(int256,int256): -4266, 17 -> -1 -// f(int256,int256): -4267, 0 -> -4267 -// f(int256,int256): -4267, 1 -> -2134 -// f(int256,int256): -4267, 4 -> -267 -// f(int256,int256): -4267, 8 -> -17 -// f(int256,int256): -4267, 16 -> -1 -// f(int256,int256): -4267, 17 -> -1 +// f(int256,uint256): -4266, 0 -> -4266 +// f(int256,uint256): -4266, 1 -> -2133 +// f(int256,uint256): -4266, 4 -> -267 +// f(int256,uint256): -4266, 8 -> -17 +// f(int256,uint256): -4266, 16 -> -1 +// f(int256,uint256): -4266, 17 -> -1 +// f(int256,uint256): -4267, 0 -> -4267 +// f(int256,uint256): -4267, 1 -> -2134 +// f(int256,uint256): -4267, 4 -> -267 +// f(int256,uint256): -4267, 8 -> -17 +// f(int256,uint256): -4267, 16 -> -1 +// f(int256,uint256): -4267, 17 -> -1 diff --git a/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_int16.sol b/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_int16.sol index 883f004d0..2132f13b1 100644 --- a/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_int16.sol +++ b/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_int16.sol @@ -1,5 +1,5 @@ contract C { - function f(int16 a, int16 b) public returns (int256) { + function f(int16 a, uint16 b) public returns (int256) { return a >> b; } } @@ -7,15 +7,15 @@ contract C { // ==== // compileViaYul: also // ---- -// f(int16,int16): -4266, 0 -> -4266 -// f(int16,int16): -4266, 1 -> -2133 -// f(int16,int16): -4266, 4 -> -267 -// f(int16,int16): -4266, 8 -> -17 -// f(int16,int16): -4266, 16 -> -1 -// f(int16,int16): -4266, 17 -> -1 -// f(int16,int16): -4267, 0 -> -4267 -// f(int16,int16): -4267, 1 -> -2134 -// f(int16,int16): -4267, 4 -> -267 -// f(int16,int16): -4267, 8 -> -17 -// f(int16,int16): -4267, 16 -> -1 -// f(int16,int16): -4267, 17 -> -1 +// f(int16,uint16): -4266, 0 -> -4266 +// f(int16,uint16): -4266, 1 -> -2133 +// f(int16,uint16): -4266, 4 -> -267 +// f(int16,uint16): -4266, 8 -> -17 +// f(int16,uint16): -4266, 16 -> -1 +// f(int16,uint16): -4266, 17 -> -1 +// f(int16,uint16): -4267, 0 -> -4267 +// f(int16,uint16): -4267, 1 -> -2134 +// f(int16,uint16): -4267, 4 -> -267 +// f(int16,uint16): -4267, 8 -> -17 +// f(int16,uint16): -4267, 16 -> -1 +// f(int16,uint16): -4267, 17 -> -1 diff --git a/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_int32.sol b/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_int32.sol index 4f689c015..8c944e26e 100644 --- a/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_int32.sol +++ b/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_int32.sol @@ -1,5 +1,5 @@ contract C { - function f(int32 a, int32 b) public returns (int256) { + function f(int32 a, uint32 b) public returns (int256) { return a >> b; } } @@ -7,15 +7,15 @@ contract C { // ==== // compileViaYul: also // ---- -// f(int32,int32): -4266, 0 -> -4266 -// f(int32,int32): -4266, 1 -> -2133 -// f(int32,int32): -4266, 4 -> -267 -// f(int32,int32): -4266, 8 -> -17 -// f(int32,int32): -4266, 16 -> -1 -// f(int32,int32): -4266, 17 -> -1 -// f(int32,int32): -4267, 0 -> -4267 -// f(int32,int32): -4267, 1 -> -2134 -// f(int32,int32): -4267, 4 -> -267 -// f(int32,int32): -4267, 8 -> -17 -// f(int32,int32): -4267, 16 -> -1 -// f(int32,int32): -4267, 17 -> -1 +// f(int32,uint32): -4266, 0 -> -4266 +// f(int32,uint32): -4266, 1 -> -2133 +// f(int32,uint32): -4266, 4 -> -267 +// f(int32,uint32): -4266, 8 -> -17 +// f(int32,uint32): -4266, 16 -> -1 +// f(int32,uint32): -4266, 17 -> -1 +// f(int32,uint32): -4267, 0 -> -4267 +// f(int32,uint32): -4267, 1 -> -2134 +// f(int32,uint32): -4267, 4 -> -267 +// f(int32,uint32): -4267, 8 -> -17 +// f(int32,uint32): -4267, 16 -> -1 +// f(int32,uint32): -4267, 17 -> -1 diff --git a/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_int8.sol b/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_int8.sol index 02f293e3c..d224a2379 100644 --- a/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_int8.sol +++ b/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_int8.sol @@ -1,5 +1,5 @@ contract C { - function f(int8 a, int8 b) public returns (int256) { + function f(int8 a, uint8 b) public returns (int256) { return a >> b; } } @@ -7,15 +7,15 @@ contract C { // ==== // compileViaYul: also // ---- -// f(int8,int8): -66, 0 -> -66 -// f(int8,int8): -66, 1 -> -33 -// f(int8,int8): -66, 4 -> -5 -// f(int8,int8): -66, 8 -> -1 -// f(int8,int8): -66, 16 -> -1 -// f(int8,int8): -66, 17 -> -1 -// f(int8,int8): -67, 0 -> -67 -// f(int8,int8): -67, 1 -> -34 -// f(int8,int8): -67, 4 -> -5 -// f(int8,int8): -67, 8 -> -1 -// f(int8,int8): -67, 16 -> -1 -// f(int8,int8): -67, 17 -> -1 +// f(int8,uint8): -66, 0 -> -66 +// f(int8,uint8): -66, 1 -> -33 +// f(int8,uint8): -66, 4 -> -5 +// f(int8,uint8): -66, 8 -> -1 +// f(int8,uint8): -66, 16 -> -1 +// f(int8,uint8): -66, 17 -> -1 +// f(int8,uint8): -67, 0 -> -67 +// f(int8,uint8): -67, 1 -> -34 +// f(int8,uint8): -67, 4 -> -5 +// f(int8,uint8): -67, 8 -> -1 +// f(int8,uint8): -67, 16 -> -1 +// f(int8,uint8): -67, 17 -> -1 diff --git a/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int16.sol b/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int16.sol index c59107f52..daa1ffb5f 100644 --- a/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int16.sol +++ b/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int16.sol @@ -1,13 +1,13 @@ contract C { - function f(int16 a, int16 b) public returns (int16) { + function f(int16 a, uint16 b) public returns (int16) { return a >> b; } } // ==== // ABIEncoderV1Only: true // ---- -// f(int16,int16): 0xff99, 0x00 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff99 -// f(int16,int16): 0xff99, 0x01 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcc -// f(int16,int16): 0xff99, 0x02 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe6 -// f(int16,int16): 0xff99, 0x04 -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9 -// f(int16,int16): 0xff99, 0x08 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +// f(int16,uint16): 0xff99, 0x00 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff99 +// f(int16,uint16): 0xff99, 0x01 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcc +// f(int16,uint16): 0xff99, 0x02 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe6 +// f(int16,uint16): 0xff99, 0x04 -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9 +// f(int16,uint16): 0xff99, 0x08 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff diff --git a/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int16_v2.sol b/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int16_v2.sol index 850a89be3..5ffb50c23 100644 --- a/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int16_v2.sol +++ b/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int16_v2.sol @@ -2,15 +2,15 @@ pragma experimental ABIEncoderV2; contract C { - function f(int16 a, int16 b) public returns (int16) { + function f(int16 a, uint16 b) public returns (int16) { return a >> b; } } // ==== // compileViaYul: also // ---- -// f(int16,int16): 0xff99, 0x00 -> FAILURE -// f(int16,int16): 0xff99, 0x01 -> FAILURE -// f(int16,int16): 0xff99, 0x02 -> FAILURE -// f(int16,int16): 0xff99, 0x04 -> FAILURE -// f(int16,int16): 0xff99, 0x08 -> FAILURE +// f(int16,uint16): 0xff99, 0x00 -> FAILURE +// f(int16,uint16): 0xff99, 0x01 -> FAILURE +// f(int16,uint16): 0xff99, 0x02 -> FAILURE +// f(int16,uint16): 0xff99, 0x04 -> FAILURE +// f(int16,uint16): 0xff99, 0x08 -> FAILURE diff --git a/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int32.sol b/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int32.sol index 74e9d53b0..4070fe7e1 100644 --- a/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int32.sol +++ b/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int32.sol @@ -1,13 +1,13 @@ contract C { - function f(int32 a, int32 b) public returns (int32) { + function f(int32 a, uint32 b) public returns (int32) { return a >> b; } } // ==== // ABIEncoderV1Only: true // ---- -// f(int32,int32): 0xffffff99, 0x00 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff99 -// f(int32,int32): 0xffffff99, 0x01 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcc -// f(int32,int32): 0xffffff99, 0x02 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe6 -// f(int32,int32): 0xffffff99, 0x04 -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9 -// f(int32,int32): 0xffffff99, 0x08 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +// f(int32,uint32): 0xffffff99, 0x00 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff99 +// f(int32,uint32): 0xffffff99, 0x01 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcc +// f(int32,uint32): 0xffffff99, 0x02 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe6 +// f(int32,uint32): 0xffffff99, 0x04 -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9 +// f(int32,uint32): 0xffffff99, 0x08 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff diff --git a/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int32_v2.sol b/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int32_v2.sol index d797531ec..a4cb461a1 100644 --- a/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int32_v2.sol +++ b/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int32_v2.sol @@ -2,15 +2,15 @@ pragma experimental ABIEncoderV2; contract C { - function f(int32 a, int32 b) public returns (int32) { + function f(int32 a, uint32 b) public returns (int32) { return a >> b; } } // ==== // compileViaYul: also // ---- -// f(int32,int32): 0xffffff99, 0x00 -> FAILURE -// f(int32,int32): 0xffffff99, 0x01 -> FAILURE -// f(int32,int32): 0xffffff99, 0x02 -> FAILURE -// f(int32,int32): 0xffffff99, 0x04 -> FAILURE -// f(int32,int32): 0xffffff99, 0x08 -> FAILURE +// f(int32,uint32): 0xffffff99, 0x00 -> FAILURE +// f(int32,uint32): 0xffffff99, 0x01 -> FAILURE +// f(int32,uint32): 0xffffff99, 0x02 -> FAILURE +// f(int32,uint32): 0xffffff99, 0x04 -> FAILURE +// f(int32,uint32): 0xffffff99, 0x08 -> FAILURE diff --git a/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int8.sol b/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int8.sol index 06dcf8eb5..95d983dcd 100644 --- a/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int8.sol +++ b/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int8.sol @@ -1,13 +1,13 @@ contract C { - function f(int8 a, int8 b) public returns (int8) { + function f(int8 a, uint8 b) public returns (int8) { return a >> b; } } // ==== // ABIEncoderV1Only: true // ---- -// f(int8,int8): 0x99, 0x00 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff99 -// f(int8,int8): 0x99, 0x01 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcc -// f(int8,int8): 0x99, 0x02 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe6 -// f(int8,int8): 0x99, 0x04 -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9 -// f(int8,int8): 0x99, 0x08 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +// f(int8,uint8): 0x99, 0x00 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff99 +// f(int8,uint8): 0x99, 0x01 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcc +// f(int8,uint8): 0x99, 0x02 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe6 +// f(int8,uint8): 0x99, 0x04 -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9 +// f(int8,uint8): 0x99, 0x08 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff diff --git a/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int8_v2.sol b/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int8_v2.sol index ee485335d..f42f06773 100644 --- a/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int8_v2.sol +++ b/test/libsolidity/semanticTests/shifts/shift_right_negative_lvalue_signextend_int8_v2.sol @@ -2,15 +2,15 @@ pragma experimental ABIEncoderV2; contract C { - function f(int8 a, int8 b) public returns (int8) { + function f(int8 a, uint8 b) public returns (int8) { return a >> b; } } // ==== // compileViaYul: also // ---- -// f(int8,int8): 0x99, 0x00 -> FAILURE -// f(int8,int8): 0x99, 0x01 -> FAILURE -// f(int8,int8): 0x99, 0x02 -> FAILURE -// f(int8,int8): 0x99, 0x04 -> FAILURE -// f(int8,int8): 0x99, 0x08 -> FAILURE +// f(int8,uint8): 0x99, 0x00 -> FAILURE +// f(int8,uint8): 0x99, 0x01 -> FAILURE +// f(int8,uint8): 0x99, 0x02 -> FAILURE +// f(int8,uint8): 0x99, 0x04 -> FAILURE +// f(int8,uint8): 0x99, 0x08 -> FAILURE diff --git a/test/libsolidity/semanticTests/shifts/shift_signed_cleanup_amount.sol b/test/libsolidity/semanticTests/shifts/shift_signed_cleanup_amount.sol deleted file mode 100644 index 72b8f69c8..000000000 --- a/test/libsolidity/semanticTests/shifts/shift_signed_cleanup_amount.sol +++ /dev/null @@ -1,16 +0,0 @@ -contract C { - function f(uint256 a, int8 b) public returns (uint256) { - assembly { b := 0xff } - return a << b; - } - function g(uint256 a, int8 b) public returns (uint256) { - assembly { b := 0xff } - return a >> b; - } -} - -// ==== -// compileViaYul: also -// ---- -// f(uint256,int8): 0x1234, 0x0 -> FAILURE -// g(uint256,int8): 0x1234, 0x0 -> FAILURE diff --git a/test/libsolidity/semanticTests/shifts/shift_underflow_negative_rvalue.sol b/test/libsolidity/semanticTests/shifts/shift_underflow_negative_rvalue.sol new file mode 100644 index 000000000..ad14558be --- /dev/null +++ b/test/libsolidity/semanticTests/shifts/shift_underflow_negative_rvalue.sol @@ -0,0 +1,15 @@ +contract C { + function f(int256 a, uint256 b) public returns (int256) { + return a << b; + } + + function g(int256 a, uint256 b) public returns (int256) { + return a >> b; + } +} + +// ==== +// compileViaYul: also +// ---- +// f(int256,uint256): 1, -1 -> 0 +// g(int256,uint256): 1, -1 -> 0 diff --git a/test/libsolidity/semanticTests/smoke/constructor.sol b/test/libsolidity/semanticTests/smoke/constructor.sol index 27e26f1eb..9cf435087 100644 --- a/test/libsolidity/semanticTests/smoke/constructor.sol +++ b/test/libsolidity/semanticTests/smoke/constructor.sol @@ -1,6 +1,6 @@ contract C { uint public state = 0; - constructor(uint _state) public payable { + constructor(uint _state) payable { state = _state; } function balance() public payable returns (uint256) { diff --git a/test/libsolidity/semanticTests/state_var_initialization.sol b/test/libsolidity/semanticTests/state_var_initialization.sol index ba97a9441..5da329fa4 100644 --- a/test/libsolidity/semanticTests/state_var_initialization.sol +++ b/test/libsolidity/semanticTests/state_var_initialization.sol @@ -2,7 +2,7 @@ contract C { uint public i = 1; uint public k = 2; - constructor() public { + constructor() { i = i + i; k = k - i; } diff --git a/test/libsolidity/semanticTests/state_variables_init_order_2.sol b/test/libsolidity/semanticTests/state_variables_init_order_2.sol index 9bdf9c70c..67e38da6b 100644 --- a/test/libsolidity/semanticTests/state_variables_init_order_2.sol +++ b/test/libsolidity/semanticTests/state_variables_init_order_2.sol @@ -8,7 +8,7 @@ contract A { } contract B is A { uint public z; - constructor() public { + constructor() { z = x; } } diff --git a/test/libsolidity/semanticTests/state_variables_init_order_3.sol b/test/libsolidity/semanticTests/state_variables_init_order_3.sol index 81a5a693d..0a0aad59b 100644 --- a/test/libsolidity/semanticTests/state_variables_init_order_3.sol +++ b/test/libsolidity/semanticTests/state_variables_init_order_3.sol @@ -2,7 +2,7 @@ contract A { uint public a = 42; uint public b; uint public c; - constructor(uint x) public { + constructor(uint x) { b = a; a = x; } @@ -14,7 +14,7 @@ contract B is A { uint public b_a; uint public b_b; uint public b_c; - constructor() public A(17) { b_a = a; b_b = b; b_c = c; } + constructor() A(17) { b_a = a; b_b = b; b_c = c; } } // ==== // compileViaYul: true diff --git a/test/libsolidity/semanticTests/storage/accessors_mapping_for_array.sol b/test/libsolidity/semanticTests/storage/accessors_mapping_for_array.sol index 01460a1c8..2a478f35f 100644 --- a/test/libsolidity/semanticTests/storage/accessors_mapping_for_array.sol +++ b/test/libsolidity/semanticTests/storage/accessors_mapping_for_array.sol @@ -1,7 +1,7 @@ contract test { mapping(uint => uint[8]) public data; mapping(uint => uint[]) public dynamicData; - constructor() public { + constructor() { data[2][2] = 8; for (uint i = 0; i < 3; i++) dynamicData[2].push(); diff --git a/test/libsolidity/semanticTests/storage/array_accessor.sol b/test/libsolidity/semanticTests/storage/array_accessor.sol index eb4d3ce36..599931a37 100644 --- a/test/libsolidity/semanticTests/storage/array_accessor.sol +++ b/test/libsolidity/semanticTests/storage/array_accessor.sol @@ -5,7 +5,7 @@ contract test { struct st { uint a; uint[] finalArray; } mapping(uint256 => mapping(uint256 => st[5])) public multiple_map; - constructor() public { + constructor() { data[0] = 8; dynamicData.push(); diff --git a/test/libsolidity/semanticTests/storage/complex_accessors.sol b/test/libsolidity/semanticTests/storage/complex_accessors.sol index 9b3fa7a3c..d1087f800 100644 --- a/test/libsolidity/semanticTests/storage/complex_accessors.sol +++ b/test/libsolidity/semanticTests/storage/complex_accessors.sol @@ -3,7 +3,7 @@ contract test { mapping(uint256 => bool) public to_bool_map; mapping(uint256 => uint256) public to_uint_map; mapping(uint256 => mapping(uint256 => uint256)) public to_multiple_map; - constructor() public { + constructor() { to_string_map[42] = "24"; to_bool_map[42] = false; to_uint_map[42] = 12; diff --git a/test/libsolidity/semanticTests/storage/simple_accessor.sol b/test/libsolidity/semanticTests/storage/simple_accessor.sol index aacfb93a0..70e8a331f 100644 --- a/test/libsolidity/semanticTests/storage/simple_accessor.sol +++ b/test/libsolidity/semanticTests/storage/simple_accessor.sol @@ -1,6 +1,6 @@ contract test { uint256 public data; - constructor() public { + constructor() { data = 8; } } diff --git a/test/libsolidity/semanticTests/storage/struct_accessor.sol b/test/libsolidity/semanticTests/storage/struct_accessor.sol index de57d4697..ea030de1a 100644 --- a/test/libsolidity/semanticTests/storage/struct_accessor.sol +++ b/test/libsolidity/semanticTests/storage/struct_accessor.sol @@ -1,7 +1,7 @@ contract test { struct Data { uint a; uint8 b; mapping(uint => uint) c; bool d; } mapping(uint => Data) public data; - constructor() public { + constructor() { data[7].a = 1; data[7].b = 2; data[7].c[0] = 3; diff --git a/test/libsolidity/semanticTests/structs/conversion/assignment_ignore_mapping.sol b/test/libsolidity/semanticTests/structs/conversion/assignment_ignore_mapping.sol deleted file mode 100644 index dd3bceb28..000000000 --- a/test/libsolidity/semanticTests/structs/conversion/assignment_ignore_mapping.sol +++ /dev/null @@ -1,50 +0,0 @@ -contract Test { - struct A { - mapping(uint=>uint) m; - } - struct B { - mapping(uint=>uint) m; - uint x; - } - struct C { - mapping(uint=>uint)[] ma; - } - struct D { - A[] a; - } - A storageA; - B storageB; - C storageC; - D storageD; - constructor() public { - storageA.m[1] = 2; - storageB.m[3] = 4; - storageB.x = 5; - for (uint i = 0; i < 6; i++) - storageC.ma.push(); - for (uint i = 0; i < 7; i++) - storageD.a.push(); - } - function run() public returns (uint, uint, uint, uint, uint, uint) { - A memory memoryA = A(); - B memory memoryB = B(42); - C memory memoryC = C(); - D memory memoryD1 = D(new A[](999)); - D memory memoryD2 = storageD; - storageA = memoryA; - storageB = memoryB; - storageC = memoryC; - // the following line does not compile because unimplemented - // storageD = memoryD1; - return ( - storageA.m[1], - storageB.x, - memoryB.x, - storageC.ma.length, - memoryD1.a.length, - memoryD2.a.length - ); - } -} -// ---- -// run() -> 2, 42, 42, 6, 999, 7 diff --git a/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory.sol b/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory.sol index fc0748b7f..89138b60b 100644 --- a/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory.sol +++ b/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory.sol @@ -6,7 +6,7 @@ contract CopyTest { Tree storageTree; Tree[] children; - constructor() public { + constructor() { for (uint i = 0; i < 2; i++) storageTree.children.push(); for (uint i = 0; i < 23; i++) diff --git a/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory_complex.sol b/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory_complex.sol index e8a08e513..d14bff969 100644 --- a/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory_complex.sol +++ b/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory_complex.sol @@ -6,7 +6,7 @@ contract CopyTest { Tree storageTree; Tree childStorageTree; - constructor() public { + constructor() { storageTree.data = 0x42; for (uint i = 0; i < 2; i++) storageTree.children.push(childStorageTree); diff --git a/test/libsolidity/semanticTests/structs/delete_struct.sol b/test/libsolidity/semanticTests/structs/delete_struct.sol index 7f57ce63a..48de502c7 100644 --- a/test/libsolidity/semanticTests/structs/delete_struct.sol +++ b/test/libsolidity/semanticTests/structs/delete_struct.sol @@ -10,7 +10,7 @@ contract test { uint nestedValue; mapping (uint => bool) nestedMapping; } - constructor() public { + constructor() { toDelete = 5; str.topValue = 1; str.topMapping[0] = 1; diff --git a/test/libsolidity/semanticTests/structs/memory_structs_with_mappings.sol b/test/libsolidity/semanticTests/structs/memory_structs_with_mappings.sol deleted file mode 100644 index 3aaa354f8..000000000 --- a/test/libsolidity/semanticTests/structs/memory_structs_with_mappings.sol +++ /dev/null @@ -1,24 +0,0 @@ -contract Test { - struct S { - uint8 a; - mapping(uint256 => uint256) b; - uint8 c; - } - S s; - - function f() public returns (uint256) { - S memory x; - if (x.a != 0 || x.c != 0) return 1; - x.a = 4; - x.c = 5; - s = x; - if (s.a != 4 || s.c != 5) return 2; - x = S(2, 3); - if (x.a != 2 || x.c != 3) return 3; - x = s; - if (s.a != 4 || s.c != 5) return 4; - } -} - -// ---- -// f() -> 0 diff --git a/test/libsolidity/semanticTests/structs/struct_assign_reference_to_struct.sol b/test/libsolidity/semanticTests/structs/struct_assign_reference_to_struct.sol index 8591131be..ca6dffb9d 100644 --- a/test/libsolidity/semanticTests/structs/struct_assign_reference_to_struct.sol +++ b/test/libsolidity/semanticTests/structs/struct_assign_reference_to_struct.sol @@ -6,7 +6,7 @@ contract test { testStruct data2; testStruct data3; - constructor() public { + constructor() { data1.m_value = 2; } diff --git a/test/libsolidity/semanticTests/structs/struct_constructor_nested.sol b/test/libsolidity/semanticTests/structs/struct_constructor_nested.sol index dbd67ab58..7ce22e45a 100644 --- a/test/libsolidity/semanticTests/structs/struct_constructor_nested.sol +++ b/test/libsolidity/semanticTests/structs/struct_constructor_nested.sol @@ -10,7 +10,7 @@ contract C { } S s; - constructor() public { + constructor() { uint256[3] memory s2; s2[1] = 9; s = S(1, s2, X(4, 5)); diff --git a/test/libsolidity/semanticTests/structs/struct_copy.sol b/test/libsolidity/semanticTests/structs/struct_copy.sol index f6c35f7da..2849c16bc 100644 --- a/test/libsolidity/semanticTests/structs/struct_copy.sol +++ b/test/libsolidity/semanticTests/structs/struct_copy.sol @@ -5,7 +5,6 @@ contract c { } struct Struct { uint256 a; - mapping(uint256 => Struct) b; Nested nested; uint256 c; } diff --git a/test/libsolidity/semanticTests/structs/struct_delete_member.sol b/test/libsolidity/semanticTests/structs/struct_delete_member.sol index fbaf7b6d9..2b3f41402 100644 --- a/test/libsolidity/semanticTests/structs/struct_delete_member.sol +++ b/test/libsolidity/semanticTests/structs/struct_delete_member.sol @@ -4,7 +4,7 @@ contract test { } testStruct data1; - constructor() public { + constructor() { data1.m_value = 2; } diff --git a/test/libsolidity/semanticTests/structs/struct_delete_struct_in_mapping.sol b/test/libsolidity/semanticTests/structs/struct_delete_struct_in_mapping.sol index 59d79da9f..b5c8a2cfa 100644 --- a/test/libsolidity/semanticTests/structs/struct_delete_struct_in_mapping.sol +++ b/test/libsolidity/semanticTests/structs/struct_delete_struct_in_mapping.sol @@ -4,7 +4,7 @@ contract test { } mapping(uint256 => testStruct) campaigns; - constructor() public { + constructor() { campaigns[0].m_value = 2; } diff --git a/test/libsolidity/semanticTests/structs/struct_named_constructor.sol b/test/libsolidity/semanticTests/structs/struct_named_constructor.sol index 5368b090e..f74cc90bd 100644 --- a/test/libsolidity/semanticTests/structs/struct_named_constructor.sol +++ b/test/libsolidity/semanticTests/structs/struct_named_constructor.sol @@ -5,7 +5,7 @@ contract C { } S public s; - constructor() public { + constructor() { s = S({a: 1, x: true}); } } diff --git a/test/libsolidity/semanticTests/tryCatch/create.sol b/test/libsolidity/semanticTests/tryCatch/create.sol index e80f1944a..ad7f734c7 100644 --- a/test/libsolidity/semanticTests/tryCatch/create.sol +++ b/test/libsolidity/semanticTests/tryCatch/create.sol @@ -1,8 +1,8 @@ contract Reverts { - constructor(uint) public { revert("test message."); } + constructor(uint) { revert("test message."); } } contract Succeeds { - constructor(uint) public { } + constructor(uint) { } } contract C { diff --git a/test/libsolidity/semanticTests/uninitializedFunctionPointer/invalidInConstructor.sol b/test/libsolidity/semanticTests/uninitializedFunctionPointer/invalidInConstructor.sol index 26c02f3e3..15ebeca43 100644 --- a/test/libsolidity/semanticTests/uninitializedFunctionPointer/invalidInConstructor.sol +++ b/test/libsolidity/semanticTests/uninitializedFunctionPointer/invalidInConstructor.sol @@ -4,7 +4,7 @@ contract C { bool flag; - constructor() public { + constructor() { if (!flag) { flag = true; function() internal invalid; diff --git a/test/libsolidity/semanticTests/uninitializedFunctionPointer/invalidStoredInConstructor.sol b/test/libsolidity/semanticTests/uninitializedFunctionPointer/invalidStoredInConstructor.sol index 710348a1a..323e47f8b 100644 --- a/test/libsolidity/semanticTests/uninitializedFunctionPointer/invalidStoredInConstructor.sol +++ b/test/libsolidity/semanticTests/uninitializedFunctionPointer/invalidStoredInConstructor.sol @@ -4,7 +4,7 @@ contract C { bool flag; - constructor() public { + constructor() { if (!flag) { flag = true; function() internal invalid; diff --git a/test/libsolidity/semanticTests/uninitializedFunctionPointer/store2.sol b/test/libsolidity/semanticTests/uninitializedFunctionPointer/store2.sol index 527ec52c1..a9ffff0b6 100644 --- a/test/libsolidity/semanticTests/uninitializedFunctionPointer/store2.sol +++ b/test/libsolidity/semanticTests/uninitializedFunctionPointer/store2.sol @@ -1,11 +1,11 @@ -pragma solidity >=0.5.7 <0.7.0; +pragma solidity >=0.4.0 <0.8.0; contract InvalidTest { function() internal storedFn; uint public x; - constructor() public { + constructor() { uint _y1; uint _y2; uint _y3; diff --git a/test/libsolidity/semanticTests/uninitializedFunctionPointer/storeInConstructor.sol b/test/libsolidity/semanticTests/uninitializedFunctionPointer/storeInConstructor.sol index 8a11832c8..df28ca1cc 100644 --- a/test/libsolidity/semanticTests/uninitializedFunctionPointer/storeInConstructor.sol +++ b/test/libsolidity/semanticTests/uninitializedFunctionPointer/storeInConstructor.sol @@ -4,7 +4,7 @@ contract InvalidTest { bool flag; - constructor() public { + constructor() { function() internal invalid; storedFn = invalid; } diff --git a/test/libsolidity/semanticTests/various/balance.sol b/test/libsolidity/semanticTests/various/balance.sol index d6a80dbf9..99fdf4da7 100644 --- a/test/libsolidity/semanticTests/various/balance.sol +++ b/test/libsolidity/semanticTests/various/balance.sol @@ -1,5 +1,5 @@ contract test { - constructor() public payable {} + constructor() payable {} function getBalance() public returns (uint256 balance) { return address(this).balance; diff --git a/test/libsolidity/semanticTests/various/code_access_content.sol b/test/libsolidity/semanticTests/various/code_access_content.sol index c0a74fe1a..f4bd9c5c5 100644 --- a/test/libsolidity/semanticTests/various/code_access_content.sol +++ b/test/libsolidity/semanticTests/various/code_access_content.sol @@ -1,7 +1,7 @@ contract D { bytes32 public x; - constructor() public { + constructor() { bytes32 codeHash; assembly { let size := codesize() diff --git a/test/libsolidity/semanticTests/various/code_access_create.sol b/test/libsolidity/semanticTests/various/code_access_create.sol index 9029e59ec..9b8b3175e 100644 --- a/test/libsolidity/semanticTests/various/code_access_create.sol +++ b/test/libsolidity/semanticTests/various/code_access_create.sol @@ -1,7 +1,7 @@ contract D { uint256 x; - constructor() public { + constructor() { x = 7; } diff --git a/test/libsolidity/semanticTests/various/code_access_runtime.sol b/test/libsolidity/semanticTests/various/code_access_runtime.sol index 36264f84d..0a55088a2 100644 --- a/test/libsolidity/semanticTests/various/code_access_runtime.sol +++ b/test/libsolidity/semanticTests/various/code_access_runtime.sol @@ -1,7 +1,7 @@ contract D { uint256 x; - constructor() public { + constructor() { x = 7; } diff --git a/test/libsolidity/semanticTests/various/external_types_in_calls.sol b/test/libsolidity/semanticTests/various/external_types_in_calls.sol index 0e65511c1..1b3ab196a 100644 --- a/test/libsolidity/semanticTests/various/external_types_in_calls.sol +++ b/test/libsolidity/semanticTests/various/external_types_in_calls.sol @@ -1,7 +1,7 @@ contract C1 { C1 public bla; - constructor(C1 x) public { + constructor(C1 x) { bla = x; } } diff --git a/test/libsolidity/semanticTests/various/inline_member_init.sol b/test/libsolidity/semanticTests/various/inline_member_init.sol index cac10c786..15ad78fe1 100644 --- a/test/libsolidity/semanticTests/various/inline_member_init.sol +++ b/test/libsolidity/semanticTests/various/inline_member_init.sol @@ -1,5 +1,5 @@ contract test { - constructor() public { + constructor() { m_b = 6; m_c = 8; } diff --git a/test/libsolidity/semanticTests/various/inline_member_init_inheritence.sol b/test/libsolidity/semanticTests/various/inline_member_init_inheritence.sol index 7ee1028c9..00ea47451 100644 --- a/test/libsolidity/semanticTests/various/inline_member_init_inheritence.sol +++ b/test/libsolidity/semanticTests/various/inline_member_init_inheritence.sol @@ -1,5 +1,5 @@ contract Base { - constructor() public {} + constructor() {} uint256 m_base = 5; @@ -10,7 +10,7 @@ contract Base { contract Derived is Base { - constructor() public {} + constructor() {} uint256 m_derived = 6; diff --git a/test/libsolidity/semanticTests/various/senders_balance.sol b/test/libsolidity/semanticTests/various/senders_balance.sol index 7da77aab2..08b83401c 100644 --- a/test/libsolidity/semanticTests/various/senders_balance.sol +++ b/test/libsolidity/semanticTests/various/senders_balance.sol @@ -8,7 +8,7 @@ contract C { contract D { C c = new C(); - constructor() public payable {} + constructor() payable {} function f() public view returns (uint256) { return c.f(); diff --git a/test/libsolidity/semanticTests/various/value_complex.sol b/test/libsolidity/semanticTests/various/value_complex.sol index 19d11342f..8d091ec98 100644 --- a/test/libsolidity/semanticTests/various/value_complex.sol +++ b/test/libsolidity/semanticTests/various/value_complex.sol @@ -8,16 +8,18 @@ contract helper { contract test { helper h; - constructor() public payable { + constructor() payable { h = new helper(); } function sendAmount(uint256 amount) public payable returns (uint256 bal) { uint256 someStackElement = 20; - return h.getBalance.value(amount).gas(1000).value(amount + 3)(); + return h.getBalance{value: amount + 3, gas: 1000}(); } } +// ==== +// compileViaYul: also // ---- // constructor(), 20 wei -> // sendAmount(uint256): 5 -> 8 diff --git a/test/libsolidity/semanticTests/various/value_insane.sol b/test/libsolidity/semanticTests/various/value_insane.sol index d74a0f7f4..c81570626 100644 --- a/test/libsolidity/semanticTests/various/value_insane.sol +++ b/test/libsolidity/semanticTests/various/value_insane.sol @@ -8,15 +8,17 @@ contract helper { contract test { helper h; - constructor() public payable { + constructor() payable { h = new helper(); } function sendAmount(uint256 amount) public returns (uint256 bal) { - return h.getBalance.value(amount).gas(1000).value(amount + 3)(); // overwrite value + return h.getBalance{value: amount + 3, gas: 1000}(); } } +// ==== +// compileViaYul: also // ---- // constructor(), 20 wei -> // sendAmount(uint256): 5 -> 8 diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_index_zeroed_test.sol b/test/libsolidity/semanticTests/viaYul/array_storage_index_zeroed_test.sol index 98b25a40e..c0ae21681 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_index_zeroed_test.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_index_zeroed_test.sol @@ -20,7 +20,7 @@ contract C { for (uint i = 3; i < len; i++) { assembly { - mstore(0, storageArray_slot) + mstore(0, storageArray.slot) let pos := add(keccak256(0, 0x20), i) if iszero(eq(sload(pos), 0)) { diff --git a/test/libsolidity/semanticTests/viaYul/erc20.sol b/test/libsolidity/semanticTests/viaYul/erc20.sol index 6b524e0bf..9a49a053b 100644 --- a/test/libsolidity/semanticTests/viaYul/erc20.sol +++ b/test/libsolidity/semanticTests/viaYul/erc20.sol @@ -1,4 +1,4 @@ -pragma solidity >=0.4.0 <0.7.0; +pragma solidity >=0.4.0 <0.8.0; contract ERC20 { event Transfer(address indexed from, address indexed to, uint256 value); @@ -8,7 +8,7 @@ contract ERC20 { mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; - constructor() public { + constructor() { _mint(msg.sender, 20); } diff --git a/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_bytes.sol b/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_bytes.sol index ea0112fe5..d79bceb55 100644 --- a/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_bytes.sol +++ b/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_bytes.sol @@ -2,7 +2,7 @@ contract C { bytes b; function f() public returns (bool correct) { assembly { - sstore(b_slot, or("deadbeef", 0x08)) + sstore(b.slot, or("deadbeef", 0x08)) } byte s = b[3]; uint r; diff --git a/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_bytes_long.sol b/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_bytes_long.sol index 9cb01d63a..6770df0f3 100644 --- a/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_bytes_long.sol +++ b/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_bytes_long.sol @@ -2,8 +2,8 @@ contract C { bytes b; function f() public returns (bool correct) { assembly { - sstore(b_slot, 0x41) - mstore(0, b_slot) + sstore(b.slot, 0x41) + mstore(0, b.slot) sstore(keccak256(0, 0x20), "deadbeefdeadbeefdeadbeefdeadbeef") } byte s = b[31]; diff --git a/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_dynamic_array.sol b/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_dynamic_array.sol index bc886b93d..011cf7d88 100644 --- a/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_dynamic_array.sol +++ b/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_dynamic_array.sol @@ -3,7 +3,7 @@ contract C { function f() public returns (bool correct) { s.push(); assembly { - mstore(0, s_slot) + mstore(0, s.slot) sstore(keccak256(0, 0x20), 257) } uint8 x = s[0]; diff --git a/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_static_array.sol b/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_static_array.sol index 7d7298fee..e3bec359d 100644 --- a/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_static_array.sol +++ b/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_static_array.sol @@ -2,7 +2,7 @@ contract C { uint8[1] s; function f() public returns (bool correct) { assembly { - sstore(s_slot, 257) + sstore(s.slot, 257) } uint8 x = s[0]; uint r; diff --git a/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_struct.sol b/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_struct.sol index 1cf19c5be..695184c8f 100644 --- a/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_struct.sol +++ b/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_struct.sol @@ -6,7 +6,7 @@ contract C { function f() public returns (bool correct) { s.m.push(); assembly { - mstore(0, s_slot) + mstore(0, s.slot) sstore(keccak256(0, 0x20), 257) } uint8 x = s.m[0]; diff --git a/test/libsolidity/semanticTests/viaYul/struct_member_access.sol b/test/libsolidity/semanticTests/viaYul/struct_member_access.sol index 60733d414..957226195 100644 --- a/test/libsolidity/semanticTests/viaYul/struct_member_access.sol +++ b/test/libsolidity/semanticTests/viaYul/struct_member_access.sol @@ -8,7 +8,7 @@ contract C { } S s; - constructor() public { + constructor() { s.a = 42; s.b.push(1); s.b.push(2); diff --git a/test/libsolidity/semanticTests/virtualFunctions/virtual_function_usage_in_constructor_arguments.sol b/test/libsolidity/semanticTests/virtualFunctions/virtual_function_usage_in_constructor_arguments.sol index e66b8ad4f..71ee82fd3 100644 --- a/test/libsolidity/semanticTests/virtualFunctions/virtual_function_usage_in_constructor_arguments.sol +++ b/test/libsolidity/semanticTests/virtualFunctions/virtual_function_usage_in_constructor_arguments.sol @@ -1,7 +1,7 @@ contract BaseBase { uint256 m_a; - constructor(uint256 a) public { + constructor(uint256 a) { m_a = a; } diff --git a/test/libsolidity/smtCheckerTests/array_members/pop_constructor_safe.sol b/test/libsolidity/smtCheckerTests/array_members/pop_constructor_safe.sol index 4842ee56f..c462713df 100644 --- a/test/libsolidity/smtCheckerTests/array_members/pop_constructor_safe.sol +++ b/test/libsolidity/smtCheckerTests/array_members/pop_constructor_safe.sol @@ -2,7 +2,7 @@ pragma experimental SMTChecker; contract C { uint[] a; - constructor() public { + constructor() { a.push(); a.pop(); } diff --git a/test/libsolidity/smtCheckerTests/array_members/pop_constructor_unsafe.sol b/test/libsolidity/smtCheckerTests/array_members/pop_constructor_unsafe.sol index fc1264ddc..d7fc43fc4 100644 --- a/test/libsolidity/smtCheckerTests/array_members/pop_constructor_unsafe.sol +++ b/test/libsolidity/smtCheckerTests/array_members/pop_constructor_unsafe.sol @@ -2,9 +2,9 @@ pragma experimental SMTChecker; contract C { uint[] a; - constructor() public { + constructor() { a.pop(); } } // ---- -// Warning 2529: (83-90): Empty array "pop" detected here. +// Warning 2529: (76-83): Empty array "pop" detected here. diff --git a/test/libsolidity/smtCheckerTests/array_members/push_overflow_1_safe.sol b/test/libsolidity/smtCheckerTests/array_members/push_overflow_1_safe.sol index f563504f4..dac9b10a0 100644 --- a/test/libsolidity/smtCheckerTests/array_members/push_overflow_1_safe.sol +++ b/test/libsolidity/smtCheckerTests/array_members/push_overflow_1_safe.sol @@ -2,7 +2,7 @@ pragma experimental SMTChecker; contract C { uint256[] x; - constructor() public { x.push(42); } + constructor() { x.push(42); } function f() public { x.push(23); assert(x[0] == 42 || x[0] == 23); diff --git a/test/libsolidity/smtCheckerTests/array_members/push_overflow_1_safe_no_overflow_assumption.sol b/test/libsolidity/smtCheckerTests/array_members/push_overflow_1_safe_no_overflow_assumption.sol index 7ed99a69e..6b4642bfd 100644 --- a/test/libsolidity/smtCheckerTests/array_members/push_overflow_1_safe_no_overflow_assumption.sol +++ b/test/libsolidity/smtCheckerTests/array_members/push_overflow_1_safe_no_overflow_assumption.sol @@ -2,7 +2,7 @@ pragma experimental SMTChecker; contract C { uint256[] x; - constructor() public { x.push(42); } + constructor() { x.push(42); } function f() public { x.push(23); assert(x[0] == 42); diff --git a/test/libsolidity/smtCheckerTests/complex/slither/data_dependency.sol b/test/libsolidity/smtCheckerTests/complex/slither/data_dependency.sol index b75ef605f..d88e553b7 100644 --- a/test/libsolidity/smtCheckerTests/complex/slither/data_dependency.sol +++ b/test/libsolidity/smtCheckerTests/complex/slither/data_dependency.sol @@ -46,7 +46,7 @@ contract SolidityVar{ address addr_1; address addr_2; - constructor() public{ + constructor(){ addr_1 = msg.sender; } @@ -117,7 +117,7 @@ contract PropagateThroughReturnValue { } } // ---- -// Warning 2018: (1886-1954): Function state mutability can be restricted to view +// Warning 2018: (1879-1947): Function state mutability can be restricted to view // Warning 8115: (318-332): Assertion checker does not yet support the type of this variable. // Warning 8115: (338-347): Assertion checker does not yet support the type of this variable. // Warning 8115: (353-378): Assertion checker does not yet support the type of this variable. diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_hash.sol b/test/libsolidity/smtCheckerTests/external_calls/external_hash.sol index c0e9a7965..f98b1fc8e 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_hash.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_hash.sol @@ -10,7 +10,7 @@ contract C { bytes32 sig_2; Crypto d; - constructor() public { + constructor() { owner = msg.sender; } @@ -26,4 +26,4 @@ contract C { } } // ---- -// Warning 4661: (430-452): Assertion violation happens here +// Warning 4661: (423-445): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_pure.sol b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_pure.sol index 8aef1f312..8e0adad37 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_pure.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_pure.sol @@ -12,7 +12,7 @@ contract C { bytes32 sig_2; Crypto d; - constructor() public { + constructor() { owner = msg.sender; } @@ -28,4 +28,4 @@ contract C { } } // ---- -// Warning 4661: (438-460): Assertion violation happens here +// Warning 4661: (431-453): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state.sol b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state.sol index 3f6244e1e..2a2e79328 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state.sol @@ -16,7 +16,7 @@ contract C { uint z; State s; - constructor() public { + constructor() { owner = msg.sender; } @@ -34,5 +34,5 @@ contract C { } } // ---- -// Warning 5084: (551-561): Type conversion is not yet fully supported and might yield false positives. -// Warning 4661: (535-572): Assertion violation happens here +// Warning 5084: (544-554): Type conversion is not yet fully supported and might yield false positives. +// Warning 4661: (528-565): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy.sol b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy.sol index 2439fc864..e862a8e9e 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy.sol @@ -13,7 +13,7 @@ contract C { uint y; State s; - constructor() public { + constructor() { owner = msg.sender; } @@ -29,4 +29,4 @@ contract C { } } // ---- -// Warning 4661: (306-320): Assertion violation happens here +// Warning 4661: (299-313): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_indirect.sol b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_indirect.sol index 9a8f9ed8e..46fae86b6 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_indirect.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_indirect.sol @@ -22,7 +22,7 @@ contract C { uint y; State s; - constructor() public { + constructor() { owner = msg.sender; } @@ -43,5 +43,5 @@ contract C { } // ---- // Warning 5084: (92-102): Type conversion is not yet fully supported and might yield false positives. -// Warning 4661: (459-473): Assertion violation happens here -// Warning 4661: (477-503): Assertion violation happens here +// Warning 4661: (452-466): Assertion violation happens here +// Warning 4661: (470-496): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_unsafe.sol b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_unsafe.sol index c60b6b05d..39e9f0749 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_unsafe.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_unsafe.sol @@ -14,7 +14,7 @@ contract C { uint y; State s; - constructor() public { + constructor() { owner = msg.sender; } @@ -35,5 +35,5 @@ contract C { } // ---- // Warning 5084: (116-126): Type conversion is not yet fully supported and might yield false positives. -// Warning 4661: (388-402): Assertion violation happens here -// Warning 4661: (406-432): Assertion violation happens here +// Warning 4661: (381-395): Assertion violation happens here +// Warning 4661: (399-425): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_unsafe.sol b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_unsafe.sol index 336d75b97..5465eb57b 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_unsafe.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_unsafe.sol @@ -16,7 +16,7 @@ contract C { uint z; State s; - constructor() public { + constructor() { owner = msg.sender; } @@ -38,6 +38,6 @@ contract C { } } // ---- -// Warning 4661: (442-468): Assertion violation happens here -// Warning 5084: (617-627): Type conversion is not yet fully supported and might yield false positives. -// Warning 4661: (601-638): Assertion violation happens here +// Warning 4661: (435-461): Assertion violation happens here +// Warning 5084: (610-620): Type conversion is not yet fully supported and might yield false positives. +// Warning 4661: (594-631): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_base_basic.sol b/test/libsolidity/smtCheckerTests/functions/constructor_base_basic.sol index f1ea2e053..155290dcc 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_base_basic.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_base_basic.sol @@ -2,13 +2,13 @@ pragma experimental SMTChecker; contract A { uint x; - constructor() public { + constructor() { x = 2; } } contract B is A { - constructor() A() public { + constructor() A() { x = 3; } } diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy.sol b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy.sol index 1521f833d..fd7c9663b 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy.sol @@ -1,16 +1,16 @@ pragma experimental SMTChecker; contract C { uint a; - constructor(uint x) public { + constructor(uint x) { a = x; } } contract A is C { - constructor() C(2) public { + constructor() C(2) { assert(a == 2); assert(a == 3); } } // ---- -// Warning 4661: (166-180): Assertion violation happens here +// Warning 4661: (152-166): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_2.sol b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_2.sol index 7efa68b94..126f5b745 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_2.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_2.sol @@ -1,7 +1,7 @@ pragma experimental SMTChecker; -contract C { uint a; constructor(uint x) public { a = x; } } -contract A is C { constructor() C(2) public { assert(a == 2); } } -contract B is C { constructor() C(3) public { assert(a == 3); } } -contract J is C { constructor() C(3) public { assert(a == 4); } } +contract C { uint a; constructor(uint x) { a = x; } } +contract A is C { constructor() C(2) { assert(a == 2); } } +contract B is C { constructor() C(3) { assert(a == 3); } } +contract J is C { constructor() C(3) { assert(a == 4); } } // ---- -// Warning 4661: (271-285): Assertion violation happens here +// Warning 4661: (243-257): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_3.sol b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_3.sol index 638b29f5e..6b59b9829 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_3.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_3.sol @@ -1,24 +1,24 @@ pragma experimental SMTChecker; contract C { uint a; - constructor(uint x) public { + constructor(uint x) { a = x; } } abstract contract B is C { - constructor(uint x) public { + constructor(uint x) { a = x; } } contract A is B { - constructor(uint x) B(x) C(x + 2) public { + constructor(uint x) B(x) C(x + 2) { assert(a == x); assert(a == x + 1); } } // ---- -// Warning 2661: (217-222): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (265-270): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 4661: (253-271): Assertion violation happens here +// Warning 2661: (203-208): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (244-249): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 4661: (232-250): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_4.sol b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_4.sol index aa964a102..c2466c0d1 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_4.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_4.sol @@ -1,23 +1,23 @@ pragma experimental SMTChecker; contract C { uint a; - constructor(uint x) public { + constructor(uint x) { a = x; } } abstract contract B is C { - constructor(uint x) public { + constructor(uint x) { a = x; } } contract A is B { - constructor(uint x) C(x + 2) B(x + 1) public { + constructor(uint x) C(x + 2) B(x + 1) { assert(a == x + 1); } } // ---- -// Warning 2661: (221-226): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (212-217): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (251-256): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (207-212): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (198-203): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (230-235): Overflow (resulting value larger than 2**256 - 1) happens here diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_diamond.sol b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_diamond.sol index 1427498c4..1e3166920 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_diamond.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_diamond.sol @@ -1,31 +1,31 @@ pragma experimental SMTChecker; contract C { uint a; - constructor(uint x) public { + constructor(uint x) { a = x; } } abstract contract B1 is C { - constructor(uint x) public { + constructor(uint x) { a = x; } } contract B2 is C { - constructor(uint x) C(x + 2) public { + constructor(uint x) C(x + 2) { a = x; } } contract A is B2, B1 { - constructor(uint x) B2(x) B1(x) public { + constructor(uint x) B2(x) B1(x) { assert(a == x); assert(a == x + 1); } } // ---- -// Warning 2661: (214-219): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (214-219): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (342-347): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 4661: (330-348): Assertion violation happens here +// Warning 2661: (200-205): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (200-205): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (314-319): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 4661: (302-320): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_diamond_2.sol b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_diamond_2.sol index 18505a24e..0ec12ffac 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_diamond_2.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_diamond_2.sol @@ -1,31 +1,31 @@ pragma experimental SMTChecker; contract C { uint a; - constructor(uint x) public { + constructor(uint x) { a = x; } } abstract contract B1 is C { - constructor(uint x) public { + constructor(uint x) { a = x; } } contract B2 is C { - constructor(uint x) C(x + 2) public { + constructor(uint x) C(x + 2) { a = x; } } contract A is B2, B1 { - constructor(uint x) B1(x) B2(x) public { + constructor(uint x) B1(x) B2(x) { assert(a == x); assert(a == x + 1); } } // ---- -// Warning 2661: (214-219): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (214-219): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (342-347): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 4661: (330-348): Assertion violation happens here +// Warning 2661: (200-205): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (200-205): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (314-319): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 4661: (302-320): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_diamond_3.sol b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_diamond_3.sol index caa4e67e2..9f5d6d402 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_diamond_3.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_diamond_3.sol @@ -1,37 +1,37 @@ pragma experimental SMTChecker; contract C { uint a; - constructor(uint x) public { + constructor(uint x) { a = x; } } abstract contract B1 is C { uint b1; - constructor(uint x) public { + constructor(uint x) { b1 = x + a; } } contract B2 is C { uint b2; - constructor(uint x) C(x + 2) public { + constructor(uint x) C(x + 2) { b2 = x + a; } } contract A is B2, B1 { - constructor(uint x) B2(x) B1(x) public { + constructor(uint x) B2(x) B1(x) { assert(b1 == b2); assert(b1 != b2); } } // ---- -// Warning 4144: (174-179): Underflow (resulting value less than 0) happens here -// Warning 2661: (174-179): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (239-244): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (262-267): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (239-244): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (262-267): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (174-179): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 4661: (362-378): Assertion violation happens here +// Warning 4144: (160-165): Underflow (resulting value less than 0) happens here +// Warning 2661: (160-165): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (225-230): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (241-246): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (225-230): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (241-246): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (160-165): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 4661: (334-350): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_diamond_empty_middle.sol b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_diamond_empty_middle.sol index b9e6232e2..64acae437 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_diamond_empty_middle.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_diamond_empty_middle.sol @@ -1,7 +1,7 @@ pragma experimental SMTChecker; contract C { uint a; - constructor() public { + constructor() { a = 2; } } @@ -13,11 +13,11 @@ contract B2 is C { } contract A is B, B2 { - constructor(uint x) public { + constructor(uint x) { assert(a == 2); assert(a == 3); } } // ---- -// Warning 5667: (171-177): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning 4661: (208-222): Assertion violation happens here +// Warning 5667: (164-170): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning 4661: (194-208): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_diamond_empty_middle_empty_base.sol b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_diamond_empty_middle_empty_base.sol index 7c35f4fae..2a196b23f 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_diamond_empty_middle_empty_base.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_diamond_empty_middle_empty_base.sol @@ -1,7 +1,7 @@ pragma experimental SMTChecker; contract C { uint a; - constructor() public { + constructor() { a = 2; } } @@ -10,7 +10,7 @@ contract B is C { } contract B2 is C { - constructor() public { + constructor() { assert(a == 2); } } diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_empty_chain.sol b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_empty_chain.sol index 7e4a1a28f..6cb0cd8ab 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_empty_chain.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_empty_chain.sol @@ -1,7 +1,7 @@ pragma experimental SMTChecker; contract F { uint a; - constructor() public { + constructor() { a = 2; } } @@ -12,11 +12,11 @@ contract C is D {} contract B is C {} contract A is B { - constructor(uint x) public { + constructor(uint x) { assert(a == 2); assert(a == 3); } } // ---- -// Warning 5667: (201-207): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning 4661: (238-252): Assertion violation happens here +// Warning 5667: (194-200): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning 4661: (224-238): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_empty_middle.sol b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_empty_middle.sol index 3e2d932e7..40a67ce2f 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_empty_middle.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_empty_middle.sol @@ -1,7 +1,7 @@ pragma experimental SMTChecker; contract C { uint a; - constructor() public { + constructor() { a = 2; } } @@ -10,11 +10,11 @@ contract B is C { } contract A is B { - constructor(uint x) B() public { + constructor(uint x) B() { assert(a == 2); assert(a == 3); } } // ---- -// Warning 5667: (145-151): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning 4661: (186-200): Assertion violation happens here +// Warning 5667: (138-144): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning 4661: (172-186): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_empty_middle_no_invocation.sol b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_empty_middle_no_invocation.sol index ffcc13c99..a3891d3bd 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_empty_middle_no_invocation.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_empty_middle_no_invocation.sol @@ -1,7 +1,7 @@ pragma experimental SMTChecker; contract C { uint a; - constructor() public { + constructor() { a = 2; } } @@ -10,10 +10,10 @@ contract B is C { } contract A is B { - constructor(uint x) public { + constructor(uint x) { assert(a == 3); } } // ---- -// Warning 5667: (145-151): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning 4661: (164-178): Assertion violation happens here +// Warning 5667: (138-144): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning 4661: (150-164): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_mixed_chain.sol b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_mixed_chain.sol index 189297364..ae93d962a 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_mixed_chain.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_mixed_chain.sol @@ -1,30 +1,30 @@ pragma experimental SMTChecker; contract F { uint a; - constructor() public { + constructor() { a = 2; } } contract E is F {} contract D is E { - constructor() public { + constructor() { a = 3; } } contract C is D {} contract B is C { - constructor() public { + constructor() { a = 4; } } contract A is B { - constructor(uint x) public { + constructor(uint x) { assert(a == 4); assert(a == 5); } } // ---- -// Warning 5667: (275-281): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning 4661: (312-326): Assertion violation happens here +// Warning 5667: (254-260): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning 4661: (284-298): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_mixed_chain_empty_base.sol b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_mixed_chain_empty_base.sol index 71cbbd13c..534c0eecb 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_mixed_chain_empty_base.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_mixed_chain_empty_base.sol @@ -1,20 +1,20 @@ pragma experimental SMTChecker; contract F { uint a; - constructor() public { + constructor() { a = 2; } } contract E is F {} contract D is E { - constructor() public { + constructor() { a = 3; } } contract C is D {} contract B is C { - constructor() public { + constructor() { assert(a == 3); a = 4; } diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_mixed_chain_local_vars.sol b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_mixed_chain_local_vars.sol index 6f3e1e55f..b595f7951 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_mixed_chain_local_vars.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_mixed_chain_local_vars.sol @@ -1,7 +1,7 @@ pragma experimental SMTChecker; contract F { uint a; - constructor() public { + constructor() { uint f = 2; a = f; } @@ -9,21 +9,21 @@ contract F { contract E is F {} contract D is E { - constructor() public { + constructor() { uint d = 3; a = d; } } contract C is D {} contract B is C { - constructor() public { + constructor() { uint b = 4; a = b; } } contract A is B { - constructor(uint x) public { + constructor(uint x) { uint a1 = 4; uint a2 = 5; assert(a == a1); @@ -31,5 +31,5 @@ contract A is B { } } // ---- -// Warning 5667: (317-323): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning 4661: (385-400): Assertion violation happens here +// Warning 5667: (296-302): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning 4661: (357-372): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_mixed_chain_with_params.sol b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_mixed_chain_with_params.sol index 179c9bc7b..60c3ce9ef 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_mixed_chain_with_params.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_mixed_chain_with_params.sol @@ -1,30 +1,30 @@ pragma experimental SMTChecker; contract F { uint a; - constructor(uint x) public { + constructor(uint x) { a = x; } } abstract contract E is F {} abstract contract D is E { - constructor() public { + constructor() { a = 3; } } abstract contract C is D {} contract B is C { - constructor(uint x) F(x + 1) public { + constructor(uint x) F(x + 1) { } } contract A is B { - constructor(uint x) B(x) public { + constructor(uint x) B(x) { assert(a == 3); assert(a == 4); } } // ---- -// Warning 2661: (261-266): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (261-266): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 4661: (356-370): Assertion violation happens here +// Warning 2661: (247-252): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (247-252): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 4661: (328-342): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_mixed_chain_with_params_2.sol b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_mixed_chain_with_params_2.sol index 6bbc33d1e..291636786 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_mixed_chain_with_params_2.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_mixed_chain_with_params_2.sol @@ -1,20 +1,20 @@ pragma experimental SMTChecker; contract F { uint a; - constructor(uint x) public { + constructor(uint x) { a = x; } } abstract contract E is F {} abstract contract D is E { - constructor() public { + constructor() { a = 3; } } abstract contract C is D {} contract B is C { - constructor() F(1) public { + constructor() F(1) { assert(a == 3); assert(a == 2); } @@ -23,5 +23,5 @@ contract B is C { contract A is B { } // ---- -// Warning 4661: (287-301): Assertion violation happens here -// Warning 4661: (287-301): Assertion violation happens here +// Warning 4661: (266-280): Assertion violation happens here +// Warning 4661: (266-280): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_modifier.sol b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_modifier.sol index d0aa94920..6a15e4e93 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_modifier.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_modifier.sol @@ -2,16 +2,16 @@ pragma experimental SMTChecker; contract C { uint a; modifier n { _; a = 7; } - constructor(uint x) n public { + constructor(uint x) n { a = x; } } contract A is C { modifier m { a = 5; _; } - constructor() C(2) public { + constructor() C(2) { assert(a == 4); } } // ---- -// Warning 4661: (202-216): Assertion violation happens here +// Warning 4661: (188-202): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_same_var.sol b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_same_var.sol index 572c04aa8..daa89fe0a 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_same_var.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_hierarchy_same_var.sol @@ -1,17 +1,17 @@ pragma experimental SMTChecker; contract C { uint a; - constructor(uint x) public { + constructor(uint x) { a = x; } } contract A is C { - constructor() C(2) public { + constructor() C(2) { assert(a == 0); assert(C.a == 0); } } // ---- -// Warning 4661: (148-162): Assertion violation happens here -// Warning 4661: (166-182): Assertion violation happens here +// Warning 4661: (134-148): Assertion violation happens here +// Warning 4661: (152-168): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_simple.sol b/test/libsolidity/smtCheckerTests/functions/constructor_simple.sol index 5503f66ab..cb8e7b560 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_simple.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_simple.sol @@ -3,7 +3,7 @@ pragma experimental SMTChecker; contract C { uint x; - constructor() public { + constructor() { assert(x == 0); x = 10; } @@ -13,4 +13,4 @@ contract C { } } // ---- -// Warning 4661: (148-162): Assertion violation happens here +// Warning 4661: (141-155): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_state_value.sol b/test/libsolidity/smtCheckerTests/functions/constructor_state_value.sol index b238a0c1b..f1657cddd 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_state_value.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_state_value.sol @@ -3,7 +3,7 @@ pragma experimental SMTChecker; contract C { uint x = 5; - constructor() public { + constructor() { assert(x == 5); x = 10; } @@ -13,4 +13,4 @@ contract C { } } // ---- -// Warning 4661: (152-166): Assertion violation happens here +// Warning 4661: (145-159): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_state_value_inherited.sol b/test/libsolidity/smtCheckerTests/functions/constructor_state_value_inherited.sol index 27b3c8b30..5b0c2b11a 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_state_value_inherited.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_state_value_inherited.sol @@ -5,7 +5,7 @@ contract B { } contract C is B { - constructor() public { + constructor() { assert(x == 5); x = 10; } @@ -15,4 +15,4 @@ contract C is B { } } // ---- -// Warning 4661: (172-186): Assertion violation happens here +// Warning 4661: (165-179): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_state_value_parameter.sol b/test/libsolidity/smtCheckerTests/functions/constructor_state_value_parameter.sol index 80e633f6a..19a36a7c0 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_state_value_parameter.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_state_value_parameter.sol @@ -3,15 +3,15 @@ pragma experimental SMTChecker; contract C { uint x = 5; - constructor(uint a, uint b) public { + constructor(uint a, uint b) { assert(x == 5); x = a + b; } - function f(uint y) public view { + function f(uint y) view public { assert(y == x); } } // ---- -// Warning 4661: (169-183): Assertion violation happens here -// Warning 2661: (122-127): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 4661: (162-176): Assertion violation happens here +// Warning 2661: (115-120): Overflow (resulting value larger than 2**256 - 1) happens here diff --git a/test/libsolidity/smtCheckerTests/functions/constructor_this.sol b/test/libsolidity/smtCheckerTests/functions/constructor_this.sol index 591cd8245..a72dc095b 100644 --- a/test/libsolidity/smtCheckerTests/functions/constructor_this.sol +++ b/test/libsolidity/smtCheckerTests/functions/constructor_this.sol @@ -1,7 +1,7 @@ pragma experimental SMTChecker; contract C { function f() public pure {} - constructor() public { + constructor() { C c = this; c.f(); // this does not warn now, but should warn in the future this.f(); @@ -9,5 +9,5 @@ contract C { } } // ---- -// Warning 5805: (204-208): "this" used in constructor. Note that external functions of a contract cannot be called while it is being constructed. -// Warning 5805: (223-227): "this" used in constructor. Note that external functions of a contract cannot be called while it is being constructed. +// Warning 5805: (197-201): "this" used in constructor. Note that external functions of a contract cannot be called while it is being constructed. +// Warning 5805: (216-220): "this" used in constructor. Note that external functions of a contract cannot be called while it is being constructed. diff --git a/test/libsolidity/smtCheckerTests/functions/internal_call_with_assertion_1.sol b/test/libsolidity/smtCheckerTests/functions/internal_call_with_assertion_1.sol index 3ea4f4c46..05d965aa3 100644 --- a/test/libsolidity/smtCheckerTests/functions/internal_call_with_assertion_1.sol +++ b/test/libsolidity/smtCheckerTests/functions/internal_call_with_assertion_1.sol @@ -2,7 +2,7 @@ pragma experimental SMTChecker; contract C{ uint x; - constructor(uint y) public { + constructor(uint y) { assert(x == 0); x = 1; } @@ -21,5 +21,5 @@ contract C{ } // ---- // Warning 5667: (70-76): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning 2661: (163-166): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 4144: (245-248): Underflow (resulting value less than 0) happens here +// Warning 2661: (156-159): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 4144: (238-241): Underflow (resulting value less than 0) happens here diff --git a/test/libsolidity/smtCheckerTests/functions/internal_call_with_assertion_1_fail.sol b/test/libsolidity/smtCheckerTests/functions/internal_call_with_assertion_1_fail.sol index d43391255..f704de56c 100644 --- a/test/libsolidity/smtCheckerTests/functions/internal_call_with_assertion_1_fail.sol +++ b/test/libsolidity/smtCheckerTests/functions/internal_call_with_assertion_1_fail.sol @@ -2,7 +2,7 @@ pragma experimental SMTChecker; contract C{ uint x; - constructor(uint y) public { + constructor(uint y) { assert(x == 1); x = 1; } @@ -21,12 +21,12 @@ contract C{ } // ---- // Warning 5667: (70-76): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning 4661: (145-159): Assertion violation happens here -// Warning 2661: (163-166): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 4661: (227-241): Assertion violation happens here -// Warning 4661: (252-266): Assertion violation happens here -// Warning 4661: (177-191): Assertion violation happens here -// Warning 4661: (227-241): Assertion violation happens here -// Warning 4144: (245-248): Underflow (resulting value less than 0) happens here -// Warning 4661: (252-266): Assertion violation happens here -// Warning 4661: (89-103): Assertion violation happens here +// Warning 4661: (138-152): Assertion violation happens here +// Warning 2661: (156-159): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 4661: (220-234): Assertion violation happens here +// Warning 4661: (245-259): Assertion violation happens here +// Warning 4661: (170-184): Assertion violation happens here +// Warning 4661: (220-234): Assertion violation happens here +// Warning 4144: (238-241): Underflow (resulting value less than 0) happens here +// Warning 4661: (245-259): Assertion violation happens here +// Warning 4661: (82-96): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/functions/internal_call_with_assertion_inheritance_1.sol b/test/libsolidity/smtCheckerTests/functions/internal_call_with_assertion_inheritance_1.sol index ec3b88ed5..067ce603b 100644 --- a/test/libsolidity/smtCheckerTests/functions/internal_call_with_assertion_inheritance_1.sol +++ b/test/libsolidity/smtCheckerTests/functions/internal_call_with_assertion_inheritance_1.sol @@ -9,7 +9,7 @@ contract A { } contract C is A { - constructor() public { + constructor() { assert(x == 0); ++x; f(); diff --git a/test/libsolidity/smtCheckerTests/functions/internal_call_with_assertion_inheritance_1_fail.sol b/test/libsolidity/smtCheckerTests/functions/internal_call_with_assertion_inheritance_1_fail.sol index 1e2390164..3fd4a7477 100644 --- a/test/libsolidity/smtCheckerTests/functions/internal_call_with_assertion_inheritance_1_fail.sol +++ b/test/libsolidity/smtCheckerTests/functions/internal_call_with_assertion_inheritance_1_fail.sol @@ -9,7 +9,7 @@ contract A { } contract C is A { - constructor() public { + constructor() { assert(x == 1); ++x; f(); @@ -21,6 +21,6 @@ contract C is A { // Warning 4144: (100-103): Underflow (resulting value less than 0) happens here // Warning 4661: (82-96): Assertion violation happens here // Warning 4144: (100-103): Underflow (resulting value less than 0) happens here -// Warning 4661: (155-169): Assertion violation happens here +// Warning 4661: (148-162): Assertion violation happens here // Warning 4661: (82-96): Assertion violation happens here -// Warning 4661: (187-201): Assertion violation happens here +// Warning 4661: (180-194): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/functions/internal_multiple_calls_with_assertion_1.sol b/test/libsolidity/smtCheckerTests/functions/internal_multiple_calls_with_assertion_1.sol index 338a91cd7..f8ec40ab7 100644 --- a/test/libsolidity/smtCheckerTests/functions/internal_multiple_calls_with_assertion_1.sol +++ b/test/libsolidity/smtCheckerTests/functions/internal_multiple_calls_with_assertion_1.sol @@ -2,7 +2,7 @@ pragma experimental SMTChecker; contract C{ uint x; - constructor(uint y) public { + constructor(uint y) { assert(x == 0); x = 1; } @@ -21,7 +21,7 @@ contract C{ } // ---- // Warning 5667: (70-76): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning 2661: (156-159): Overflow (resulting value larger than 2**256 - 1) happens here // Warning 2661: (163-166): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (170-173): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (241-244): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 4144: (241-244): Underflow (resulting value less than 0) happens here +// Warning 2661: (234-237): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 4144: (234-237): Underflow (resulting value less than 0) happens here diff --git a/test/libsolidity/smtCheckerTests/functions/internal_multiple_calls_with_assertion_1_fail.sol b/test/libsolidity/smtCheckerTests/functions/internal_multiple_calls_with_assertion_1_fail.sol index 509bf241d..f3fda1b8a 100644 --- a/test/libsolidity/smtCheckerTests/functions/internal_multiple_calls_with_assertion_1_fail.sol +++ b/test/libsolidity/smtCheckerTests/functions/internal_multiple_calls_with_assertion_1_fail.sol @@ -2,7 +2,7 @@ pragma experimental SMTChecker; contract C{ uint x; - constructor(uint y) public { + constructor(uint y) { assert(x == 1); x = 1; } @@ -21,10 +21,10 @@ contract C{ } // ---- // Warning 5667: (70-76): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning 4661: (145-159): Assertion violation happens here +// Warning 4661: (138-152): Assertion violation happens here +// Warning 2661: (156-159): Overflow (resulting value larger than 2**256 - 1) happens here // Warning 2661: (163-166): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (170-173): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (241-244): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 4661: (191-205): Assertion violation happens here -// Warning 4144: (241-244): Underflow (resulting value less than 0) happens here -// Warning 4661: (89-103): Assertion violation happens here +// Warning 2661: (234-237): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 4661: (184-198): Assertion violation happens here +// Warning 4144: (234-237): Underflow (resulting value less than 0) happens here +// Warning 4661: (82-96): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/inheritance/constructor_hierarchy_mixed_chain_with_params.sol b/test/libsolidity/smtCheckerTests/inheritance/constructor_hierarchy_mixed_chain_with_params.sol index 179c9bc7b..60c3ce9ef 100644 --- a/test/libsolidity/smtCheckerTests/inheritance/constructor_hierarchy_mixed_chain_with_params.sol +++ b/test/libsolidity/smtCheckerTests/inheritance/constructor_hierarchy_mixed_chain_with_params.sol @@ -1,30 +1,30 @@ pragma experimental SMTChecker; contract F { uint a; - constructor(uint x) public { + constructor(uint x) { a = x; } } abstract contract E is F {} abstract contract D is E { - constructor() public { + constructor() { a = 3; } } abstract contract C is D {} contract B is C { - constructor(uint x) F(x + 1) public { + constructor(uint x) F(x + 1) { } } contract A is B { - constructor(uint x) B(x) public { + constructor(uint x) B(x) { assert(a == 3); assert(a == 4); } } // ---- -// Warning 2661: (261-266): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (261-266): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 4661: (356-370): Assertion violation happens here +// Warning 2661: (247-252): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (247-252): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 4661: (328-342): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init.sol b/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init.sol index ec6c995e5..ccb9a9386 100644 --- a/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init.sol +++ b/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init.sol @@ -2,10 +2,10 @@ pragma experimental SMTChecker; contract C { uint x = 2; - constructor () public { + constructor () { assert(x == 2); assert(x == 3); } } // ---- -// Warning 4661: (104-118): Assertion violation happens here +// Warning 4661: (97-111): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_base.sol b/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_base.sol index 8112ddb59..876616fa7 100644 --- a/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_base.sol +++ b/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_base.sol @@ -5,10 +5,10 @@ contract C { } contract D is C { - constructor() public { + constructor() { assert(x == 2); assert(x == 3); } } // ---- -// Warning 4661: (124-138): Assertion violation happens here +// Warning 4661: (117-131): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_chain.sol b/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_chain.sol index c7b42c043..fac5f2545 100644 --- a/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_chain.sol +++ b/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_chain.sol @@ -5,18 +5,18 @@ contract A { } contract B is A { - constructor() public { x = 2; } + constructor() { x = 2; } } contract C is B { - constructor() public { x = 3; } + constructor() { x = 3; } } contract D is C { - constructor() public { + constructor() { assert(x == 3); assert(x == 2); } } // ---- -// Warning 4661: (232-246): Assertion violation happens here +// Warning 4661: (211-225): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_chain_alternate.sol b/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_chain_alternate.sol index 820829a9e..bba7fc27b 100644 --- a/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_chain_alternate.sol +++ b/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_chain_alternate.sol @@ -5,17 +5,17 @@ contract A { } contract B is A { - constructor() public { x = 2; } + constructor() { x = 2; } } contract C is B { } contract D is C { - constructor() public { + constructor() { assert(x == 2); assert(x == 3); } } // ---- -// Warning 4661: (199-213): Assertion violation happens here +// Warning 4661: (185-199): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_chain_run_all.sol b/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_chain_run_all.sol index c75e003b2..0f391dac3 100644 --- a/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_chain_run_all.sol +++ b/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_chain_run_all.sol @@ -1,20 +1,20 @@ pragma experimental SMTChecker; contract C { uint a; - constructor(uint x) public { + constructor(uint x) { a = x; } } abstract contract B is C { uint b; - constructor(uint x) public { + constructor(uint x) { b = a + x; } } contract A is B { - constructor(uint x) B(x) C(x + 2) public { + constructor(uint x) B(x) C(x + 2) { assert(a == x + 2); assert(b == x + x + 2); assert(a == x + 5); @@ -22,12 +22,12 @@ contract A is B { } // ---- -// Warning 4144: (171-176): Underflow (resulting value less than 0) happens here -// Warning 2661: (171-176): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (230-235): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (171-176): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (260-265): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (282-287): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (282-291): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (308-313): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 4661: (296-314): Assertion violation happens here +// Warning 4144: (157-162): Underflow (resulting value less than 0) happens here +// Warning 2661: (157-162): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (216-221): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (157-162): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (239-244): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (261-266): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (261-270): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (287-292): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 4661: (275-293): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_chain_run_all_2.sol b/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_chain_run_all_2.sol index cac139446..5912dd855 100644 --- a/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_chain_run_all_2.sol +++ b/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_chain_run_all_2.sol @@ -1,20 +1,20 @@ pragma experimental SMTChecker; contract C { uint a; - constructor(uint x) public { + constructor(uint x) { a = x; } } abstract contract B is C { uint b; - constructor(uint x) public { + constructor(uint x) { b = x + 10; } } contract A is B { - constructor(uint x) B(x) C(x + 2) public { + constructor(uint x) B(x) C(x + 2) { assert(a == x + 2); assert(b == x + 10); assert(b == x + 5); @@ -22,10 +22,10 @@ contract A is B { } // ---- -// Warning 2661: (171-177): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (231-236): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (171-177): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (261-266): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (283-289): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 2661: (306-311): Overflow (resulting value larger than 2**256 - 1) happens here -// Warning 4661: (294-312): Assertion violation happens here +// Warning 2661: (157-163): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (217-222): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (157-163): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (240-245): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (262-268): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 2661: (285-290): Overflow (resulting value larger than 2**256 - 1) happens here +// Warning 4661: (273-291): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_diamond.sol b/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_diamond.sol index 066651f72..4841d6fa2 100644 --- a/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_diamond.sol +++ b/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_diamond.sol @@ -11,10 +11,10 @@ contract C is A { } contract D is B, C { - constructor() public { + constructor() { assert(x == 2); assert(x == 3); } } // ---- -// Warning 4661: (169-183): Assertion violation happens here +// Warning 4661: (162-176): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_diamond_middle.sol b/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_diamond_middle.sol index 1b5563c69..ba2cb9549 100644 --- a/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_diamond_middle.sol +++ b/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_diamond_middle.sol @@ -5,18 +5,18 @@ contract A { } contract B is A { - constructor() public { x = 2; } + constructor() { x = 2; } } contract C is A { - constructor() public { x = 3; } + constructor() { x = 3; } } contract D is B, C { - constructor() public { + constructor() { assert(x == 3); assert(x == 4); } } // ---- -// Warning 4661: (235-249): Assertion violation happens here +// Warning 4661: (214-228): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_function_call.sol b/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_function_call.sol index 36c8ce551..451ef0c96 100644 --- a/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_function_call.sol +++ b/test/libsolidity/smtCheckerTests/inheritance/constructor_state_variable_init_function_call.sol @@ -2,7 +2,7 @@ pragma experimental SMTChecker; contract C { uint x = f(2); - constructor () public { + constructor () { assert(x == 2); } diff --git a/test/libsolidity/smtCheckerTests/inheritance/implicit_constructor_hierarchy.sol b/test/libsolidity/smtCheckerTests/inheritance/implicit_constructor_hierarchy.sol index 37210a843..4c8835950 100644 --- a/test/libsolidity/smtCheckerTests/inheritance/implicit_constructor_hierarchy.sol +++ b/test/libsolidity/smtCheckerTests/inheritance/implicit_constructor_hierarchy.sol @@ -2,11 +2,11 @@ pragma experimental SMTChecker; contract A { uint x; - constructor (uint y) public { assert(x == 0); x = y; } + constructor (uint y) { assert(x == 0); x = y; } } contract B is A { - constructor () A(2) public { assert(x == 2); } + constructor () A(2) { assert(x == 2); } } contract C is B { diff --git a/test/libsolidity/smtCheckerTests/special/many.sol b/test/libsolidity/smtCheckerTests/special/many.sol index 83afe0fde..9e40708f0 100644 --- a/test/libsolidity/smtCheckerTests/special/many.sol +++ b/test/libsolidity/smtCheckerTests/special/many.sol @@ -10,7 +10,7 @@ contract C assert(tx.origin == msg.sender); uint x = block.number; assert(x + 2 > block.number); - assert(now > 10); + assert(block.timestamp > 10); assert(gasleft() > 100); } } @@ -22,5 +22,5 @@ contract C // Warning 4661: (244-275): Assertion violation happens here // Warning 2661: (311-316): Overflow (resulting value larger than 2**256 - 1) happens here // Warning 4661: (304-332): Assertion violation happens here -// Warning 4661: (336-352): Assertion violation happens here -// Warning 4661: (356-379): Assertion violation happens here +// Warning 4661: (336-364): Assertion violation happens here +// Warning 4661: (368-391): Assertion violation happens here diff --git a/test/libsolidity/smtCheckerTests/types/function_type_members.sol b/test/libsolidity/smtCheckerTests/types/function_type_members.sol index 9ac6036bf..7b9a0f44d 100644 --- a/test/libsolidity/smtCheckerTests/types/function_type_members.sol +++ b/test/libsolidity/smtCheckerTests/types/function_type_members.sol @@ -2,13 +2,8 @@ pragma experimental SMTChecker; contract C { function f(function(uint) external payable g) internal { g.selector; - g.gas(2).value(3)(4); g{gas: 2, value: 3}(4); } } // ---- -// Warning 1621: (122-127): Using ".gas(...)" is deprecated. Use "{gas: ...}" instead. -// Warning 1621: (122-136): Using ".value(...)" is deprecated. Use "{value: ...}" instead. // Warning 7650: (108-118): Assertion checker does not yet support this expression. -// Warning 4588: (122-130): Assertion checker does not yet implement this type of function call. -// Warning 4588: (122-139): Assertion checker does not yet implement this type of function call. diff --git a/test/libsolidity/syntaxTests/abstract/abstract_contract_instantiation.sol b/test/libsolidity/syntaxTests/abstract/abstract_contract_instantiation.sol index 1c374383c..560f47373 100644 --- a/test/libsolidity/syntaxTests/abstract/abstract_contract_instantiation.sol +++ b/test/libsolidity/syntaxTests/abstract/abstract_contract_instantiation.sol @@ -1,5 +1,5 @@ abstract contract AbstractContract { - constructor() public { } + constructor() { } function utterance() public returns (bytes32) { return "miaow"; } } @@ -9,4 +9,4 @@ contract Test { } } // ---- -// TypeError 4614: (215-235): Cannot instantiate an abstract contract. +// TypeError 4614: (208-228): Cannot instantiate an abstract contract. diff --git a/test/libsolidity/syntaxTests/abstract/contract.sol b/test/libsolidity/syntaxTests/abstract/contract.sol index 0888b8fb9..799b4ca64 100644 --- a/test/libsolidity/syntaxTests/abstract/contract.sol +++ b/test/libsolidity/syntaxTests/abstract/contract.sol @@ -1 +1 @@ -abstract contract A { constructor() public {} } +abstract contract A { constructor() {} } diff --git a/test/libsolidity/syntaxTests/array/function_mapping.sol b/test/libsolidity/syntaxTests/array/function_mapping.sol new file mode 100644 index 000000000..934c7ebd8 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/function_mapping.sol @@ -0,0 +1,8 @@ +pragma experimental ABIEncoderV2; + +contract Test { + function f(mapping(uint => uint)[] memory x) public pure {} +} +// ---- +// TypeError 4103: (66-98): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. +// TypeError 4061: (66-98): Type mapping(uint256 => uint256)[] is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/array/function_mapping_library.sol b/test/libsolidity/syntaxTests/array/function_mapping_library.sol new file mode 100644 index 000000000..fb709292a --- /dev/null +++ b/test/libsolidity/syntaxTests/array/function_mapping_library.sol @@ -0,0 +1,6 @@ +pragma experimental ABIEncoderV2; +library L { + function f(mapping(uint => uint)[2] memory a) external pure returns (mapping(uint => uint)[2] memory) {} +} +// ---- +// TypeError 4061: (61-94): Type mapping(uint256 => uint256)[2] is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/constructor/abstract_creation_forward_reference.sol b/test/libsolidity/syntaxTests/constructor/abstract_creation_forward_reference.sol index 3f989b001..491c688cc 100644 --- a/test/libsolidity/syntaxTests/constructor/abstract_creation_forward_reference.sol +++ b/test/libsolidity/syntaxTests/constructor/abstract_creation_forward_reference.sol @@ -6,10 +6,10 @@ contract Test { } contract Parent { - constructor(address _address) public {} + constructor(address _address) {} } contract Child is Parent { } // ---- -// TypeError 3656: (233-261): Contract "Child" should be marked as abstract. +// TypeError 3656: (226-254): Contract "Child" should be marked as abstract. diff --git a/test/libsolidity/syntaxTests/constructor/calldata_constructor_args.sol b/test/libsolidity/syntaxTests/constructor/calldata_constructor_args.sol index c4ce52102..5562117ce 100644 --- a/test/libsolidity/syntaxTests/constructor/calldata_constructor_args.sol +++ b/test/libsolidity/syntaxTests/constructor/calldata_constructor_args.sol @@ -2,4 +2,4 @@ contract C { constructor(uint[] calldata) public {} } // ---- -// TypeError 6651: (29-44): Data location must be "memory" for parameter in function, but "calldata" was given. +// TypeError 6651: (29-44): Data location must be "storage" or "memory" for parameter in function, but "calldata" was given. diff --git a/test/libsolidity/syntaxTests/constructor/constructer_internal_function_abstract.sol b/test/libsolidity/syntaxTests/constructor/constructer_internal_function_abstract.sol new file mode 100644 index 000000000..de9a1d5f0 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/constructer_internal_function_abstract.sol @@ -0,0 +1,3 @@ +abstract contract A { + constructor(function() internal) {} +} diff --git a/test/libsolidity/syntaxTests/constructor/constructible_abstract_base.sol b/test/libsolidity/syntaxTests/constructor/constructible_abstract_base.sol new file mode 100644 index 000000000..de68229c9 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/constructible_abstract_base.sol @@ -0,0 +1,6 @@ +abstract contract C { + constructor() {} +} +contract D is C { + constructor() { } +} diff --git a/test/libsolidity/syntaxTests/constructor/constructible_internal_constructor.sol b/test/libsolidity/syntaxTests/constructor/constructible_internal_constructor.sol index 8dee4c712..c2735f467 100644 --- a/test/libsolidity/syntaxTests/constructor/constructible_internal_constructor.sol +++ b/test/libsolidity/syntaxTests/constructor/constructible_internal_constructor.sol @@ -1,6 +1,8 @@ -contract C { +abstract contract C { constructor() internal {} } contract D is C { - constructor() public { } + constructor() { } } +// ---- +// Warning 2462: (23-48): Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is sufficient. diff --git a/test/libsolidity/syntaxTests/constructor/constructor.sol b/test/libsolidity/syntaxTests/constructor/constructor.sol index aa3422cc2..4e5c360a7 100644 --- a/test/libsolidity/syntaxTests/constructor/constructor.sol +++ b/test/libsolidity/syntaxTests/constructor/constructor.sol @@ -1 +1 @@ -contract A { constructor() public {} } +contract A { constructor() {} } diff --git a/test/libsolidity/syntaxTests/constructor/constructor_internal_function.sol b/test/libsolidity/syntaxTests/constructor/constructor_internal_function.sol new file mode 100644 index 000000000..bc57055e8 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/constructor_internal_function.sol @@ -0,0 +1,5 @@ +contract A { + constructor(function() internal) {} +} +// ---- +// TypeError 4103: (29-49): Internal type is not allowed for public or external functions. You can make the contract abstract to avoid this problem. diff --git a/test/libsolidity/syntaxTests/constructor/constructor_mapping_memory.sol b/test/libsolidity/syntaxTests/constructor/constructor_mapping_memory.sol new file mode 100644 index 000000000..266a440d6 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/constructor_mapping_memory.sol @@ -0,0 +1,6 @@ +contract A { + constructor(mapping(uint => uint) memory a) {} +} +// ---- +// TypeError 4103: (29-59): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. You can make the contract abstract to avoid this problem. +// TypeError 4061: (29-59): Type mapping(uint256 => uint256) is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/constructor/constructor_mapping_memory_abstract.sol b/test/libsolidity/syntaxTests/constructor/constructor_mapping_memory_abstract.sol new file mode 100644 index 000000000..416287895 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/constructor_mapping_memory_abstract.sol @@ -0,0 +1,5 @@ +abstract contract A { + constructor(mapping(uint => uint) memory a) {} +} +// ---- +// TypeError 4061: (38-68): Type mapping(uint256 => uint256) is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/constructor/constructor_no_visibility.sol b/test/libsolidity/syntaxTests/constructor/constructor_no_visibility.sol deleted file mode 100644 index 0b8f45947..000000000 --- a/test/libsolidity/syntaxTests/constructor/constructor_no_visibility.sol +++ /dev/null @@ -1,3 +0,0 @@ -contract A { constructor() {} } -// ---- -// SyntaxError 4937: (13-29): No visibility specified. Did you intend to add "public"? diff --git a/test/libsolidity/syntaxTests/constructor/constructor_override.sol b/test/libsolidity/syntaxTests/constructor/constructor_override.sol index ddcafcf7a..c0e363f35 100644 --- a/test/libsolidity/syntaxTests/constructor/constructor_override.sol +++ b/test/libsolidity/syntaxTests/constructor/constructor_override.sol @@ -1,5 +1,5 @@ contract C { - constructor() override public {} + constructor() override {} } // ---- -// TypeError 1209: (17-49): Constructors cannot override. +// TypeError 1209: (17-42): Constructors cannot override. diff --git a/test/libsolidity/syntaxTests/constructor/constructor_payable.sol b/test/libsolidity/syntaxTests/constructor/constructor_payable.sol index e5c6ac28d..8885e6256 100644 --- a/test/libsolidity/syntaxTests/constructor/constructor_payable.sol +++ b/test/libsolidity/syntaxTests/constructor/constructor_payable.sol @@ -1,5 +1,5 @@ contract C { - constructor() public payable { } + constructor() payable { } } contract D { diff --git a/test/libsolidity/syntaxTests/constructor/constructor_state_mutability.sol b/test/libsolidity/syntaxTests/constructor/constructor_state_mutability.sol index 37bf60bb5..487009d07 100644 --- a/test/libsolidity/syntaxTests/constructor/constructor_state_mutability.sol +++ b/test/libsolidity/syntaxTests/constructor/constructor_state_mutability.sol @@ -1,9 +1,9 @@ contract test1 { - constructor() public view {} + constructor() view {} } contract test2 { - constructor() public pure {} + constructor() pure {} } // ---- -// TypeError 1558: (19-47): Constructor must be payable or non-payable, but is "view". -// TypeError 1558: (69-97): Constructor must be payable or non-payable, but is "pure". +// TypeError 1558: (19-40): Constructor must be payable or non-payable, but is "view". +// TypeError 1558: (62-83): Constructor must be payable or non-payable, but is "pure". diff --git a/test/libsolidity/syntaxTests/constructor/constructor_storage.sol b/test/libsolidity/syntaxTests/constructor/constructor_storage.sol new file mode 100644 index 000000000..9388da132 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/constructor_storage.sol @@ -0,0 +1,5 @@ +contract A { + constructor(uint[] storage a) {} +} +// ---- +// TypeError 3644: (29-45): This parameter has a type that can only be used internally. You can make the contract abstract to avoid this problem. diff --git a/test/libsolidity/syntaxTests/constructor/constructor_storage_abstract.sol b/test/libsolidity/syntaxTests/constructor/constructor_storage_abstract.sol new file mode 100644 index 000000000..d00d4f5e3 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/constructor_storage_abstract.sol @@ -0,0 +1,3 @@ +abstract contract A { + constructor(uint[] storage a) {} +} diff --git a/test/libsolidity/syntaxTests/constructor/constructor_virtual.sol b/test/libsolidity/syntaxTests/constructor/constructor_virtual.sol index 7d75eec38..61955b6ef 100644 --- a/test/libsolidity/syntaxTests/constructor/constructor_virtual.sol +++ b/test/libsolidity/syntaxTests/constructor/constructor_virtual.sol @@ -1,5 +1,5 @@ contract C { - constructor() virtual public {} + constructor() virtual {} } // ---- -// TypeError 7001: (17-48): Constructors cannot be virtual. +// TypeError 7001: (17-41): Constructors cannot be virtual. diff --git a/test/libsolidity/syntaxTests/constructor/constructor_visibility.sol b/test/libsolidity/syntaxTests/constructor/constructor_visibility.sol index f2ebd21d2..9213f4189 100644 --- a/test/libsolidity/syntaxTests/constructor/constructor_visibility.sol +++ b/test/libsolidity/syntaxTests/constructor/constructor_visibility.sol @@ -1,5 +1,5 @@ // The constructor of a base class should not be visible in the derived class -contract A { constructor(string memory) public { } } +contract A { constructor(string memory) { } } contract B is A { function f() pure public { A x = A(0); // convert from address @@ -9,5 +9,5 @@ contract B is A { } } // ---- -// TypeError 3656: (131-301): Contract "B" should be marked as abstract. -// TypeError 9640: (250-254): Explicit type conversion not allowed from "string memory" to "contract A". +// TypeError 3656: (124-294): Contract "B" should be marked as abstract. +// TypeError 9640: (243-247): Explicit type conversion not allowed from "string memory" to "contract A". diff --git a/test/libsolidity/syntaxTests/constructor/constructor_without_implementation.sol b/test/libsolidity/syntaxTests/constructor/constructor_without_implementation.sol index 0d65fe984..869cc18ad 100644 --- a/test/libsolidity/syntaxTests/constructor/constructor_without_implementation.sol +++ b/test/libsolidity/syntaxTests/constructor/constructor_without_implementation.sol @@ -1,5 +1,5 @@ contract C { - constructor() public; + constructor(); } // ---- -// TypeError 5700: (14-35): Constructor must be implemented if declared. +// TypeError 5700: (14-28): Constructor must be implemented if declared. diff --git a/test/libsolidity/syntaxTests/constructor/external_constructor.sol b/test/libsolidity/syntaxTests/constructor/external_constructor.sol index d3f21b8fa..54ce01b28 100644 --- a/test/libsolidity/syntaxTests/constructor/external_constructor.sol +++ b/test/libsolidity/syntaxTests/constructor/external_constructor.sol @@ -2,4 +2,4 @@ contract test { constructor() external {} } // ---- -// TypeError 9239: (17-42): Constructor must be public or internal. +// TypeError 9239: (17-42): Constructor cannot have visibility. diff --git a/test/libsolidity/syntaxTests/constructor/function_named_constructor.sol b/test/libsolidity/syntaxTests/constructor/function_named_constructor.sol index e6a2ca3be..ae0815ec6 100644 --- a/test/libsolidity/syntaxTests/constructor/function_named_constructor.sol +++ b/test/libsolidity/syntaxTests/constructor/function_named_constructor.sol @@ -1,5 +1,5 @@ contract C { - function constructor() public; + function constructor(); } // ---- // ParserError 3323: (26-37): This function is named "constructor" but is not the constructor of the contract. If you intend this to be a constructor, use "constructor(...) { ... }" without the "function" keyword to define it. diff --git a/test/libsolidity/syntaxTests/constructor/inconstructible_abstract_contract.sol b/test/libsolidity/syntaxTests/constructor/inconstructible_abstract_contract.sol new file mode 100644 index 000000000..461857ff1 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/inconstructible_abstract_contract.sol @@ -0,0 +1,8 @@ +abstract contract C { + constructor() {} +} +contract D { + function f() public { C c = new C(); c; } +} +// ---- +// TypeError 4614: (84-89): Cannot instantiate an abstract contract. diff --git a/test/libsolidity/syntaxTests/constructor/inconstructible_abstract_contract_inverted.sol b/test/libsolidity/syntaxTests/constructor/inconstructible_abstract_contract_inverted.sol new file mode 100644 index 000000000..f947ed675 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/inconstructible_abstract_contract_inverted.sol @@ -0,0 +1,13 @@ +// Previously, the type information for A was not yet available at the point of +// "new A". +contract B { + A a; + constructor() { + a = new A(address(this)); + } +} +abstract contract A { + constructor(address) {} +} +// ---- +// TypeError 4614: (134-139): Cannot instantiate an abstract contract. diff --git a/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor.sol b/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor.sol index 1c03e249b..fa2b494c0 100644 --- a/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor.sol +++ b/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor.sol @@ -5,4 +5,4 @@ contract D { function f() public { C c = new C(); c; } } // ---- -// TypeError 9054: (84-89): Contract with internal constructor cannot be created directly. +// DeclarationError 1845: (14-39): Non-abstract contracts cannot have internal constructors. Remove the "internal" keyword and make the contract abstract to fix this. diff --git a/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol b/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol index 76ba97663..a20e9e2e3 100644 --- a/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol +++ b/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol @@ -2,7 +2,7 @@ // "new A". contract B { A a; - constructor() public { + constructor() { a = new A(address(this)); } } @@ -10,4 +10,4 @@ contract A { constructor(address) internal {} } // ---- -// TypeError 9054: (141-146): Contract with internal constructor cannot be created directly. +// DeclarationError 1845: (175-207): Non-abstract contracts cannot have internal constructors. Remove the "internal" keyword and make the contract abstract to fix this. diff --git a/test/libsolidity/syntaxTests/constructor/interface_constructor.sol b/test/libsolidity/syntaxTests/constructor/interface_constructor.sol index 864e4e6d2..bbdab25a6 100644 --- a/test/libsolidity/syntaxTests/constructor/interface_constructor.sol +++ b/test/libsolidity/syntaxTests/constructor/interface_constructor.sol @@ -1,7 +1,6 @@ interface I { - constructor() public; + constructor(); } // ---- -// TypeError 1560: (15-36): Functions in interfaces must be declared external. -// TypeError 6482: (15-36): Constructor cannot be defined in interfaces. -// TypeError 5700: (15-36): Constructor must be implemented if declared. +// TypeError 6482: (15-29): Constructor cannot be defined in interfaces. +// TypeError 5700: (15-29): Constructor must be implemented if declared. diff --git a/test/libsolidity/syntaxTests/constructor/internal_constructor_non_abstract.sol b/test/libsolidity/syntaxTests/constructor/internal_constructor_non_abstract.sol new file mode 100644 index 000000000..66f663605 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/internal_constructor_non_abstract.sol @@ -0,0 +1,5 @@ +contract C { + constructor() internal {} +} +// ---- +// DeclarationError 1845: (14-39): Non-abstract contracts cannot have internal constructors. Remove the "internal" keyword and make the contract abstract to fix this. diff --git a/test/libsolidity/syntaxTests/constructor/library_constructor.sol b/test/libsolidity/syntaxTests/constructor/library_constructor.sol index 230b144f5..bd1fa9550 100644 --- a/test/libsolidity/syntaxTests/constructor/library_constructor.sol +++ b/test/libsolidity/syntaxTests/constructor/library_constructor.sol @@ -1,6 +1,6 @@ library Lib { - constructor() public; + constructor(); } // ---- -// TypeError 7634: (15-36): Constructor cannot be defined in libraries. -// TypeError 5700: (15-36): Constructor must be implemented if declared. +// TypeError 7634: (15-29): Constructor cannot be defined in libraries. +// TypeError 5700: (15-29): Constructor must be implemented if declared. diff --git a/test/libsolidity/syntaxTests/constructor/nonabiv2_type.sol b/test/libsolidity/syntaxTests/constructor/nonabiv2_type.sol new file mode 100644 index 000000000..13b0d02af --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/nonabiv2_type.sol @@ -0,0 +1,5 @@ +contract C { + constructor(uint[][][] memory t) {} +} +// ---- +// TypeError 4957: (26-45): This type is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. Alternatively, make the contract abstract and supply the constructor arguments from a derived contract. diff --git a/test/libsolidity/syntaxTests/constructor/nonabiv2_type_abstract.sol b/test/libsolidity/syntaxTests/constructor/nonabiv2_type_abstract.sol new file mode 100644 index 000000000..7fc802247 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/nonabiv2_type_abstract.sol @@ -0,0 +1,4 @@ +abstract contract C { + constructor(uint[][][] memory t) {} +} +// ---- diff --git a/test/libsolidity/syntaxTests/constructor/nonpayable_new.sol b/test/libsolidity/syntaxTests/constructor/nonpayable_new.sol index fa94ee4e5..cb1923c1f 100644 --- a/test/libsolidity/syntaxTests/constructor/nonpayable_new.sol +++ b/test/libsolidity/syntaxTests/constructor/nonpayable_new.sol @@ -1,12 +1,12 @@ -contract A1 { constructor() public {} } +contract A1 { constructor() {} } contract B1 is A1 {} -contract A2 { constructor() public payable {} } +contract A2 { constructor() payable {} } contract B2 is A2 {} contract B3 {} -contract B4 { constructor() public {} } +contract B4 { constructor() {} } contract C { function f() public payable { @@ -17,7 +17,7 @@ contract C { } } // ---- -// TypeError 7006: (235-252): Cannot set option "value", since the constructor of contract B1 is not payable. -// TypeError 7006: (258-275): Cannot set option "value", since the constructor of contract B2 is not payable. -// TypeError 7006: (281-298): Cannot set option "value", since the constructor of contract B3 is not payable. -// TypeError 7006: (304-321): Cannot set option "value", since the constructor of contract B4 is not payable. +// TypeError 7006: (214-231): Cannot set option "value", since the constructor of contract B1 is not payable. +// TypeError 7006: (237-254): Cannot set option "value", since the constructor of contract B2 is not payable. +// TypeError 7006: (260-277): Cannot set option "value", since the constructor of contract B3 is not payable. +// TypeError 7006: (283-300): Cannot set option "value", since the constructor of contract B4 is not payable. diff --git a/test/libsolidity/syntaxTests/constructor/payable_new.sol b/test/libsolidity/syntaxTests/constructor/payable_new.sol index fb8e9ef53..350956a4c 100644 --- a/test/libsolidity/syntaxTests/constructor/payable_new.sol +++ b/test/libsolidity/syntaxTests/constructor/payable_new.sol @@ -1,10 +1,10 @@ contract A1 {} -contract B1 is A1 { constructor() public payable {} } +contract B1 is A1 { constructor() payable {} } -contract A2 { constructor() public {} } -contract B2 is A2 { constructor() public payable {} } +contract A2 { constructor() {} } +contract B2 is A2 { constructor() payable {} } -contract B3 { constructor() public payable {} } +contract B3 { constructor() payable {} } contract C { function f() public payable { diff --git a/test/libsolidity/syntaxTests/constructor/public_constructor_abstract.sol b/test/libsolidity/syntaxTests/constructor/public_constructor_abstract.sol new file mode 100644 index 000000000..0134fd243 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/public_constructor_abstract.sol @@ -0,0 +1,5 @@ +abstract contract C { + constructor() public {} +} +// ---- +// DeclarationError 8295: (23-46): Abstract contracts cannot have public constructors. Remove the "public" keyword to fix this. diff --git a/test/libsolidity/syntaxTests/constructor/public_constructor_non_abstract.sol b/test/libsolidity/syntaxTests/constructor/public_constructor_non_abstract.sol new file mode 100644 index 000000000..8f6ca5e54 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/public_constructor_non_abstract.sol @@ -0,0 +1,5 @@ +contract C { + constructor() public {} +} +// ---- +// Warning 2462: (14-37): Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is sufficient. diff --git a/test/libsolidity/syntaxTests/constructor/returns_in_constructor.sol b/test/libsolidity/syntaxTests/constructor/returns_in_constructor.sol index 20920dea7..c3eea9ea8 100644 --- a/test/libsolidity/syntaxTests/constructor/returns_in_constructor.sol +++ b/test/libsolidity/syntaxTests/constructor/returns_in_constructor.sol @@ -1,5 +1,5 @@ contract test { - constructor() public returns (uint a) { } + constructor() returns (uint a) { } } // ---- -// TypeError 9712: (46-54): Non-empty "returns" directive for constructor. +// TypeError 9712: (39-47): Non-empty "returns" directive for constructor. diff --git a/test/libsolidity/syntaxTests/constructor/two_constructors.sol b/test/libsolidity/syntaxTests/constructor/two_constructors.sol index d44124d38..6cd7abf73 100644 --- a/test/libsolidity/syntaxTests/constructor/two_constructors.sol +++ b/test/libsolidity/syntaxTests/constructor/two_constructors.sol @@ -1,6 +1,6 @@ contract test { - constructor(uint) public { } - constructor() public {} + constructor(uint) { } + constructor() {} } // ---- -// DeclarationError 7997: (47-70): More than one constructor defined. +// DeclarationError 7997: (40-56): More than one constructor defined. diff --git a/test/libsolidity/syntaxTests/constructor_this.sol b/test/libsolidity/syntaxTests/constructor_this.sol index 7d18407dc..3740cf867 100644 --- a/test/libsolidity/syntaxTests/constructor_this.sol +++ b/test/libsolidity/syntaxTests/constructor_this.sol @@ -1,6 +1,6 @@ contract C { function f() public pure {} - constructor() public { + constructor() { C c = this; c.f(); // this does not warn now, but should warn in the future this.f(); @@ -8,5 +8,5 @@ contract C { } } // ---- -// Warning 5805: (172-176): "this" used in constructor. Note that external functions of a contract cannot be called while it is being constructed. -// Warning 5805: (191-195): "this" used in constructor. Note that external functions of a contract cannot be called while it is being constructed. +// Warning 5805: (165-169): "this" used in constructor. Note that external functions of a contract cannot be called while it is being constructed. +// Warning 5805: (184-188): "this" used in constructor. Note that external functions of a contract cannot be called while it is being constructed. diff --git a/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/for_declaration_err.sol b/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/for_declaration_err.sol index 516861a8c..61c382282 100644 --- a/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/for_declaration_err.sol +++ b/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/for_declaration_err.sol @@ -4,28 +4,28 @@ contract C { function f() internal pure { S storage c; assembly { - for {} eq(0,0) { c_slot := s_slot } {} + for {} eq(0,0) { c.slot := s.slot } {} } c; } function g() internal pure { S storage c; assembly { - for {} eq(0,1) { c_slot := s_slot } {} + for {} eq(0,1) { c.slot := s.slot } {} } c; } function h() internal pure { S storage c; assembly { - for {} eq(0,0) {} { c_slot := s_slot } + for {} eq(0,0) {} { c.slot := s.slot } } c; } function i() internal pure { S storage c; assembly { - for {} eq(0,1) {} { c_slot := s_slot } + for {} eq(0,1) {} { c.slot := s.slot } } c; } diff --git a/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/for_declaration_fine.sol b/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/for_declaration_fine.sol index 19a58b234..4d797e6bd 100644 --- a/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/for_declaration_fine.sol +++ b/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/for_declaration_fine.sol @@ -4,14 +4,14 @@ contract C { function f() internal pure { S storage c; assembly { - for { c_slot := s_slot } iszero(0) {} {} + for { c.slot := s.slot } iszero(0) {} {} } c; } function g() internal pure { S storage c; assembly { - for { c_slot := s_slot } iszero(1) {} {} + for { c.slot := s.slot } iszero(1) {} {} } c; } diff --git a/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/if_declaration_err.sol b/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/if_declaration_err.sol index 13874595c..120199c14 100644 --- a/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/if_declaration_err.sol +++ b/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/if_declaration_err.sol @@ -4,7 +4,7 @@ contract C { function f(bool flag) internal pure { S storage c; assembly { - if flag { c_slot := s_slot } + if flag { c.slot := s.slot } } c; } diff --git a/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/returning_function_declaration.sol b/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/returning_function_declaration.sol index 180feb770..6c4ee97d6 100644 --- a/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/returning_function_declaration.sol +++ b/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/returning_function_declaration.sol @@ -7,7 +7,7 @@ contract C { assembly { function f() { return(0, 0) } f() - c_slot := s_slot + c.slot := s.slot } c; } diff --git a/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/stub_declaration.sol b/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/stub_declaration.sol index c3f240915..f637652c1 100644 --- a/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/stub_declaration.sol +++ b/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/stub_declaration.sol @@ -4,7 +4,7 @@ contract C { function f() internal pure { S storage c; assembly { - c_slot := s_slot + c.slot := s.slot } c; } diff --git a/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/switch_declaration_err.sol b/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/switch_declaration_err.sol index c3aff356a..da2f2fe61 100644 --- a/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/switch_declaration_err.sol +++ b/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/switch_declaration_err.sol @@ -5,7 +5,7 @@ contract C { S storage c; assembly { switch a - case 0 { c_slot := s_slot } + case 0 { c.slot := s.slot } } c; } @@ -13,8 +13,8 @@ contract C { S storage c; assembly { switch flag - case 0 { c_slot := s_slot } - case 1 { c_slot := s_slot } + case 0 { c.slot := s.slot } + case 1 { c.slot := s.slot } } c; } @@ -22,7 +22,7 @@ contract C { S storage c; assembly { switch a - case 0 { c_slot := s_slot } + case 0 { c.slot := s.slot } default { return(0,0) } } c; diff --git a/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/switch_declaration_fine.sol b/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/switch_declaration_fine.sol index a32599d7b..a92664f4d 100644 --- a/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/switch_declaration_fine.sol +++ b/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/assembly/switch_declaration_fine.sol @@ -5,8 +5,8 @@ contract C { S storage c; assembly { switch flag - case 0 { c_slot := s_slot } - default { c_slot := s_slot } + case 0 { c.slot := s.slot } + default { c.slot := s.slot } } c; } @@ -15,7 +15,7 @@ contract C { assembly { switch a case 0 { revert(0, 0) } - default { c_slot := s_slot } + default { c.slot := s.slot } } c; } diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/for_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/for_err.sol index f44469228..5195d0379 100644 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/for_err.sol +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/for_err.sol @@ -3,22 +3,22 @@ contract C { S s; function f() internal pure returns (S storage c) { assembly { - for {} eq(0,0) { c_slot := s_slot } {} + for {} eq(0,0) { c.slot := s.slot } {} } } function g() internal pure returns (S storage c) { assembly { - for {} eq(0,1) { c_slot := s_slot } {} + for {} eq(0,1) { c.slot := s.slot } {} } } function h() internal pure returns (S storage c) { assembly { - for {} eq(0,0) {} { c_slot := s_slot } + for {} eq(0,0) {} { c.slot := s.slot } } } function i() internal pure returns (S storage c) { assembly { - for {} eq(0,1) {} { c_slot := s_slot } + for {} eq(0,1) {} { c.slot := s.slot } } } } diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/for_fine.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/for_fine.sol index ac3532aaf..3160c9e28 100644 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/for_fine.sol +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/for_fine.sol @@ -3,12 +3,12 @@ contract C { S s; function f() internal pure returns (S storage c) { assembly { - for { c_slot := s_slot } iszero(0) {} {} + for { c.slot := s.slot } iszero(0) {} {} } } function g() internal pure returns (S storage c) { assembly { - for { c_slot := s_slot } iszero(1) {} {} + for { c.slot := s.slot } iszero(1) {} {} } } } diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/if_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/if_err.sol index 1bf0d25c3..7e3ceeb20 100644 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/if_err.sol +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/if_err.sol @@ -3,7 +3,7 @@ contract C { S s; function f(bool flag) internal pure returns (S storage c) { assembly { - if flag { c_slot := s_slot } + if flag { c.slot := s.slot } } } } diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/returning_function.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/returning_function.sol index 81b6bcfe7..fbff48f46 100644 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/returning_function.sol +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/returning_function.sol @@ -6,7 +6,7 @@ contract C { assembly { function f() { return(0, 0) } f() - c_slot := s_slot + c.slot := s.slot } } } diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/stub.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/stub.sol index e5873f3d1..df747d623 100644 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/stub.sol +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/stub.sol @@ -3,7 +3,7 @@ contract C { S s; function f() internal pure returns (S storage c) { assembly { - c_slot := s_slot + c.slot := s.slot } } } diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/switch_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/switch_err.sol index a0dfa5dd4..414078fb1 100644 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/switch_err.sol +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/switch_err.sol @@ -4,20 +4,20 @@ contract C { function f(uint256 a) internal pure returns (S storage c) { assembly { switch a - case 0 { c_slot := s_slot } + case 0 { c.slot := s.slot } } } function g(bool flag) internal pure returns (S storage c) { assembly { switch flag - case 0 { c_slot := s_slot } - case 1 { c_slot := s_slot } + case 0 { c.slot := s.slot } + case 1 { c.slot := s.slot } } } function h(uint256 a) internal pure returns (S storage c) { assembly { switch a - case 0 { c_slot := s_slot } + case 0 { c.slot := s.slot } default { return(0,0) } } } diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/switch_fine.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/switch_fine.sol index 8d0b564fc..42f58eac3 100644 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/switch_fine.sol +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/switch_fine.sol @@ -4,15 +4,15 @@ contract C { function f(bool flag) internal pure returns (S storage c) { assembly { switch flag - case 0 { c_slot := s_slot } - default { c_slot := s_slot } + case 0 { c.slot := s.slot } + default { c.slot := s.slot } } } function g(uint256 a) internal pure returns (S storage c) { assembly { switch a case 0 { revert(0, 0) } - default { c_slot := s_slot } + default { c.slot := s.slot } } } } diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/switch_only_default_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/switch_only_default_warn.sol index ce4d4b262..611f68624 100644 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/switch_only_default_warn.sol +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly/switch_only_default_warn.sol @@ -4,7 +4,7 @@ contract C { function f(uint256 a) internal pure returns (S storage c) { assembly { switch a - default { c_slot := s_slot } + default { c.slot := s.slot } } } } diff --git a/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/assembly.sol b/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/assembly.sol index cb9f2d54c..4b3f17219 100644 --- a/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/assembly.sol +++ b/test/libsolidity/syntaxTests/controlFlow/uninitializedAccess/assembly.sol @@ -1,7 +1,7 @@ contract C { uint[] r; function f() internal view returns (uint[] storage s) { - assembly { pop(s_slot) } + assembly { pop(s.slot) } s = r; } } diff --git a/test/libsolidity/syntaxTests/denominations/denominations.sol b/test/libsolidity/syntaxTests/denominations/denominations.sol index a34c03de0..3c1c305cf 100644 --- a/test/libsolidity/syntaxTests/denominations/denominations.sol +++ b/test/libsolidity/syntaxTests/denominations/denominations.sol @@ -1,7 +1,7 @@ contract C { - uint constant a = 1 wei + 2 szabo + 3 finney + 4 ether; + uint constant a = 1 wei + 4 ether; uint constant b = 1 seconds + 2 minutes + 3 hours + 4 days + 5 weeks; - uint constant c = 2 szabo / 1 seconds + 3 finney * 3 hours; - uint constant d = 2 gwei / 1 seconds + 3 finney * 3 hours; + uint constant c = 2 ether / 1 seconds + 3 gwei * 3 hours; + uint constant d = 2 gwei / 1 seconds + 3 minutes * 3 hours; } // ---- diff --git a/test/libsolidity/syntaxTests/denominations/finney_invalid.sol b/test/libsolidity/syntaxTests/denominations/finney_invalid.sol new file mode 100644 index 000000000..b7bae7fa7 --- /dev/null +++ b/test/libsolidity/syntaxTests/denominations/finney_invalid.sol @@ -0,0 +1,7 @@ +contract C { + function f() { + uint x = 1 finney; + } +} +// ---- +// ParserError 2314: (45-51): Expected ';' but got identifier diff --git a/test/libsolidity/syntaxTests/denominations/gwei.sol b/test/libsolidity/syntaxTests/denominations/gwei.sol deleted file mode 100644 index 5bc5edb3d..000000000 --- a/test/libsolidity/syntaxTests/denominations/gwei.sol +++ /dev/null @@ -1,3 +0,0 @@ -contract C { - uint constant gwei = 1 gwei; -} diff --git a/test/libsolidity/syntaxTests/denominations/gwei_as_identifier.sol b/test/libsolidity/syntaxTests/denominations/gwei_as_identifier.sol new file mode 100644 index 000000000..43fde5ed7 --- /dev/null +++ b/test/libsolidity/syntaxTests/denominations/gwei_as_identifier.sol @@ -0,0 +1,5 @@ +contract C { + uint constant gwei = 1; +} +// ---- +// ParserError 2314: (28-32): Expected identifier but got 'gwei' diff --git a/test/libsolidity/syntaxTests/denominations/szabo_finney_identifiers.sol b/test/libsolidity/syntaxTests/denominations/szabo_finney_identifiers.sol new file mode 100644 index 000000000..8facd62d4 --- /dev/null +++ b/test/libsolidity/syntaxTests/denominations/szabo_finney_identifiers.sol @@ -0,0 +1,6 @@ +contract C { + function f(uint finney) public pure returns (uint szabo) { + // These used to be denominations. + szabo = finney; + } +} \ No newline at end of file diff --git a/test/libsolidity/syntaxTests/denominations/szabo_invalid.sol b/test/libsolidity/syntaxTests/denominations/szabo_invalid.sol new file mode 100644 index 000000000..d206830d5 --- /dev/null +++ b/test/libsolidity/syntaxTests/denominations/szabo_invalid.sol @@ -0,0 +1,7 @@ +contract C { + function f() { + uint x = 1 szabo; + } +} +// ---- +// ParserError 2314: (45-50): Expected ';' but got identifier diff --git a/test/libsolidity/syntaxTests/events/inheritance_adds_anonymous.sol b/test/libsolidity/syntaxTests/events/inheritance_adds_anonymous.sol new file mode 100644 index 000000000..0e92a88b9 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/inheritance_adds_anonymous.sol @@ -0,0 +1,8 @@ +contract A { + event X(); +} +contract B is A { + event X() anonymous; +} +// ---- +// DeclarationError 5883: (52-72): Event with same name and parameter types defined twice. diff --git a/test/libsolidity/syntaxTests/events/inheritance_adds_indexed.sol b/test/libsolidity/syntaxTests/events/inheritance_adds_indexed.sol new file mode 100644 index 000000000..f68a96ea9 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/inheritance_adds_indexed.sol @@ -0,0 +1,8 @@ +contract A { + event X(uint); +} +contract B is A { + event X(uint indexed); +} +// ---- +// DeclarationError 5883: (56-78): Event with same name and parameter types defined twice. diff --git a/test/libsolidity/syntaxTests/events/inheritance_adds_parameter.sol b/test/libsolidity/syntaxTests/events/inheritance_adds_parameter.sol new file mode 100644 index 000000000..d987570c3 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/inheritance_adds_parameter.sol @@ -0,0 +1,6 @@ +contract A { + event X(); +} +contract B is A { + event X(uint); +} \ No newline at end of file diff --git a/test/libsolidity/syntaxTests/events/inheritance_event_repeated.sol b/test/libsolidity/syntaxTests/events/inheritance_event_repeated.sol new file mode 100644 index 000000000..9c19ebb33 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/inheritance_event_repeated.sol @@ -0,0 +1,8 @@ +contract A { + event X(uint); +} +contract B is A { + event X(uint); +} +// ---- +// DeclarationError 5883: (56-70): Event with same name and parameter types defined twice. diff --git a/test/libsolidity/syntaxTests/events/inheritance_multi_parent.sol b/test/libsolidity/syntaxTests/events/inheritance_multi_parent.sol new file mode 100644 index 000000000..3724fc10c --- /dev/null +++ b/test/libsolidity/syntaxTests/events/inheritance_multi_parent.sol @@ -0,0 +1,10 @@ +contract A { + event X(uint, uint indexed); +} +contract B { + event X(uint, uint); +} +contract C is A, B { +} +// ---- +// DeclarationError 5883: (65-85): Event with same name and parameter types defined twice. diff --git a/test/libsolidity/syntaxTests/events/inheritance_removes_indexed.sol b/test/libsolidity/syntaxTests/events/inheritance_removes_indexed.sol new file mode 100644 index 000000000..6379618b1 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/inheritance_removes_indexed.sol @@ -0,0 +1,8 @@ +contract A { + event X(uint, uint indexed); +} +contract B is A { + event X(uint, uint); +} +// ---- +// DeclarationError 5883: (70-90): Event with same name and parameter types defined twice. diff --git a/test/libsolidity/syntaxTests/events/multiple_inheritance.sol b/test/libsolidity/syntaxTests/events/multiple_inheritance.sol new file mode 100644 index 000000000..2cc158f77 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/multiple_inheritance.sol @@ -0,0 +1,4 @@ +contract A { event X(uint); } +contract B is A {} +contract C is A {} +contract D is B, C {} diff --git a/test/libsolidity/syntaxTests/events/overloading_in_contract.sol b/test/libsolidity/syntaxTests/events/overloading_in_contract.sol new file mode 100644 index 000000000..9349f1751 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/overloading_in_contract.sol @@ -0,0 +1,5 @@ +contract A { + event X(); + event X(uint); +} +// ---- \ No newline at end of file diff --git a/test/libsolidity/syntaxTests/functionCalls/calloptions_repeated.sol b/test/libsolidity/syntaxTests/functionCalls/calloptions_repeated.sol index 4a96e088a..8185304d1 100644 --- a/test/libsolidity/syntaxTests/functionCalls/calloptions_repeated.sol +++ b/test/libsolidity/syntaxTests/functionCalls/calloptions_repeated.sol @@ -4,7 +4,6 @@ contract C { this.foo{value:2, gas: 5}{gas:2}; (this.foo{value:2, gas: 5}){gas:2}; this.foo{value:2, gas: 5}{value:6}; - this.foo.value(4){value:2, gas: 5}; this.foo{gas:2, value: 5}{value:2, gas:5}; new D{salt:"abc"}{salt:"a"}(); } @@ -15,8 +14,6 @@ contract C { // TypeError 9886: (78-110): Option "gas" has already been set. // TypeError 9886: (120-154): Option "gas" has already been set. // TypeError 9886: (164-198): Option "value" has already been set. -// Warning 1621: (208-222): Using ".value(...)" is deprecated. Use "{value: ...}" instead. -// TypeError 9886: (208-242): Option "value" has already been set. -// TypeError 9886: (252-293): Option "value" has already been set. -// TypeError 9886: (252-293): Option "gas" has already been set. -// TypeError 9886: (303-330): Option "salt" has already been set. +// TypeError 9886: (208-249): Option "value" has already been set. +// TypeError 9886: (208-249): Option "gas" has already been set. +// TypeError 9886: (259-286): Option "salt" has already been set. diff --git a/test/libsolidity/syntaxTests/functionCalls/int_not_callable.sol b/test/libsolidity/syntaxTests/functionCalls/int_not_callable.sol index feb4a9ed0..5c7260f36 100644 --- a/test/libsolidity/syntaxTests/functionCalls/int_not_callable.sol +++ b/test/libsolidity/syntaxTests/functionCalls/int_not_callable.sol @@ -1,8 +1,8 @@ contract C { function f ( ) public { - var i = ( ( 1 ( 3 ) ) , 2 ); + ( ( 1 ( 3 ) ) , 2 ); } } // ---- -// TypeError 5704: (61-68): Type is not callable +// TypeError 5704: (53-60): Type is not callable diff --git a/test/libsolidity/syntaxTests/functionCalls/new_with_calloptions.sol b/test/libsolidity/syntaxTests/functionCalls/new_with_calloptions.sol index 5f961fbb9..173bfc545 100644 --- a/test/libsolidity/syntaxTests/functionCalls/new_with_calloptions.sol +++ b/test/libsolidity/syntaxTests/functionCalls/new_with_calloptions.sol @@ -1,4 +1,4 @@ -contract D { constructor() public payable {} } +contract D { constructor() payable {} } contract C { function foo() pure internal { new D{salt:"abc", value:3}; diff --git a/test/libsolidity/syntaxTests/functionCalls/new_with_calloptions_unsupported.sol b/test/libsolidity/syntaxTests/functionCalls/new_with_calloptions_unsupported.sol index 5fd802c0a..89ec2b110 100644 --- a/test/libsolidity/syntaxTests/functionCalls/new_with_calloptions_unsupported.sol +++ b/test/libsolidity/syntaxTests/functionCalls/new_with_calloptions_unsupported.sol @@ -1,4 +1,4 @@ -contract D { constructor() public payable {} } +contract D { constructor() payable {} } contract C { function foo() pure internal { new D{salt:"abc", value:3}; @@ -10,6 +10,6 @@ contract C { // ==== // EVMVersion: address payable ) c ; uint [ 9 hours ** 16 ] d ; string s ; } @@ -14,4 +13,4 @@ contract C { } } // ---- -// TypeError 1534: (530-540): Type too large for memory. +// TypeError 1534: (474-484): Type too large for memory. diff --git a/test/libsolidity/syntaxTests/iceRegressionTests/memory_mapping_array.sol b/test/libsolidity/syntaxTests/iceRegressionTests/memory_mapping_array.sol index dda35f8ce..aa1f63e4c 100644 --- a/test/libsolidity/syntaxTests/iceRegressionTests/memory_mapping_array.sol +++ b/test/libsolidity/syntaxTests/iceRegressionTests/memory_mapping_array.sol @@ -4,4 +4,4 @@ } } // ---- -// TypeError 6651: (91-136): Data location must be "storage" for variable, but "memory" was given. +// TypeError 4061: (91-136): Type mapping(string => uint24)[1] is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/iceRegressionTests/oversized_var.sol b/test/libsolidity/syntaxTests/iceRegressionTests/oversized_var.sol index 45e2779c5..15118322f 100644 --- a/test/libsolidity/syntaxTests/iceRegressionTests/oversized_var.sol +++ b/test/libsolidity/syntaxTests/iceRegressionTests/oversized_var.sol @@ -4,12 +4,11 @@ contract b { } c d; - function e() public { - var d = d; + function e() public view { + c storage x = d; + x.a[0]; } } // ---- -// Warning 2519: (105-110): This declaration shadows an existing declaration. // Warning 3408: (66-69): Variable "d" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. -// Warning 2332: (105-110): Type "b.c" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. -// SyntaxError 1719: (105-114): Use of the "var" keyword is disallowed. Use explicit declaration `struct b.c storage pointer d = ...` instead. +// Warning 2332: (110-111): Type "b.c" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. diff --git a/test/libsolidity/syntaxTests/iceRegressionTests/recursive_struct_memory.sol b/test/libsolidity/syntaxTests/iceRegressionTests/recursive_struct_memory.sol index aa79246c4..892cfdd8d 100644 --- a/test/libsolidity/syntaxTests/iceRegressionTests/recursive_struct_memory.sol +++ b/test/libsolidity/syntaxTests/iceRegressionTests/recursive_struct_memory.sol @@ -11,3 +11,4 @@ contract Test { } // ---- // DeclarationError 2333: (157-198): Identifier already declared. +// TypeError 4061: (268-300): Type struct Test.RecursiveStruct[1] is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/immutable/conditional_return_uninitialized.sol b/test/libsolidity/syntaxTests/immutable/conditional_return_uninitialized.sol index ec9591d70..77e73c51f 100644 --- a/test/libsolidity/syntaxTests/immutable/conditional_return_uninitialized.sol +++ b/test/libsolidity/syntaxTests/immutable/conditional_return_uninitialized.sol @@ -1,6 +1,6 @@ contract C { uint immutable x; - constructor() public { + constructor() { if (false) return; @@ -8,4 +8,4 @@ contract C { } } // ---- -// TypeError 2658: (93-100): Construction control flow ends without initializing all immutable state variables. +// TypeError 2658: (86-93): Construction control flow ends without initializing all immutable state variables. diff --git a/test/libsolidity/syntaxTests/immutable/conditionally_initialized.sol b/test/libsolidity/syntaxTests/immutable/conditionally_initialized.sol index 85c82cd44..b4808b844 100644 --- a/test/libsolidity/syntaxTests/immutable/conditionally_initialized.sol +++ b/test/libsolidity/syntaxTests/immutable/conditionally_initialized.sol @@ -1,9 +1,9 @@ contract C { uint immutable x; - constructor() public { + constructor() { if (false) x = 1; } } // ---- -// TypeError 4599: (93-94): Immutable variables must be initialized unconditionally, not in an if statement. +// TypeError 4599: (86-87): Immutable variables must be initialized unconditionally, not in an if statement. diff --git a/test/libsolidity/syntaxTests/immutable/ctor_indirect_initialization.sol b/test/libsolidity/syntaxTests/immutable/ctor_indirect_initialization.sol index 47932f729..f91e98333 100644 --- a/test/libsolidity/syntaxTests/immutable/ctor_indirect_initialization.sol +++ b/test/libsolidity/syntaxTests/immutable/ctor_indirect_initialization.sol @@ -1,6 +1,6 @@ contract C { uint immutable x; - constructor() public { + constructor() { initX(); } @@ -9,4 +9,4 @@ contract C { } } // ---- -// TypeError 1581: (126-127): Immutable variables can only be initialized inline or assigned directly in the constructor. +// TypeError 1581: (119-120): Immutable variables can only be initialized inline or assigned directly in the constructor. diff --git a/test/libsolidity/syntaxTests/immutable/ctor_initialization_indirect_reading.sol b/test/libsolidity/syntaxTests/immutable/ctor_initialization_indirect_reading.sol index bbc01bb0e..509e0d311 100644 --- a/test/libsolidity/syntaxTests/immutable/ctor_initialization_indirect_reading.sol +++ b/test/libsolidity/syntaxTests/immutable/ctor_initialization_indirect_reading.sol @@ -1,10 +1,10 @@ contract C { uint immutable x; - constructor() public { + constructor() { x = f(); } function f() public pure returns (uint) { return 3 + x; } } // ---- -// TypeError 7733: (143-144): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. +// TypeError 7733: (136-137): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. diff --git a/test/libsolidity/syntaxTests/immutable/ctor_initialization_reading.sol b/test/libsolidity/syntaxTests/immutable/ctor_initialization_reading.sol index 66d8c2ead..9f944a890 100644 --- a/test/libsolidity/syntaxTests/immutable/ctor_initialization_reading.sol +++ b/test/libsolidity/syntaxTests/immutable/ctor_initialization_reading.sol @@ -1,8 +1,8 @@ contract C { uint immutable x; - constructor() public { + constructor() { x = 3 + x; } } // ---- -// TypeError 7733: (78-79): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. +// TypeError 7733: (71-72): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. diff --git a/test/libsolidity/syntaxTests/immutable/ctor_initialization_tuple.sol b/test/libsolidity/syntaxTests/immutable/ctor_initialization_tuple.sol index f3b724f03..86d995553 100644 --- a/test/libsolidity/syntaxTests/immutable/ctor_initialization_tuple.sol +++ b/test/libsolidity/syntaxTests/immutable/ctor_initialization_tuple.sol @@ -1,7 +1,7 @@ contract C { uint immutable x; uint immutable y; - constructor() public { + constructor() { (x, y) = f(); } diff --git a/test/libsolidity/syntaxTests/immutable/ctor_modifier_args.sol b/test/libsolidity/syntaxTests/immutable/ctor_modifier_args.sol index fd39a3c57..3f2461456 100644 --- a/test/libsolidity/syntaxTests/immutable/ctor_modifier_args.sol +++ b/test/libsolidity/syntaxTests/immutable/ctor_modifier_args.sol @@ -1,6 +1,6 @@ contract C { uint immutable x; - constructor() readX(x = 3) public { } + constructor() readX(x = 3) { } modifier readX(uint _x) { _; f(_x); diff --git a/test/libsolidity/syntaxTests/immutable/ctor_modifier_initialization.sol b/test/libsolidity/syntaxTests/immutable/ctor_modifier_initialization.sol index c5bfbae6d..14f47364a 100644 --- a/test/libsolidity/syntaxTests/immutable/ctor_modifier_initialization.sol +++ b/test/libsolidity/syntaxTests/immutable/ctor_modifier_initialization.sol @@ -1,6 +1,6 @@ contract C { uint immutable x; - constructor() initX public { + constructor() initX { } modifier initX() { @@ -8,4 +8,4 @@ contract C { } } // ---- -// TypeError 1581: (109-110): Immutable variables can only be initialized inline or assigned directly in the constructor. +// TypeError 1581: (102-103): Immutable variables can only be initialized inline or assigned directly in the constructor. diff --git a/test/libsolidity/syntaxTests/immutable/ctor_modifier_reading.sol b/test/libsolidity/syntaxTests/immutable/ctor_modifier_reading.sol index 8df31542a..61c13828d 100644 --- a/test/libsolidity/syntaxTests/immutable/ctor_modifier_reading.sol +++ b/test/libsolidity/syntaxTests/immutable/ctor_modifier_reading.sol @@ -1,6 +1,6 @@ contract C { uint immutable x; - constructor() readX public { + constructor() readX { x = 3; } @@ -11,4 +11,4 @@ contract C { function f(uint a) internal pure {} } // ---- -// TypeError 7733: (126-127): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. +// TypeError 7733: (119-120): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. diff --git a/test/libsolidity/syntaxTests/immutable/decrement.sol b/test/libsolidity/syntaxTests/immutable/decrement.sol index 8b604926b..3c34dd3b7 100644 --- a/test/libsolidity/syntaxTests/immutable/decrement.sol +++ b/test/libsolidity/syntaxTests/immutable/decrement.sol @@ -1,8 +1,8 @@ contract C { uint immutable x = 3; - constructor() public { + constructor() { x--; } } // ---- -// TypeError 7733: (74-75): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. +// TypeError 7733: (67-68): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. diff --git a/test/libsolidity/syntaxTests/immutable/delete.sol b/test/libsolidity/syntaxTests/immutable/delete.sol index a21c0cade..58e9235f3 100644 --- a/test/libsolidity/syntaxTests/immutable/delete.sol +++ b/test/libsolidity/syntaxTests/immutable/delete.sol @@ -1,8 +1,8 @@ contract C { uint immutable x = 3; - constructor() public { + constructor() { delete x; } } // ---- -// TypeError 7733: (81-82): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. +// TypeError 7733: (74-75): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. diff --git a/test/libsolidity/syntaxTests/immutable/function_pointer_initializing.sol b/test/libsolidity/syntaxTests/immutable/function_pointer_initializing.sol index 960048733..629d80f66 100644 --- a/test/libsolidity/syntaxTests/immutable/function_pointer_initializing.sol +++ b/test/libsolidity/syntaxTests/immutable/function_pointer_initializing.sol @@ -1,7 +1,7 @@ -contract B { +abstract contract B { uint immutable x; - constructor(function() internal returns(uint) fp) internal { + constructor(function() internal returns(uint) fp) { x = fp(); } } diff --git a/test/libsolidity/syntaxTests/immutable/function_pointer_reading.sol b/test/libsolidity/syntaxTests/immutable/function_pointer_reading.sol index f07d7ea42..10726cc04 100644 --- a/test/libsolidity/syntaxTests/immutable/function_pointer_reading.sol +++ b/test/libsolidity/syntaxTests/immutable/function_pointer_reading.sol @@ -1,7 +1,7 @@ -contract B { +abstract contract B { uint immutable x; - constructor(function() internal returns(uint) fp) internal { + constructor(function() internal returns(uint) fp) { x = fp(); } } diff --git a/test/libsolidity/syntaxTests/immutable/increment.sol b/test/libsolidity/syntaxTests/immutable/increment.sol index 8846e3d5b..00c20422c 100644 --- a/test/libsolidity/syntaxTests/immutable/increment.sol +++ b/test/libsolidity/syntaxTests/immutable/increment.sol @@ -1,8 +1,8 @@ contract C { uint immutable x = 3; - constructor() public { + constructor() { x++; } } // ---- -// TypeError 7733: (74-75): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. +// TypeError 7733: (67-68): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. diff --git a/test/libsolidity/syntaxTests/immutable/inheritance_ctor.sol b/test/libsolidity/syntaxTests/immutable/inheritance_ctor.sol index ee794fd37..3c15e7fa5 100644 --- a/test/libsolidity/syntaxTests/immutable/inheritance_ctor.sol +++ b/test/libsolidity/syntaxTests/immutable/inheritance_ctor.sol @@ -1,14 +1,14 @@ contract B { uint immutable x; - constructor() public { + constructor() { x = 3; } } contract C is B { uint immutable y; - constructor() public { + constructor() { y = 3; } } diff --git a/test/libsolidity/syntaxTests/immutable/inheritance_ctor_argument.sol b/test/libsolidity/syntaxTests/immutable/inheritance_ctor_argument.sol index 4ea84bcdd..695319378 100644 --- a/test/libsolidity/syntaxTests/immutable/inheritance_ctor_argument.sol +++ b/test/libsolidity/syntaxTests/immutable/inheritance_ctor_argument.sol @@ -1,14 +1,14 @@ contract B { uint immutable x; - constructor(uint _x) public { + constructor(uint _x) { x = _x; } } contract C is B { uint immutable y; - constructor() B(y = 3) public { } + constructor() B(y = 3) { } } // ---- -// TypeError 1581: (155-156): Immutable variables can only be initialized inline or assigned directly in the constructor. +// TypeError 1581: (148-149): Immutable variables can only be initialized inline or assigned directly in the constructor. diff --git a/test/libsolidity/syntaxTests/immutable/inheritance_ctor_inherit_specifier_argument_init.sol b/test/libsolidity/syntaxTests/immutable/inheritance_ctor_inherit_specifier_argument_init.sol index b75707c34..8e3d67145 100644 --- a/test/libsolidity/syntaxTests/immutable/inheritance_ctor_inherit_specifier_argument_init.sol +++ b/test/libsolidity/syntaxTests/immutable/inheritance_ctor_inherit_specifier_argument_init.sol @@ -1,7 +1,7 @@ contract B { uint immutable x; - constructor(uint _x) public { + constructor(uint _x) { x = _x; } } @@ -10,4 +10,4 @@ contract C is B(C.y = 3) { uint immutable y; } // ---- -// TypeError 1581: (111-114): Immutable variables can only be initialized inline or assigned directly in the constructor. +// TypeError 1581: (104-107): Immutable variables can only be initialized inline or assigned directly in the constructor. diff --git a/test/libsolidity/syntaxTests/immutable/inheritance_ctor_inherit_specifier_argument_reading.sol b/test/libsolidity/syntaxTests/immutable/inheritance_ctor_inherit_specifier_argument_reading.sol index 0c387a78f..4b4780452 100644 --- a/test/libsolidity/syntaxTests/immutable/inheritance_ctor_inherit_specifier_argument_reading.sol +++ b/test/libsolidity/syntaxTests/immutable/inheritance_ctor_inherit_specifier_argument_reading.sol @@ -1,16 +1,16 @@ contract B { uint immutable x; - constructor(uint _x) public { + constructor(uint _x) { x = _x; } } contract C is B(C.y) { uint immutable y; - constructor() public { + constructor() { y = 3; } } // ---- -// TypeError 7733: (111-114): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. +// TypeError 7733: (104-107): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. diff --git a/test/libsolidity/syntaxTests/immutable/inheritance_virtual_functions.sol b/test/libsolidity/syntaxTests/immutable/inheritance_virtual_functions.sol index bc6d5e703..a241ee84c 100644 --- a/test/libsolidity/syntaxTests/immutable/inheritance_virtual_functions.sol +++ b/test/libsolidity/syntaxTests/immutable/inheritance_virtual_functions.sol @@ -1,7 +1,7 @@ contract B { uint immutable x; - constructor() public { + constructor() { x = xInit(); } @@ -16,4 +16,4 @@ contract C is B { } } // ---- -// TypeError 7733: (260-261): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. +// TypeError 7733: (253-254): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. diff --git a/test/libsolidity/syntaxTests/immutable/inheritance_virtual_functions_direct_call.sol b/test/libsolidity/syntaxTests/immutable/inheritance_virtual_functions_direct_call.sol index 98daf6f3e..7dfd75d52 100644 --- a/test/libsolidity/syntaxTests/immutable/inheritance_virtual_functions_direct_call.sol +++ b/test/libsolidity/syntaxTests/immutable/inheritance_virtual_functions_direct_call.sol @@ -7,7 +7,7 @@ contract B { } contract C is B { - constructor() public { + constructor() { B.readX; } diff --git a/test/libsolidity/syntaxTests/immutable/inheritance_virtual_functions_super.sol b/test/libsolidity/syntaxTests/immutable/inheritance_virtual_functions_super.sol index 45e819bc1..4782e7702 100644 --- a/test/libsolidity/syntaxTests/immutable/inheritance_virtual_functions_super.sol +++ b/test/libsolidity/syntaxTests/immutable/inheritance_virtual_functions_super.sol @@ -7,7 +7,7 @@ contract B { } contract C is B { - constructor() public { + constructor() { super.readX(); } diff --git a/test/libsolidity/syntaxTests/immutable/inheritance_virtual_modifiers.sol b/test/libsolidity/syntaxTests/immutable/inheritance_virtual_modifiers.sol index 0d6bb3615..3f4eba73e 100644 --- a/test/libsolidity/syntaxTests/immutable/inheritance_virtual_modifiers.sol +++ b/test/libsolidity/syntaxTests/immutable/inheritance_virtual_modifiers.sol @@ -1,7 +1,7 @@ contract B { uint immutable x; - constructor() readX public { + constructor() readX { x = 3; } @@ -18,4 +18,4 @@ contract C is B { } } // ---- -// TypeError 7733: (252-253): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. +// TypeError 7733: (245-246): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. diff --git a/test/libsolidity/syntaxTests/immutable/inheritance_wrong_ctor.sol b/test/libsolidity/syntaxTests/immutable/inheritance_wrong_ctor.sol index 3789389e4..4f431474b 100644 --- a/test/libsolidity/syntaxTests/immutable/inheritance_wrong_ctor.sol +++ b/test/libsolidity/syntaxTests/immutable/inheritance_wrong_ctor.sol @@ -3,10 +3,10 @@ contract B { } contract C is B { - constructor() public { + constructor() { x = 3; } } // ---- -// TypeError 7484: (95-96): Immutable variables must be initialized in the constructor of the contract they are defined in. -// TypeError 1574: (95-96): Immutable state variable already initialized. +// TypeError 7484: (88-89): Immutable variables must be initialized in the constructor of the contract they are defined in. +// TypeError 1574: (88-89): Immutable state variable already initialized. diff --git a/test/libsolidity/syntaxTests/immutable/initialized_after_ctor.sol b/test/libsolidity/syntaxTests/immutable/initialized_after_ctor.sol index a6db6a665..a9fe45f1b 100644 --- a/test/libsolidity/syntaxTests/immutable/initialized_after_ctor.sol +++ b/test/libsolidity/syntaxTests/immutable/initialized_after_ctor.sol @@ -1,5 +1,5 @@ contract C { - constructor() public { + constructor() { return; } diff --git a/test/libsolidity/syntaxTests/immutable/loop_initialized.sol b/test/libsolidity/syntaxTests/immutable/loop_initialized.sol index ca1f13250..b831f0f0b 100644 --- a/test/libsolidity/syntaxTests/immutable/loop_initialized.sol +++ b/test/libsolidity/syntaxTests/immutable/loop_initialized.sol @@ -1,9 +1,9 @@ contract C { uint immutable x; - constructor() public { + constructor() { while (true) x = 1; } } // ---- -// TypeError 6672: (95-96): Immutable variables can only be initialized once, not in a while statement. +// TypeError 6672: (88-89): Immutable variables can only be initialized once, not in a while statement. diff --git a/test/libsolidity/syntaxTests/immutable/multiple_inheritance_virtual_functions.sol b/test/libsolidity/syntaxTests/immutable/multiple_inheritance_virtual_functions.sol index d7636a1b9..36363159c 100644 --- a/test/libsolidity/syntaxTests/immutable/multiple_inheritance_virtual_functions.sol +++ b/test/libsolidity/syntaxTests/immutable/multiple_inheritance_virtual_functions.sol @@ -5,7 +5,7 @@ contract A { contract B { uint immutable x; - constructor() public { + constructor() { x = xInit(); } @@ -26,4 +26,4 @@ contract C is A, B { } } // ---- -// TypeError 7733: (496-497): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. +// TypeError 7733: (489-490): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. diff --git a/test/libsolidity/syntaxTests/immutable/multiple_inheritance_virtual_functions_with_super.sol b/test/libsolidity/syntaxTests/immutable/multiple_inheritance_virtual_functions_with_super.sol index 7f8c4adad..e97e72b44 100644 --- a/test/libsolidity/syntaxTests/immutable/multiple_inheritance_virtual_functions_with_super.sol +++ b/test/libsolidity/syntaxTests/immutable/multiple_inheritance_virtual_functions_with_super.sol @@ -5,7 +5,7 @@ contract A { contract B { uint immutable x; - constructor() public { + constructor() { x = xInit(); } @@ -26,4 +26,4 @@ contract C is A, B { } } // ---- -// TypeError 7733: (500-501): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. +// TypeError 7733: (493-494): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. diff --git a/test/libsolidity/syntaxTests/immutable/multiple_initializations.sol b/test/libsolidity/syntaxTests/immutable/multiple_initializations.sol index 66bb10974..93e01db30 100644 --- a/test/libsolidity/syntaxTests/immutable/multiple_initializations.sol +++ b/test/libsolidity/syntaxTests/immutable/multiple_initializations.sol @@ -1,9 +1,9 @@ contract C { uint immutable x; - constructor() public { + constructor() { x = 1; x = 4; } } // ---- -// TypeError 1574: (85-86): Immutable state variable already initialized. +// TypeError 1574: (78-79): Immutable state variable already initialized. diff --git a/test/libsolidity/syntaxTests/immutable/private_state_var.sol b/test/libsolidity/syntaxTests/immutable/private_state_var.sol index 46c7a7b04..6e9ae734a 100644 --- a/test/libsolidity/syntaxTests/immutable/private_state_var.sol +++ b/test/libsolidity/syntaxTests/immutable/private_state_var.sol @@ -1,7 +1,7 @@ contract B { uint immutable private x = f(); - constructor() public { + constructor() { } function f() internal view virtual returns(uint) { return 1; } @@ -10,11 +10,11 @@ contract B { contract C is B { uint immutable y; - constructor() public { + constructor() { y = 3; } function f() internal view override returns(uint) { return readX(); } } // ---- -// TypeError 7733: (209-210): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. +// TypeError 7733: (202-203): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it. diff --git a/test/libsolidity/syntaxTests/immutable/return_uninitialized.sol b/test/libsolidity/syntaxTests/immutable/return_uninitialized.sol index abe9d8d0a..852b5d350 100644 --- a/test/libsolidity/syntaxTests/immutable/return_uninitialized.sol +++ b/test/libsolidity/syntaxTests/immutable/return_uninitialized.sol @@ -1,10 +1,10 @@ contract C { uint immutable x; - constructor() public { + constructor() { return; x = 1; } } // ---- -// TypeError 2658: (70-77): Construction control flow ends without initializing all immutable state variables. +// TypeError 2658: (63-70): Construction control flow ends without initializing all immutable state variables. diff --git a/test/libsolidity/syntaxTests/immutable/selector.sol b/test/libsolidity/syntaxTests/immutable/selector.sol index db9647b67..01bf91e23 100644 --- a/test/libsolidity/syntaxTests/immutable/selector.sol +++ b/test/libsolidity/syntaxTests/immutable/selector.sol @@ -1,6 +1,6 @@ contract C { uint immutable x; - constructor() public { + constructor() { x = 3; this.readX.selector; } @@ -8,5 +8,5 @@ contract C { function readX() external view returns(uint) { return x; } } // ---- -// Warning 6133: (85-104): Statement has no effect. -// Warning 5805: (85-89): "this" used in constructor. Note that external functions of a contract cannot be called while it is being constructed. +// Warning 6133: (78-97): Statement has no effect. +// Warning 5805: (78-82): "this" used in constructor. Note that external functions of a contract cannot be called while it is being constructed. diff --git a/test/libsolidity/syntaxTests/immutable/selector_function_name.sol b/test/libsolidity/syntaxTests/immutable/selector_function_name.sol index c5ffb6e9e..19e45d06e 100644 --- a/test/libsolidity/syntaxTests/immutable/selector_function_name.sol +++ b/test/libsolidity/syntaxTests/immutable/selector_function_name.sol @@ -1,6 +1,6 @@ contract C { uint immutable x; - constructor() public { + constructor() { x = 3; C.selector.selector; C.selector; @@ -9,5 +9,5 @@ contract C { function selector() external view returns(uint) { return x; } } // ---- -// Warning 6133: (85-104): Statement has no effect. -// Warning 6133: (114-124): Statement has no effect. +// Warning 6133: (78-97): Statement has no effect. +// Warning 6133: (107-117): Statement has no effect. diff --git a/test/libsolidity/syntaxTests/immutable/selector_function_pointer.sol b/test/libsolidity/syntaxTests/immutable/selector_function_pointer.sol index a8b91a639..5e6232279 100644 --- a/test/libsolidity/syntaxTests/immutable/selector_function_pointer.sol +++ b/test/libsolidity/syntaxTests/immutable/selector_function_pointer.sol @@ -1,6 +1,6 @@ contract C { uint immutable x; - constructor() public { + constructor() { x = 3; readX().selector; } diff --git a/test/libsolidity/syntaxTests/immutable/uninitialized_private_state_var.sol b/test/libsolidity/syntaxTests/immutable/uninitialized_private_state_var.sol index 305501369..544111e4c 100644 --- a/test/libsolidity/syntaxTests/immutable/uninitialized_private_state_var.sol +++ b/test/libsolidity/syntaxTests/immutable/uninitialized_private_state_var.sol @@ -1,7 +1,7 @@ contract B { uint immutable private x; - constructor() public { + constructor() { } function f() internal view virtual returns(uint) { return 1; } @@ -10,12 +10,12 @@ contract B { contract C is B { uint immutable y; - constructor() public { + constructor() { y = 3; } function f() internal view override returns(uint) { return readX(); } } // ---- -// TypeError 2658: (0-209): Construction control flow ends without initializing all immutable state variables. -// TypeError 2658: (211-375): Construction control flow ends without initializing all immutable state variables. +// TypeError 2658: (0-202): Construction control flow ends without initializing all immutable state variables. +// TypeError 2658: (204-361): Construction control flow ends without initializing all immutable state variables. diff --git a/test/libsolidity/syntaxTests/inheritance/allow_empty_duplicated_super_constructor_call.sol b/test/libsolidity/syntaxTests/inheritance/allow_empty_duplicated_super_constructor_call.sol index ce9d5f5fc..2590e7271 100644 --- a/test/libsolidity/syntaxTests/inheritance/allow_empty_duplicated_super_constructor_call.sol +++ b/test/libsolidity/syntaxTests/inheritance/allow_empty_duplicated_super_constructor_call.sol @@ -1,2 +1,2 @@ -contract A { constructor() public { } } -contract B is A { constructor() A() public { } } +contract A { constructor() { } } +contract B is A { constructor() A() { } } diff --git a/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol b/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol index e1072e47d..422ee9080 100644 --- a/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol +++ b/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol @@ -1,7 +1,7 @@ contract Base { - constructor(uint) public {} + constructor(uint) {} } contract Derived is Base(2) { } contract Derived2 is Base(), Derived() { } // ---- -// TypeError 7927: (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. +// TypeError 7927: (94-100): 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_multiple_inheritance.sol b/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol index 16c936b3e..3824b74b9 100644 --- a/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol +++ b/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol @@ -1,9 +1,9 @@ contract Base { - constructor(uint) public { } + constructor(uint) { } } contract Base1 is Base(3) {} contract Derived is Base, Base1 { - constructor(uint i) Base(i) public {} + constructor(uint i) Base(i) {} } // ---- -// DeclarationError 3364: (138-145): Base constructor arguments given twice. +// DeclarationError 3364: (131-138): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/base_arguments_no_parentheses.sol b/test/libsolidity/syntaxTests/inheritance/base_arguments_no_parentheses.sol index 24cca8f0b..6752420b8 100644 --- a/test/libsolidity/syntaxTests/inheritance/base_arguments_no_parentheses.sol +++ b/test/libsolidity/syntaxTests/inheritance/base_arguments_no_parentheses.sol @@ -1,5 +1,5 @@ contract Base { - constructor(uint) public {} + constructor(uint) {} } contract Derived is Base(2) { } contract Derived2 is Base, Derived {} diff --git a/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol b/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol index 15d4e7142..2f2801e5f 100644 --- a/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol +++ b/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol @@ -1,4 +1,4 @@ -contract A { constructor() public { } } -contract B is A { constructor() A public { } } +contract A { constructor() { } } +contract B is A { constructor() A { } } // ---- -// DeclarationError 1563: (72-73): Modifier-style base constructor call without arguments. +// DeclarationError 1563: (65-66): Modifier-style base constructor call without arguments. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol index 48d626927..0cab1a1eb 100644 --- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol @@ -1,5 +1,5 @@ -contract A { constructor(uint) public { } } -contract B is A(2) { constructor() public { } } -contract C is B { constructor() A(3) public { } } +contract A { constructor(uint) { } } +contract B is A(2) { constructor() { } } +contract C is B { constructor() A(3) { } } // ---- -// DeclarationError 3364: (125-129): Base constructor arguments given twice. +// DeclarationError 3364: (111-115): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol index 8986854b1..ca1e839b5 100644 --- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol @@ -1,4 +1,4 @@ -contract A { constructor(uint) public { } } -contract B is A(2) { constructor() A(3) public { } } +contract A { constructor(uint) { } } +contract B is A(2) { constructor() A(3) { } } // ---- -// DeclarationError 3364: (79-83): Base constructor arguments given twice. +// DeclarationError 3364: (72-76): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol index 217dd2175..f7a655b9f 100644 --- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol @@ -1,7 +1,7 @@ -contract C { constructor(uint) public {} } +contract C { constructor(uint) {} } contract A is C(2) {} contract B is C(2) {} -contract D is A, B { constructor() C(3) public {} } +contract D is A, B { constructor() C(3) {} } // ---- -// DeclarationError 3364: (122-126): Base constructor arguments given twice. -// DeclarationError 3364: (122-126): Base constructor arguments given twice. +// DeclarationError 3364: (115-119): Base constructor arguments given twice. +// DeclarationError 3364: (115-119): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol index 3d0e01eb5..09a1593f7 100644 --- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol @@ -1,6 +1,6 @@ -contract C { constructor(uint) public {} } +contract C { constructor(uint) {} } contract A is C(2) {} contract B is C(2) {} contract D is A, B {} // ---- -// DeclarationError 3364: (87-108): Base constructor arguments given twice. +// DeclarationError 3364: (80-101): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol index e03ba8d63..0b29661d0 100644 --- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol @@ -1,6 +1,6 @@ -contract C { constructor(uint) public {} } -contract A is C { constructor() C(2) public {} } -contract B is C { constructor() C(2) public {} } +contract C { constructor(uint) {} } +contract A is C { constructor() C(2) {} } +contract B is C { constructor() C(2) {} } contract D is A, B { } // ---- -// DeclarationError 3364: (141-163): Base constructor arguments given twice. +// DeclarationError 3364: (120-142): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/interface/diamond/diamond_no_relist.sol b/test/libsolidity/syntaxTests/inheritance/interface/diamond/diamond_no_relist.sol index 5d525fde4..23b98f2c9 100644 --- a/test/libsolidity/syntaxTests/inheritance/interface/diamond/diamond_no_relist.sol +++ b/test/libsolidity/syntaxTests/inheritance/interface/diamond/diamond_no_relist.sol @@ -1,10 +1,10 @@ interface Parent { - function test() external returns (uint256); + function test() external pure returns (uint256); } interface SubA is Parent {} interface SubB is Parent {} contract C is SubA, SubB { - function test() external override returns (uint256) { return 42; } + function test() external override pure returns (uint256) { return 42; } } diff --git a/test/libsolidity/syntaxTests/inheritance/interface/diamond/diamond_with_relist.sol b/test/libsolidity/syntaxTests/inheritance/interface/diamond/diamond_with_relist.sol index 30ee63cc7..ecffe019e 100644 --- a/test/libsolidity/syntaxTests/inheritance/interface/diamond/diamond_with_relist.sol +++ b/test/libsolidity/syntaxTests/inheritance/interface/diamond/diamond_with_relist.sol @@ -1,15 +1,15 @@ interface Parent { - function test() external returns (uint256); + function test() external pure returns (uint256); } interface SubA is Parent { - function test() external override returns (uint256); + function test() external pure override returns (uint256); } interface SubB is Parent { - function test() external override returns (uint256); + function test() external pure override returns (uint256); } contract C is SubA, SubB { - function test() external override(SubA, SubB) returns (uint256) { return 42; } + function test() external pure override(SubA, SubB) returns (uint256) { return 42; } } diff --git a/test/libsolidity/syntaxTests/inheritance/interface/implementation/complete.sol b/test/libsolidity/syntaxTests/inheritance/interface/implementation/complete.sol index 09334dafc..acdd01200 100644 --- a/test/libsolidity/syntaxTests/inheritance/interface/implementation/complete.sol +++ b/test/libsolidity/syntaxTests/inheritance/interface/implementation/complete.sol @@ -1,17 +1,17 @@ interface ParentA { - function testA() external returns (uint256); + function testA() external pure returns (uint256); } interface ParentB { - function testB() external returns (uint256); + function testB() external pure returns (uint256); } interface Sub is ParentA, ParentB { - function testSub() external returns (uint256); + function testSub() external pure returns (uint256); } contract SubImpl is Sub { - function testA() external override returns (uint256) { return 12; } - function testB() external override(ParentB) returns (uint256) { return 42; } - function testSub() external override returns (uint256) { return 99; } + function testA() external pure override returns (uint256) { return 12; } + function testB() external pure override(ParentB) returns (uint256) { return 42; } + function testSub() external pure override returns (uint256) { return 99; } } diff --git a/test/libsolidity/syntaxTests/inheritance/modifiers_in_constructor_context.sol b/test/libsolidity/syntaxTests/inheritance/modifiers_in_constructor_context.sol index d8ce0e488..db62d4e42 100644 --- a/test/libsolidity/syntaxTests/inheritance/modifiers_in_constructor_context.sol +++ b/test/libsolidity/syntaxTests/inheritance/modifiers_in_constructor_context.sol @@ -1,9 +1,9 @@ // This generated an invalid warning on m1 in some compiler versions. contract A { - constructor() m1 public { } + constructor() m1 { } modifier m1 { _; } } contract B is A { modifier m2 { _; } - constructor() A() m1 m2 public { } + constructor() A() m1 m2 { } } diff --git a/test/libsolidity/syntaxTests/inheritance/override/add_view.sol b/test/libsolidity/syntaxTests/inheritance/override/add_view.sol index 14c6297c3..508678514 100644 --- a/test/libsolidity/syntaxTests/inheritance/override/add_view.sol +++ b/test/libsolidity/syntaxTests/inheritance/override/add_view.sol @@ -1,5 +1,3 @@ contract B { function f() virtual public {} } -contract C is B { function f() public view {} } +contract C is B { function f() override public view {} } // ---- -// TypeError 9456: (64-91): Overriding function is missing "override" specifier. -// TypeError 6959: (64-91): Overriding function changes state mutability from "nonpayable" to "view". diff --git a/test/libsolidity/syntaxTests/inheritance/override/diamond_top_implemented_intermediate_empty_bottom_public_state_variable.sol b/test/libsolidity/syntaxTests/inheritance/override/diamond_top_implemented_intermediate_empty_bottom_public_state_variable.sol index 3af8fd6e1..61c159b08 100644 --- a/test/libsolidity/syntaxTests/inheritance/override/diamond_top_implemented_intermediate_empty_bottom_public_state_variable.sol +++ b/test/libsolidity/syntaxTests/inheritance/override/diamond_top_implemented_intermediate_empty_bottom_public_state_variable.sol @@ -1,5 +1,5 @@ contract I { - function f() external pure virtual returns (uint) { return 1; } + function f() external view virtual returns (uint) { return 1; } } contract A is I { @@ -11,3 +11,4 @@ contract C is A, B { uint public override f; } +// ---- diff --git a/test/libsolidity/syntaxTests/inheritance/override/diamond_top_implemented_intermediate_implemented_public_state_variable.sol b/test/libsolidity/syntaxTests/inheritance/override/diamond_top_implemented_intermediate_implemented_public_state_variable.sol index d59dade35..392b6640b 100644 --- a/test/libsolidity/syntaxTests/inheritance/override/diamond_top_implemented_intermediate_implemented_public_state_variable.sol +++ b/test/libsolidity/syntaxTests/inheritance/override/diamond_top_implemented_intermediate_implemented_public_state_variable.sol @@ -1,5 +1,5 @@ contract I { - function f() external pure virtual returns (uint) { return 1; } + function f() external view virtual returns (uint) { return 1; } } contract A is I { diff --git a/test/libsolidity/syntaxTests/inheritance/override/diamond_top_implemented_intermediate_public_state_variable.sol b/test/libsolidity/syntaxTests/inheritance/override/diamond_top_implemented_intermediate_public_state_variable.sol index 390e763e8..5e7052a62 100644 --- a/test/libsolidity/syntaxTests/inheritance/override/diamond_top_implemented_intermediate_public_state_variable.sol +++ b/test/libsolidity/syntaxTests/inheritance/override/diamond_top_implemented_intermediate_public_state_variable.sol @@ -1,5 +1,5 @@ contract I { - function f() external pure virtual returns (uint) { return 1; } + function f() external view virtual returns (uint) { return 1; } } contract A is I { diff --git a/test/libsolidity/syntaxTests/inheritance/override/implement_interface_by_public_variable.sol b/test/libsolidity/syntaxTests/inheritance/override/implement_interface_by_public_variable.sol index 781d72a12..917277898 100644 --- a/test/libsolidity/syntaxTests/inheritance/override/implement_interface_by_public_variable.sol +++ b/test/libsolidity/syntaxTests/inheritance/override/implement_interface_by_public_variable.sol @@ -3,5 +3,5 @@ contract Y is X { uint256 public override test = 42; } contract T { - constructor() public { new Y(); } + constructor() { new Y(); } } diff --git a/test/libsolidity/syntaxTests/inheritance/override/implement_internal_function_by_public_variable.sol b/test/libsolidity/syntaxTests/inheritance/override/implement_internal_function_by_public_variable.sol index c7602dfee..9bdfdeb7b 100644 --- a/test/libsolidity/syntaxTests/inheritance/override/implement_internal_function_by_public_variable.sol +++ b/test/libsolidity/syntaxTests/inheritance/override/implement_internal_function_by_public_variable.sol @@ -3,7 +3,7 @@ contract Y is X { uint256 public override test = 42; } contract T { - constructor() public { new Y(); } + constructor() { new Y(); } } // ---- // TypeError 5225: (98-131): Public state variables can only override functions with external visibility. diff --git a/test/libsolidity/syntaxTests/inheritance/override/implement_private_function_by_public_variable.sol b/test/libsolidity/syntaxTests/inheritance/override/implement_private_function_by_public_variable.sol index 99798028d..f78403d15 100644 --- a/test/libsolidity/syntaxTests/inheritance/override/implement_private_function_by_public_variable.sol +++ b/test/libsolidity/syntaxTests/inheritance/override/implement_private_function_by_public_variable.sol @@ -3,7 +3,7 @@ contract Y is X { uint256 public override test = 42; } contract T { - constructor() public { new Y(); } + constructor() { new Y(); } } // ---- // TypeError 5225: (97-130): Public state variables can only override functions with external visibility. diff --git a/test/libsolidity/syntaxTests/inheritance/override/implement_public_function_by_public_variable.sol b/test/libsolidity/syntaxTests/inheritance/override/implement_public_function_by_public_variable.sol index a0c689078..c4e1b4ece 100644 --- a/test/libsolidity/syntaxTests/inheritance/override/implement_public_function_by_public_variable.sol +++ b/test/libsolidity/syntaxTests/inheritance/override/implement_public_function_by_public_variable.sol @@ -3,6 +3,6 @@ contract Y is X { uint256 public override test = 42; } contract T { - constructor() public { new Y(); } + constructor() { new Y(); } } // ---- diff --git a/test/libsolidity/syntaxTests/inheritance/override/override_less_strict_mutability.sol b/test/libsolidity/syntaxTests/inheritance/override/override_less_strict_mutability.sol new file mode 100644 index 000000000..4bf72532c --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/override_less_strict_mutability.sol @@ -0,0 +1,24 @@ +contract A { + function foo() external pure virtual returns (uint256) {} +} +contract B is A { + function foo() external pure override virtual returns (uint256) {} +} +contract C is A { + function foo() external view override virtual returns (uint256) {} +} +contract D is B, C { + function foo() external override(B, C) virtual returns (uint256) {} +} +contract E is C, B { + function foo() external pure override(B, C) virtual returns (uint256) {} +} +contract F is C, B { + function foo() external payable override(B, C) virtual returns (uint256) {} +} +// ---- +// TypeError 6959: (181-247): Overriding function changes state mutability from "pure" to "view". +// TypeError 6959: (272-339): Overriding function changes state mutability from "pure" to "nonpayable". +// TypeError 6959: (272-339): Overriding function changes state mutability from "view" to "nonpayable". +// TypeError 6959: (461-536): Overriding function changes state mutability from "view" to "payable". +// TypeError 6959: (461-536): Overriding function changes state mutability from "pure" to "payable". diff --git a/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability.sol b/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability.sol new file mode 100644 index 000000000..3c09e5722 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability.sol @@ -0,0 +1,16 @@ +contract A { + function foo() internal view virtual returns (uint256) {} +} +contract B is A { + function foo() internal pure override virtual returns (uint256) {} +} +contract C is A { + function foo() internal view override virtual returns (uint256) {} +} +contract D is B, C { + function foo() internal pure override(B, C) virtual returns (uint256) {} +} +contract E is C, B { + function foo() internal pure override(B, C) virtual returns (uint256) {} +} +// ---- diff --git a/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability1.sol b/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability1.sol new file mode 100644 index 000000000..959774a7b --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability1.sol @@ -0,0 +1,8 @@ +contract A { + function foo() public payable virtual returns (uint256) {} +} +contract B is A { + function foo() public override virtual returns (uint256) {} +} +// ---- +// TypeError 6959: (94-153): Overriding function changes state mutability from "payable" to "nonpayable". diff --git a/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability2.sol b/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability2.sol new file mode 100644 index 000000000..7e62c2023 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability2.sol @@ -0,0 +1,7 @@ +contract A { + function foo() internal virtual returns (uint256) {} +} +contract B is A { + function foo() internal view override virtual returns (uint256) {} +} +// ---- diff --git a/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability3.sol b/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability3.sol new file mode 100644 index 000000000..e1117f2b2 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability3.sol @@ -0,0 +1,7 @@ +contract A { + function foo() internal view virtual returns (uint256) {} +} +contract B is A { + function foo() internal pure override virtual returns (uint256) {} +} +// ---- diff --git a/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability4.sol b/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability4.sol new file mode 100644 index 000000000..da539d6df --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability4.sol @@ -0,0 +1,8 @@ +contract A { + function foo() public payable virtual returns (uint256) {} +} +contract B is A { + function foo() public view override virtual returns (uint256) {} +} +// ---- +// TypeError 6959: (94-158): Overriding function changes state mutability from "payable" to "view". diff --git a/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability5.sol b/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability5.sol new file mode 100644 index 000000000..2c11faed9 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability5.sol @@ -0,0 +1,8 @@ +contract A { + function foo() public payable virtual returns (uint256) {} +} +contract B is A { + function foo() public pure override virtual returns (uint256) {} +} +// ---- +// TypeError 6959: (94-158): Overriding function changes state mutability from "payable" to "pure". diff --git a/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability6.sol b/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability6.sol new file mode 100644 index 000000000..8947c357a --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability6.sol @@ -0,0 +1,8 @@ +contract A { + function foo() public virtual returns (uint256) {} +} +contract B is A { + function foo() public payable override virtual returns (uint256) {} +} +// ---- +// TypeError 6959: (86-153): Overriding function changes state mutability from "nonpayable" to "payable". diff --git a/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability7.sol b/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability7.sol new file mode 100644 index 000000000..c09656608 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/override_stricter_mutability7.sol @@ -0,0 +1,8 @@ +contract A { + function foo() public view virtual returns (uint256) {} +} +contract B is A { + function foo() public payable override virtual returns (uint256) {} +} +// ---- +// TypeError 6959: (91-158): Overriding function changes state mutability from "view" to "payable". diff --git a/test/libsolidity/syntaxTests/inheritance/override/public_constant_var_overrides_pure.sol b/test/libsolidity/syntaxTests/inheritance/override/public_constant_var_overrides_pure.sol new file mode 100644 index 000000000..92f83a01f --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/public_constant_var_overrides_pure.sol @@ -0,0 +1,7 @@ +abstract contract C { + function foo() external pure virtual returns (uint); +} +contract X is C { + uint public constant override foo = 7; +} +// ---- diff --git a/test/libsolidity/syntaxTests/inheritance/override/public_immutable_var_overrides_pure.sol b/test/libsolidity/syntaxTests/inheritance/override/public_immutable_var_overrides_pure.sol new file mode 100644 index 000000000..53f7170f4 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/public_immutable_var_overrides_pure.sol @@ -0,0 +1,8 @@ +abstract contract C { + function foo() external pure virtual returns (uint); +} +contract X is C { + uint public immutable override foo = 7; +} +// ---- +// TypeError 6959: (100-138): Overriding public state variable changes state mutability from "pure" to "view". diff --git a/test/libsolidity/syntaxTests/inheritance/override/public_var_no_override_but_function.sol b/test/libsolidity/syntaxTests/inheritance/override/public_var_no_override_but_function.sol index 059450fe6..15b6e7b5d 100644 --- a/test/libsolidity/syntaxTests/inheritance/override/public_var_no_override_but_function.sol +++ b/test/libsolidity/syntaxTests/inheritance/override/public_var_no_override_but_function.sol @@ -1,5 +1,5 @@ contract A { - function foo() internal virtual pure returns(uint) { return 5; } + function foo() internal virtual view returns(uint) { return 5; } } contract X is A { uint public foo; diff --git a/test/libsolidity/syntaxTests/inheritance/override/public_var_overrides_pure.sol b/test/libsolidity/syntaxTests/inheritance/override/public_var_overrides_pure.sol new file mode 100644 index 000000000..835351b3d --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/public_var_overrides_pure.sol @@ -0,0 +1,8 @@ +abstract contract C { + function foo() external pure virtual returns (uint); +} +contract X is C { + uint public override foo; +} +// ---- +// TypeError 6959: (100-124): Overriding public state variable changes state mutability from "pure" to "view". diff --git a/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple.sol b/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple.sol index f0a79beb2..0222db63b 100644 --- a/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple.sol +++ b/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple.sol @@ -1,8 +1,8 @@ contract A { - function foo() external virtual pure returns(uint) { return 5; } + function foo() external virtual view returns(uint) { return 5; } } contract B { - function foo() external virtual pure returns(uint) { return 5; } + function foo() external virtual view returns(uint) { return 5; } } contract X is A, B { uint public override foo; diff --git a/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple1.sol b/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple1.sol index 719c917c7..7cba6cf0a 100644 --- a/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple1.sol +++ b/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple1.sol @@ -2,7 +2,7 @@ contract A { uint public foo; } contract B { - function foo() external virtual pure returns(uint) { return 5; } + function foo() external virtual view returns(uint) { return 5; } } contract X is A, B { uint public override foo; diff --git a/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple2.sol b/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple2.sol index fa0c17880..42c0a97f1 100644 --- a/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple2.sol +++ b/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple2.sol @@ -1,7 +1,7 @@ contract A { - function foo() external virtual pure returns(uint) { return 4; } - function foo(uint ) external virtual pure returns(uint) { return 4; } - function foo(uint , uint ) external pure virtual returns(A) { } + function foo() external virtual view returns(uint) { return 4; } + function foo(uint ) external virtual view returns(uint) { return 4; } + function foo(uint , uint ) external view virtual returns(A) { } } contract X is A { uint public override foo; diff --git a/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple3.sol b/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple3.sol index 1ef6cf296..35e3e78ac 100644 --- a/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple3.sol +++ b/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple3.sol @@ -1,7 +1,7 @@ contract A { - function foo() external virtual pure returns(A) { } - function foo(uint ) external virtual pure returns(uint) { return 4; } - function foo(uint , uint ) external pure virtual returns(A) { } + function foo() external virtual view returns(A) { } + function foo(uint ) external virtual view returns(uint) { return 4; } + function foo(uint , uint ) external view virtual returns(A) { } } contract X is A { uint public override foo; diff --git a/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple_diamond.sol b/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple_diamond.sol index ffac63dc8..67e95e129 100644 --- a/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple_diamond.sol +++ b/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple_diamond.sol @@ -1,11 +1,11 @@ contract A { - function foo() external virtual pure returns(uint) { return 5; } + function foo() external virtual view returns(uint) { return 5; } } contract B is A { - function foo() external virtual override pure returns(uint) { return 5; } + function foo() external virtual override view returns(uint) { return 5; } } contract C is A { - function foo() external virtual override pure returns(uint) { return 5; } + function foo() external virtual override view returns(uint) { return 5; } } contract X is B, C { uint public override foo; diff --git a/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple_diamond1.sol b/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple_diamond1.sol index b0b4d22fc..9830bfce7 100644 --- a/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple_diamond1.sol +++ b/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple_diamond1.sol @@ -1,11 +1,11 @@ contract A { - function foo() external virtual pure returns(uint) { return 5; } + function foo() external virtual view returns(uint) { return 5; } } contract B is A { uint public override foo; } contract C is A { - function foo() external virtual override pure returns(uint) { return 5; } + function foo() external virtual override view returns(uint) { return 5; } } contract X is B, C { uint public override foo; diff --git a/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple_diamond2.sol b/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple_diamond2.sol index f303b82cd..0ce74dc6b 100644 --- a/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple_diamond2.sol +++ b/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple_diamond2.sol @@ -1,11 +1,11 @@ contract A { - function foo() external virtual pure returns(uint) { return 5; } + function foo() external virtual view returns(uint) { return 5; } } contract B is A { uint public override foo; } contract C is A { - function foo() external virtual override pure returns(uint) { return 5; } + function foo() external virtual override view returns(uint) { return 5; } } contract X is B, C { uint public override(A, C) foo; diff --git a/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple_explicit_override.sol b/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple_explicit_override.sol index caf3f9ea8..b0579b307 100644 --- a/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple_explicit_override.sol +++ b/test/libsolidity/syntaxTests/inheritance/override/public_vars_multiple_explicit_override.sol @@ -1,8 +1,8 @@ contract A { - function foo() external virtual pure returns(uint) { return 5; } + function foo() external virtual view returns(uint) { return 5; } } contract B { - function foo() external virtual pure returns(uint) { return 5; } + function foo() external virtual view returns(uint) { return 5; } } contract X is A, B { uint public override(A, B) foo; diff --git a/test/libsolidity/syntaxTests/inheritance/override/restrict_mutability_for_override_only.sol b/test/libsolidity/syntaxTests/inheritance/override/restrict_mutability_for_override_only.sol new file mode 100644 index 000000000..bbcb89203 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/restrict_mutability_for_override_only.sol @@ -0,0 +1,14 @@ +contract A { + // no "state mutability can be restricted"-warning here + function foo() external virtual returns (uint) { return 1; } +} +contract B is A { + // no "state mutability can be restricted"-warning here + function foo() external virtual override returns (uint) { return 2; } +} +contract C is B { + // warning is here + function foo() external override returns (uint) { return 3; } +} +// ---- +// Warning 2018: (339-400): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/inheritance/reference_non_base_ctor.sol b/test/libsolidity/syntaxTests/inheritance/reference_non_base_ctor.sol index 0f21a6b56..a871d3ce0 100644 --- a/test/libsolidity/syntaxTests/inheritance/reference_non_base_ctor.sol +++ b/test/libsolidity/syntaxTests/inheritance/reference_non_base_ctor.sol @@ -1,6 +1,6 @@ contract X {} contract D { - constructor() X(5) public {} + constructor() X(5) {} } // ---- // TypeError 4659: (45-49): Referenced declaration is neither modifier nor base class. diff --git a/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol b/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol index 9bd33615d..d3f33f6d6 100644 --- a/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol +++ b/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol @@ -1,10 +1,10 @@ contract Base { - constructor(uint, uint) public {} + constructor(uint, uint) {} } contract Derived is Base(2) { } contract Derived2 is Base { - constructor() Base(2) public { } + constructor() Base(2) { } } // ---- -// TypeError 7927: (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 2973: (130-137): Wrong argument count for modifier invocation: 1 arguments given but expected 2. +// TypeError 7927: (67-74): Wrong argument count for constructor call: 1 arguments given but expected 2. Remove parentheses if you do not want to provide arguments here. +// TypeError 2973: (123-130): Wrong argument count for modifier invocation: 1 arguments given but expected 2. diff --git a/test/libsolidity/syntaxTests/inheritance/virtual/library_err.sol b/test/libsolidity/syntaxTests/inheritance/virtual/library_err.sol new file mode 100644 index 000000000..7c2e1bbce --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/virtual/library_err.sol @@ -0,0 +1,5 @@ +library L { + function f() internal pure virtual returns (uint) { return 0; } +} +// ---- +// TypeError 7801: (16-79): Library functions cannot be "virtual". diff --git a/test/libsolidity/syntaxTests/inheritance/wrong_type_base_arguments.sol b/test/libsolidity/syntaxTests/inheritance/wrong_type_base_arguments.sol index 44bca7b3e..6f85c2c0a 100644 --- a/test/libsolidity/syntaxTests/inheritance/wrong_type_base_arguments.sol +++ b/test/libsolidity/syntaxTests/inheritance/wrong_type_base_arguments.sol @@ -1,9 +1,9 @@ contract Base { - constructor(uint8) public {} + constructor(uint8) {} } contract Derived is Base(300) { } contract Derived2 is Base { - constructor() Base(2) public { } + constructor() Base(2) { } } // ---- -// TypeError 9827: (74-77): Invalid type for argument in constructor call. Invalid implicit conversion from int_const 300 to uint8 requested. Literal is too large to fit in uint8. +// TypeError 9827: (67-70): Invalid type for argument in constructor call. Invalid implicit conversion from int_const 300 to uint8 requested. Literal is too large to fit in uint8. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_functiontype2.sol b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_functiontype2.sol index aef6dd3e9..aedf53ea8 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_functiontype2.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_functiontype2.sol @@ -1,10 +1,10 @@ contract C { function f() public pure {} - constructor() public { + constructor() { assembly { let x := f } } } // ---- -// DeclarationError 2025: (112-113): Access to functions is not allowed in inline assembly. +// DeclarationError 2025: (105-106): Access to functions is not allowed in inline assembly. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/evm_istanbul_on_petersburg.sol b/test/libsolidity/syntaxTests/inlineAssembly/evm_istanbul_on_petersburg.sol index 66095a021..9937fc465 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/evm_istanbul_on_petersburg.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/evm_istanbul_on_petersburg.sol @@ -15,5 +15,5 @@ contract C { // ---- // TypeError 1561: (101-108): The "chainid" instruction is only available for Istanbul-compatible VMs (you are currently compiling for "petersburg"). // DeclarationError 8678: (95-110): Variable count does not match number of values (1 vs. 0) -// TypeError 3672: (215-226): The "selfbalance" instruction is only available for Istanbul-compatible VMs (you are currently compiling for "petersburg"). +// TypeError 7721: (215-226): The "selfbalance" instruction is only available for Istanbul-compatible VMs (you are currently compiling for "petersburg"). // DeclarationError 8678: (209-228): Variable count does not match number of values (1 vs. 0) diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/constant_variable_via_offset.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/constant_variable_via_offset.sol index 063199ab4..eab2d2b4e 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/invalid/constant_variable_via_offset.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/constant_variable_via_offset.sol @@ -2,9 +2,9 @@ contract test { uint constant x = 2; function f() pure public { assembly { - let r := x_offset + let r := x.offset } } } // ---- -// TypeError 6617: (112-120): The suffixes _offset and _slot can only be used on non-constant storage variables. +// TypeError 6617: (112-120): The suffixes .offset and .slot can only be used on non-constant storage variables. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/dot_in_fun_param.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/dot_in_fun_param.sol new file mode 100644 index 000000000..e6644e9da --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/dot_in_fun_param.sol @@ -0,0 +1,12 @@ +contract C { + function f() public pure { + assembly { + function f(a., x.b) -> t.b, b.. {} + } + } +} +// ---- +// DeclarationError 3927: (74-76): User-defined identifiers in inline assembly cannot contain '.'. +// DeclarationError 3927: (78-81): User-defined identifiers in inline assembly cannot contain '.'. +// DeclarationError 3927: (86-89): User-defined identifiers in inline assembly cannot contain '.'. +// DeclarationError 3927: (91-94): User-defined identifiers in inline assembly cannot contain '.'. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/dot_in_fundecl.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/dot_in_fundecl.sol new file mode 100644 index 000000000..2e8118b78 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/dot_in_fundecl.sol @@ -0,0 +1,11 @@ +contract C { + function f() public pure { + assembly { + function f.() {} + function g.f() {} + } + } +} +// ---- +// DeclarationError 3927: (63-79): User-defined identifiers in inline assembly cannot contain '.'. +// DeclarationError 3927: (86-103): User-defined identifiers in inline assembly cannot contain '.'. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/dot_in_multi_vardecl.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/dot_in_multi_vardecl.sol new file mode 100644 index 000000000..58efb2de6 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/dot_in_multi_vardecl.sol @@ -0,0 +1,11 @@ +contract C { + function f() public pure { + assembly { + function f() -> x, y, z {} + let a., aa.b := f() + } + } +} +// ---- +// DeclarationError 3927: (100-102): User-defined identifiers in inline assembly cannot contain '.'. +// DeclarationError 3927: (104-108): User-defined identifiers in inline assembly cannot contain '.'. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/dot_in_vardecl.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/dot_in_vardecl.sol new file mode 100644 index 000000000..0537afb74 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/dot_in_vardecl.sol @@ -0,0 +1,15 @@ +contract C { + function f() public pure { + assembly { + let a. := 2 + let a.. := 2 + let a.b := 2 + let a..b := 2 + } + } +} +// ---- +// DeclarationError 3927: (67-69): User-defined identifiers in inline assembly cannot contain '.'. +// DeclarationError 3927: (85-88): User-defined identifiers in inline assembly cannot contain '.'. +// DeclarationError 3927: (104-107): User-defined identifiers in inline assembly cannot contain '.'. +// DeclarationError 3927: (123-127): User-defined identifiers in inline assembly cannot contain '.'. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/identifier_starting_with_dot.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/identifier_starting_with_dot.sol new file mode 100644 index 000000000..0122dc4db --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/identifier_starting_with_dot.sol @@ -0,0 +1,9 @@ +contract C { + function f() public pure { + assembly { + let a, .a, aa.b := f() + } + } +} +// ---- +// ParserError 2314: (70-71): Expected identifier but got '.' diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/local_variable_access_out_of_functions_storage_ptr.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/local_variable_access_out_of_functions_storage_ptr.sol index d8df7e45d..24cc283b1 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/invalid/local_variable_access_out_of_functions_storage_ptr.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/local_variable_access_out_of_functions_storage_ptr.sol @@ -3,7 +3,7 @@ contract test { function f() public { uint[] storage a = r; assembly { - function g() -> x { x := a_offset } + function g() -> x { x := a.offset } } } } diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/storage_assignment.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/storage_assignment.sol index fa1c97431..f833d1740 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/invalid/storage_assignment.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/storage_assignment.sol @@ -7,4 +7,4 @@ contract test { } } // ---- -// TypeError 1408: (89-90): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes. +// TypeError 1408: (89-90): Only local variables are supported. To access storage variables, use the .slot and .offset suffixes. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/storage_assignment_in_modifier.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/storage_assignment_in_modifier.sol index 945295e77..a86fdc14b 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/invalid/storage_assignment_in_modifier.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/storage_assignment_in_modifier.sol @@ -10,4 +10,4 @@ contract test { } } // ---- -// TypeError 1408: (80-81): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes. +// TypeError 1408: (80-81): Only local variables are supported. To access storage variables, use the .slot and .offset suffixes. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/storage_variable_access_out_of_functions.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/storage_variable_access_out_of_functions.sol index abe9067a5..9d2db8162 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/invalid/storage_variable_access_out_of_functions.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/storage_variable_access_out_of_functions.sol @@ -2,7 +2,7 @@ contract test { uint a; function f() pure public { assembly { - function g() -> x { x := a_slot } + function g() -> x { x := a.slot } } } } diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/unbalanced_two_stack_load.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/unbalanced_two_stack_load.sol index b41cd93df..9f51fe572 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/invalid/unbalanced_two_stack_load.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/unbalanced_two_stack_load.sol @@ -5,4 +5,4 @@ contract c { } } // ---- -// TypeError 1408: (75-76): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes. +// TypeError 1408: (75-76): Only local variables are supported. To access storage variables, use the .slot and .offset suffixes. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/variable_declaration_suffix_offset.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/variable_declaration_suffix_offset.sol index 68de25206..dd69058f3 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/invalid/variable_declaration_suffix_offset.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/variable_declaration_suffix_offset.sol @@ -1,15 +1,11 @@ contract C { function f() public pure { assembly { - let x_offset := 1 - let x_slot := 1 - let _offset := 1 - let _slot := 1 + let x.offset := 1 + let x.slot := 1 } } } // ---- -// DeclarationError 9155: (79-87): In variable declarations _slot and _offset can not be used as a suffix. -// DeclarationError 9155: (109-115): In variable declarations _slot and _offset can not be used as a suffix. -// DeclarationError 9155: (137-144): In variable declarations _slot and _offset can not be used as a suffix. -// DeclarationError 9155: (166-171): In variable declarations _slot and _offset can not be used as a suffix. +// DeclarationError 3927: (79-87): User-defined identifiers in inline assembly cannot contain '.'. +// DeclarationError 3927: (109-115): User-defined identifiers in inline assembly cannot contain '.'. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/pc.sol b/test/libsolidity/syntaxTests/inlineAssembly/pc.sol index 2bac970bb..816bb1c0d 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/pc.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/pc.sol @@ -6,4 +6,4 @@ contract C { } } // ---- -// Warning 2450: (61-63): The "pc" instruction is deprecated and will be removed in the next breaking release. +// SyntaxError 2450: (61-63): PC instruction is a low-level EVM feature. Because of that PC is disallowed in strict assembly. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/shadowing/name_clash_in_import.sol b/test/libsolidity/syntaxTests/inlineAssembly/shadowing/name_clash_in_import.sol index 50a1b749c..c5cc1a578 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/shadowing/name_clash_in_import.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/shadowing/name_clash_in_import.sol @@ -15,4 +15,4 @@ contract B { } // ---- // DeclarationError 3859: (b:105-106): This declaration shadows a declaration outside the inline assembly block. -// DeclarationError 3859: (b:128-131): The prefix of this declaration conflicts with a declaration outside the inline assembly block. +// DeclarationError 3927: (b:128-131): User-defined identifiers in inline assembly cannot contain '.'. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/shadowing/no_name_clash_in_import.sol b/test/libsolidity/syntaxTests/inlineAssembly/shadowing/no_name_clash_in_import.sol index 86426aad9..bb593da64 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/shadowing/no_name_clash_in_import.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/shadowing/no_name_clash_in_import.sol @@ -9,7 +9,6 @@ contract B { function f() public pure { assembly { let A := 1 - let A.b := 2 } } } diff --git a/test/libsolidity/syntaxTests/inlineAssembly/shadowing/qualified_names.sol b/test/libsolidity/syntaxTests/inlineAssembly/shadowing/qualified_names.sol index 7fba010f5..ea410943e 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/shadowing/qualified_names.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/shadowing/qualified_names.sol @@ -10,5 +10,5 @@ contract C { } } // ---- -// DeclarationError 3859: (115-118): The prefix of this declaration conflicts with a declaration outside the inline assembly block. -// DeclarationError 3859: (140-143): The prefix of this declaration conflicts with a declaration outside the inline assembly block. +// DeclarationError 3927: (115-118): User-defined identifiers in inline assembly cannot contain '.'. +// DeclarationError 3927: (140-143): User-defined identifiers in inline assembly cannot contain '.'. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol index 649195c17..91ea7aea4 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol @@ -8,4 +8,4 @@ contract C { } } // ---- -// TypeError 9068: (118-119): You have to use the _slot or _offset suffix to access storage reference variables. +// TypeError 9068: (118-119): You have to use the .slot or .offset suffix to access storage reference variables. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol index effe60460..4f8e36068 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol @@ -3,10 +3,10 @@ contract C { fallback() external { uint[] storage y = x; assembly { - y_slot := 1 - y_offset := 2 + y.slot := 1 + y.offset := 2 } } } // ---- -// TypeError 9739: (138-146): Only _slot can be assigned to. +// TypeError 9739: (138-146): Only .slot can be assigned to. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment_statevar.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment_statevar.sol index 783306b5e..f4ed7c378 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment_statevar.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment_statevar.sol @@ -2,8 +2,8 @@ contract C { uint[] x; fallback() external { assembly { - x_slot := 1 - x_offset := 2 + x.slot := 1 + x.offset := 2 } } } diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_offset.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_offset.sol index 479b34718..ab13d1dd6 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_offset.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_offset.sol @@ -1,9 +1,9 @@ contract C { function f() public pure { assembly { - let x := _offset + let x := .offset } } } // ---- -// DeclarationError 4794: (84-91): In variable names _slot and _offset can only be used as a suffix. +// ParserError 1856: (84-85): Literal or identifier expected. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_slot.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_slot.sol index b0f383d3a..43d5ab8e2 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_slot.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_slot.sol @@ -1,9 +1,9 @@ contract C { function f() public pure { assembly { - let x := _slot + let x := .slot } } } // ---- -// DeclarationError 4794: (84-89): In variable names _slot and _offset can only be used as a suffix. +// ParserError 1856: (84-85): Literal or identifier expected. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol index fd5d2596a..362a5c647 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol @@ -3,8 +3,8 @@ contract C { fallback() external { uint[] storage y = x; assembly { - pop(y_slot) - pop(y_offset) + pop(y.slot) + pop(y.offset) } } } diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_old.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_old.sol new file mode 100644 index 000000000..4b50fbd6e --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_old.sol @@ -0,0 +1,13 @@ +contract C { + uint[] x; + fallback() external { + uint[] storage y = x; + assembly { + pop(y_slot) + pop(y_offset) + } + } +} +// ---- +// DeclarationError 9467: (118-124): Identifier not found. Use ``.slot`` and ``.offset`` to access storage variables. +// DeclarationError 9467: (142-150): Identifier not found. Use ``.slot`` and ``.offset`` to access storage variables. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_old_shadow.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_old_shadow.sol new file mode 100644 index 000000000..9914eb09f --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_old_shadow.sol @@ -0,0 +1,14 @@ +contract C { + uint[] x; + fallback() external { + uint y_slot = 2; + uint y_offset = 3; + uint[] storage y = x; + assembly { + pop(y_slot) + pop(y_offset) + } + y[0] = 2; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol index 8f680ec3c..b5ac0b1d8 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol @@ -1,9 +1,9 @@ contract C { function f() pure public { assembly { - let x := f_slot + let x := f.slot } } } // ---- -// TypeError 7944: (84-90): The suffixes _offset and _slot can only be used on storage variables. +// TypeError 7944: (84-90): The suffixes .offset and .slot can only be used on storage variables. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol index 552a717dd..d85bc8c28 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol @@ -3,11 +3,11 @@ contract C { fallback() external { uint[] memory y = x; assembly { - pop(y_slot) - pop(y_offset) + pop(y.slot) + pop(y.offset) } } } // ---- -// TypeError 3622: (117-123): The suffixes _offset and _slot can only be used on storage variables. -// TypeError 3622: (141-149): The suffixes _offset and _slot can only be used on storage variables. +// TypeError 3622: (117-123): The suffixes .offset and .slot can only be used on storage variables. +// TypeError 3622: (141-149): The suffixes .offset and .slot can only be used on storage variables. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_slot_assign.yul b/test/libsolidity/syntaxTests/inlineAssembly/storage_slot_assign.yul index effe60460..4f8e36068 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_slot_assign.yul +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_slot_assign.yul @@ -3,10 +3,10 @@ contract C { fallback() external { uint[] storage y = x; assembly { - y_slot := 1 - y_offset := 2 + y.slot := 1 + y.offset := 2 } } } // ---- -// TypeError 9739: (138-146): Only _slot can be assigned to. +// TypeError 9739: (138-146): Only .slot can be assigned to. diff --git a/test/libsolidity/syntaxTests/lvalues/library_mapping.sol b/test/libsolidity/syntaxTests/lvalues/library_mapping.sol index 2a1fe1fd8..2c774f55c 100644 --- a/test/libsolidity/syntaxTests/lvalues/library_mapping.sol +++ b/test/libsolidity/syntaxTests/lvalues/library_mapping.sol @@ -4,4 +4,4 @@ library L { } } // ---- -// TypeError 9214: (108-109): Mappings cannot be assigned to. +// TypeError 9214: (108-109): Types in storage containing (nested) mappings cannot be assigned to. diff --git a/test/libsolidity/syntaxTests/memberLookup/internal_function_type.sol b/test/libsolidity/syntaxTests/memberLookup/internal_function_type.sol index 560a6c2ae..b1f70f533 100644 --- a/test/libsolidity/syntaxTests/memberLookup/internal_function_type.sol +++ b/test/libsolidity/syntaxTests/memberLookup/internal_function_type.sol @@ -1,6 +1,6 @@ contract C { function () internal returns (uint) x; - constructor() public { + constructor() { C.x = g; } function g() public pure returns (uint) {} diff --git a/test/libsolidity/syntaxTests/memberLookup/memory_structs_with_mapping_array_struct_array.sol b/test/libsolidity/syntaxTests/memberLookup/memory_structs_with_mapping_array_struct_array.sol index e9e1f7a06..164d32ff0 100644 --- a/test/libsolidity/syntaxTests/memberLookup/memory_structs_with_mapping_array_struct_array.sol +++ b/test/libsolidity/syntaxTests/memberLookup/memory_structs_with_mapping_array_struct_array.sol @@ -9,4 +9,4 @@ contract Test { } } // ---- -// TypeError 4994: (208-218): Member "b1" is not available in struct Test.S1 memory outside of storage. +// TypeError 4061: (161-172): Type struct Test.S2 is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/memberLookup/memory_structs_with_mappings.sol b/test/libsolidity/syntaxTests/memberLookup/memory_structs_with_mappings.sol index 594c881b7..fd510ed17 100644 --- a/test/libsolidity/syntaxTests/memberLookup/memory_structs_with_mappings.sol +++ b/test/libsolidity/syntaxTests/memberLookup/memory_structs_with_mappings.sol @@ -3,8 +3,7 @@ contract Test { S s; function f() public { S memory x; - x.b[1]; } } // ---- -// TypeError 4994: (118-121): Member "b" is not available in struct Test.S memory outside of storage. +// TypeError 4061: (104-114): Type struct Test.S is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/metaTypes/runtimeCodeWarningAssembly.sol b/test/libsolidity/syntaxTests/metaTypes/runtimeCodeWarningAssembly.sol index d0727833b..40eaee040 100644 --- a/test/libsolidity/syntaxTests/metaTypes/runtimeCodeWarningAssembly.sol +++ b/test/libsolidity/syntaxTests/metaTypes/runtimeCodeWarningAssembly.sol @@ -7,10 +7,10 @@ contract Test { } } contract C { - constructor() public { assembly {} } + constructor() { assembly {} } } contract D is C { - constructor() public {} + constructor() {} } // ---- // Warning 6417: (77-96): The constructor of the contract (or its base) uses inline assembly. Because of that, it might be that the deployed bytecode is different from type(...).runtimeCode. diff --git a/test/libsolidity/syntaxTests/missing_functions_duplicate_bug.sol b/test/libsolidity/syntaxTests/missing_functions_duplicate_bug.sol index a78de8788..0ba307b8f 100644 --- a/test/libsolidity/syntaxTests/missing_functions_duplicate_bug.sol +++ b/test/libsolidity/syntaxTests/missing_functions_duplicate_bug.sol @@ -1,5 +1,3 @@ -pragma solidity ^0.6.0; - pragma experimental ABIEncoderV2; contract Ownable { @@ -20,9 +18,9 @@ library VoteTiming { } contract Voting is Ownable { - constructor() public { + constructor() { VoteTiming.init(1); } } // ---- -// Warning 5667: (324-340): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning 5667: (299-315): Unused function parameter. Remove or comment out the variable name to silence this warning. diff --git a/test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol b/test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol index 67a1b6da2..d0a376fa5 100644 --- a/test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol +++ b/test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol @@ -1,7 +1,7 @@ -contract C { constructor(uint a) public {} } +contract C { constructor(uint a) {} } contract B is C { - constructor() C(2) C(2) public {} + constructor() C(2) C(2) {} } // ---- -// DeclarationError 3364: (81-85): Base constructor arguments given twice. -// DeclarationError 1697: (86-90): Base constructor already provided. +// DeclarationError 3364: (74-78): Base constructor arguments given twice. +// DeclarationError 1697: (79-83): Base constructor already provided. diff --git a/test/libsolidity/syntaxTests/modifiers/constructor_as_modifier.sol b/test/libsolidity/syntaxTests/modifiers/constructor_as_modifier.sol index 36a98fae3..8a1071a6c 100644 --- a/test/libsolidity/syntaxTests/modifiers/constructor_as_modifier.sol +++ b/test/libsolidity/syntaxTests/modifiers/constructor_as_modifier.sol @@ -1,5 +1,5 @@ contract C { - constructor() C() public {} + constructor() C() {} } // ---- // TypeError 4659: (31-34): Referenced declaration is neither modifier nor base class. diff --git a/test/libsolidity/syntaxTests/modifiers/constructor_call_invalid_arg_count.sol b/test/libsolidity/syntaxTests/modifiers/constructor_call_invalid_arg_count.sol index 4826ed4ef..007a1bc13 100644 --- a/test/libsolidity/syntaxTests/modifiers/constructor_call_invalid_arg_count.sol +++ b/test/libsolidity/syntaxTests/modifiers/constructor_call_invalid_arg_count.sol @@ -1,9 +1,9 @@ // This caused a segfault in an earlier version contract C { - constructor() public {} + constructor() {} } contract D is C { - constructor() C(5) public {} + constructor() C(5) {} } // ---- -// TypeError 2973: (127-131): Wrong argument count for modifier invocation: 1 arguments given but expected 0. +// TypeError 2973: (120-124): Wrong argument count for modifier invocation: 1 arguments given but expected 0. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/017_assignment_to_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/017_assignment_to_struct.sol index 6fbd09aea..a1fed9967 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/017_assignment_to_struct.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/017_assignment_to_struct.sol @@ -9,3 +9,4 @@ contract test { } } // ---- +// TypeError 9214: (152-156): Types in storage containing (nested) mappings cannot be assigned to. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/041_functions_with_stucts_of_non_external_types_in_interface.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/041_functions_with_structs_of_non_external_types_in_interface.sol similarity index 100% rename from test/libsolidity/syntaxTests/nameAndTypeResolution/041_functions_with_stucts_of_non_external_types_in_interface.sol rename to test/libsolidity/syntaxTests/nameAndTypeResolution/041_functions_with_structs_of_non_external_types_in_interface.sol diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/042_functions_with_structs_of_non_external_types_in_interface_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/042_functions_with_structs_of_non_external_types_in_interface_2.sol new file mode 100644 index 000000000..541dd0a04 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/042_functions_with_structs_of_non_external_types_in_interface_2.sol @@ -0,0 +1,9 @@ +pragma experimental ABIEncoderV2; + +contract C { + struct S { mapping(uint => uint) a; } + function f(S memory) public {} +} +// ---- +// TypeError 4103: (105-113): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. +// TypeError 4061: (105-113): Type struct C.S is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/042_functions_with_stucts_of_non_external_types_in_interface_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/042_functions_with_stucts_of_non_external_types_in_interface_2.sol index 0254a1928..541dd0a04 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/042_functions_with_stucts_of_non_external_types_in_interface_2.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/042_functions_with_stucts_of_non_external_types_in_interface_2.sol @@ -5,4 +5,5 @@ contract C { function f(S memory) public {} } // ---- -// TypeError 4103: (105-113): Only libraries are allowed to use the mapping type in public or external functions. +// TypeError 4103: (105-113): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. +// TypeError 4061: (105-113): Type struct C.S is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/043_functions_with_structs_of_non_external_types_in_interface_nested.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/043_functions_with_structs_of_non_external_types_in_interface_nested.sol new file mode 100644 index 000000000..d2c96d4bc --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/043_functions_with_structs_of_non_external_types_in_interface_nested.sol @@ -0,0 +1,10 @@ +pragma experimental ABIEncoderV2; + +contract C { + struct T { mapping(uint => uint) a; } + struct S { T[][2] b; } + function f(S memory) public {} +} +// ---- +// TypeError 4103: (132-140): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. +// TypeError 4061: (132-140): Type struct C.S is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/043_functions_with_stucts_of_non_external_types_in_interface_nested.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/043_functions_with_stucts_of_non_external_types_in_interface_nested.sol index c36e4ac0e..d2c96d4bc 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/043_functions_with_stucts_of_non_external_types_in_interface_nested.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/043_functions_with_stucts_of_non_external_types_in_interface_nested.sol @@ -6,4 +6,5 @@ contract C { function f(S memory) public {} } // ---- -// TypeError 4103: (132-140): Only libraries are allowed to use the mapping type in public or external functions. +// TypeError 4103: (132-140): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. +// TypeError 4061: (132-140): Type struct C.S is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/061_missing_base_constructor_arguments.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/061_missing_base_constructor_arguments.sol index 8952a48c4..0e123ae23 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/061_missing_base_constructor_arguments.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/061_missing_base_constructor_arguments.sol @@ -1,4 +1,4 @@ -contract A { constructor(uint a) public { } } +contract A { constructor(uint a) { } } contract B is A { } // ---- -// TypeError 3656: (46-65): Contract "B" should be marked as abstract. +// TypeError 3656: (39-58): Contract "B" should be marked as abstract. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/062_base_constructor_arguments_override.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/062_base_constructor_arguments_override.sol index 8952a48c4..0e123ae23 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/062_base_constructor_arguments_override.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/062_base_constructor_arguments_override.sol @@ -1,4 +1,4 @@ -contract A { constructor(uint a) public { } } +contract A { constructor(uint a) { } } contract B is A { } // ---- -// TypeError 3656: (46-65): Contract "B" should be marked as abstract. +// TypeError 3656: (39-58): Contract "B" should be marked as abstract. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/110_no_overflow_with_large_literal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/110_no_overflow_with_large_literal.sol index 9b36fa70b..bdec196fe 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/110_no_overflow_with_large_literal.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/110_no_overflow_with_large_literal.sol @@ -1,5 +1,5 @@ contract c { - constructor() public { + constructor() { a = 115792089237316195423570985008687907853269984665640564039458; } uint256 a; diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/111_overflow_caused_by_ether_units.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/111_overflow_caused_by_ether_units.sol index 9ac069cf2..e0ac9fa5d 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/111_overflow_caused_by_ether_units.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/111_overflow_caused_by_ether_units.sol @@ -1,8 +1,8 @@ contract c { - constructor() public { + constructor() { a = 115792089237316195423570985008687907853269984665640564039458 ether; } uint256 a; } // ---- -// TypeError 7407: (52-118): Type int_const 1157...(70 digits omitted)...0000 is not implicitly convertible to expected type uint256. +// TypeError 7407: (45-111): Type int_const 1157...(70 digits omitted)...0000 is not implicitly convertible to expected type uint256. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/113_exp_warn_literal_base_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/113_exp_warn_literal_base_1.sol index cceba6f0b..e80497460 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/113_exp_warn_literal_base_1.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/113_exp_warn_literal_base_1.sol @@ -5,4 +5,3 @@ contract test { } } // ---- -// Warning 9085: (99-104): Result of exponentiation has type uint8 and thus might overflow. Silence this warning by converting the literal to the expected type. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/116_shift_warn_literal_base_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/116_shift_warn_literal_base_1.sol index 6793c304c..9de53237d 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/116_shift_warn_literal_base_1.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/116_shift_warn_literal_base_1.sol @@ -5,4 +5,3 @@ contract test { } } // ---- -// Warning 9085: (99-106): Result of shift has type uint8 and thus might overflow. Silence this warning by converting the literal to the expected type. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/124_enum_member_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/124_enum_member_access.sol index 98bc8e668..496d15206 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/124_enum_member_access.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/124_enum_member_access.sol @@ -1,6 +1,6 @@ contract test { enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } - constructor() public + constructor() { choices = ActionChoices.GoStraight; } diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/126_enum_invalid_member_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/126_enum_invalid_member_access.sol index 0c0137d9a..b19360a78 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/126_enum_invalid_member_access.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/126_enum_invalid_member_access.sol @@ -1,9 +1,9 @@ contract test { enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } - constructor() public { + constructor() { choices = ActionChoices.RunAroundWavingYourHands; } ActionChoices choices; } // ---- -// TypeError 9582: (121-159): Member "RunAroundWavingYourHands" not found or not visible after argument-dependent lookup in type(enum test.ActionChoices). +// TypeError 9582: (114-152): Member "RunAroundWavingYourHands" not found or not visible after argument-dependent lookup in type(enum test.ActionChoices). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/127_enum_invalid_direct_member_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/127_enum_invalid_direct_member_access.sol index d23cf82da..9dc9fb449 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/127_enum_invalid_direct_member_access.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/127_enum_invalid_direct_member_access.sol @@ -1,9 +1,9 @@ contract test { enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } - constructor() public { + constructor() { choices = Sit; } ActionChoices choices; } // ---- -// DeclarationError 7576: (121-124): Undeclared identifier. +// DeclarationError 7576: (114-117): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/128_enum_explicit_conversion_is_okay.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/128_enum_explicit_conversion_is_okay.sol index 0948d5505..a74421805 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/128_enum_explicit_conversion_is_okay.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/128_enum_explicit_conversion_is_okay.sol @@ -1,6 +1,6 @@ contract test { enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } - constructor() public { + constructor() { a = uint256(ActionChoices.GoStraight); b = uint64(ActionChoices.Sit); } diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/129_int_to_enum_explicit_conversion_is_okay.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/129_int_to_enum_explicit_conversion_is_okay.sol index 2639decf5..a76beb93d 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/129_int_to_enum_explicit_conversion_is_okay.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/129_int_to_enum_explicit_conversion_is_okay.sol @@ -1,6 +1,6 @@ contract test { enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } - constructor() public { + constructor() { a = 2; b = ActionChoices(a); } diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/130_enum_implicit_conversion_is_not_okay_256.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/130_enum_implicit_conversion_is_not_okay_256.sol index 52296a9c6..79e45f82c 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/130_enum_implicit_conversion_is_not_okay_256.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/130_enum_implicit_conversion_is_not_okay_256.sol @@ -1,9 +1,9 @@ contract test { enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } - constructor() public { + constructor() { a = ActionChoices.GoStraight; } uint256 a; } // ---- -// TypeError 7407: (115-139): Type enum test.ActionChoices is not implicitly convertible to expected type uint256. +// TypeError 7407: (108-132): Type enum test.ActionChoices is not implicitly convertible to expected type uint256. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/131_enum_implicit_conversion_is_not_okay_64.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/131_enum_implicit_conversion_is_not_okay_64.sol index fdfc4f606..f57df6707 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/131_enum_implicit_conversion_is_not_okay_64.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/131_enum_implicit_conversion_is_not_okay_64.sol @@ -1,9 +1,9 @@ contract test { enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } - constructor() public { + constructor() { b = ActionChoices.Sit; } uint64 b; } // ---- -// TypeError 7407: (115-132): Type enum test.ActionChoices is not implicitly convertible to expected type uint64. +// TypeError 7407: (108-125): Type enum test.ActionChoices is not implicitly convertible to expected type uint64. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/132_enum_to_enum_conversion_is_not_okay.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/132_enum_to_enum_conversion_is_not_okay.sol index 367a9fbdd..73588a5bc 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/132_enum_to_enum_conversion_is_not_okay.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/132_enum_to_enum_conversion_is_not_okay.sol @@ -1,9 +1,9 @@ contract test { enum Paper { Up, Down, Left, Right } enum Ground { North, South, West, East } - constructor() public { + constructor() { Ground(Paper.Up); } } // ---- -// TypeError 9640: (137-153): Explicit type conversion not allowed from "enum test.Paper" to "enum test.Ground". +// TypeError 9640: (130-146): Explicit type conversion not allowed from "enum test.Paper" to "enum test.Ground". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/149_test_for_bug_override_function_with_bytearray_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/149_test_for_bug_override_function_with_bytearray_type.sol index 284f85341..1864913f7 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/149_test_for_bug_override_function_with_bytearray_type.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/149_test_for_bug_override_function_with_bytearray_type.sol @@ -5,4 +5,4 @@ contract Bike is Vehicle { function f(bytes calldata) override external returns (uint256 r) {r = 42;} } // ---- -// Warning 2018: (23-95): Function state mutability can be restricted to pure +// Warning 2018: (129-203): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/207_no_mappings_in_memory_array.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/207_no_mappings_in_memory_array.sol index b60ba1896..d9e929da2 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/207_no_mappings_in_memory_array.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/207_no_mappings_in_memory_array.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// TypeError 6651: (47-77): Data location must be "storage" for variable, but "memory" was given. +// TypeError 4061: (47-77): Type mapping(uint256 => uint256)[] is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/264_mapping_in_memory_array.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/264_mapping_in_memory_array.sol index 1102f6ecd..d561bd29e 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/264_mapping_in_memory_array.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/264_mapping_in_memory_array.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// TypeError 1164: (94-117): Type cannot live outside storage. +// TypeError 1164: (94-117): Array containing a (nested) mapping cannot be constructed in memory. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/333_fixed_point_casting_exponents_15.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/333_fixed_point_casting_exponents_15.sol index 2ba80faab..f988745ea 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/333_fixed_point_casting_exponents_15.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/333_fixed_point_casting_exponents_15.sol @@ -4,4 +4,4 @@ contract test { } } // ---- -// TypeError 2271: (61-77): Operator ** not compatible with types int_const 3 and ufixed128x18 +// TypeError 2271: (61-77): Operator ** not compatible with types int_const 3 and ufixed128x18. Exponent is fractional. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/334_fixed_point_casting_exponents_neg.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/334_fixed_point_casting_exponents_neg.sol index 36cee8557..68e80e635 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/334_fixed_point_casting_exponents_neg.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/334_fixed_point_casting_exponents_neg.sol @@ -4,4 +4,4 @@ contract test { } } // ---- -// TypeError 2271: (61-78): Operator ** not compatible with types int_const 42 and fixed128x18 +// TypeError 2271: (61-78): Operator ** not compatible with types int_const 42 and fixed128x18. Exponent is fractional. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/348_unused_return_value_call_value.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/348_unused_return_value_call_value.sol index 13beb232a..e837a6e66 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/348_unused_return_value_call_value.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/348_unused_return_value_call_value.sol @@ -1,10 +1,7 @@ contract test { function f() public { - address(0x12).call.value(2)("abc"); address(0x12).call{value: 2}("abc"); } } // ---- -// Warning 1621: (50-74): Using ".value(...)" is deprecated. Use "{value: ...}" instead. -// Warning 9302: (50-84): Return value of low-level calls not used. -// Warning 9302: (94-129): Return value of low-level calls not used. +// Warning 9302: (50-85): Return value of low-level calls not used. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/361_calling_payable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/361_calling_payable.sol index 19068fab9..cefd2514e 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/361_calling_payable.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/361_calling_payable.sol @@ -1,11 +1,7 @@ contract receiver { function pay() payable public {} } contract test { function f() public { (new receiver()).pay{value: 10}(); } - function g() public { (new receiver()).pay.value(10)(); } receiver r = new receiver(); function h() public { r.pay{value: 10}(); } - function i() public { r.pay.value(10)(); } } // ---- -// Warning 1621: (160-186): Using ".value(...)" is deprecated. Use "{value: ...}" instead. -// Warning 1621: (303-314): Using ".value(...)" is deprecated. Use "{value: ...}" instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/363_non_payable_constructor.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/363_non_payable_constructor.sol index f6760317f..fe0224b4d 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/363_non_payable_constructor.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/363_non_payable_constructor.sol @@ -1,11 +1,11 @@ contract C { - constructor() public { } + constructor() { } } contract D { function f() public returns (uint) { - (new C).value(2)(); + (new C){value: 2}(); return 2; } } // ---- -// TypeError 8827: (106-119): Constructor for contract C must be payable for member "value" to be available. +// TypeError 7006: (99-116): Cannot set option "value", since the constructor of contract C is not payable. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/366_invalid_array_as_statement.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/366_invalid_array_as_statement.sol index 8fe564bba..2eaff9c0c 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/366_invalid_array_as_statement.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/366_invalid_array_as_statement.sol @@ -1,6 +1,6 @@ contract test { struct S { uint x; } - constructor(uint k) public { S[k]; } + constructor(uint k) { S[k]; } } // ---- -// TypeError 3940: (76-77): Integer constant expected. +// TypeError 3940: (69-70): Integer constant expected. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/462_callable_crash.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/462_callable_crash.sol index 69f659ef4..05239fa1b 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/462_callable_crash.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/462_callable_crash.sol @@ -1,9 +1,9 @@ contract C { struct S { uint a; bool x; } S public s; - constructor() public { + constructor() { 3({a: 1, x: true}); } } // ---- -// TypeError 5704: (97-115): Type is not callable +// TypeError 5704: (90-108): Type is not callable diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/491_using_this_in_constructor.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/491_using_this_in_constructor.sol index 5f4b2a6c3..114046584 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/491_using_this_in_constructor.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/491_using_this_in_constructor.sol @@ -1,9 +1,9 @@ contract C { - constructor() public { + constructor() { this.f(); } function f() pure public { } } // ---- -// Warning 5805: (48-52): "this" used in constructor. Note that external functions of a contract cannot be called while it is being constructed. +// Warning 5805: (41-45): "this" used in constructor. Note that external functions of a contract cannot be called while it is being constructed. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/587_event_param_type_outside_storage.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/587_event_param_type_outside_storage.sol index b15dbc8df..483bfab21 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/587_event_param_type_outside_storage.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/587_event_param_type_outside_storage.sol @@ -2,6 +2,6 @@ contract c { event e(uint indexed a, mapping(uint => uint) indexed b, bool indexed c, uint indexed d, uint indexed e) anonymous; } // ---- -// TypeError 3448: (41-72): Type is required to live outside storage. +// TypeError 3448: (41-72): Type containing a (nested) mapping is not allowed as event parameter type. // TypeError 3417: (41-72): Internal or recursive type is not allowed as event parameter type. // TypeError 8598: (17-132): More than 4 indexed arguments for anonymous event. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/invalidArgs/creating_struct_members_skipped.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/invalidArgs/creating_struct_members_skipped.sol index 08714f500..cbcb02f6f 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/invalidArgs/creating_struct_members_skipped.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/invalidArgs/creating_struct_members_skipped.sol @@ -2,8 +2,8 @@ contract C { struct S { uint a; uint b; mapping(uint=>uint) c; } function f() public { - S memory s = S({a: 1}); + S({a: 1}); } } // ---- -// TypeError 9755: (117-126): Wrong argument count for struct constructor: 1 arguments given but expected 2. Members that have to be skipped in memory: c +// TypeError 9515: (104-113): Struct containing a (nested) mapping cannot be constructed. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/invalidTypes/constructor_call.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/invalidTypes/constructor_call.sol index 4ef5f7465..58d9f8ce6 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/invalidTypes/constructor_call.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/invalidTypes/constructor_call.sol @@ -1,5 +1,5 @@ contract C { - constructor(bytes32 _arg) public { + constructor(bytes32 _arg) { } } @@ -9,4 +9,4 @@ contract A { } } // ---- -// TypeError 9553: (115-121): Invalid type for argument in function call. Invalid implicit conversion from int_const 1234 to bytes32 requested. +// TypeError 9553: (108-114): Invalid type for argument in function call. Invalid implicit conversion from int_const 1234 to bytes32 requested. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/shadowsBuiltin/ignores_constructor.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/shadowsBuiltin/ignores_constructor.sol index 86c0b4f0b..75930d2f0 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/shadowsBuiltin/ignores_constructor.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/shadowsBuiltin/ignores_constructor.sol @@ -1,3 +1,3 @@ contract C { - constructor() public {} + constructor() {} } diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/shift_warn_literal_large_shift_amount.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/shift_warn_literal_large_shift_amount.sol new file mode 100644 index 000000000..7ba9bf3db --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/shift_warn_literal_large_shift_amount.sol @@ -0,0 +1,7 @@ +contract test { + function f() pure public returns(uint) { + uint x = 100; + return 10 << x; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/natspec/docstring_author_function.sol b/test/libsolidity/syntaxTests/natspec/docstring_author_function.sol index 7b6ca862b..71db9907b 100644 --- a/test/libsolidity/syntaxTests/natspec/docstring_author_function.sol +++ b/test/libsolidity/syntaxTests/natspec/docstring_author_function.sol @@ -3,4 +3,4 @@ contract C { function iHaveAuthor() public pure {} } // ---- -// Warning 9843: (17-35): Documentation tag @author is only allowed on contract definitions. It will be disallowed in 0.7.0. +// DocstringParsingError 6546: (17-35): Documentation tag @author not valid for functions. diff --git a/test/libsolidity/syntaxTests/natspec/docstring_author_title_state_variable.sol b/test/libsolidity/syntaxTests/natspec/docstring_author_title_state_variable.sol index 3fb4527b4..e861d31ce 100644 --- a/test/libsolidity/syntaxTests/natspec/docstring_author_title_state_variable.sol +++ b/test/libsolidity/syntaxTests/natspec/docstring_author_title_state_variable.sol @@ -4,4 +4,5 @@ contract C { uint private state; } // ---- -// Warning 8532: (17-56): Documentation tag @title and @author is only allowed on contract definitions. It will be disallowed in 0.7.0. +// DocstringParsingError 6546: (17-56): Documentation tag @author not valid for non-public state variables. +// DocstringParsingError 6546: (17-56): Documentation tag @title not valid for non-public state variables. diff --git a/test/libsolidity/syntaxTests/natspec/docstring_non_public_state_variable_with_return.sol b/test/libsolidity/syntaxTests/natspec/docstring_non_public_state_variable_with_return.sol index 2eb51cdda..da2d75fe8 100644 --- a/test/libsolidity/syntaxTests/natspec/docstring_non_public_state_variable_with_return.sol +++ b/test/libsolidity/syntaxTests/natspec/docstring_non_public_state_variable_with_return.sol @@ -3,4 +3,4 @@ contract test { uint private state; } // ---- -// DocstringParsingError 9440: (18-47): Documentation tag "@return" is only allowed on public state-variables. +// DocstringParsingError 6546: (18-47): Documentation tag @return not valid for non-public state variables. diff --git a/test/libsolidity/syntaxTests/natspec/docstring_private_state_variable.sol b/test/libsolidity/syntaxTests/natspec/docstring_private_state_variable.sol index 2a9572d72..548669442 100644 --- a/test/libsolidity/syntaxTests/natspec/docstring_private_state_variable.sol +++ b/test/libsolidity/syntaxTests/natspec/docstring_private_state_variable.sol @@ -4,4 +4,4 @@ contract C { uint private state; } // ---- -// Warning 7816: (17-74): Documentation tag on non-public state variables will be disallowed in 0.7.0. You will need to use the @dev tag explicitly. +// DocstringParsingError 6546: (17-74): Documentation tag @notice not valid for non-public state variables. diff --git a/test/libsolidity/syntaxTests/natspec/docstring_variable.sol b/test/libsolidity/syntaxTests/natspec/docstring_variable.sol index 1b8142f17..a126ca940 100644 --- a/test/libsolidity/syntaxTests/natspec/docstring_variable.sol +++ b/test/libsolidity/syntaxTests/natspec/docstring_variable.sol @@ -11,4 +11,4 @@ contract C { } } // ---- -// Warning 2837: (290-295): Only state variables can have a docstring. This will be disallowed in 0.7.0. +// ParserError 2837: (290-295): Only state variables can have a docstring. diff --git a/test/libsolidity/syntaxTests/parsing/constant_state_modifier.sol b/test/libsolidity/syntaxTests/parsing/constant_state_modifier.sol index 6f007633d..ea3b7abd8 100644 --- a/test/libsolidity/syntaxTests/parsing/constant_state_modifier.sol +++ b/test/libsolidity/syntaxTests/parsing/constant_state_modifier.sol @@ -5,4 +5,4 @@ contract C { } } // ---- -// ParserError 7698: (43-51): The state mutability modifier "constant" was removed in version 0.5.0. Use "view" or "pure" instead. +// ParserError 2314: (43-51): Expected '{' but got 'constant' diff --git a/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol b/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol index b66253e4f..b3dacf409 100644 --- a/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol +++ b/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol @@ -3,7 +3,7 @@ contract A { } } contract B { - constructor(C) public { + constructor(C) { } function b(C) public returns (A) { return new A(); @@ -12,7 +12,7 @@ contract B { contract C { B m_b; C m_c; - constructor(C other_c) public { + constructor(C other_c) { m_c = other_c; m_b = new B(this); m_b.b(this).a(); diff --git a/test/libsolidity/syntaxTests/parsing/constructor_super.sol b/test/libsolidity/syntaxTests/parsing/constructor_super.sol index fa1be1878..08507819d 100644 --- a/test/libsolidity/syntaxTests/parsing/constructor_super.sol +++ b/test/libsolidity/syntaxTests/parsing/constructor_super.sol @@ -3,7 +3,7 @@ contract A { } contract B is A { - constructor() public { + constructor() { // used to trigger warning about using ``this`` in constructor super.x(); } diff --git a/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol b/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol index 606f59d72..1a730dd98 100644 --- a/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol +++ b/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol @@ -1,6 +1,6 @@ contract c { enum validEnum { Value1, Value2, Value3, Value4 } - constructor() public { + constructor() { a = validEnum.Value3; } validEnum a; diff --git a/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol index 51ce8b4d5..6b3ccc7c0 100644 --- a/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol +++ b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol @@ -2,15 +2,11 @@ contract C { function f() public { a = 1 wei; - b = 2 szabo; - c = 3 finney; - d = 4 ether; - e = 5 gwei; + b = 2 ether; + c = 3 gwei; } uint256 a; uint256 b; uint256 c; - uint256 d; - uint256 e; } // ---- diff --git a/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol index 2f2302ed2..537320737 100644 --- a/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol +++ b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol @@ -1,7 +1,7 @@ contract c { - constructor() public + constructor() { - a = 1 wei * 100 wei + 7 szabo - 3; + a = 1 wei * 100 wei + 7 gwei - 3; } uint256 a; } diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_with_var.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_with_var.sol index 35d145a3b..19af8c2c7 100644 --- a/test/libsolidity/syntaxTests/parsing/location_specifiers_with_var.sol +++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_with_var.sol @@ -2,4 +2,4 @@ contract Foo { function f() { var memory x; } } // ---- -// ParserError 7439: (35-41): Location specifier needs explicit type name. +// ParserError 6933: (31-34): Expected primary expression. diff --git a/test/libsolidity/syntaxTests/parsing/multiple_statemutability_specifiers.sol b/test/libsolidity/syntaxTests/parsing/multiple_statemutability_specifiers.sol index e92302f37..e2c56ae57 100644 --- a/test/libsolidity/syntaxTests/parsing/multiple_statemutability_specifiers.sol +++ b/test/libsolidity/syntaxTests/parsing/multiple_statemutability_specifiers.sol @@ -17,10 +17,7 @@ contract c6 { function f() pure payable {} } contract c7 { - function f() pure constant {} -} -contract c8 { - function f() view constant {} + function f() view payable {} } // ---- // ParserError 9680: (39-46): State mutability already specified as "payable". @@ -29,5 +26,4 @@ contract c8 { // ParserError 9680: (180-184): State mutability already specified as "pure". // ParserError 9680: (229-233): State mutability already specified as "payable". // ParserError 9680: (275-282): State mutability already specified as "pure". -// ParserError 9680: (324-332): State mutability already specified as "pure". -// ParserError 9680: (374-382): State mutability already specified as "view". +// ParserError 9680: (324-331): State mutability already specified as "view". diff --git a/test/libsolidity/syntaxTests/parsing/new_invalid_type_name.sol b/test/libsolidity/syntaxTests/parsing/new_invalid_type_name.sol index 5d3e6acaa..fb3855c88 100644 --- a/test/libsolidity/syntaxTests/parsing/new_invalid_type_name.sol +++ b/test/libsolidity/syntaxTests/parsing/new_invalid_type_name.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// ParserError 7059: (35-38): Expected explicit type name. +// ParserError 3546: (35-38): Expected type name diff --git a/test/libsolidity/syntaxTests/parsing/return_var.sol b/test/libsolidity/syntaxTests/parsing/return_var.sol deleted file mode 100644 index 87c706d58..000000000 --- a/test/libsolidity/syntaxTests/parsing/return_var.sol +++ /dev/null @@ -1,25 +0,0 @@ -contract C { - function f() returns(var) {} - function f() returns(var x) {} - function f() returns(var x, uint y) {} - function f() returns(uint x, var y) {} - function f() returns(var x, var y) {} - function f() public pure returns (var storage) {} - function f() public pure returns (var storage x) {} - function f() public pure returns (var storage x, var storage y) {} -} -// ---- -// ParserError 7059: (38-41): Expected explicit type name. -// ParserError 7059: (71-74): Expected explicit type name. -// ParserError 7059: (106-109): Expected explicit type name. -// ParserError 7059: (157-160): Expected explicit type name. -// ParserError 7059: (192-195): Expected explicit type name. -// ParserError 7059: (199-202): Expected explicit type name. -// ParserError 7059: (247-250): Expected explicit type name. -// ParserError 7439: (251-258): Location specifier needs explicit type name. -// ParserError 7059: (301-304): Expected explicit type name. -// ParserError 7439: (305-312): Location specifier needs explicit type name. -// ParserError 7059: (357-360): Expected explicit type name. -// ParserError 7439: (361-368): Location specifier needs explicit type name. -// ParserError 7059: (372-375): Expected explicit type name. -// ParserError 7439: (376-383): Location specifier needs explicit type name. diff --git a/test/libsolidity/syntaxTests/parsing/tuples_without_commas.sol b/test/libsolidity/syntaxTests/parsing/tuples_without_commas.sol index 4ed1afe93..45c529a77 100644 --- a/test/libsolidity/syntaxTests/parsing/tuples_without_commas.sol +++ b/test/libsolidity/syntaxTests/parsing/tuples_without_commas.sol @@ -1,7 +1,7 @@ contract C { function f() { - var a = (2 2); + uint a = (2 2); } } // ---- -// ParserError 2314: (42-43): Expected ',' but got 'Number' +// ParserError 2314: (43-44): Expected ',' but got 'Number' diff --git a/test/libsolidity/syntaxTests/parsing/var_array.sol b/test/libsolidity/syntaxTests/parsing/var_array.sol index 132d234c4..160b073a4 100644 --- a/test/libsolidity/syntaxTests/parsing/var_array.sol +++ b/test/libsolidity/syntaxTests/parsing/var_array.sol @@ -2,4 +2,4 @@ contract Foo { function f() { var[] a; } } // ---- -// ParserError 2314: (34-35): Expected identifier but got '[' +// ParserError 6933: (31-34): Expected primary expression. diff --git a/test/libsolidity/syntaxTests/parsing/var_in_function_arguments.sol b/test/libsolidity/syntaxTests/parsing/var_in_function_arguments.sol deleted file mode 100644 index 85d78441d..000000000 --- a/test/libsolidity/syntaxTests/parsing/var_in_function_arguments.sol +++ /dev/null @@ -1,25 +0,0 @@ -contract C { - function f(var) public pure {} - function f(var x) public pure {} - function f(var x, var y) public pure {} - function f(uint x, var y) public pure {} - function f(var x, uint y) public pure {} - function f(var storage) public pure {} - function f(var storage x) public pure {} - function f(var storage x, var storage y) public pure {} -} -// ---- -// ParserError 7059: (28-31): Expected explicit type name. -// ParserError 7059: (63-66): Expected explicit type name. -// ParserError 7059: (100-103): Expected explicit type name. -// ParserError 7059: (107-110): Expected explicit type name. -// ParserError 7059: (152-155): Expected explicit type name. -// ParserError 7059: (189-192): Expected explicit type name. -// ParserError 7059: (234-237): Expected explicit type name. -// ParserError 7439: (238-245): Location specifier needs explicit type name. -// ParserError 7059: (277-280): Expected explicit type name. -// ParserError 7439: (281-288): Location specifier needs explicit type name. -// ParserError 7059: (322-325): Expected explicit type name. -// ParserError 7439: (326-333): Location specifier needs explicit type name. -// ParserError 7059: (337-340): Expected explicit type name. -// ParserError 7439: (341-348): Location specifier needs explicit type name. diff --git a/test/libsolidity/syntaxTests/scoping/library_inherited.sol b/test/libsolidity/syntaxTests/scoping/library_inherited.sol new file mode 100644 index 000000000..60c16d7c4 --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/library_inherited.sol @@ -0,0 +1,17 @@ +library Lib { + function foo(uint256 value) internal returns (uint256) { + return value + 42; + } +} + +contract A { + using Lib for uint256; +} + +contract B is A { + function bar(uint256 value) public returns (uint256) { + return value.foo(); // Usage of Lib + } +} +// ---- +// TypeError 9582: (246-255): Member "foo" not found or not visible after argument-dependent lookup in uint256. diff --git a/test/libsolidity/syntaxTests/scoping/library_inherited2.sol b/test/libsolidity/syntaxTests/scoping/library_inherited2.sol new file mode 100644 index 000000000..528ee05f3 --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/library_inherited2.sol @@ -0,0 +1,16 @@ +library Lib { + function foo(uint256 value) internal pure returns (uint256) { + return value + 42; + } +} + +contract A { + using Lib for uint256; +} + +contract B is A { + using Lib for uint256; + function bar(uint256 value) public pure returns (uint256) { + return value.foo(); // Usage of Lib + } +} diff --git a/test/libsolidity/syntaxTests/shifts/shift_singed_rvalue.sol b/test/libsolidity/syntaxTests/shifts/shift_singed_rvalue.sol new file mode 100644 index 000000000..adca80cc4 --- /dev/null +++ b/test/libsolidity/syntaxTests/shifts/shift_singed_rvalue.sol @@ -0,0 +1,11 @@ +contract C { + function f(int256 a, int256 b) public returns (int256) { + return a >> b; + } + function g(int256 a, int256 b) public returns (int256) { + return a >> (256 - b); + } +} +// ---- +// TypeError 2271: (89-95): Operator >> not compatible with types int256 and int256 +// TypeError 2271: (179-193): Operator >> not compatible with types int256 and int256 diff --git a/test/libsolidity/syntaxTests/signed_rational_modulus.sol b/test/libsolidity/syntaxTests/signed_rational_modulus.sol index d01d2fabf..999086ae1 100644 --- a/test/libsolidity/syntaxTests/signed_rational_modulus.sol +++ b/test/libsolidity/syntaxTests/signed_rational_modulus.sol @@ -7,4 +7,4 @@ contract test { } } // ---- -// UnimplementedFeatureError: Not yet implemented - FixedPointType. +// TypeError 2271: (117-123): Operator % not compatible with types rational_const 1 / 2 and fixed128x18. Fractional literals not supported. diff --git a/test/libsolidity/syntaxTests/structs/calldata_struct_mapping_function.sol b/test/libsolidity/syntaxTests/structs/calldata_struct_mapping_function.sol new file mode 100644 index 000000000..398c52701 --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/calldata_struct_mapping_function.sol @@ -0,0 +1,15 @@ +pragma experimental ABIEncoderV2; + +contract test { + struct S { + T t; + } + struct T { + mapping (uint => uint) k; + } + function f(S calldata b) external { + } +} +// ---- +// TypeError 4103: (155-167): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. +// TypeError 4061: (155-167): Type struct test.S is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/structs/recursion/recursive_struct_as_contract_function_parameter.sol b/test/libsolidity/syntaxTests/structs/recursion/recursive_struct_as_contract_function_parameter.sol index 7f4c0e014..f0a3de401 100644 --- a/test/libsolidity/syntaxTests/structs/recursion/recursive_struct_as_contract_function_parameter.sol +++ b/test/libsolidity/syntaxTests/structs/recursion/recursive_struct_as_contract_function_parameter.sol @@ -1,3 +1,5 @@ +pragma experimental ABIEncoderV2; + contract Test { struct MyStructName { address addr; @@ -7,4 +9,4 @@ contract Test { function f(MyStructName memory s) public {} } // ---- -// TypeError 4103: (112-133): Recursive type not allowed for public or external contract functions. +// TypeError 4103: (147-168): Recursive type not allowed for public or external contract functions. diff --git a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs.sol b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs.sol index 680c8b8a9..15fca7d71 100644 --- a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs.sol +++ b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs.sol @@ -1,7 +1,9 @@ +pragma experimental ABIEncoderV2; + contract C { struct S { uint a; S[] sub; } function f() public pure returns (uint, S memory) { } } // ---- -// TypeError 4103: (91-99): Recursive type not allowed for public or external contract functions. +// TypeError 4103: (126-134): Recursive type not allowed for public or external contract functions. diff --git a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs2.sol b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs2.sol index 085d333d3..a5b1507d3 100644 --- a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs2.sol +++ b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs2.sol @@ -1,7 +1,9 @@ +pragma experimental ABIEncoderV2; + contract C { struct S { uint a; S[2][] sub; } function f() public pure returns (uint, S memory) { } } // ---- -// TypeError 4103: (94-102): Recursive type not allowed for public or external contract functions. +// TypeError 4103: (129-137): Recursive type not allowed for public or external contract functions. diff --git a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs3.sol b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs3.sol index 4e32d57ec..fa9eebb9b 100644 --- a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs3.sol +++ b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs3.sol @@ -1,3 +1,5 @@ +pragma experimental ABIEncoderV2; + contract C { struct S { uint a; S[][][] sub; } struct T { S s; } @@ -5,4 +7,4 @@ contract C { } } // ---- -// TypeError 4103: (119-129): Recursive type not allowed for public or external contract functions. +// TypeError 4103: (154-164): Recursive type not allowed for public or external contract functions. diff --git a/test/libsolidity/syntaxTests/structs/struct_var_member.sol b/test/libsolidity/syntaxTests/structs/struct_var_member.sol deleted file mode 100644 index 8d42459ae..000000000 --- a/test/libsolidity/syntaxTests/structs/struct_var_member.sol +++ /dev/null @@ -1,7 +0,0 @@ -contract C { - struct S { - var x; - } -} -// ---- -// ParserError 7059: (27-30): Expected explicit type name. diff --git a/test/libsolidity/syntaxTests/types/mapping/assignment_local_err.sol b/test/libsolidity/syntaxTests/types/mapping/assignment_local_err.sol index b353a521a..1d75c53b9 100644 --- a/test/libsolidity/syntaxTests/types/mapping/assignment_local_err.sol +++ b/test/libsolidity/syntaxTests/types/mapping/assignment_local_err.sol @@ -7,4 +7,4 @@ contract D { } } // ---- -// TypeError 9214: (160-161): Mappings cannot be assigned to. +// TypeError 9214: (160-161): Types in storage containing (nested) mappings cannot be assigned to. diff --git a/test/libsolidity/syntaxTests/types/mapping/assignment_map.sol b/test/libsolidity/syntaxTests/types/mapping/assignment_map.sol index 3c756e945..fda9abf3d 100644 --- a/test/libsolidity/syntaxTests/types/mapping/assignment_map.sol +++ b/test/libsolidity/syntaxTests/types/mapping/assignment_map.sol @@ -20,8 +20,18 @@ contract G { uint x = 1; mapping (uint => uint) b = x; } + +contract H { + struct S {mapping (uint => uint) a;} + + S x; + S y = x; + S z = z; +} // ---- -// TypeError 6280: (17-67): Mappings cannot be assigned to. -// TypeError 6280: (120-148): Mappings cannot be assigned to. -// TypeError 9214: (263-264): Mappings cannot be assigned to. -// TypeError 6280: (312-340): Mappings cannot be assigned to. +// TypeError 6280: (17-67): Types in storage containing (nested) mappings cannot be assigned to. +// TypeError 6280: (120-148): Types in storage containing (nested) mappings cannot be assigned to. +// TypeError 9214: (263-264): Types in storage containing (nested) mappings cannot be assigned to. +// TypeError 6280: (312-340): Types in storage containing (nested) mappings cannot be assigned to. +// TypeError 6280: (407-414): Types in storage containing (nested) mappings cannot be assigned to. +// TypeError 6280: (417-424): Types in storage containing (nested) mappings cannot be assigned to. diff --git a/test/libsolidity/syntaxTests/types/mapping/assignment_state_variable.sol b/test/libsolidity/syntaxTests/types/mapping/assignment_state_variable.sol index d78f319dd..bcf0c7e7b 100644 --- a/test/libsolidity/syntaxTests/types/mapping/assignment_state_variable.sol +++ b/test/libsolidity/syntaxTests/types/mapping/assignment_state_variable.sol @@ -8,7 +8,7 @@ contract test { } } // ---- -// TypeError 9214: (126-129): Mappings cannot be assigned to. -// TypeError 9214: (144-147): Mappings cannot be assigned to. -// TypeError 9214: (163-166): Mappings cannot be assigned to. -// TypeError 9214: (168-171): Mappings cannot be assigned to. +// TypeError 9214: (126-129): Types in storage containing (nested) mappings cannot be assigned to. +// TypeError 9214: (144-147): Types in storage containing (nested) mappings cannot be assigned to. +// TypeError 9214: (163-166): Types in storage containing (nested) mappings cannot be assigned to. +// TypeError 9214: (168-171): Types in storage containing (nested) mappings cannot be assigned to. diff --git a/test/libsolidity/syntaxTests/types/mapping/assignment_struct.sol b/test/libsolidity/syntaxTests/types/mapping/assignment_struct.sol index b1ef76ee0..c1051f25a 100644 --- a/test/libsolidity/syntaxTests/types/mapping/assignment_struct.sol +++ b/test/libsolidity/syntaxTests/types/mapping/assignment_struct.sol @@ -11,7 +11,7 @@ contract test { } } // ---- -// TypeError 9214: (172-180): Mappings cannot be assigned to. -// TypeError 9214: (195-203): Mappings cannot be assigned to. -// TypeError 9214: (219-227): Mappings cannot be assigned to. -// TypeError 9214: (229-237): Mappings cannot be assigned to. +// TypeError 9214: (172-180): Types in storage containing (nested) mappings cannot be assigned to. +// TypeError 9214: (195-203): Types in storage containing (nested) mappings cannot be assigned to. +// TypeError 9214: (219-227): Types in storage containing (nested) mappings cannot be assigned to. +// TypeError 9214: (229-237): Types in storage containing (nested) mappings cannot be assigned to. diff --git a/test/libsolidity/syntaxTests/types/mapping/function_type_argument_array.sol b/test/libsolidity/syntaxTests/types/mapping/function_type_argument_array.sol new file mode 100644 index 000000000..e7587ad0c --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/function_type_argument_array.sol @@ -0,0 +1,6 @@ +contract test { + function f(mapping(uint => uint)[2] memory b) internal { + } +} +// ---- +// TypeError 4061: (31-64): Type mapping(uint256 => uint256)[2] is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/library_argument_storage.sol b/test/libsolidity/syntaxTests/types/mapping/library_argument_storage.sol new file mode 100644 index 000000000..edf86e397 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/library_argument_storage.sol @@ -0,0 +1,13 @@ +library Set { + struct Data { mapping(uint => bool) flags; } + + function insert(Data storage self, uint value) + public + returns (bool) + { + if (self.flags[value]) + return false; // already there + self.flags[value] = true; + return true; + } +} diff --git a/test/libsolidity/syntaxTests/types/mapping/library_array_argument_external.sol b/test/libsolidity/syntaxTests/types/mapping/library_array_argument_external.sol index 1826ea2b9..ca875546e 100644 --- a/test/libsolidity/syntaxTests/types/mapping/library_array_argument_external.sol +++ b/test/libsolidity/syntaxTests/types/mapping/library_array_argument_external.sol @@ -3,4 +3,3 @@ library L { } } // ---- -// TypeError 3312: (27-58): Type is required to live outside storage. diff --git a/test/libsolidity/syntaxTests/types/mapping/library_array_argument_public.sol b/test/libsolidity/syntaxTests/types/mapping/library_array_argument_public.sol index 644bc5129..03ca40145 100644 --- a/test/libsolidity/syntaxTests/types/mapping/library_array_argument_public.sol +++ b/test/libsolidity/syntaxTests/types/mapping/library_array_argument_public.sol @@ -3,4 +3,3 @@ library L { } } // ---- -// TypeError 3312: (27-58): Type is required to live outside storage. diff --git a/test/libsolidity/syntaxTests/types/mapping/library_nested_mapping.sol b/test/libsolidity/syntaxTests/types/mapping/library_nested_mapping.sol new file mode 100644 index 000000000..31bf3cb1f --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/library_nested_mapping.sol @@ -0,0 +1,7 @@ +pragma experimental ABIEncoderV2; +library L { + struct S { mapping(uint => uint) m; } + function f(S memory a) external pure returns (S memory) {} +} +// ---- +// TypeError 4061: (103-113): Type struct L.S is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/library_nested_storage.sol b/test/libsolidity/syntaxTests/types/mapping/library_nested_storage.sol new file mode 100644 index 000000000..11b09ce25 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/library_nested_storage.sol @@ -0,0 +1,6 @@ +library Test { + struct Nested { mapping(uint => uint)[2][] a; uint y; } + struct X { Nested n; } + function f(X storage x) external {} +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_array_data_location_function_param_external.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_array_data_location_function_param_external.sol index 07b7553ca..72c2a12a8 100644 --- a/test/libsolidity/syntaxTests/types/mapping/mapping_array_data_location_function_param_external.sol +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_array_data_location_function_param_external.sol @@ -2,5 +2,5 @@ contract c { function f1(mapping(uint => uint)[] calldata) pure external {} } // ---- -// TypeError 3312: (29-61): Type is required to live outside storage. -// TypeError 4103: (29-61): Only libraries are allowed to use the mapping type in public or external functions. +// TypeError 4103: (29-61): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. +// TypeError 4061: (29-61): Type mapping(uint256 => uint256)[] is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_calldata.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_calldata.sol index 3652aebe2..86f971d38 100644 --- a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_calldata.sol +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_calldata.sol @@ -6,4 +6,4 @@ contract c { } } // ---- -// TypeError 6651: (81-113): Data location must be "storage" for variable, but "calldata" was given. +// TypeError 4061: (81-113): Type mapping(uint256 => uint256) is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_default.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_default.sol index 490d987ad..6874deb88 100644 --- a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_default.sol +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_default.sol @@ -6,4 +6,4 @@ contract c { } } // ---- -// TypeError 6651: (81-104): Data location must be "storage" for variable, but none was given. +// TypeError 6651: (81-104): Data location must be "storage", "memory" or "calldata" for variable, but none was given. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_external.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_external.sol index db2b3235b..3bc5d7a29 100644 --- a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_external.sol +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_external.sol @@ -2,5 +2,5 @@ contract c { function f1(mapping(uint => uint) calldata) pure external returns (mapping(uint => uint) memory) {} } // ---- -// TypeError 3442: (29-59): Mapping types can only have a data location of "storage" and thus only be parameters or return variables for internal or library functions. -// TypeError 3442: (84-112): Mapping types can only have a data location of "storage" and thus only be parameters or return variables for internal or library functions. +// TypeError 4103: (29-59): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. +// TypeError 4061: (29-59): Type mapping(uint256 => uint256) is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_internal.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_internal.sol index 92f2e0ed4..95ca53279 100644 --- a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_internal.sol +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_internal.sol @@ -3,4 +3,4 @@ contract c { function f5(mapping(uint => uint) memory) pure internal {} } // ---- -// TypeError 5380: (93-121): Mapping types can only have a data location of "storage". +// TypeError 4061: (93-121): Type mapping(uint256 => uint256) is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_public.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_public.sol index 5547e071d..f8a666675 100644 --- a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_public.sol +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_function_param_public.sol @@ -2,4 +2,5 @@ contract c { function f3(mapping(uint => uint) memory) view public {} } // ---- -// TypeError 3442: (29-57): Mapping types can only have a data location of "storage" and thus only be parameters or return variables for internal or library functions. +// TypeError 4103: (29-57): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. +// TypeError 4061: (29-57): Type mapping(uint256 => uint256) is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_memory.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_memory.sol index 1b04b63fd..f31c79315 100644 --- a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_memory.sol +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_memory.sol @@ -6,4 +6,4 @@ contract c { } } // ---- -// TypeError 6651: (81-111): Data location must be "storage" for variable, but "memory" was given. +// TypeError 4061: (81-111): Type mapping(uint256 => uint256) is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_function_calldata.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_function_calldata.sol new file mode 100644 index 000000000..f2360b2d1 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_function_calldata.sol @@ -0,0 +1,12 @@ +pragma experimental ABIEncoderV2; + +contract test { + struct S { + mapping (uint => uint) s; + } + function f(S calldata b) external { + } +} +// ---- +// TypeError 4103: (121-133): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. +// TypeError 4061: (121-133): Type struct test.S is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_return_public_memory.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_return_public_memory.sol index e3e4d2cc3..4d06bad5a 100644 --- a/test/libsolidity/syntaxTests/types/mapping/mapping_return_public_memory.sol +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_return_public_memory.sol @@ -3,4 +3,5 @@ contract C { } } // ---- -// TypeError 3442: (51-79): Mapping types can only have a data location of "storage" and thus only be parameters or return variables for internal or library functions. +// TypeError 4103: (51-79): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. +// TypeError 4061: (51-79): Type mapping(uint256 => uint256) is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_struct_data_location_memory.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_struct_data_location_memory.sol new file mode 100644 index 000000000..648e2f74e --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_struct_data_location_memory.sol @@ -0,0 +1,8 @@ +pragma experimental ABIEncoderV2; +contract C { + struct S { mapping(uint => uint) a; } + function f(S memory) public {} +} +// ---- +// TypeError 4103: (104-112): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. +// TypeError 4061: (104-112): Type struct C.S is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_struct_recusrive_data_location_memory.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_struct_recusrive_data_location_memory.sol new file mode 100644 index 000000000..350129dff --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_struct_recusrive_data_location_memory.sol @@ -0,0 +1,10 @@ +pragma experimental ABIEncoderV2; +contract C { + struct S { mapping(uint => uint) a; } + struct T { S s; } + struct U { T t; } + function f(U memory) public {} +} +// ---- +// TypeError 4103: (148-156): Types containing (nested) mappings can only be parameters or return variables of internal or library functions. +// TypeError 4061: (148-156): Type struct C.U is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/memory_struct_recursive.sol b/test/libsolidity/syntaxTests/types/mapping/memory_struct_recursive.sol new file mode 100644 index 000000000..c6f8f48f3 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/memory_struct_recursive.sol @@ -0,0 +1,20 @@ +contract Test { + struct S { + T[] t; + } + + struct T { + U[] u; + } + + struct U { + S[] s; + mapping (uint => S) map; + } + + function f() public { + S memory s; + } +} +// ---- +// TypeError 4061: (143-153): Type struct Test.S is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/memory_structs_with_mappings.sol b/test/libsolidity/syntaxTests/types/mapping/memory_structs_with_mappings.sol new file mode 100644 index 000000000..f583b4314 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/memory_structs_with_mappings.sol @@ -0,0 +1,15 @@ +contract Test { + struct S { + uint8 a; + mapping(uint256 => uint256) b; + uint8 c; + } + S s; + + function f() public returns (uint256) { + S memory x; + } +} + +// ---- +// TypeError 4061: (172-182): Type struct Test.S is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/unnamed_tuple_decl.sol b/test/libsolidity/syntaxTests/types/unnamed_tuple_decl.sol index 5c67ae5e8..00301cde0 100644 --- a/test/libsolidity/syntaxTests/types/unnamed_tuple_decl.sol +++ b/test/libsolidity/syntaxTests/types/unnamed_tuple_decl.sol @@ -4,13 +4,11 @@ contract C { function h() internal pure returns (uint, uint) { return (1, 2); } function test() internal pure { - var () = f(); - var () = g(); - var (,) = h(); + () = f(); + () = g(); + (,) = h(); } } // ---- -// SyntaxError 3299: (223-235): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. -// SyntaxError 3299: (245-257): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. -// SyntaxError 3299: (267-280): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. +// ParserError 6933: (224-225): Expected primary expression. diff --git a/test/libsolidity/syntaxTests/types/var_decl_val_mismatch.sol b/test/libsolidity/syntaxTests/types/var_decl_val_mismatch.sol index 8561b1cba..314d2bb73 100644 --- a/test/libsolidity/syntaxTests/types/var_decl_val_mismatch.sol +++ b/test/libsolidity/syntaxTests/types/var_decl_val_mismatch.sol @@ -3,13 +3,14 @@ contract n fallback() external { // Used to cause a segfault - var (x,y) = (1); - var (z) = (); + (uint x, ) = (1); + (uint z) = (); assembly { - mstore(y, z) + mstore(x, z) } } } // ---- -// TypeError 7364: (69-84): Different number of components on the left hand side (2) than on the right hand side (1). +// TypeError 7364: (69-85): Different number of components on the left hand side (2) than on the right hand side (1). +// TypeError 7364: (89-102): Different number of components on the left hand side (1) than on the right hand side (0). diff --git a/test/libsolidity/syntaxTests/types/var_empty_decl_0.sol b/test/libsolidity/syntaxTests/types/var_empty_decl_0.sol deleted file mode 100644 index 0106fd92c..000000000 --- a/test/libsolidity/syntaxTests/types/var_empty_decl_0.sol +++ /dev/null @@ -1,9 +0,0 @@ -contract C { - function f() public pure { - var (); - var (,); - } -} -// ---- -// SyntaxError 3299: (52-58): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. -// SyntaxError 3299: (68-75): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. diff --git a/test/libsolidity/syntaxTests/types/var_empty_decl_1.sol b/test/libsolidity/syntaxTests/types/var_empty_decl_1.sol index 09572cb08..7f55029c2 100644 --- a/test/libsolidity/syntaxTests/types/var_empty_decl_1.sol +++ b/test/libsolidity/syntaxTests/types/var_empty_decl_1.sol @@ -5,4 +5,4 @@ contract C { } } // ---- -// TypeError 6983: (52-57): Use of the "var" keyword is disallowed. +// ParserError 6933: (52-55): Expected primary expression. diff --git a/test/libsolidity/syntaxTests/types/var_empty_decl_2.sol b/test/libsolidity/syntaxTests/types/var_empty_decl_2.sol index 179d63533..dad288d79 100644 --- a/test/libsolidity/syntaxTests/types/var_empty_decl_2.sol +++ b/test/libsolidity/syntaxTests/types/var_empty_decl_2.sol @@ -6,4 +6,4 @@ contract C { } } // ---- -// TypeError 4626: (52-62): Use of the "var" keyword is disallowed. +// ParserError 6933: (52-55): Expected primary expression. diff --git a/test/libsolidity/syntaxTests/types/var_empty_decl_3.sol b/test/libsolidity/syntaxTests/types/var_empty_decl_3.sol index 8166f5284..caf178761 100644 --- a/test/libsolidity/syntaxTests/types/var_empty_decl_3.sol +++ b/test/libsolidity/syntaxTests/types/var_empty_decl_3.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// TypeError 4626: (52-63): Use of the "var" keyword is disallowed. +// ParserError 6933: (52-55): Expected primary expression. diff --git a/test/libsolidity/syntaxTests/types/var_type_invalid_rational.sol b/test/libsolidity/syntaxTests/types/var_type_invalid_rational.sol index 893d49637..c56e50b62 100644 --- a/test/libsolidity/syntaxTests/types/var_type_invalid_rational.sol +++ b/test/libsolidity/syntaxTests/types/var_type_invalid_rational.sol @@ -1,8 +1,8 @@ contract C { function f() internal pure { - var i = 31415999999999999999999999999999999999999999999999999999999999999999933**3; - var unreachable = 123; + uint i = 31415999999999999999999999999999999999999999999999999999999999999999933**3; + uint unreachable = 123; } } // ---- -// TypeError 6963: (62-136): Invalid rational int_const 3100...(204 digits omitted)...9237 (absolute value too large or division by zero). +// TypeError 9574: (54-137): Type int_const 3100...(204 digits omitted)...9237 is not implicitly convertible to expected type uint256. Literal is too large to fit in uint256. diff --git a/test/libsolidity/syntaxTests/types/var_type_suggest.sol b/test/libsolidity/syntaxTests/types/var_type_suggest.sol deleted file mode 100644 index 61ee7d317..000000000 --- a/test/libsolidity/syntaxTests/types/var_type_suggest.sol +++ /dev/null @@ -1,30 +0,0 @@ -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 s = -31415; - var i = 31415; - var t = "string"; - var g2 = g; - var myblockhash = block.blockhash; - var (a, b) = (2, "troi"); - var (x,, z) = h(); - var (c, d) = (""); - var (k, l) = (2); - var (m, n) = 1; - var (o, p) = ""; - } -} -// ---- -// SyntaxError 1719: (224-238): Use of the "var" keyword is disallowed. Use explicit declaration `int16 s = ...` instead. -// SyntaxError 1719: (248-261): Use of the "var" keyword is disallowed. Use explicit declaration `uint16 i = ...` instead. -// SyntaxError 1719: (271-287): Use of the "var" keyword is disallowed. Use explicit declaration `string memory t = ...` instead. -// SyntaxError 1719: (297-307): Use of the "var" keyword is disallowed. Use explicit declaration `function (uint256) pure returns (uint256) g2 = ...` instead. -// SyntaxError 3478: (317-350): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. -// SyntaxError 1719: (360-384): Use of the "var" keyword is disallowed. Use explicit declaration `(uint8 a, string memory b) = ...` instead. -// SyntaxError 1719: (394-411): Use of the "var" keyword is disallowed. Use explicit declaration `(uint256 x, , uint256 z) = ...` instead. -// TypeError 7364: (421-438): Different number of components on the left hand side (2) than on the right hand side (1). diff --git a/test/libsolidity/syntaxTests/viewPureChecker/assembly.sol b/test/libsolidity/syntaxTests/viewPureChecker/assembly.sol index 92b5e4c8b..c3ab88b5b 100644 --- a/test/libsolidity/syntaxTests/viewPureChecker/assembly.sol +++ b/test/libsolidity/syntaxTests/viewPureChecker/assembly.sol @@ -2,7 +2,7 @@ contract C { struct S { uint x; } S s; function e() pure public { - assembly { mstore(keccak256(0, 20), mul(s_slot, 2)) } + assembly { mstore(keccak256(0, 20), mul(s.slot, 2)) } } function f() pure public { uint x; diff --git a/test/libsolidity/syntaxTests/viewPureChecker/gas_value_without_call.sol b/test/libsolidity/syntaxTests/viewPureChecker/gas_value_without_call.sol index a4b8af9f2..41120bf08 100644 --- a/test/libsolidity/syntaxTests/viewPureChecker/gas_value_without_call.sol +++ b/test/libsolidity/syntaxTests/viewPureChecker/gas_value_without_call.sol @@ -1,26 +1,14 @@ contract C { function f() external payable {} function g(address a) external pure { - a.call.value(42); a.call{value: 42}; - a.call.gas(42); a.call{gas: 42}; - a.staticcall.gas(42); a.staticcall{gas: 42}; - a.delegatecall.gas(42); a.delegatecall{gas: 42}; } function h() external view { - this.f.value(42); this.f{value: 42}; - this.f.gas(42); this.f{gas: 42}; } } // ---- -// Warning 1621: (91-103): Using ".value(...)" is deprecated. Use "{value: ...}" instead. -// Warning 1621: (132-142): Using ".gas(...)" is deprecated. Use "{gas: ...}" instead. -// Warning 1621: (169-185): Using ".gas(...)" is deprecated. Use "{gas: ...}" instead. -// Warning 1621: (218-236): Using ".gas(...)" is deprecated. Use "{gas: ...}" instead. -// Warning 1621: (304-316): Using ".value(...)" is deprecated. Use "{value: ...}" instead. -// Warning 1621: (345-355): Using ".gas(...)" is deprecated. Use "{gas: ...}" instead. diff --git a/test/libsolidity/syntaxTests/viewPureChecker/gas_with_call_nonpayable.sol b/test/libsolidity/syntaxTests/viewPureChecker/gas_with_call_nonpayable.sol index c26f0dd78..be8a5aeb8 100644 --- a/test/libsolidity/syntaxTests/viewPureChecker/gas_with_call_nonpayable.sol +++ b/test/libsolidity/syntaxTests/viewPureChecker/gas_with_call_nonpayable.sol @@ -1,27 +1,12 @@ contract C { function f(address a) external view returns (bool success) { - (success,) = a.call.gas(42)(""); - (success,) = a.call{gas: 42}(""); - } - function g(address a) external view returns (bool success) { - (success,) = a.call.gas(42)(""); (success,) = a.call{gas: 42}(""); } function h() external payable {} function i() external view { - this.h.gas(42)(); - } - function j() external view { this.h{gas: 42}(); } } // ---- -// Warning 1621: (90-100): Using ".gas(...)" is deprecated. Use "{gas: ...}" instead. -// Warning 1621: (226-236): Using ".gas(...)" is deprecated. Use "{gas: ...}" instead. -// Warning 1621: (351-361): Using ".gas(...)" is deprecated. Use "{gas: ...}" instead. -// TypeError 8961: (90-108): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. -// TypeError 8961: (125-144): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. -// TypeError 8961: (226-244): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. -// TypeError 8961: (261-280): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. -// TypeError 8961: (351-367): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. -// TypeError 8961: (404-421): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. +// TypeError 8961: (90-109): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. +// TypeError 8961: (180-197): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. diff --git a/test/libsolidity/syntaxTests/viewPureChecker/smoke_test.sol b/test/libsolidity/syntaxTests/viewPureChecker/smoke_test.sol index 0e397efcc..c6eec48b1 100644 --- a/test/libsolidity/syntaxTests/viewPureChecker/smoke_test.sol +++ b/test/libsolidity/syntaxTests/viewPureChecker/smoke_test.sol @@ -1,7 +1,7 @@ contract C { uint x; function g() pure public {} - function f() view public returns (uint) { return now; } + function f() view public returns (uint) { return block.timestamp; } function h() public { x = 2; } function i() payable public { x = 2; } } diff --git a/test/libsolidity/syntaxTests/viewPureChecker/staticcall_gas_view.sol b/test/libsolidity/syntaxTests/viewPureChecker/staticcall_gas_view.sol index 10ce2b99e..f49327a92 100644 --- a/test/libsolidity/syntaxTests/viewPureChecker/staticcall_gas_view.sol +++ b/test/libsolidity/syntaxTests/viewPureChecker/staticcall_gas_view.sol @@ -2,14 +2,10 @@ contract C { function f() external view {} function test(address a) external view returns (bool status) { // This used to incorrectly raise an error about violating the view mutability. - (status,) = a.staticcall.gas(42)(""); (status,) = a.staticcall{gas: 42}(""); - this.f.gas(42)(); this.f{gas: 42}(); } } // ==== // EVMVersion: >=byzantium // ---- -// Warning 1621: (207-223): Using ".gas(...)" is deprecated. Use "{gas: ...}" instead. -// Warning 1621: (276-286): Using ".gas(...)" is deprecated. Use "{gas: ...}" instead. diff --git a/test/libsolidity/syntaxTests/viewPureChecker/value_with_call_nonpayable.sol b/test/libsolidity/syntaxTests/viewPureChecker/value_with_call_nonpayable.sol index 1f1c48fcf..af95cbe49 100644 --- a/test/libsolidity/syntaxTests/viewPureChecker/value_with_call_nonpayable.sol +++ b/test/libsolidity/syntaxTests/viewPureChecker/value_with_call_nonpayable.sol @@ -1,25 +1,12 @@ contract C { function f(address a) external view returns (bool success) { - (success,) = a.call.value(42)(""); - (success,) = a.call{value: 42}(""); - } - function g(address a) external view returns (bool success) { - (success,) = a.call.value(42)(""); (success,) = a.call{value: 42}(""); } function h() external payable {} function i() external view { - this.h.value(42)(); this.h{value: 42}(); } } // ---- -// Warning 1621: (90-102): Using ".value(...)" is deprecated. Use "{value: ...}" instead. -// Warning 1621: (230-242): Using ".value(...)" is deprecated. Use "{value: ...}" instead. -// Warning 1621: (359-371): Using ".value(...)" is deprecated. Use "{value: ...}" instead. -// TypeError 8961: (90-110): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. -// TypeError 8961: (127-148): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. -// TypeError 8961: (230-250): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. -// TypeError 8961: (267-288): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. -// TypeError 8961: (359-377): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. -// TypeError 8961: (381-400): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. +// TypeError 8961: (90-111): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. +// TypeError 8961: (182-201): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. diff --git a/test/libyul/yulSyntaxTests/are_we_perl_yet.yul b/test/libyul/yulSyntaxTests/are_we_perl_yet.yul index ffe8da407..7a79436b4 100644 --- a/test/libyul/yulSyntaxTests/are_we_perl_yet.yul +++ b/test/libyul/yulSyntaxTests/are_we_perl_yet.yul @@ -4,3 +4,9 @@ _...(a...) } // ---- +// SyntaxError 3384: (6-27): "_..." is not a valid identifier (ends with a dot). +// SyntaxError 7771: (6-27): "_..." is not a valid identifier (contains consecutive dots). +// SyntaxError 3384: (20-23): "$.." is not a valid identifier (ends with a dot). +// SyntaxError 7771: (20-23): "$.." is not a valid identifier (contains consecutive dots). +// SyntaxError 3384: (36-40): "a..." is not a valid identifier (ends with a dot). +// SyntaxError 7771: (36-40): "a..." is not a valid identifier (contains consecutive dots). diff --git a/test/libyul/yulSyntaxTests/dot_consecutive_function.yul b/test/libyul/yulSyntaxTests/dot_consecutive_function.yul index 6b8c0db08..3d58fd47d 100644 --- a/test/libyul/yulSyntaxTests/dot_consecutive_function.yul +++ b/test/libyul/yulSyntaxTests/dot_consecutive_function.yul @@ -2,3 +2,4 @@ function x..y() {} } // ---- +// SyntaxError 7771: (6-24): "x..y" is not a valid identifier (contains consecutive dots). diff --git a/test/libyul/yulSyntaxTests/dot_consecutive_function_arg.yul b/test/libyul/yulSyntaxTests/dot_consecutive_function_arg.yul index 1af439328..150b81405 100644 --- a/test/libyul/yulSyntaxTests/dot_consecutive_function_arg.yul +++ b/test/libyul/yulSyntaxTests/dot_consecutive_function_arg.yul @@ -2,3 +2,4 @@ function x(a..b) {} } // ---- +// SyntaxError 7771: (17-21): "a..b" is not a valid identifier (contains consecutive dots). diff --git a/test/libyul/yulSyntaxTests/dot_consecutive_function_ret.yul b/test/libyul/yulSyntaxTests/dot_consecutive_function_ret.yul index 1fc66a18a..0d3a7be3f 100644 --- a/test/libyul/yulSyntaxTests/dot_consecutive_function_ret.yul +++ b/test/libyul/yulSyntaxTests/dot_consecutive_function_ret.yul @@ -2,3 +2,4 @@ function x() -> a..b {} } // ---- +// SyntaxError 7771: (22-26): "a..b" is not a valid identifier (contains consecutive dots). diff --git a/test/libyul/yulSyntaxTests/dot_consecutive_variabledeclaration.yul b/test/libyul/yulSyntaxTests/dot_consecutive_variabledeclaration.yul index 0f2b4c336..d426a7b7d 100644 --- a/test/libyul/yulSyntaxTests/dot_consecutive_variabledeclaration.yul +++ b/test/libyul/yulSyntaxTests/dot_consecutive_variabledeclaration.yul @@ -2,3 +2,4 @@ let a..b := 1 } // ---- +// SyntaxError 7771: (10-14): "a..b" is not a valid identifier (contains consecutive dots). diff --git a/test/libyul/yulSyntaxTests/dot_ellipse_function.yul b/test/libyul/yulSyntaxTests/dot_ellipse_function.yul index fbb8f32a3..ebfa0f579 100644 --- a/test/libyul/yulSyntaxTests/dot_ellipse_function.yul +++ b/test/libyul/yulSyntaxTests/dot_ellipse_function.yul @@ -2,3 +2,4 @@ function x...y() {} } // ---- +// SyntaxError 7771: (6-25): "x...y" is not a valid identifier (contains consecutive dots). diff --git a/test/libyul/yulSyntaxTests/dot_ellipse_function_arg.yul b/test/libyul/yulSyntaxTests/dot_ellipse_function_arg.yul index 47dd7b2bb..75298aa0e 100644 --- a/test/libyul/yulSyntaxTests/dot_ellipse_function_arg.yul +++ b/test/libyul/yulSyntaxTests/dot_ellipse_function_arg.yul @@ -2,3 +2,4 @@ function x(a...b) {} } // ---- +// SyntaxError 7771: (17-22): "a...b" is not a valid identifier (contains consecutive dots). diff --git a/test/libyul/yulSyntaxTests/dot_ellipse_function_ret.yul b/test/libyul/yulSyntaxTests/dot_ellipse_function_ret.yul index 70ba65069..7d1b95155 100644 --- a/test/libyul/yulSyntaxTests/dot_ellipse_function_ret.yul +++ b/test/libyul/yulSyntaxTests/dot_ellipse_function_ret.yul @@ -2,3 +2,4 @@ function x() -> a...b {} } // ---- +// SyntaxError 7771: (22-27): "a...b" is not a valid identifier (contains consecutive dots). diff --git a/test/libyul/yulSyntaxTests/dot_ellipse_variabledeclaration.yul b/test/libyul/yulSyntaxTests/dot_ellipse_variabledeclaration.yul index 47870bfb2..c772073cd 100644 --- a/test/libyul/yulSyntaxTests/dot_ellipse_variabledeclaration.yul +++ b/test/libyul/yulSyntaxTests/dot_ellipse_variabledeclaration.yul @@ -2,3 +2,4 @@ let a...b := 1 } // ---- +// SyntaxError 7771: (10-15): "a...b" is not a valid identifier (contains consecutive dots). diff --git a/test/libyul/yulSyntaxTests/dot_trailing_function.yul b/test/libyul/yulSyntaxTests/dot_trailing_function.yul index 4348149d3..c3b151e89 100644 --- a/test/libyul/yulSyntaxTests/dot_trailing_function.yul +++ b/test/libyul/yulSyntaxTests/dot_trailing_function.yul @@ -2,3 +2,4 @@ function x.() {} } // ---- +// SyntaxError 3384: (6-22): "x." is not a valid identifier (ends with a dot). diff --git a/test/libyul/yulSyntaxTests/dot_trailing_function_arg.yul b/test/libyul/yulSyntaxTests/dot_trailing_function_arg.yul index d8fc0336d..c81c18446 100644 --- a/test/libyul/yulSyntaxTests/dot_trailing_function_arg.yul +++ b/test/libyul/yulSyntaxTests/dot_trailing_function_arg.yul @@ -2,3 +2,4 @@ function x(a.) {} } // ---- +// SyntaxError 3384: (17-19): "a." is not a valid identifier (ends with a dot). diff --git a/test/libyul/yulSyntaxTests/dot_trailing_function_ret.yul b/test/libyul/yulSyntaxTests/dot_trailing_function_ret.yul index 92b9daf16..adfa02410 100644 --- a/test/libyul/yulSyntaxTests/dot_trailing_function_ret.yul +++ b/test/libyul/yulSyntaxTests/dot_trailing_function_ret.yul @@ -2,3 +2,4 @@ function x() -> a. {} } // ---- +// SyntaxError 3384: (22-24): "a." is not a valid identifier (ends with a dot). diff --git a/test/libyul/yulSyntaxTests/dot_trailing_variabledeclaration.yul b/test/libyul/yulSyntaxTests/dot_trailing_variabledeclaration.yul index b71a3d583..cc86ca23e 100644 --- a/test/libyul/yulSyntaxTests/dot_trailing_variabledeclaration.yul +++ b/test/libyul/yulSyntaxTests/dot_trailing_variabledeclaration.yul @@ -2,3 +2,4 @@ let a. := 1 } // ---- +// SyntaxError 3384: (10-12): "a." is not a valid identifier (ends with a dot). diff --git a/test/libyul/yulSyntaxTests/pc.yul b/test/libyul/yulSyntaxTests/pc.yul index 15fa55a48..e43d7a141 100644 --- a/test/libyul/yulSyntaxTests/pc.yul +++ b/test/libyul/yulSyntaxTests/pc.yul @@ -4,4 +4,4 @@ // ==== // dialect: evmTyped // ---- -// Warning 2450: (10-12): The "pc" instruction is deprecated and will be removed in the next breaking release. +// SyntaxError 2450: (10-12): PC instruction is a low-level EVM feature. Because of that PC is disallowed in strict assembly. diff --git a/test/tools/ossfuzz/config/solidity.dict b/test/tools/ossfuzz/config/solidity.dict index f788d49c2..f80fab989 100644 --- a/test/tools/ossfuzz/config/solidity.dict +++ b/test/tools/ossfuzz/config/solidity.dict @@ -6,7 +6,6 @@ " block.timestamp " " days " " ether " -" finney " " gasleft() " " gwei " " hours " @@ -18,7 +17,6 @@ " msg.value " " now " " seconds " -" szabo " " tx.gasprice " " tx.origin " " weeks " diff --git a/test/tools/ossfuzz/protoToYul.cpp b/test/tools/ossfuzz/protoToYul.cpp index 1d78dc802..63cbc2446 100644 --- a/test/tools/ossfuzz/protoToYul.cpp +++ b/test/tools/ossfuzz/protoToYul.cpp @@ -631,9 +631,6 @@ void ProtoConverter::visit(NullaryOp const& _x) { switch (_x.op()) { - case NullaryOp::PC: - m_output << "pc()"; - break; case NullaryOp::MSIZE: m_output << "msize()"; break; diff --git a/test/tools/ossfuzz/yulProto.proto b/test/tools/ossfuzz/yulProto.proto index d87d067f2..8c948914d 100644 --- a/test/tools/ossfuzz/yulProto.proto +++ b/test/tools/ossfuzz/yulProto.proto @@ -215,24 +215,23 @@ message ExtCodeCopy { message NullaryOp { enum NOp { - PC = 1; - MSIZE = 2; - GAS = 3; - CALLDATASIZE = 4; - CODESIZE = 5; - RETURNDATASIZE = 6; - ADDRESS = 7; - ORIGIN = 8; - CALLER = 9; - CALLVALUE = 10; - GASPRICE = 11; - COINBASE = 12; - TIMESTAMP = 13; - NUMBER = 14; - DIFFICULTY = 15; - GASLIMIT = 16; - SELFBALANCE = 17; - CHAINID = 18; + MSIZE = 1; + GAS = 2; + CALLDATASIZE = 3; + CODESIZE = 4; + RETURNDATASIZE = 5; + ADDRESS = 6; + ORIGIN = 7; + CALLER = 8; + CALLVALUE = 9; + GASPRICE = 10; + COINBASE = 11; + TIMESTAMP = 12; + NUMBER = 13; + DIFFICULTY = 14; + GASLIMIT = 15; + SELFBALANCE = 16; + CHAINID = 17; } required NOp op = 1; } diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index f6b87c9f6..1d4daeac8 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -5,6 +5,7 @@ add_executable(solidity-upgrade solidityUpgrade/UpgradeSuite.h solidityUpgrade/Upgrade050.cpp solidityUpgrade/Upgrade060.cpp + solidityUpgrade/Upgrade070.cpp solidityUpgrade/SourceTransform.h solidityUpgrade/SourceUpgrade.cpp ) diff --git a/tools/solidityUpgrade/SourceTransform.h b/tools/solidityUpgrade/SourceTransform.h index 571811983..65226a442 100644 --- a/tools/solidityUpgrade/SourceTransform.h +++ b/tools/solidityUpgrade/SourceTransform.h @@ -22,17 +22,39 @@ #include +#include #include namespace solidity::tools { +/** + * Helper for displaying location during asserts + */ +class LocationHelper +{ + std::stringstream m_stream; + +public: + + template + LocationHelper& operator<<(T const& data) + { + m_stream << data; + return *this; + } + + operator std::string() { return m_stream.str(); } +}; + + /** * Helper that provides functions which analyze certain source locations * on a textual base. They utilize regular expression to search for * keywords or to determine formatting. */ -class SourceAnalysis { +class SourceAnalysis +{ public: static bool isMultilineKeyword( langutil::SourceLocation const& _location, @@ -85,6 +107,7 @@ public: for (auto inheritedContract: _contracts) overrideList += inheritedContract->name() + ","; + // Note: Can create incorrect replacements return "override(" + overrideList.substr(0, overrideList.size() - 1) + ")"; } }; @@ -105,11 +128,22 @@ public: std::string const& _expression ) { - return regex_replace( - _location.text(), - std::regex{"(\\b" + _keyword + "\\b)"}, - _expression + " " + _keyword - ); + auto _regex = std::regex{"(\\b" + _keyword + "\\b)"}; + if (regex_search(_location.text(), _regex)) + return regex_replace( + _location.text(), + _regex, + _expression + " " + _keyword, + std::regex_constants::format_first_only + ); + else + solAssert( + false, + LocationHelper() << "Could not fix: " << _location.text() << " at " << _location << + "\nNeeds to be fixed manually." + ); + + return ""; } /// Searches for the keyword given and appends the expression. @@ -124,7 +158,17 @@ public: std::string toAppend = isMultiline ? ("\n " + _expression) : (" " + _expression); std::regex keyword{"(\\b" + _keyword + "\\b)"}; - return regex_replace(_location.text(), keyword, _keyword + toAppend); + if (regex_search(_location.text(), keyword)) + return regex_replace(_location.text(), keyword, _keyword + toAppend); + else + solAssert( + false, + LocationHelper() << "Could not fix: " << _location.text() << " at " << _location << + "\nNeeds to be fixed manually." + ); + + return ""; + } /// Searches for the first right parenthesis and appends the expression @@ -135,11 +179,21 @@ public: std::string const& _expression ) { - return regex_replace( - _location.text(), - std::regex{"(\\))"}, - ") " + _expression - ); + auto _regex = std::regex{"(\\))"}; + if (regex_search(_location.text(), _regex)) + return regex_replace( + _location.text(), + std::regex{"(\\))"}, + ") " + _expression + ); + else + solAssert( + false, + LocationHelper() << "Could not fix: " << _location.text() << " at " << _location << + "\nNeeds to be fixed manually." + ); + + return ""; } /// Searches for the `function` keyword and its identifier and replaces @@ -151,11 +205,84 @@ public: std::string const& _expression ) { - return regex_replace( - _location.text(), - std::regex{"(\\bfunction\\s*" + _name + "\\b)"}, - _expression - ); + auto _regex = std::regex{ "(\\bfunction\\s*" + _name + "\\b)"}; + if (regex_search(_location.text(), _regex)) + return regex_replace( + _location.text(), + _regex, + _expression + ); + else + solAssert( + false, + LocationHelper() << "Could not fix: " << _location.text() << " at " << _location << + "\nNeeds to be fixed manually." + ); + + return ""; + } + + static std::string gasUpdate(langutil::SourceLocation const& _location) + { + // dot, "gas", any number of whitespaces, left bracket + std::regex gasReg{"\\.gas\\s*\\("}; + + if (regex_search(_location.text(), gasReg)) + { + std::string out = regex_replace( + _location.text(), + gasReg, + "{gas: ", + std::regex_constants::format_first_only + ); + return regex_replace(out, std::regex{"\\)$"}, "}"); + } + else + solAssert( + false, + LocationHelper() << "Could not fix: " << _location.text() << " at " << _location << + "\nNeeds to be fixed manually." + ); + + return ""; + } + + static std::string valueUpdate(langutil::SourceLocation const& _location) + { + // dot, "value", any number of whitespaces, left bracket + std::regex valueReg{"\\.value\\s*\\("}; + + if (regex_search(_location.text(), valueReg)) + { + std::string out = regex_replace( + _location.text(), + valueReg, + "{value: ", + std::regex_constants::format_first_only + ); + return regex_replace(out, std::regex{"\\)$"}, "}"); + } + else + solAssert( + false, + LocationHelper() << "Could not fix: " << _location.text() << " at " << _location << + "\nNeeds to be fixed manually." + ); + + return ""; + } + + static std::string nowUpdate(langutil::SourceLocation const& _location) + { + return regex_replace(_location.text(), std::regex{"now"}, "block.timestamp"); + } + + static std::string removeVisibility(langutil::SourceLocation const& _location) + { + std::string replacement = _location.text(); + for (auto const& replace: {"public ", "public", "internal ", "internal", "external ", "external"}) + replacement = regex_replace(replacement, std::regex{replace}, ""); + return replacement; } }; diff --git a/tools/solidityUpgrade/SourceUpgrade.cpp b/tools/solidityUpgrade/SourceUpgrade.cpp index 5379f4b70..dbd974f1f 100644 --- a/tools/solidityUpgrade/SourceUpgrade.cpp +++ b/tools/solidityUpgrade/SourceUpgrade.cpp @@ -195,6 +195,12 @@ Allowed options)", m_suite.activateModule(Module::OverridingFunction); else if (module == "virtual") m_suite.activateModule(Module::VirtualFunction); + else if (module == "dotsyntax") + m_suite.activateModule(Module::DotSyntax); + else if (module == "now") + m_suite.activateModule(Module::NowKeyword); + else if (module == "constructor-visibility") + m_suite.activateModule(Module::ConstrutorVisibility); else { error() << "Unknown upgrade module \"" + module + "\"" << endl; diff --git a/tools/solidityUpgrade/SourceUpgrade.h b/tools/solidityUpgrade/SourceUpgrade.h index e5ad378b3..f70d24080 100644 --- a/tools/solidityUpgrade/SourceUpgrade.h +++ b/tools/solidityUpgrade/SourceUpgrade.h @@ -1,4 +1,4 @@ -/* +/* This file is part of solidity. solidity is free software: you can redistribute it and/or modify @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -57,7 +58,10 @@ private: VisibilitySpecifier, AbstractContract, OverridingFunction, - VirtualFunction + VirtualFunction, + DotSyntax, + NowKeyword, + ConstrutorVisibility }; /// Upgrade suite that hosts all available modules. @@ -79,6 +83,14 @@ private: OverridingFunction{m_changes}.analyze(_sourceUnit); if (isActivated(Module::VirtualFunction)) VirtualFunction{m_changes}.analyze(_sourceUnit); + + /// Solidity 0.7.0 + if (isActivated(Module::DotSyntax)) + DotSyntax{m_changes}.analyze(_sourceUnit); + if (isActivated(Module::NowKeyword)) + NowKeyword{m_changes}.analyze(_sourceUnit); + if (isActivated(Module::ConstrutorVisibility)) + ConstructorVisibility{m_changes}.analyze(_sourceUnit); } void activateModule(Module _module) { m_modules.insert(_module); } @@ -97,7 +109,10 @@ private: Module::VisibilitySpecifier, Module::AbstractContract, Module::OverridingFunction, - Module::VirtualFunction + Module::VirtualFunction, + Module::DotSyntax, + Module::NowKeyword, + Module::ConstrutorVisibility }; }; diff --git a/tools/solidityUpgrade/Upgrade070.cpp b/tools/solidityUpgrade/Upgrade070.cpp new file mode 100644 index 000000000..a5ee50c01 --- /dev/null +++ b/tools/solidityUpgrade/Upgrade070.cpp @@ -0,0 +1,85 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + +n You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +#include +#include + +using namespace solidity::frontend; +using namespace solidity::tools; + +void DotSyntax::endVisit(FunctionCall const& _functionCall) +{ + TypePointer type = _functionCall.annotation().type; + if (auto const funcType = dynamic_cast(type)) + { + if (funcType->valueSet()) + m_changes.emplace_back( + UpgradeChange::Level::Safe, + _functionCall.location(), + SourceTransform::valueUpdate(_functionCall.location()) + ); + + if (funcType->gasSet()) + m_changes.emplace_back( + UpgradeChange::Level::Safe, + _functionCall.location(), + SourceTransform::gasUpdate(_functionCall.location()) + ); + } +} + +void NowKeyword::endVisit(Identifier const& _identifier) +{ + IdentifierAnnotation& annotation = _identifier.annotation(); + + if ( + MagicVariableDeclaration const* magicVar = + dynamic_cast(annotation.referencedDeclaration) + ) + if (magicVar->type()->category() == Type::Category::Integer) + { + solAssert(_identifier.name() == "now", ""); + m_changes.emplace_back( + UpgradeChange::Level::Safe, + _identifier.location(), + SourceTransform::nowUpdate(_identifier.location()) + ); + } +} + +void ConstructorVisibility::endVisit(ContractDefinition const& _contract) +{ + if (!_contract.abstract()) + for (FunctionDefinition const* function: _contract.definedFunctions()) + if ( + function->isConstructor() && + !function->noVisibilitySpecified() && + function->visibility() == Visibility::Internal + ) + m_changes.emplace_back( + UpgradeChange::Level::Safe, + _contract.location(), + SourceTransform::insertBeforeKeyword(_contract.location(), "contract", "abstract") + ); + + for (FunctionDefinition const* function: _contract.definedFunctions()) + if (function->isConstructor() && !function->noVisibilitySpecified()) + m_changes.emplace_back( + UpgradeChange::Level::Safe, + function->location(), + SourceTransform::removeVisibility(function->location()) + ); +} diff --git a/tools/solidityUpgrade/Upgrade070.h b/tools/solidityUpgrade/Upgrade070.h new file mode 100644 index 000000000..b99f9d306 --- /dev/null +++ b/tools/solidityUpgrade/Upgrade070.h @@ -0,0 +1,53 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +#pragma once + +#include + +#include + +namespace solidity::tools +{ + +class DotSyntax: public AnalysisUpgrade +{ +public: + using AnalysisUpgrade::AnalysisUpgrade; + void analyze(frontend::SourceUnit const& _sourceUnit) { _sourceUnit.accept(*this); } +private: + void endVisit(frontend::FunctionCall const& _expression) override; +}; + +class NowKeyword: public AnalysisUpgrade +{ +public: + using AnalysisUpgrade::AnalysisUpgrade; + void analyze(frontend::SourceUnit const& _sourceUnit) { _sourceUnit.accept(*this); } +private: + void endVisit(frontend::Identifier const& _expression) override; +}; + +class ConstructorVisibility: public AnalysisUpgrade +{ +public: + using AnalysisUpgrade::AnalysisUpgrade; + void analyze(frontend::SourceUnit const& _sourceUnit) { _sourceUnit.accept(*this); } +private: + void endVisit(frontend::ContractDefinition const& _contract) override; +}; + +} diff --git a/tools/solidityUpgrade/main.cpp b/tools/solidityUpgrade/main.cpp index d13639b9a..11026884a 100644 --- a/tools/solidityUpgrade/main.cpp +++ b/tools/solidityUpgrade/main.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -75,8 +76,16 @@ int main(int argc, char** argv) if (!upgrade.parseArguments(argc, argv)) return 1; upgrade.printPrologue(); - if (!upgrade.processInput()) - return 1; + + try + { + if (!upgrade.processInput()) + return 1; + } + catch (boost::exception const& _exception) + { + cerr << "Exception while processing input: " << boost::diagnostic_information(_exception) << endl; + } return 0; } diff --git a/tools/yulPhaser/Program.cpp b/tools/yulPhaser/Program.cpp index a1d79f75a..e254ca241 100644 --- a/tools/yulPhaser/Program.cpp +++ b/tools/yulPhaser/Program.cpp @@ -120,7 +120,7 @@ ostream& phaser::operator<<(ostream& _stream, Program const& _program) string Program::toJson() const { Json::Value serializedAst = AsmJsonConverter(0)(*m_ast); - return jsonPrettyPrint(serializedAst); + return jsonPrettyPrint(removeNullMembers(std::move(serializedAst))); } variant, ErrorList> Program::parseObject(Dialect const& _dialect, CharStream _source)