Skip to content

Commit 4cb486e

Browse files
authored
Merge pull request #3892 from ethereum/develop
Merge develop into release for 0.4.22
2 parents dfe3193 + b8431c5 commit 4cb486e

File tree

328 files changed

+8696
-2254
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

328 files changed

+8696
-2254
lines changed

.travis.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ matrix:
8484
sudo: required
8585
compiler: gcc
8686
node_js:
87-
- "7"
87+
- "8"
8888
services:
8989
- docker
9090
before_install:
91-
- nvm install 7
92-
- nvm use 7
91+
- nvm install 8
92+
- nvm use 8
9393
- docker pull trzeci/emscripten:sdk-tag-1.35.4-64bit
9494
env:
9595
- SOLC_EMSCRIPTEN=On
@@ -159,6 +159,8 @@ cache:
159159
install:
160160
- test $SOLC_INSTALL_DEPS_TRAVIS != On || (scripts/install_deps.sh)
161161
- test "$TRAVIS_OS_NAME" != "linux" || (scripts/install_cmake.sh)
162+
# - if [ "$TRAVIS_BRANCH" != release -a -z "$TRAVIS_TAG" ]; then SOLC_TESTS=Off; fi
163+
- SOLC_TESTS=Off
162164
- if [ "$TRAVIS_BRANCH" = release -o -n "$TRAVIS_TAG" ]; then echo -n > prerelease.txt; else date -u +"nightly.%Y.%-m.%-d" > prerelease.txt; fi
163165
- echo -n "$TRAVIS_COMMIT" > commit_hash.txt
164166

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ include(EthPolicy)
88
eth_policy()
99

1010
# project name and version should be set after cmake_policy CMP0048
11-
set(PROJECT_VERSION "0.4.21")
11+
set(PROJECT_VERSION "0.4.22")
1212
project(solidity VERSION ${PROJECT_VERSION})
1313

1414
option(SOLC_LINK_STATIC "Link solc executable statically on supported platforms" OFF)

CODING_STYLE.md

Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
0. Formatting
2+
3+
GOLDEN RULE: Follow the style of the existing code when you make changes.
4+
5+
a. Use tabs for leading indentation
6+
- tab stops are every 4 characters (only relevant for line length).
7+
- One indentation level -> exactly one byte (i.e. a tab character) in the source file.
8+
b. Line widths:
9+
- Lines should be at most 99 characters wide to make diff views readable and reduce merge conflicts.
10+
- Lines of comments should be formatted according to ease of viewing, but simplicity is to be preferred over beauty.
11+
c. Single-statement blocks should not have braces, unless required for clarity.
12+
d. Never place condition bodies on same line as condition.
13+
e. Space between keyword and opening parenthesis, but not following opening parenthesis or before final parenthesis.
14+
f. No spaces for unary operators, `->` or `.`.
15+
g. No space before ':' but one after it, except in the ternary operator: one on both sides.
16+
h. Add spaces around all other operators.
17+
i. Braces, when used, always have their own lines and are at same indentation level as "parent" scope.
18+
j. If lines are broken, a list of elements enclosed with parentheses (of any kind) and separated by a
19+
separator (of any kind) are formatted such that there is exactly one element per line, followed by
20+
the separator, the opening parenthesis is on the first line, followed by a line break and the closing
21+
parenthesis is on a line of its own (unindented). See example below.
22+
23+
(WRONG)
24+
if( a==b[ i ] ) { printf ("Hello\n"); }
25+
foo->bar(someLongVariableName,
26+
anotherLongVariableName,
27+
anotherLongVariableName,
28+
anotherLongVariableName,
29+
anotherLongVariableName);
30+
cout << "some very long string that contains completely irrelevant text that talks about this and that and contains the words \"lorem\" and \"ipsum\"" << endl;
31+
32+
(RIGHT)
33+
if (a == b[i])
34+
printf("Hello\n"); // NOTE spaces used instead of tab here for clarity - first byte should be '\t'.
35+
foo->bar(
36+
someLongVariableName,
37+
anotherLongVariableName,
38+
anotherLongVariableName,
39+
anotherLongVariableName,
40+
anotherLongVariableName
41+
);
42+
cout <<
43+
"some very long string that contains completely irrelevant " <<
44+
"text that talks about this and that and contains the words " <<
45+
"\"lorem\" and \"ipsum\"" <<
46+
endl;
47+
48+
49+
50+
1. Namespaces;
51+
52+
a. No "using namespace" declarations in header files.
53+
b. All symbols should be declared in a namespace except for final applications.
54+
c. Use anonymous namespaces for helpers whose scope is a cpp file only.
55+
d. Preprocessor symbols should be prefixed with the namespace in all-caps and an underscore.
56+
57+
(WRONG)
58+
#include <cassert>
59+
using namespace std;
60+
tuple<float, float> meanAndSigma(vector<float> const& _v);
61+
62+
(CORRECT)
63+
#include <cassert>
64+
std::tuple<float, float> meanAndSigma(std::vector<float> const& _v);
65+
66+
67+
68+
2. Preprocessor;
69+
70+
a. File comment is always at top, and includes:
71+
- Copyright.
72+
- License (e.g. see COPYING).
73+
b. Never use #ifdef/#define/#endif file guards. Prefer #pragma once as first line below file comment.
74+
c. Prefer static const variable to value macros.
75+
d. Prefer inline constexpr functions to function macros.
76+
e. Split complex macro on multiple lines with '\'.
77+
78+
79+
80+
3. Capitalization;
81+
82+
GOLDEN RULE: Preprocessor: ALL_CAPS; C++: camelCase.
83+
84+
a. Use camelCase for splitting words in names, except where obviously extending STL/boost functionality in which case follow those naming conventions.
85+
b. The following entities' first alpha is upper case:
86+
- Type names.
87+
- Template parameters.
88+
- Enum members.
89+
- static const variables that form an external API.
90+
c. All preprocessor symbols (macros, macro arguments) in full uppercase with underscore word separation.
91+
92+
93+
All other entities' first alpha is lower case.
94+
95+
96+
97+
4. Variable prefixes:
98+
99+
a. Leading underscore "_" to parameter names.
100+
- Exception: "o_parameterName" when it is used exclusively for output. See 6(f).
101+
- Exception: "io_parameterName" when it is used for both input and output. See 6(f).
102+
b. Leading "g_" to global (non-const) variables.
103+
c. Leading "s_" to static (non-const, non-global) variables.
104+
105+
106+
107+
5. Assertions:
108+
109+
- use `solAssert` and `solUnimplementedAssert` generously to check assumptions
110+
that span across different parts of the code base, for example before dereferencing
111+
a pointer.
112+
113+
114+
6. Declarations:
115+
116+
a. {Typename} + {qualifiers} + {name}.
117+
b. Only one per line.
118+
c. Associate */& with type, not variable (at ends with parser, but more readable, and safe if in conjunction with (b)).
119+
d. Favour declarations close to use; don't habitually declare at top of scope ala C.
120+
e. Pass non-trivial parameters as const reference, unless the data is to be copied into the function, then either pass by const reference or by value and use std::move.
121+
f. If a function returns multiple values, use std::tuple (std::pair acceptable) or better introduce a struct type. Do not use */& arguments.
122+
g. Use parameters of pointer type only if ``nullptr`` is a valid argument, use references otherwise. Often, ``boost::optional`` is better suited than a raw pointer.
123+
h. Never use a macro where adequate non-preprocessor C++ can be written.
124+
i. Only use ``auto`` if the type is very long and rather irrelevant.
125+
j. Do not pass bools: prefer enumerations instead.
126+
k. Prefer enum class to straight enum.
127+
l. Always initialize POD variables, even if their value is overwritten later.
128+
129+
130+
(WRONG)
131+
const double d = 0;
132+
int i, j;
133+
char *s;
134+
float meanAndSigma(std::vector<float> _v, float* _sigma, bool _approximate);
135+
Derived* x(dynamic_cast<Derived*>(base));
136+
for (map<ComplexTypeOne, ComplexTypeTwo>::iterator i = l.begin(); i != l.end(); ++l) {}
137+
138+
139+
(CORRECT)
140+
enum class Accuracy
141+
{
142+
Approximate,
143+
Exact
144+
};
145+
struct MeanSigma
146+
{
147+
float mean;
148+
float standardDeviation;
149+
};
150+
double const d = 0;
151+
int i;
152+
int j;
153+
char* s;
154+
MeanAndSigma ms meanAndSigma(std::vector<float> const& _v, Accuracy _a);
155+
Derived* x = dynamic_cast<Derived*>(base);
156+
for (auto i = x->begin(); i != x->end(); ++i) {}
157+
158+
159+
7. Structs & classes
160+
161+
a. Structs to be used when all members public and no virtual functions.
162+
- In this case, members should be named naturally and not prefixed with 'm_'
163+
b. Classes to be used in all other circumstances.
164+
165+
166+
167+
8. Members:
168+
169+
a. One member per line only.
170+
b. Private, non-static, non-const fields prefixed with m_.
171+
c. Avoid public fields, except in structs.
172+
d. Use override, final and const as much as possible.
173+
e. No implementations with the class declaration, except:
174+
- template or force-inline method (though prefer implementation at bottom of header file).
175+
- one-line implementation (in which case include it in same line as declaration).
176+
f. For a property 'foo'
177+
- Member: m_foo;
178+
- Getter: foo() [ also: for booleans, isFoo() ];
179+
- Setter: setFoo();
180+
181+
182+
183+
9. Naming
184+
185+
a. Avoid unpronouncable names
186+
b. Names should be shortened only if they are extremely common, but shortening should be generally avoided
187+
c. Avoid prefixes of initials (e.g. do not use IMyInterface, CMyImplementation)
188+
c. Find short, memorable & (at least semi-) descriptive names for commonly used classes or name-fragments.
189+
- A dictionary and thesaurus are your friends.
190+
- Spell correctly.
191+
- Think carefully about the class's purpose.
192+
- Imagine it as an isolated component to try to decontextualise it when considering its name.
193+
- Don't be trapped into naming it (purely) in terms of its implementation.
194+
195+
196+
197+
10. Type-definitions
198+
199+
a. Prefer 'using' to 'typedef'. e.g. using ints = std::vector<int>; rather than typedef std::vector<int> ints;
200+
b. Generally avoid shortening a standard form that already includes all important information:
201+
- e.g. stick to shared_ptr<X> rather than shortening to ptr<X>.
202+
c. Where there are exceptions to this (due to excessive use and clear meaning), note the change prominently and use it consistently.
203+
- e.g. using Guard = std::lock_guard<std::mutex>; ///< Guard is used throughout the codebase since it is clear in meaning and used commonly.
204+
d. In general expressions should be roughly as important/semantically meaningful as the space they occupy.
205+
e. Avoid introducing aliases for types unless they are very complicated. Consider the number of items a brain can keep track of at the same time.
206+
207+
208+
209+
11. Commenting
210+
211+
a. Comments should be doxygen-compilable, using @notation rather than \notation.
212+
b. Document the interface, not the implementation.
213+
- Documentation should be able to remain completely unchanged, even if the method is reimplemented.
214+
- Comment in terms of the method properties and intended alteration to class state (or what aspects of the state it reports).
215+
- Be careful to scrutinise documentation that extends only to intended purpose and usage.
216+
- Reject documentation that is simply an English transaction of the implementation.
217+
c. Avoid in-code comments. Instead, try to extract blocks of functionality into functions. This often already eliminates the need for an in-code comment.
218+
219+
220+
12. Include Headers
221+
222+
Includes should go in increasing order of generality (libsolidity -> libevmasm -> libdevcore -> boost -> STL).
223+
The corresponding .h file should be the first include in the respective .cpp file.
224+
Insert empty lines between blocks of include files.
225+
226+
Example:
227+
228+
```
229+
#include <libsolidity/codegen/ExpressionCompiler.h>
230+
231+
#include <libsolidity/ast/AST.h>
232+
#include <libsolidity/codegen/CompilerContext.h>
233+
#include <libsolidity/codegen/CompilerUtils.h>
234+
#include <libsolidity/codegen/LValue.h>
235+
236+
#include <libevmasm/GasMeter.h>
237+
238+
#include <libdevcore/Common.h>
239+
#include <libdevcore/SHA3.h>
240+
241+
#include <boost/range/adaptor/reversed.hpp>
242+
#include <boost/algorithm/string/replace.hpp>
243+
244+
#include <utility>
245+
#include <numeric>
246+
```
247+
248+
See http://stackoverflow.com/questions/614302/c-header-order/614333#614333 for the reason: this makes it easier to find missing includes in header files.
249+
250+
251+
13. Recommended reading
252+
253+
Herb Sutter and Bjarne Stroustrup
254+
- "C++ Core Guidelines" (https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md)
255+
256+
Herb Sutter and Andrei Alexandrescu
257+
- "C++ Coding Standards: 101 Rules, Guidelines, and Best Practices"
258+
259+
Scott Meyers
260+
- "Effective C++: 55 Specific Ways to Improve Your Programs and Designs (3rd Edition)"
261+
- "More Effective C++: 35 New Ways to Improve Your Programs and Designs"
262+
- "Effective Modern C++: 42 Specific Ways to Improve Your Use of C++11 and C++14"

Changelog.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,56 @@
1+
### 0.4.22 (2018-04-16)
2+
3+
Features:
4+
* Code Generator: Initialize arrays without using ``msize()``.
5+
* Code Generator: More specialized and thus optimized implementation for ``x.push(...)``
6+
* Commandline interface: Error when missing or inaccessible file detected. Suppress it with the ``--ignore-missing`` flag.
7+
* Constant Evaluator: Fix evaluation of single element tuples.
8+
* General: Add encoding routines ``abi.encodePacked``, ``abi.encode``, ``abi.encodeWithSelector`` and ``abi.encodeWithSignature``.
9+
* General: Add global function ``gasleft()`` and deprecate ``msg.gas``.
10+
* General: Add global function ``blockhash(uint)`` and deprecate ``block.hash(uint)``.
11+
* General: Allow providing reason string for ``revert()`` and ``require()``.
12+
* General: Introduce new constructor syntax using the ``constructor`` keyword as experimental 0.5.0 feature.
13+
* General: Limit the number of errors output in a single run to 256.
14+
* General: Support accessing dynamic return data in post-byzantium EVMs.
15+
* Inheritance: Error when using empty parentheses for base class constructors that require arguments as experimental 0.5.0 feature.
16+
* Inheritance: Error when using no parentheses in modifier-style constructor calls as experimental 0.5.0 feature.
17+
* Interfaces: Allow overriding external functions in interfaces with public in an implementing contract.
18+
* Optimizer: Optimize ``SHL`` and ``SHR`` only involving constants (Constantinople only).
19+
* Optimizer: Remove useless ``SWAP1`` instruction preceding a commutative instruction (such as ``ADD``, ``MUL``, etc).
20+
* Optimizer: Replace comparison operators (``LT``, ``GT``, etc) with opposites if preceded by ``SWAP1``, e.g. ``SWAP1 LT`` is replaced with ``GT``.
21+
* Optimizer: Optimize across ``mload`` if ``msize()`` is not used.
22+
* Static Analyzer: Error on duplicated super constructor calls as experimental 0.5.0 feature.
23+
* Syntax Checker: Issue warning for empty structs (or error as experimental 0.5.0 feature).
24+
* Syntax Checker: Warn about modifiers on functions without implementation (this will turn into an error with version 0.5.0).
25+
* Syntax Tests: Add source locations to syntax test expectations.
26+
* Type Checker: Improve documentation and warnings for accessing contract members inherited from ``address``.
27+
28+
29+
Bugfixes:
30+
* Code Generator: Allow ``block.blockhash`` without being called.
31+
* Code Generator: Do not include internal functions in the runtime bytecode which are only referenced in the constructor.
32+
* Code Generator: Properly skip unneeded storage array cleanup when not reducing length.
33+
* Code Generator: Bugfix in modifier lookup in libraries.
34+
* Code Generator: Implement packed encoding of external function types.
35+
* Code Generator: Treat empty base constructor argument list as not provided.
36+
* Code Generator: Properly force-clean bytesXX types for shortening conversions.
37+
* Commandline interface: Fix error messages for imported files that do not exist.
38+
* Commandline interface: Support ``--evm-version constantinople`` properly.
39+
* DocString Parser: Fix error message for empty descriptions.
40+
* Gas Estimator: Correctly ignore costs of fallback function for other functions.
41+
* JSON AST: Remove storage qualifier for type name strings.
42+
* Parser: Fix internal compiler error when parsing ``var`` declaration without identifier.
43+
* Parser: Fix parsing of getters for function type variables.
44+
* Standard JSON: Support ``constantinople`` as ``evmVersion`` properly.
45+
* Static Analyzer: Fix non-deterministic order of unused variable warnings.
46+
* Static Analyzer: Invalid arithmetic with constant expressions causes errors.
47+
* Type Checker: Fix detection of recursive structs.
48+
* Type Checker: Fix asymmetry bug when comparing with literal numbers.
49+
* Type System: Improve error message when attempting to shift by a fractional amount.
50+
* Type System: Make external library functions accessible.
51+
* Type System: Prevent encoding of weird types.
52+
* Type System: Restrict rational numbers to 4096 bits.
53+
154
### 0.4.21 (2018-03-07)
255

356
Features:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
## Useful links
55
To get started you can find an introduction to the language in the [Solidity documentation](https://solidity.readthedocs.org). In the documentation, you can find [code examples](https://solidity.readthedocs.io/en/latest/solidity-by-example.html) as well as [a reference](https://solidity.readthedocs.io/en/latest/solidity-in-depth.html) of the syntax and details on how to write smart contracts.
66

7-
You can start using [Solidity in your browser](https://ethereum.github.io/browser-solidity/) with no need to download or compile anything.
7+
You can start using [Solidity in your browser](http://remix.ethereum.org) with no need to download or compile anything.
88

99
The changelog for this project can be found [here](https://github.com/ethereum/solidity/blob/develop/Changelog.md).
1010

ReleaseChecklist.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Checklist for making a release:
1111
- [ ] Run ``scripts/release_ppa.sh release`` to create the PPA release (you need the relevant openssl key).
1212
- [ ] Check that the Docker release was pushed to Docker Hub (this still seems to have problems).
1313
- [ ] Update the homebrew realease in https://github.com/ethereum/homebrew-ethereum/blob/master/solidity.rb (version and hash)
14+
- [ ] Update the default version on readthedocs.
1415
- [ ] Make a release of ``solc-js``: Increment the version number, create a pull request for that, merge it after tests succeeded.
1516
- [ ] Run ``npm publish`` in the updated ``solc-js`` repository.
1617
- [ ] Create a commit to increase the version number on ``develop`` in ``CMakeLists.txt`` and add a new skeleton changelog entry.

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ build_script:
7171

7272
test_script:
7373
- cd %APPVEYOR_BUILD_FOLDER%\build\test\%CONFIGURATION%
74-
- soltest.exe --show-progress -- --no-ipc --no-smt
74+
- soltest.exe --show-progress -- --testpath %APPVEYOR_BUILD_FOLDER%\test --no-ipc --no-smt
7575
# Skip bytecode compare if private key is not available
7676
- cd %APPVEYOR_BUILD_FOLDER%
7777
- ps: if ($env:priv_key) {

0 commit comments

Comments
 (0)