Merge remote-tracking branch 'origin/develop' into HEAD

This commit is contained in:
chriseth
2020-10-08 20:18:04 +02:00
91 changed files with 924 additions and 171 deletions
+7 -2
View File
@@ -1,5 +1,7 @@
.. index:: ! constant
.. _constants:
**************************************
Constant and Immutable State Variables
**************************************
@@ -9,6 +11,8 @@ In both cases, the variables cannot be modified after the contract has been cons
For ``constant`` variables, the value has to be fixed at compile-time, while
for ``immutable``, it can still be assigned at construction time.
It is also possible to define ``constant`` variables at the file level.
The compiler does not reserve a storage slot for these variables, and every occurrence is
replaced by the respective value.
@@ -26,10 +30,11 @@ Not all types for constants and immutables are implemented at this time. The onl
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
pragma solidity >0.7.2 <0.9.0;
uint constant X = 32**22 + 8;
contract C {
uint constant X = 32**22 + 8;
string constant TEXT = "abc";
bytes32 constant MY_HASH = keccak256("abc");
uint immutable decimals;
+13 -1
View File
@@ -7,7 +7,7 @@ options { tokenVocab=SolidityLexer; }
/**
* On top level, Solidity allows pragmas, import directives, and
* definitions of contracts, interfaces, libraries, structs and enums.
* definitions of contracts, interfaces, libraries, structs, enums and constants.
*/
sourceUnit: (
pragmaDirective
@@ -16,6 +16,7 @@ sourceUnit: (
| interfaceDefinition
| libraryDefinition
| functionDefinition
| constantVariableDeclaration
| structDefinition
| enumDefinition
)* EOF;
@@ -240,6 +241,17 @@ locals [boolean constantnessSet = false, boolean visibilitySet = false, boolean
(Assign initialValue=expression)?
Semicolon;
/**
* The declaration of a constant variable.
*/
constantVariableDeclaration
:
type=typeName
Constant
name=identifier
Assign initialValue=expression
Semicolon;
/**
* Parameter of an event.
*/
+2 -1
View File
@@ -5,7 +5,8 @@ Layout of a Solidity Source File
Source files can contain an arbitrary number of
:ref:`contract definitions<contract_structure>`, import_ directives,
:ref:`pragma directives<pragma>` and
:ref:`struct<structs>`, :ref:`enum<enums>` and :ref:`function<functions>` definitions.
:ref:`struct<structs>`, :ref:`enum<enums>`, :ref:`function<functions>`
and :ref:`constant variable<constants>` definitions.
.. index:: ! license, spdx