aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.circleci/config.yml4
-rw-r--r--docs/050-breaking-changes.rst2
-rw-r--r--docs/assembly.rst6
-rw-r--r--docs/contracts.rst4
-rw-r--r--docs/contributing.rst78
-rw-r--r--docs/introduction-to-smart-contracts.rst2
-rw-r--r--docs/yul.rst9
-rw-r--r--libevmasm/Assembly.cpp13
-rw-r--r--libjulia/optimiser/FullInliner.cpp5
-rw-r--r--libsolidity/analysis/TypeChecker.cpp4
-rw-r--r--libsolidity/ast/AST.cpp17
-rw-r--r--libsolidity/ast/AST.h2
-rw-r--r--libsolidity/ast/ASTJsonConverter.cpp9
-rw-r--r--libsolidity/ast/Types.cpp2
-rw-r--r--libsolidity/codegen/ArrayUtils.cpp2
-rw-r--r--libsolidity/codegen/CompilerUtils.cpp9
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp2
-rw-r--r--libsolidity/formal/SMTChecker.cpp2
-rw-r--r--libsolidity/formal/Z3Interface.cpp2
-rw-r--r--libsolidity/interface/CompilerStack.cpp3
-rw-r--r--libsolidity/interface/Exceptions.cpp3
-rwxr-xr-xscripts/tests.sh10
-rwxr-xr-xtest/cmdlineTests.sh10
-rw-r--r--test/libjulia/Inliner.cpp35
-rw-r--r--test/libsolidity/syntaxTests/types/address/literal_to_address.sol1
-rw-r--r--test/tools/fuzzer.cpp71
26 files changed, 176 insertions, 131 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 8766883d..f8e380d9 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -141,7 +141,7 @@ jobs:
build_x86_mac:
macos:
- xcode: "9.0"
+ xcode: "10.0.0"
environment:
TERM: xterm
steps:
@@ -236,7 +236,7 @@ jobs:
test_x86_mac:
macos:
- xcode: "9.0"
+ xcode: "10.0.0"
environment:
TERM: xterm
steps:
diff --git a/docs/050-breaking-changes.rst b/docs/050-breaking-changes.rst
index b49dd1e0..9094000e 100644
--- a/docs/050-breaking-changes.rst
+++ b/docs/050-breaking-changes.rst
@@ -53,7 +53,7 @@ Semantic and Syntactic Changes
This section highlights changes that affect syntax and semantics.
-* The functions ``.call()``, ``.delegatecall()`, ``staticcall()``,
+* The functions ``.call()``, ``.delegatecall()``, ``staticcall()``,
``keccak256()``, ``sha256()`` and ``ripemd160()`` now accept only a single
``bytes`` argument. Moreover, the argument is not padded. This was changed to
make more explicit and clear how the arguments are concatenated. Change every
diff --git a/docs/assembly.rst b/docs/assembly.rst
index 02a802a8..c609fa9d 100644
--- a/docs/assembly.rst
+++ b/docs/assembly.rst
@@ -277,8 +277,10 @@ In the grammar, opcodes are represented as pre-defined identifiers.
| | | | and return the new address |
+-------------------------+-----+---+-----------------------------------------------------------------+
| create2(v, n, p, s) | | C | create new contract with code mem[p...(p+s)) at address |
-| | | | keccak256(0xff . <address> . n . keccak256(mem[p...(p+s))) |
-| | | | and send v wei and return the new address |
+| | | | keccak256(0xff . self . n . keccak256(mem[p...(p+s))) |
+| | | | and send v wei and return the new address, where ``0xff`` is a |
+| | | | 8 byte value, ``self`` is the current contract's address |
+| | | | as a 20 byte value and ``n`` is a big-endian 256-bit value |
+-------------------------+-----+---+-----------------------------------------------------------------+
| call(g, a, v, in, | | F | call contract at address a with input mem[in...(in+insize)) |
| insize, out, outsize) | | | providing g gas and v wei and output area |
diff --git a/docs/contracts.rst b/docs/contracts.rst
index 315d1815..93f54e4a 100644
--- a/docs/contracts.rst
+++ b/docs/contracts.rst
@@ -1131,7 +1131,7 @@ Multiple Inheritance and Linearization
Languages that allow multiple inheritance have to deal with
several problems. One is the `Diamond Problem <https://en.wikipedia.org/wiki/Multiple_inheritance#The_diamond_problem>`_.
Solidity is similar to Python in that it uses "`C3 Linearization <https://en.wikipedia.org/wiki/C3_linearization>`_"
-to force a specific order in the directed acyclic graph of base classes. This
+to force a specific order in the directed acyclic graph (DAG) of base classes. This
results in the desirable property of monotonicity but
disallows some inheritance graphs. Especially, the order in
which the base classes are given in the ``is`` directive is
@@ -1295,7 +1295,7 @@ contract, and a regular ``JUMP`` call will be used instead of a ``DELEGATECALL``
.. index:: using for, set
-The following example illustrates how to use libraries (butmanual method
+The following example illustrates how to use libraries (but manual method
be sure to check out :ref:`using for <using-for>` for a
more advanced example to implement a set).
diff --git a/docs/contributing.rst b/docs/contributing.rst
index d1ed9c6b..361570a0 100644
--- a/docs/contributing.rst
+++ b/docs/contributing.rst
@@ -47,13 +47,14 @@ in addition to *what* you did (unless it is a tiny change).
If you need to pull in any changes from ``develop`` after making your fork (for
example, to resolve potential merge conflicts), please avoid using ``git merge``
-and instead, ``git rebase`` your branch.
+and instead, ``git rebase`` your branch. This will help us review your change
+more easily.
-Additionally, if you are writing a new feature, please ensure you write appropriate
-Boost test cases and place them under ``test/``.
+Additionally, if you are writing a new feature, please ensure you add appropriate
+test cases under ``test/`` (see below).
However, if you are making a larger change, please consult with the `Solidity Development Gitter channel
-<https://gitter.im/ethereum/solidity-dev>`_ (different from the one mentioned above, this on is
+<https://gitter.im/ethereum/solidity-dev>`_ (different from the one mentioned above, this one is
focused on compiler and language development instead of language use) first.
New features and bugfixes should be added to the ``Changelog.md`` file: please
@@ -69,41 +70,47 @@ Thank you for your help!
Running the compiler tests
==========================
-Solidity includes different types of tests. They are included in the application
-called ``soltest``. Some of them require the ``cpp-ethereum`` client in testing mode,
+There is a script at ``scripts/tests.sh`` which executes most of the tests and
+runs ``aleth`` automatically if it is in the path, but does not download it,
+so it most likely will not work right away. Please read on for the details.
+
+Solidity includes different types of tests. Most of them are bundled in the application
+called ``soltest``. Some of them require the ``aleth`` client in testing mode,
some others require ``libz3`` to be installed.
-``soltest`` reads test contracts that are annotated with expected results
-stored in ``./test/libsolidity/syntaxTests``. In order for soltest to find these
-tests the root test directory has to be specified using the ``--testpath`` command
-line option, e.g. ``./build/test/soltest -- --testpath ./test``.
+To run a basic set of tests that neither require ``aleth`` nor ``libz3``, run
+``./scripts/soltest.sh --no-ipc --no-smt``. This script will run ``build/test/soltest``
+internally.
-To disable the z3 tests, use ``./build/test/soltest -- --no-smt --testpath ./test`` and
-to run a subset of the tests that do not require ``cpp-ethereum``, use
-``./build/test/soltest -- --no-ipc --testpath ./test``.
+The option ``--no-smt`` disables the tests that require ``libz3`` and
+``--no-ipc`` disables those that require ``aleth``.
-For all other tests, you need to install `cpp-ethereum <https://github.com/ethereum/cpp-ethereum/releases/download/solidityTester/eth>`_ and run it in testing mode: ``eth --test -d /tmp/testeth``.
+If you want to run the ipc tests (those test the semantics of the generated code),
+you need to install `aleth <https://github.com/ethereum/cpp-ethereum/releases/download/solidityTester/aleth_2018-06-20_artful>`_ and run it in testing mode: ``aleth --test -d /tmp/testeth`` (make sure to rename it).
-Then you run the actual tests: ``./build/test/soltest -- --ipcpath /tmp/testeth/geth.ipc --testpath ./test``.
+Then you run the actual tests: ``./scripts/soltest.sh --ipcpath /tmp/testeth/geth.ipc``.
To run a subset of tests, filters can be used:
-``soltest -t TestSuite/TestName -- --ipcpath /tmp/testeth/geth.ipc --testpath ./test``,
+``./scripts/soltest.sh -t TestSuite/TestName --ipcpath /tmp/testeth/geth.ipc``,
where ``TestName`` can be a wildcard ``*``.
-Alternatively, there is a testing script at ``scripts/tests.sh`` which executes all tests and runs
-``cpp-ethereum`` automatically if it is in the path (but does not download it).
+The script ``scripts/tests.sh`` also runs commandline tests and compilation tests
+in addition to those found in ``soltest``.
-Travis CI even runs some additional tests (including ``solc-js`` and testing third party Solidity frameworks) that require compiling the Emscripten target.
+The CI even runs some additional tests (including ``solc-js`` and testing third party Solidity frameworks) that require compiling the Emscripten target.
.. note ::
- While any version of ``cpp-ethereum`` should be usable, this cannot be guaranteed, and it is suggested to use the same version that is used by the Solidity continuous integration tests.
- Currently the CI uses ``d661ac4fec0aeffbedcdc195f67f5ded0c798278`` of ``cpp-ethereum``.
+ Some versions of ``aleth`` cannot be used for testing. We suggest using the same version that is used by the Solidity continuous integration tests.
+ Currently the CI uses ``d661ac4fec0aeffbedcdc195f67f5ded0c798278`` of ``aleth``.
Writing and running syntax tests
--------------------------------
-As mentioned above, syntax tests are stored in individual contracts. These files must contain annotations, stating the expected result(s) of the respective test.
+Syntax tests check that the compiler generates the correct error messages for invalid code
+and properly accepts valid code.
+They are stored in individual files inside ``tests/libsolidity/syntaxTests``.
+These files must contain annotations, stating the expected result(s) of the respective test.
The test suite will compile and check them against the given expectations.
Example: ``./test/libsolidity/syntaxTests/double_stateVariable_declaration.sol``
@@ -115,10 +122,12 @@ Example: ``./test/libsolidity/syntaxTests/double_stateVariable_declaration.sol``
uint128 variable;
}
// ----
- // DeclarationError: Identifier already declared.
+ // DeclarationError: (36-52): Identifier already declared.
-A syntax test must contain at least the contract under test itself, followed by the separator ``----``. The additional comments above are used to describe the
-expected compiler errors or warnings. This section can be empty in case that the contract should compile without any errors or warnings.
+A syntax test must contain at least the contract under test itself, followed by the separator ``// ----``. The following comments are used to describe the
+expected compiler errors or warnings. The number range denotes the location in the source where the error occurred.
+In case the contract should compile without any errors or warning, the section after the separator has to be empty
+and the separator can be left out completely.
In the above example, the state variable ``variable`` was declared twice, which is not allowed. This will result in a ``DeclarationError`` stating that the identifier was already declared.
@@ -131,7 +140,7 @@ editing of failing contracts using your preferred text editor. Let's try to brea
uint256 variable;
}
// ----
- // DeclarationError: Identifier already declared.
+ // DeclarationError: (36-52): Identifier already declared.
Running ``./test/isoltest`` again will result in a test failure:
@@ -144,16 +153,16 @@ Running ``./test/isoltest`` again will result in a test failure:
}
Expected result:
- DeclarationError: Identifier already declared.
+ DeclarationError: (36-52): Identifier already declared.
Obtained result:
Success
-which prints the expected result next to the obtained result, but also provides a way to change edit / update / skip the current contract or to even quit.
-``isoltest`` offers several options for failing tests:
+``isoltest`` prints the expected result next to the obtained result, but also provides a way to change edit / update / skip the current contract or to even quit.
+It offers several options for failing tests:
-- edit: ``isoltest`` will try to open the editor that was specified before using ``isoltest --editor /path/to/editor``. If no path was set, this will result in a runtime error. In case an editor was specified, this will open it such that the contract can be adjusted.
-- update: Updates the contract under test. This will either remove the annotation which contains the exception not met or will add missing expectations. The test will then be run again.
+- edit: ``isoltest`` tries to open the contract in an editor so you can adjust it. It either uses the editor given on the command line (as ``isoltest --editor /path/to/editor``), in the environment variable ``EDITOR`` or just ``/usr/bin/editor`` (in this order).
+- update: Updates the contract under test. This either removes the annotation which contains the exception not met or adds missing expectations. The test will then be run again.
- skip: Skips the execution of this particular test.
- quit: Quits ``isoltest``.
@@ -176,8 +185,9 @@ and re-run the test. It will now pass again:
.. note::
- Please choose a name for the contract file, that is self-explainatory in the sense of what is been tested, e.g. ``double_variable_declaration.sol``.
- Do not put more than one contract into a single file. ``isoltest`` is currently not able to recognize them individually.
+ Please choose a name for the contract file that explains what it tests, e.g. ``double_variable_declaration.sol``.
+ Do not put more than one contract into a single file, unless you are testing inheritance or cross-contract calls.
+ Each file should test one aspect of your new feature.
Running the Fuzzer via AFL
@@ -276,7 +286,7 @@ use the tool ``scripts/uniqueErrors.sh`` to filter out the unique errors.
Whiskers
========
-*Whiskers* is a templating system similar to `Mustache <https://mustache.github.io>`_. It is used by the
+*Whiskers* is a string templating system similar to `Mustache <https://mustache.github.io>`_. It is used by the
compiler in various places to aid readability, and thus maintainability and verifiability, of the code.
The syntax comes with a substantial difference to Mustache: the template markers ``{{`` and ``}}`` are
diff --git a/docs/introduction-to-smart-contracts.rst b/docs/introduction-to-smart-contracts.rst
index 5e841417..f5d5f89e 100644
--- a/docs/introduction-to-smart-contracts.rst
+++ b/docs/introduction-to-smart-contracts.rst
@@ -33,7 +33,7 @@ Storage
The first line simply tells that the source code is written for
Solidity version 0.4.0 or anything newer that does not break functionality
-(up to, but not including, version 0.5.0). This is to ensure that the
+(up to, but not including, version 0.6.0). This is to ensure that the
contract is not compilable with a new (breaking) compiler version, where it could behave differently.
So-called pragmas are common instructions for compilers about how to treat the
source code (e.g. `pragma once <https://en.wikipedia.org/wiki/Pragma_once>`_).
diff --git a/docs/yul.rst b/docs/yul.rst
index e010a708..cfeec4db 100644
--- a/docs/yul.rst
+++ b/docs/yul.rst
@@ -83,6 +83,7 @@ Grammar::
FunctionDefinition |
VariableDeclaration |
Assignment |
+ If |
Expression |
Switch |
ForLoop |
@@ -417,6 +418,12 @@ The following functions must be available:
| create(v:u256, p:u256, s:u256) | create new contract with code mem[p..(p+s)) and send v wei |
| | and return the new address |
+---------------------------------------------+-----------------------------------------------------------------+
+| create2(v:u256, n:u256, p:u256, s:u256) | create new contract with code mem[p...(p+s)) at address |
+| | keccak256(0xff . self . n . keccak256(mem[p...(p+s))) |
+| | and send v wei and return the new address, where ``0xff`` is a |
+| | 8 byte value, ``self`` is the current contract's address |
+| | as a 20 byte value and ``n`` is a big-endian 256-bit value |
++---------------------------------------------+-----------------------------------------------------------------+
| call(g:u256, a:u256, v:u256, in:u256, | call contract at address a with input mem[in..(in+insize)) |
| insize:u256, out:u256, | providing g gas and v wei and output area |
| outsize:u256) | mem[out..(out+outsize)) returning 0 on error (eg. out of gas) |
@@ -492,6 +499,8 @@ The following functions must be available:
+---------------------------------------------+-----------------------------------------------------------------+
| extcodecopy(a:u256, t:u256, f:u256, s:u256) | like codecopy(t, f, s) but take code at address a |
+---------------------------------------------+-----------------------------------------------------------------+
+| extcodehash(a:u256) | code hash of address a |
++---------------------------------------------+-----------------------------------------------------------------+
| *Others* |
+---------------------------------------------+-----------------------------------------------------------------+
| discard(unused:bool) | discard value |
diff --git a/libevmasm/Assembly.cpp b/libevmasm/Assembly.cpp
index 63452f36..c2eaa1ca 100644
--- a/libevmasm/Assembly.cpp
+++ b/libevmasm/Assembly.cpp
@@ -41,10 +41,19 @@ void Assembly::append(Assembly const& _a)
auto newDeposit = m_deposit + _a.deposit();
for (AssemblyItem i: _a.m_items)
{
- if (i.type() == Tag || i.type() == PushTag)
+ switch (i.type())
+ {
+ case Tag:
+ case PushTag:
i.setData(i.data() + m_usedTags);
- else if (i.type() == PushSub || i.type() == PushSubSize)
+ break;
+ case PushSub:
+ case PushSubSize:
i.setData(i.data() + m_subs.size());
+ break;
+ default:
+ break;
+ }
append(i);
}
m_deposit = newDeposit;
diff --git a/libjulia/optimiser/FullInliner.cpp b/libjulia/optimiser/FullInliner.cpp
index e8776e23..f41dc198 100644
--- a/libjulia/optimiser/FullInliner.cpp
+++ b/libjulia/optimiser/FullInliner.cpp
@@ -89,6 +89,9 @@ void InlineModifier::operator()(ForLoop& _loop)
void InlineModifier::operator()(Block& _block)
{
+ vector<Statement> saved;
+ saved.swap(m_statementsToPrefix);
+
// This is only used if needed to minimize the number of move operations.
vector<Statement> modifiedStatements;
for (size_t i = 0; i < _block.statements.size(); ++i)
@@ -110,6 +113,8 @@ void InlineModifier::operator()(Block& _block)
}
if (!modifiedStatements.empty())
_block.statements = std::move(modifiedStatements);
+
+ saved.swap(m_statementsToPrefix);
}
void InlineModifier::visit(Expression& _expression)
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 3d119c82..bc040623 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -2398,11 +2398,11 @@ void TypeChecker::endVisit(Literal const& _literal)
_literal.annotation().type = make_shared<AddressType>(StateMutability::Payable);
string msg;
- if (_literal.value().length() != 42) // "0x" + 40 hex digits
+ if (_literal.valueWithoutUnderscores().length() != 42) // "0x" + 40 hex digits
// looksLikeAddress enforces that it is a hex literal starting with "0x"
msg =
"This looks like an address but is not exactly 40 hex digits. It is " +
- to_string(_literal.value().length() - 2) +
+ to_string(_literal.valueWithoutUnderscores().length() - 2) +
" hex digits.";
else if (!_literal.passesAddressChecksum())
{
diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp
index 8e7a81a6..d9264230 100644
--- a/libsolidity/ast/AST.cpp
+++ b/libsolidity/ast/AST.cpp
@@ -311,8 +311,6 @@ FunctionTypePointer FunctionDefinition::functionType(bool _internal) const
return make_shared<FunctionType>(*this, _internal);
case Declaration::Visibility::External:
return {};
- default:
- solAssert(false, "visibility() should return a Visibility");
}
}
else
@@ -327,8 +325,6 @@ FunctionTypePointer FunctionDefinition::functionType(bool _internal) const
case Declaration::Visibility::Public:
case Declaration::Visibility::External:
return make_shared<FunctionType>(*this, _internal);
- default:
- solAssert(false, "visibility() should return a Visibility");
}
}
@@ -568,8 +564,6 @@ FunctionTypePointer VariableDeclaration::functionType(bool _internal) const
case Declaration::Visibility::Public:
case Declaration::Visibility::External:
return make_shared<FunctionType>(*this);
- default:
- solAssert(false, "visibility() should not return a Visibility");
}
// To make the compiler happy
@@ -639,6 +633,11 @@ IdentifierAnnotation& Identifier::annotation() const
return dynamic_cast<IdentifierAnnotation&>(*m_annotation);
}
+ASTString Literal::valueWithoutUnderscores() const
+{
+ return boost::erase_all_copy(value(), "_");
+}
+
bool Literal::isHexNumber() const
{
if (token() != Token::Number)
@@ -654,20 +653,20 @@ bool Literal::looksLikeAddress() const
if (!isHexNumber())
return false;
- return abs(int(value().length()) - 42) <= 1;
+ return abs(int(valueWithoutUnderscores().length()) - 42) <= 1;
}
bool Literal::passesAddressChecksum() const
{
solAssert(isHexNumber(), "Expected hex number");
- return dev::passesAddressChecksum(value(), true);
+ return dev::passesAddressChecksum(valueWithoutUnderscores(), true);
}
string Literal::getChecksummedAddress() const
{
solAssert(isHexNumber(), "Expected hex number");
/// Pad literal to be a proper hex address.
- string address = value().substr(2);
+ string address = valueWithoutUnderscores().substr(2);
if (address.length() > 40)
return string();
address.insert(address.begin(), 40 - address.size(), '0');
diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h
index f3464f92..b84f9730 100644
--- a/libsolidity/ast/AST.h
+++ b/libsolidity/ast/AST.h
@@ -1679,6 +1679,8 @@ public:
/// @returns the non-parsed value of the literal
ASTString const& value() const { return *m_value; }
+ ASTString valueWithoutUnderscores() const;
+
SubDenomination subDenomination() const { return m_subDenomination; }
/// @returns true if this is a number with a hex prefix.
diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp
index 8d52851a..cadc5f28 100644
--- a/libsolidity/ast/ASTJsonConverter.cpp
+++ b/libsolidity/ast/ASTJsonConverter.cpp
@@ -752,9 +752,9 @@ string ASTJsonConverter::location(VariableDeclaration::Location _location)
return "memory";
case VariableDeclaration::Location::CallData:
return "calldata";
- default:
- solAssert(false, "Unknown declaration location.");
}
+ // To make the compiler happy
+ return {};
}
string ASTJsonConverter::contractKind(ContractDefinition::ContractKind _kind)
@@ -767,9 +767,10 @@ string ASTJsonConverter::contractKind(ContractDefinition::ContractKind _kind)
return "contract";
case ContractDefinition::ContractKind::Library:
return "library";
- default:
- solAssert(false, "Unknown kind of contract.");
}
+
+ // To make the compiler happy
+ return {};
}
string ASTJsonConverter::functionCallKind(FunctionCallKind _kind)
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index fd72bf41..e45fc81d 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -499,7 +499,7 @@ u256 AddressType::literalValue(Literal const* _literal) const
{
solAssert(_literal, "");
solAssert(_literal->value().substr(0, 2) == "0x", "");
- return u256(_literal->value());
+ return u256(_literal->valueWithoutUnderscores());
}
TypePointer AddressType::unaryOperatorResult(Token::Value _operator) const
diff --git a/libsolidity/codegen/ArrayUtils.cpp b/libsolidity/codegen/ArrayUtils.cpp
index 2b77db8f..d33f749c 100644
--- a/libsolidity/codegen/ArrayUtils.cpp
+++ b/libsolidity/codegen/ArrayUtils.cpp
@@ -1108,8 +1108,6 @@ void ArrayUtils::accessIndex(ArrayType const& _arrayType, bool _doBoundsCheck) c
m_context << endTag;
break;
}
- default:
- solAssert(false, "");
}
}
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp
index e6ad6d9c..2bdf88e3 100644
--- a/libsolidity/codegen/CompilerUtils.cpp
+++ b/libsolidity/codegen/CompilerUtils.cpp
@@ -895,15 +895,6 @@ void CompilerUtils::convertType(
typeOnStack.location() == DataLocation::CallData,
"Invalid conversion to calldata type.");
break;
- default:
- solAssert(
- false,
- "Invalid type conversion " +
- _typeOnStack.toString(false) +
- " to " +
- _targetType.toString(false) +
- " requested."
- );
}
break;
}
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp
index 587cf34a..27440289 100644
--- a/libsolidity/codegen/ExpressionCompiler.cpp
+++ b/libsolidity/codegen/ExpressionCompiler.cpp
@@ -1098,8 +1098,6 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
case FunctionType::Kind::GasLeft:
m_context << Instruction::GAS;
break;
- default:
- solAssert(false, "Invalid function type.");
}
}
return false;
diff --git a/libsolidity/formal/SMTChecker.cpp b/libsolidity/formal/SMTChecker.cpp
index 49c90405..19785817 100644
--- a/libsolidity/formal/SMTChecker.cpp
+++ b/libsolidity/formal/SMTChecker.cpp
@@ -639,8 +639,6 @@ void SMTChecker::checkCondition(
case smt::CheckResult::ERROR:
m_errorReporter.warning(_location, "Error trying to invoke SMT solver.");
break;
- default:
- solAssert(false, "");
}
m_interface->pop();
}
diff --git a/libsolidity/formal/Z3Interface.cpp b/libsolidity/formal/Z3Interface.cpp
index 747c9172..9a0ccf48 100644
--- a/libsolidity/formal/Z3Interface.cpp
+++ b/libsolidity/formal/Z3Interface.cpp
@@ -91,8 +91,6 @@ pair<CheckResult, vector<string>> Z3Interface::check(vector<Expression> const& _
case z3::check_result::unknown:
result = CheckResult::UNKNOWN;
break;
- default:
- solAssert(false, "");
}
if (result == CheckResult::SATISFIABLE && !_expressionsToEvaluate.empty())
diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp
index adf59a9c..d1001c80 100644
--- a/libsolidity/interface/CompilerStack.cpp
+++ b/libsolidity/interface/CompilerStack.cpp
@@ -988,8 +988,7 @@ Json::Value CompilerStack::gasEstimates(string const& _contractName) const
if (eth::AssemblyItems const* items = assemblyItems(_contractName))
{
Gas executionGas = gasEstimator.functionalEstimation(*items);
- u256 bytecodeSize(runtimeObject(_contractName).bytecode.size());
- Gas codeDepositGas = bytecodeSize * eth::GasCosts::createDataGas;
+ Gas codeDepositGas{eth::GasMeter::dataGas(runtimeObject(_contractName).bytecode, false)};
Json::Value creation(Json::objectValue);
creation["codeDepositCost"] = gasToJson(codeDepositGas);
diff --git a/libsolidity/interface/Exceptions.cpp b/libsolidity/interface/Exceptions.cpp
index a837dce6..ecadd0b7 100644
--- a/libsolidity/interface/Exceptions.cpp
+++ b/libsolidity/interface/Exceptions.cpp
@@ -49,9 +49,6 @@ Error::Error(Type _type, SourceLocation const& _location, string const& _descrip
case Type::Warning:
m_typeName = "Warning";
break;
- default:
- solAssert(false, "");
- break;
}
if (!_location.isEmpty())
diff --git a/scripts/tests.sh b/scripts/tests.sh
index 1c0fc590..c284c05c 100755
--- a/scripts/tests.sh
+++ b/scripts/tests.sh
@@ -100,8 +100,14 @@ else
log_directory=""
fi
-function printError() { echo "$(tput setaf 1)$1$(tput sgr0)"; }
-function printTask() { echo "$(tput bold)$(tput setaf 2)$1$(tput sgr0)"; }
+if [ "$CIRCLECI" ]
+then
+ function printTask() { echo "$(tput bold)$(tput setaf 2)$1$(tput setaf 7)"; }
+ function printError() { echo "$(tput setaf 1)$1$(tput setaf 7)"; }
+else
+ function printTask() { echo "$(tput bold)$(tput setaf 2)$1$(tput sgr0)"; }
+ function printError() { echo "$(tput setaf 1)$1$(tput sgr0)"; }
+fi
printTask "Running commandline tests..."
# Only run in parallel if this is run on CI infrastructure
diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh
index 78e45429..d7b95e8a 100755
--- a/test/cmdlineTests.sh
+++ b/test/cmdlineTests.sh
@@ -37,9 +37,15 @@ FULLARGS="--optimize --ignore-missing --combined-json abi,asm,ast,bin,bin-runtim
echo "Checking that the bug list is up to date..."
"$REPO_ROOT"/scripts/update_bugs_by_version.py
-function printTask() { echo "$(tput bold)$(tput setaf 2)$1$(tput sgr0)"; }
+if [ "$CIRCLECI" ]
+then
+ function printTask() { echo "$(tput bold)$(tput setaf 2)$1$(tput setaf 7)"; }
+ function printError() { echo "$(tput setaf 1)$1$(tput setaf 7)"; }
+else
+ function printTask() { echo "$(tput bold)$(tput setaf 2)$1$(tput sgr0)"; }
+ function printError() { echo "$(tput setaf 1)$1$(tput sgr0)"; }
+fi
-function printError() { echo "$(tput setaf 1)$1$(tput sgr0)"; }
function compileFull()
{
diff --git a/test/libjulia/Inliner.cpp b/test/libjulia/Inliner.cpp
index 43a7d757..d0ecd42f 100644
--- a/test/libjulia/Inliner.cpp
+++ b/test/libjulia/Inliner.cpp
@@ -342,5 +342,40 @@ BOOST_AUTO_TEST_CASE(pop_result)
);
}
+BOOST_AUTO_TEST_CASE(inside_condition)
+{
+ // This tests that breaking the expression inside the condition works properly.
+ BOOST_CHECK_EQUAL(
+ fullInline("{"
+ "if gt(f(mload(1)), mload(0)) {"
+ "sstore(0, 2)"
+ "}"
+ "function f(a) -> r {"
+ "a := mload(a)"
+ "r := add(a, calldatasize())"
+ "}"
+ "}", false),
+ format("{"
+ "{"
+ "let _1 := mload(0)"
+ "let f_a := mload(1)"
+ "let f_r"
+ "{"
+ "f_a := mload(f_a)"
+ "f_r := add(f_a, calldatasize())"
+ "}"
+ "if gt(f_r, _1)"
+ "{"
+ "sstore(0, 2)"
+ "}"
+ "}"
+ "function f(a) -> r"
+ "{"
+ "a := mload(a)"
+ "r := add(a, calldatasize())"
+ "}"
+ "}", false)
+ );
+}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/test/libsolidity/syntaxTests/types/address/literal_to_address.sol b/test/libsolidity/syntaxTests/types/address/literal_to_address.sol
index 9d599ea5..20ee56de 100644
--- a/test/libsolidity/syntaxTests/types/address/literal_to_address.sol
+++ b/test/libsolidity/syntaxTests/types/address/literal_to_address.sol
@@ -4,5 +4,6 @@ contract C {
a = address(1);
address b = 0x0123456789012345678901234567890123456789;
b = 0x9876543210987654321098765432109876543210;
+ b = 0x9876_5432_1098_7654_3210_9876_5432_1098_7654_3210;
}
}
diff --git a/test/tools/fuzzer.cpp b/test/tools/fuzzer.cpp
index a5a63854..ce4b721f 100644
--- a/test/tools/fuzzer.cpp
+++ b/test/tools/fuzzer.cpp
@@ -84,12 +84,8 @@ void testConstantOptimizer()
}
}
-void testStandardCompiler()
+void runCompiler(string input)
{
- if (!quiet)
- cout << "Testing compiler via JSON interface." << endl;
- string input = readStandardInput();
-
string outputString(compileStandard(input.c_str(), NULL));
Json::Value output;
if (!jsonParseStrict(outputString, output))
@@ -112,52 +108,37 @@ void testStandardCompiler()
}
}
+void testStandardCompiler()
+{
+ if (!quiet)
+ cout << "Testing compiler via JSON interface." << endl;
+ string input = readStandardInput();
+
+ runCompiler(input);
+}
+
void testCompiler(bool optimize)
{
if (!quiet)
cout << "Testing compiler " << (optimize ? "with" : "without") << " optimizer." << endl;
string input = readStandardInput();
- string outputString(compileJSON(input.c_str(), optimize));
- Json::Value outputJson;
- if (!jsonParseStrict(outputString, outputJson))
- {
- cout << "Compiler produced invalid JSON output." << endl;
- abort();
- }
- if (outputJson.isMember("errors"))
- {
- if (!outputJson["errors"].isArray())
- {
- cout << "Output JSON has \"errors\" but it is not an array." << endl;
- abort();
- }
- for (Json::Value const& error: outputJson["errors"])
- {
- string invalid = contains(error.asString(), vector<string>{
- // StandardJSON error types
- "Exception",
- "InternalCompilerError",
- // Old-school error messages
- "Internal compiler error",
- "Exception during compilation",
- "Unknown exception during compilation",
- "Unknown exception while generating contract data output",
- "Unknown exception while generating source name output",
- "Unknown error while generating JSON"
- });
- if (!invalid.empty())
- {
- cout << "Invalid error: \"" << error.asString() << "\"" << endl;
- abort();
- }
- }
- }
- else if (!outputJson.isMember("contracts"))
- {
- cout << "Output JSON has neither \"errors\" nor \"contracts\"." << endl;
- abort();
- }
+ Json::Value config = Json::objectValue;
+ config["language"] = "Solidity";
+ config["sources"] = Json::objectValue;
+ config["sources"][""] = Json::objectValue;
+ config["sources"][""]["content"] = input;
+ config["settings"] = Json::objectValue;
+ config["settings"]["optimizer"] = Json::objectValue;
+ config["settings"]["optimizer"]["enabled"] = optimize;
+ config["settings"]["optimizer"]["runs"] = 200;
+
+ // Enable all SourceUnit-level outputs.
+ config["settings"]["outputSelection"]["*"][""][0] = "*";
+ // Enable all Contract-level outputs.
+ config["settings"]["outputSelection"]["*"]["*"][0] = "*";
+
+ runCompiler(jsonCompactPrint(config));
}
}