Skip to content

Commit 00c0fca

Browse files
authored
Merge pull request #9186 from ethereum/develop
Merge develop into release for 0.6.10
2 parents 3e3065a + bb6d677 commit 00c0fca

File tree

146 files changed

+1685
-641
lines changed

Some content is hidden

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

146 files changed

+1685
-641
lines changed

Diff for: CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ include(EthPolicy)
1010
eth_policy()
1111

1212
# project name and version should be set after cmake_policy CMP0048
13-
set(PROJECT_VERSION "0.6.9")
13+
set(PROJECT_VERSION "0.6.10")
1414
# OSX target needed in order to support std::visit
1515
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14")
1616
project(solidity VERSION ${PROJECT_VERSION} LANGUAGES C CXX)

Diff for: Changelog.md

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
### 0.6.10 (2020-06-11)
2+
3+
Important Bugfixes:
4+
* Fixed a bug related to internal library functions with ``calldata`` parameters called via ``using for``.
5+
6+
7+
Compiler Features:
8+
* Commandline Interface: Re-group help screen.
9+
* Output compilation error codes in standard-json and when using ``--error-codes``.
10+
* Yul: Raise warning for switch statements that only have a default and no other cases.
11+
12+
13+
Bugfixes:
14+
* SMTChecker: Fix internal error when encoding tuples of tuples.
15+
* SMTChecker: Fix aliasing soundness after pushing to an array pointer.
16+
* Type system: Fix internal compiler error on calling externally a function that returns variables with calldata location.
17+
* Type system: Fix bug where a bound function was not found if ``using for`` is applied to explicit reference types.
18+
19+
120
### 0.6.9 (2020-06-04)
221

322
Language Features:

Diff for: ReleaseChecklist.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
- [ ] Readthedocs account, access to the Solidity project
77
- [ ] Write access to https://github.com/ethereum/homebrew-ethereum
88

9-
### Pre-release
10-
- [ ] Ensure that a Github project exists for the release.
11-
- [ ] Check that all issues and pull requests from the Github project to be released are merged to ``develop``.
9+
### Blog Post
10+
- [ ] Create a post on https://github.com/ethereum/solidity-blog and explain some of the new features or concepts.
1211

1312
### Changelog
1413
- [ ] Sort the changelog entries alphabetically and correct any errors you notice.
@@ -33,8 +32,9 @@
3332
- [ ] Wait for the ``~ethereum/ubuntu/ethereum-static`` PPA build to be finished and published for *all platforms*. SERIOUSLY: DO NOT PROCEED EARLIER!!! *After* the static builds are *published*, copy the static package to the ``~ethereum/ubuntu/ethereum`` PPA for the destination series ``Trusty`` and ``Xenial`` while selecting ``Copy existing binaries``.
3433
- [ ] Check that the Docker release was pushed to Docker Hub (this still seems to have problems, run ``./scripts/docker_deploy_manual.sh v0.x.x``).
3534

36-
### Homebrew
35+
### Homebrew and MacOS
3736
- [ ] Update the version and the hash (``sha256sum solidity_x.x.x.tar.gz``) in https://github.com/ethereum/homebrew-ethereum/blob/master/solidity.rb
37+
- [ ] Take the binary from the ``b_osx`` run of the released commit in circle-ci and add it to the release page as ``solc-macos``.
3838

3939
### Documentation
4040
- [ ] Build the new version on https://readthedocs.org/projects/solidity/ (select `latest` on the bottom of the page and click `BUILD`)

Diff for: docs/060-breaking-changes.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ For most of the topics the compiler will provide suggestions.
4242
storage arrays.
4343

4444
* The new keyword ``abstract`` can be used to mark contracts as abstract. It has to be used
45-
if a contract does not implement all its functions.
45+
if a contract does not implement all its functions. Abstract contracts cannot be created using the ``new`` operator,
46+
and it is not possible to generate bytecode for them during compilation.
4647

4748
* Libraries have to implement all their functions, not only the internal ones.
4849

Diff for: docs/Solidity.g4

+6-2
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ userDefinedTypeName
124124
: identifier ( '.' identifier )* ;
125125

126126
mapping
127-
: 'mapping' '(' (elementaryTypeName | userDefinedTypeName) '=>' typeName ')' ;
127+
: 'mapping' '(' mappingKey '=>' typeName ')' ;
128+
129+
mappingKey
130+
: elementaryTypeName
131+
| userDefinedTypeName ;
128132

129133
functionTypeName
130134
: 'function' parameterList modifierList returnParameters? ;
@@ -470,7 +474,7 @@ SingleQuotedStringCharacter
470474
: ~['\r\n\\] | ('\\' .) ;
471475
472476
VersionLiteral
473-
: [0-9]+ '.' [0-9]+ ('.' [0-9]+)? ;
477+
: [0-9]+ ( '.' [0-9]+ ('.' [0-9]+)? )? ;
474478
475479
WS
476480
: [ \t\r\n\u000C]+ -> skip ;

Diff for: docs/abi-spec.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Function Selector
2424
=================
2525

2626
The first four bytes of the call data for a function call specifies the function to be called. It is the
27-
first (left, high-order in big-endian) four bytes of the Keccak-256 (SHA-3) hash of the signature of
27+
first (left, high-order in big-endian) four bytes of the Keccak-256 hash of the signature of
2828
the function. The signature is defined as the canonical expression of the basic prototype without data
2929
location specifier, i.e.
3030
the function name with the parenthesised list of parameter types. Parameter types are split by a single

Diff for: docs/bugs.json

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
[
2+
{
3+
"name": "UsingForCalldata",
4+
"summary": "Function calls to internal library functions with calldata parameters called via ``using for`` can result in invalid data being read.",
5+
"description": "Function calls to internal library functions using the ``using for`` mechanism copied all calldata parameters to memory first and passed them on like that, regardless of whether it was an internal or an external call. Due to that, the called function would receive a memory pointer that is interpreted as a calldata pointer. Since dynamically sized arrays are passed using two stack slots for calldata, but only one for memory, this can lead to stack corruption. An affected library call will consider the JUMPDEST to which it is supposed to return as part of its arguments and will instead jump out to whatever was on the stack before the call.",
6+
"introduced": "0.6.9",
7+
"fixed": "0.6.10",
8+
"severity": "very low"
9+
},
210
{
311
"name": "MissingEscapingInFormatting",
412
"summary": "String literals containing double backslash characters passed directly to external or encoding function calls can lead to a different string being used when ABIEncoderV2 is enabled.",

Diff for: docs/bugs_by_version.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,10 @@
11051105
],
11061106
"released": "2020-01-02"
11071107
},
1108+
"0.6.10": {
1109+
"bugs": [],
1110+
"released": "2020-06-11"
1111+
},
11081112
"0.6.2": {
11091113
"bugs": [
11101114
"MissingEscapingInFormatting",
@@ -1165,7 +1169,9 @@
11651169
"released": "2020-05-14"
11661170
},
11671171
"0.6.9": {
1168-
"bugs": [],
1172+
"bugs": [
1173+
"UsingForCalldata"
1174+
],
11691175
"released": "2020-06-04"
11701176
}
11711177
}

Diff for: docs/contracts/inheritance.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,10 @@ not known in the context of the class where it is used,
194194
although its type is known. This is similar for ordinary
195195
virtual method lookup.
196196

197-
.. _function-overriding:
198-
199197
.. index:: ! overriding;function
200198

199+
.. _function-overriding:
200+
201201
Function Overriding
202202
===================
203203

@@ -317,10 +317,10 @@ of the variable:
317317
While public state variables can override external functions, they themselves cannot
318318
be overridden.
319319

320-
.. _modifier-overriding:
321-
322320
.. index:: ! overriding;modifier
323321

322+
.. _modifier-overriding:
323+
324324
Modifier Overriding
325325
===================
326326

Diff for: docs/types/reference-types.rst

+7-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,13 @@ Array slices are useful to ABI-decode secondary data passed in function paramete
430430
/// Forward call to "setOwner(address)" that is implemented by client
431431
/// after doing basic validation on the address argument.
432432
function forward(bytes calldata _payload) external {
433-
bytes4 sig = abi.decode(_payload[:4], (bytes4));
433+
// Since ABI decoding requires padded data, we cannot
434+
// use abi.decode(_payload[:4], (bytes4)).
435+
bytes4 sig =
436+
_payload[0] |
437+
(bytes4(_payload[1]) >> 8) |
438+
(bytes4(_payload[2]) >> 16) |
439+
(bytes4(_payload[3]) >> 24);
434440
if (sig == bytes4(keccak256("setOwner(address)"))) {
435441
address owner = abi.decode(_payload[4:], (address));
436442
require(owner != address(0), "Address of owner cannot be zero.");

Diff for: docs/using-the-compiler.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,10 @@ Output Description
374374
"component": "general",
375375
// Mandatory ("error" or "warning")
376376
"severity": "error",
377+
// Optional: unique code for the cause of the error
378+
"errorCode": "3141",
377379
// Mandatory
378-
"message": "Invalid keyword"
380+
"message": "Invalid keyword",
379381
// Optional: the message formatted with source location
380382
"formattedMessage": "sourceFile.sol:100: Invalid keyword"
381383
}

Diff for: liblangutil/SourceReferenceExtractor.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,15 @@ SourceReferenceExtractor::Message SourceReferenceExtractor::extract(util::Except
3838
for (auto const& info: secondaryLocation->infos)
3939
secondary.emplace_back(extract(&info.second, info.first));
4040

41-
return Message{std::move(primary), _category, std::move(secondary)};
41+
return Message{std::move(primary), _category, std::move(secondary), nullopt};
42+
}
43+
44+
SourceReferenceExtractor::Message SourceReferenceExtractor::extract(Error const& _error)
45+
{
46+
string category = (_error.type() == Error::Type::Warning) ? "Warning" : "Error";
47+
Message message = extract(_error, category);
48+
message.errorId = _error.errorId();
49+
return message;
4250
}
4351

4452
SourceReference SourceReferenceExtractor::extract(SourceLocation const* _location, std::string message)

Diff for: liblangutil/SourceReferenceExtractor.h

+5-7
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@
1616
*/
1717
#pragma once
1818

19+
#include <liblangutil/Exceptions.h>
20+
1921
#include <iosfwd>
22+
#include <optional>
2023
#include <string>
2124
#include <tuple>
2225
#include <vector>
2326

24-
namespace solidity::util
25-
{
26-
struct Exception;
27-
}
28-
2927
namespace solidity::langutil
3028
{
3129

@@ -58,18 +56,18 @@ struct SourceReference
5856
}
5957
};
6058

61-
struct SourceLocation;
62-
6359
namespace SourceReferenceExtractor
6460
{
6561
struct Message
6662
{
6763
SourceReference primary;
6864
std::string category; // "Error", "Warning", ...
6965
std::vector<SourceReference> secondary;
66+
std::optional<ErrorId> errorId;
7067
};
7168

7269
Message extract(util::Exception const& _exception, std::string _category);
70+
Message extract(Error const& _error);
7371
SourceReference extract(SourceLocation const* _location, std::string message = "");
7472
}
7573

Diff for: liblangutil/SourceReferenceFormatter.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ void SourceReferenceFormatter::printExceptionInformation(util::Exception const&
8080

8181
void SourceReferenceFormatter::printErrorInformation(Error const& _error)
8282
{
83-
printExceptionInformation(
84-
_error,
85-
(_error.type() == Error::Type::Warning) ? "Warning" : "Error"
86-
);
83+
printExceptionInformation(SourceReferenceExtractor::extract(_error));
8784
}
8885

8986
void SourceReferenceFormatter::printExceptionInformation(SourceReferenceExtractor::Message const& _msg)

Diff for: liblangutil/SourceReferenceFormatterHuman.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ void SourceReferenceFormatterHuman::printExceptionInformation(SourceReferenceExt
151151
{
152152
// exception header line
153153
errorColored() << _msg.category;
154+
if (m_withErrorIds && _msg.errorId.has_value())
155+
errorColored() << " (" << _msg.errorId.value().error << ")";
154156
messageColored() << ": " << _msg.primary.message << '\n';
155157

156158
printSourceLocation(_msg.primary);

Diff for: liblangutil/SourceReferenceFormatterHuman.h

+6-12
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,14 @@
2929
#include <sstream>
3030
#include <functional>
3131

32-
namespace solidity::util
33-
{
34-
struct Exception; // forward
35-
}
36-
3732
namespace solidity::langutil
3833
{
3934

40-
struct SourceLocation;
41-
struct SourceReference;
42-
4335
class SourceReferenceFormatterHuman: public SourceReferenceFormatter
4436
{
4537
public:
46-
SourceReferenceFormatterHuman(std::ostream& _stream, bool colored):
47-
SourceReferenceFormatter{_stream}, m_colored{colored}
38+
SourceReferenceFormatterHuman(std::ostream& _stream, bool _colored, bool _withErrorIds):
39+
SourceReferenceFormatter{_stream}, m_colored{_colored}, m_withErrorIds(_withErrorIds)
4840
{}
4941

5042
void printSourceLocation(SourceReference const& _ref) override;
@@ -54,12 +46,13 @@ class SourceReferenceFormatterHuman: public SourceReferenceFormatter
5446
static std::string formatExceptionInformation(
5547
util::Exception const& _exception,
5648
std::string const& _name,
57-
bool colored = false
49+
bool _colored = false,
50+
bool _withErrorIds = false
5851
)
5952
{
6053
std::ostringstream errorOutput;
6154

62-
SourceReferenceFormatterHuman formatter(errorOutput, colored);
55+
SourceReferenceFormatterHuman formatter(errorOutput, _colored, _withErrorIds);
6356
formatter.printExceptionInformation(_exception, _name);
6457
return errorOutput.str();
6558
}
@@ -75,6 +68,7 @@ class SourceReferenceFormatterHuman: public SourceReferenceFormatter
7568

7669
private:
7770
bool m_colored;
71+
bool m_withErrorIds;
7872
};
7973

8074
}

Diff for: libsolidity/analysis/OverrideChecker.cpp

+16-13
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ struct OverrideGraph
6868
std::map<OverrideProxy, int> nodes;
6969
std::map<int, OverrideProxy> nodeInv;
7070
std::map<int, std::set<int>> edges;
71-
int numNodes = 2;
71+
size_t numNodes = 2;
7272
void addEdge(int _a, int _b)
7373
{
7474
edges[_a].insert(_b);
@@ -82,7 +82,7 @@ struct OverrideGraph
8282
auto it = nodes.find(_function);
8383
if (it != nodes.end())
8484
return it->second;
85-
int currentNode = numNodes++;
85+
int currentNode = static_cast<int>(numNodes++);
8686
nodes[_function] = currentNode;
8787
nodeInv[currentNode] = _function;
8888
if (_function.overrides())
@@ -116,21 +116,24 @@ struct CutVertexFinder
116116
std::vector<int> m_parent = std::vector<int>(m_graph.numNodes, -1);
117117
std::set<OverrideProxy> m_cutVertices{};
118118

119-
void run(int _u = 0, int _depth = 0)
119+
void run(size_t _u = 0, size_t _depth = 0)
120120
{
121121
m_visited.at(_u) = true;
122-
m_depths.at(_u) = m_low.at(_u) = _depth;
123-
for (int v: m_graph.edges.at(_u))
124-
if (!m_visited.at(v))
122+
m_depths.at(_u) = m_low.at(_u) = static_cast<int>(_depth);
123+
for (int const v: m_graph.edges.at(static_cast<int>(_u)))
124+
{
125+
auto const vInd = static_cast<size_t>(v);
126+
if (!m_visited.at(vInd))
125127
{
126-
m_parent[v] = _u;
127-
run(v, _depth + 1);
128-
if (m_low[v] >= m_depths[_u] && m_parent[_u] != -1)
129-
m_cutVertices.insert(m_graph.nodeInv.at(_u));
130-
m_low[_u] = min(m_low[_u], m_low[v]);
128+
m_parent[vInd] = static_cast<int>(_u);
129+
run(vInd, _depth + 1);
130+
if (m_low[vInd] >= m_depths[_u] && m_parent[_u] != -1)
131+
m_cutVertices.insert(m_graph.nodeInv.at(static_cast<int>(_u)));
132+
m_low[_u] = min(m_low[_u], m_low[vInd]);
131133
}
132134
else if (v != m_parent[_u])
133-
m_low[_u] = min(m_low[_u], m_depths[v]);
135+
m_low[_u] = min(m_low[_u], m_depths[vInd]);
136+
}
134137
}
135138
};
136139

@@ -213,7 +216,7 @@ bool OverrideProxy::CompareBySignature::operator()(OverrideProxy const& _a, Over
213216
size_t OverrideProxy::id() const
214217
{
215218
return std::visit(GenericVisitor{
216-
[&](auto const* _item) -> size_t { return _item->id(); }
219+
[&](auto const* _item) -> size_t { return static_cast<size_t>(_item->id()); }
217220
}, m_item);
218221
}
219222

0 commit comments

Comments
 (0)