aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--CONTRIBUTING.md5
-rw-r--r--Changelog.md37
-rw-r--r--README.md3
-rw-r--r--appveyor.yml19
-rw-r--r--cmake/EthBuildInfo.cmake4
-rw-r--r--cmake/scripts/buildinfo.cmake53
-rw-r--r--cmake/templates/BuildInfo.h.in15
-rw-r--r--docs/contracts.rst37
-rw-r--r--docs/contributing.rst55
-rw-r--r--docs/index.rst3
-rw-r--r--docs/installing-solidity.rst187
-rw-r--r--docs/introduction-to-smart-contracts.rst12
-rw-r--r--docs/security-considerations.rst4
-rw-r--r--docs/types.rst9
-rw-r--r--docs/units-and-global-variables.rst6
-rw-r--r--libsolidity/analysis/TypeChecker.cpp2
-rw-r--r--libsolidity/codegen/ContractCompiler.cpp5
-rw-r--r--libsolidity/interface/InterfaceHandler.cpp10
-rw-r--r--libsolidity/interface/Version.cpp6
-rw-r--r--lllc/main.cpp25
-rwxr-xr-xscripts/build_emscripten.sh1
-rw-r--r--scripts/install_deps.bat1
-rwxr-xr-xscripts/install_deps.sh22
-rw-r--r--scripts/install_eth.cmake76
-rwxr-xr-xscripts/release_ppa.sh4
-rwxr-xr-xscripts/tests.sh2
-rw-r--r--solc/main.cpp25
-rw-r--r--test/RPCSession.cpp7
-rw-r--r--test/TestHelper.cpp2
-rw-r--r--test/libsolidity/Assembly.cpp2
-rw-r--r--test/libsolidity/SolidityABIJSON.cpp28
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp15
-rw-r--r--test/libsolidity/SolidityExecutionFramework.cpp2
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp10
35 files changed, 525 insertions, 171 deletions
diff --git a/.travis.yml b/.travis.yml
index 1b0ff15d..da9bd2f9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -141,6 +141,8 @@ cache:
install:
- test $TRAVIS_INSTALL_DEPS != On || ./scripts/install_deps.sh
+ - echo -n "$TRAVIS_COMMIT" > commit_hash.txt
+ - test "$TRAVIS_PULL_REQUESTS" != "false" || test "$TRAVIS_BRANCH" != release || echo -n > prerelease.txt # this is a proper release
before_script:
- test $TRAVIS_EMSCRIPTEN != On || ./scripts/build_emscripten.sh
- test $TRAVIS_RELEASE != On || (mkdir -p build
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 00000000..2b591f4e
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,5 @@
+# Contribution Guidelines
+
+Please see our contribution guidelines in [the Solidity documentation](http://solidity.readthedocs.io/en/latest/contributing.html).
+
+Thank you for your help!
diff --git a/Changelog.md b/Changelog.md
index 8805498e..5cf2898b 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,9 +1,44 @@
+### 0.4.0 (unreleased)
+
+This release deliberately breaks backwards compatibility mostly to
+enforce some safety features. The most important change is
+...
+
+Breaking Changes:
+
+ * Contracts that want to receive Ether have to implement a fallback
+ function (contracts now throw if no fallback function is defined
+ and no function matches the signature).
+ * Failing contract creation through "new" throws now.
+ * Throw on division / modulus by zero
+ * Function call throws if target contract does not have code
+ * Modifiers are required to contain ``_`` (use ``if (false) _`` as a workaround if needed).
+ * Modifiers: return does not skip part in modifier after ``_``
+ * ``ecrecover`` now returns zero if the input is malformed (it previously returned garbage)
+ * Removed ``--interface`` (Solidity interface) output option
+ * JSON AST: General cleanup, renamed many nodes to match their C++ names.
+ * Json Output: srcmap-runtime renamed to srcmapRuntime
+ * Moved (and reworked) standard library contracts from inside the compiler to github.com/ethereum/solidity/std
+ (``import "std";`` or ``import owned;`` do not work anymore).
+ * Confusing and undocumented keyword "after" was removed.
+ * New reserved words: hex, payable, abstract, static, interface
+
Features:
- * Fixed point types (in progress)
+ * Hexadecimal string literals: ``hex"ab1248fe"``
+ * Internal: Inline assembly usable by the code generator.
+ * Commandline interface: Using ``-`` as filename allows reading from stdin.
+ * Interface Json: Fallback function is now part of the ABI.
+ * Interface: Version string now semver compatible.
Bugfixes:
+ * JSON AST: nodes were added at wrong parent
+ * Why3 translator: crash fix for exponentiation
+ * Type Checker: Fallback function cannot return data anymore.
+
+Lots of changes to the documentation mainly by voluntary external contributors.
+
### 0.3.6 (2016-08-10)
Features:
diff --git a/README.md b/README.md
index b2bf92f2..bda66996 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,6 @@ Solidity is still under development. So please do not hesitate and open an [issu
See the [Solidity documentation](http://solidity.readthedocs.io/en/latest/installing-solidity.html#building-from-source) for build instructions.
## How to Contribute
-This repository uses the same [coding style](https://github.com/ethereum/webthree-umbrella/blob/develop/CodingStandards.txt) as
-all of the cpp-ethereum projects. Please try to align with us in the gitter channel before making larger changes.
+Please see our contribution guidelines in [the Solidity documentation](http://solidity.readthedocs.io/en/latest/contributing.html).
Any contributions are welcome!
diff --git a/appveyor.yml b/appveyor.yml
index 2af17912..28d53062 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -34,6 +34,10 @@ configuration:
# We can re-enable it when we find a way to mitigate the unreliability
# issues. Have automated builds be reliable is the more important thing.
#cache: build
+#
+# In case we'd need a RDP detail to login into appveyor
+#init:
+# - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
install:
- git submodule update --init --recursive
- scripts/install_deps.bat
@@ -47,12 +51,15 @@ build_script:
- cd %APPVEYOR_BUILD_FOLDER%
- scripts\release.bat %CONFIGURATION%
-#test_script:
-# - cd %APPVEYOR_BUILD_FOLDER%\build\test\%CONFIGURATION%
-# - copy "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x86\Microsoft.VC140.CRT\msvc*.dll" .
-# - start eth.exe --test -d %TMP%\eth_for_soltest
-# - soltest.exe -- --ipc %TMP%\eth_for_soltest\geth.ipc
-# - pkill eth
+test_script:
+ - cd %APPVEYOR_BUILD_FOLDER%
+ - cd deps\install\x64\eth
+ - ps: $ethProc = Start-Process eth.exe --test
+ - ps: Start-Sleep -s 100
+ - cd %APPVEYOR_BUILD_FOLDER%\build\test\%CONFIGURATION%
+ - copy "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x86\Microsoft.VC140.CRT\msvc*.dll" .
+ - soltest.exe -- --ipcpath \\.\pipe\geth.ipc
+ - ps: Stop-Process -Id $ethProc.Id
artifacts:
- path: solidity-windows.zip
diff --git a/cmake/EthBuildInfo.cmake b/cmake/EthBuildInfo.cmake
index cbb9dd24..1f70d371 100644
--- a/cmake/EthBuildInfo.cmake
+++ b/cmake/EthBuildInfo.cmake
@@ -19,7 +19,7 @@ function(create_build_info NAME)
set(ETH_BUILD_COMPILER "unknown")
endif ()
- set(ETH_BUILD_PLATFORM "${ETH_BUILD_OS}/${ETH_BUILD_COMPILER}")
+ set(ETH_BUILD_PLATFORM "${ETH_BUILD_OS}.${ETH_BUILD_COMPILER}")
#cmake build type may be not speCified when using msvc
if (CMAKE_BUILD_TYPE)
@@ -36,8 +36,6 @@ function(create_build_info NAME)
-DETH_BUILD_OS="${ETH_BUILD_OS}"
-DETH_BUILD_COMPILER="${ETH_BUILD_COMPILER}"
-DETH_BUILD_PLATFORM="${ETH_BUILD_PLATFORM}"
- -DETH_BUILD_NUMBER="${BUILD_NUMBER}"
- -DETH_VERSION_SUFFIX="${VERSION_SUFFIX}"
-DPROJECT_VERSION="${PROJECT_VERSION}"
-P "${ETH_SCRIPTS_DIR}/buildinfo.cmake"
)
diff --git a/cmake/scripts/buildinfo.cmake b/cmake/scripts/buildinfo.cmake
index 39359486..ad23ca86 100644
--- a/cmake/scripts/buildinfo.cmake
+++ b/cmake/scripts/buildinfo.cmake
@@ -5,11 +5,11 @@
# ETH_DST_DIR - main CMAKE_BINARY_DIR
# ETH_BUILD_TYPE
# ETH_BUILD_PLATFORM
-# ETH_BUILD_NUMBER
-# ETH_VERSION_SUFFIX
#
# example usage:
-# cmake -DETH_SOURCE_DIR=. -DETH_DST_DIR=build -DETH_BUILD_TYPE=Debug -DETH_BUILD_PLATFORM=Darwin/appleclang -P scripts/buildinfo.cmake
+# cmake -DETH_SOURCE_DIR=. -DETH_DST_DIR=build -DETH_BUILD_TYPE=Debug -DETH_BUILD_PLATFORM=Darwin.appleclang -P scripts/buildinfo.cmake
+#
+# Its main output variables are SOL_VERSION_BUILDINFO and SOL_VERSION_PRERELEASE
if (NOT ETH_BUILD_TYPE)
set(ETH_BUILD_TYPE "unknown")
@@ -19,26 +19,45 @@ if (NOT ETH_BUILD_PLATFORM)
set(ETH_BUILD_PLATFORM "unknown")
endif()
-execute_process(
- COMMAND git --git-dir=${ETH_SOURCE_DIR}/.git --work-tree=${ETH_SOURCE_DIR} rev-parse HEAD
- OUTPUT_VARIABLE ETH_COMMIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
-)
+# Logic here: If prereleases.txt exists but is empty, it is a non-pre release.
+# If it does not exist, create our own prerelease string
+if (EXISTS ${ETH_SOURCE_DIR}/prerelease.txt)
+ file(READ ${ETH_SOURCE_DIR}/prerelease.txt SOL_VERSION_PRERELEASE)
+ string(STRIP ${SOL_VERSION_PRERELEASE} SOL_VERSION_PRERELEASE)
+else()
+ string(TIMESTAMP SOL_VERSION_PRERELEASE "develop.%Y.%m.%d" UTC)
+endif()
-if (NOT ETH_COMMIT_HASH)
- set(ETH_COMMIT_HASH 0)
+if (EXISTS ${ETH_SOURCE_DIR}/commit_hash.txt)
+ file(READ ${ETH_SOURCE_DIR}/commit_hash.txt SOL_COMMIT_HASH)
+ string(STRIP ${SOL_COMMIT_HASH} SOL_COMMIT_HASH)
+else()
+ execute_process(
+ COMMAND git --git-dir=${ETH_SOURCE_DIR}/.git --work-tree=${ETH_SOURCE_DIR} rev-parse HEAD
+ OUTPUT_VARIABLE SOL_COMMIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
+ )
+ execute_process(
+ COMMAND git --git-dir=${ETH_SOURCE_DIR}/.git --work-tree=${ETH_SOURCE_DIR} diff HEAD --shortstat
+ OUTPUT_VARIABLE SOL_LOCAL_CHANGES OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
+ )
endif()
-execute_process(
- COMMAND git --git-dir=${ETH_SOURCE_DIR}/.git --work-tree=${ETH_SOURCE_DIR} diff HEAD --shortstat
- OUTPUT_VARIABLE ETH_LOCAL_CHANGES OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
-)
+if (SOL_COMMIT_HASH)
+ string(STRIP ${SOL_COMMIT_HASH} SOL_COMMIT_HASH)
+ string(SUBSTRING ${SOL_COMMIT_HASH} 0 8 SOL_COMMIT_HASH)
+endif()
-if (ETH_LOCAL_CHANGES)
- set(ETH_CLEAN_REPO 0)
-else()
- set(ETH_CLEAN_REPO 1)
+if (SOL_COMMIT_HASH AND SOL_LOCAL_CHANGES)
+ set(SOL_COMMIT_HASH "${SOL_COMMIT_HASH}-mod")
+endif()
+
+if (NOT SOL_COMMIT_HASH)
+ message(FATAL_ERROR "Unable to determine commit hash. Either compile from within git repository or "
+ "supply a file called commit_hash.txt")
endif()
+set(SOL_VERSION_BUILDINFO "commit.${SOL_COMMIT_HASH}.${ETH_BUILD_PLATFORM}")
+
set(TMPFILE "${ETH_DST_DIR}/BuildInfo.h.tmp")
set(OUTFILE "${ETH_DST_DIR}/BuildInfo.h")
diff --git a/cmake/templates/BuildInfo.h.in b/cmake/templates/BuildInfo.h.in
index 6f9baf50..6c16e4ac 100644
--- a/cmake/templates/BuildInfo.h.in
+++ b/cmake/templates/BuildInfo.h.in
@@ -1,11 +1,10 @@
#pragma once
#define ETH_PROJECT_VERSION "@PROJECT_VERSION@"
-#define ETH_COMMIT_HASH @ETH_COMMIT_HASH@
-#define ETH_CLEAN_REPO @ETH_CLEAN_REPO@
-#define ETH_BUILD_TYPE @ETH_BUILD_TYPE@
-#define ETH_BUILD_OS @ETH_BUILD_OS@
-#define ETH_BUILD_COMPILER @ETH_BUILD_COMPILER@
-#define ETH_BUILD_PLATFORM @ETH_BUILD_PLATFORM@
-#define ETH_BUILD_NUMBER @ETH_BUILD_NUMBER@
-#define ETH_VERSION_SUFFIX "@ETH_VERSION_SUFFIX@"
+#define SOL_COMMIT_HASH "@SOL_COMMIT_HASH@"
+#define ETH_BUILD_TYPE "@ETH_BUILD_TYPE@"
+#define ETH_BUILD_OS "@ETH_BUILD_OS@"
+#define ETH_BUILD_COMPILER "@ETH_BUILD_COMPILER@"
+#define ETH_BUILD_PLATFORM "@ETH_BUILD_PLATFORM@"
+#define SOL_VERSION_PRERELEASE "@SOL_VERSION_PRERELEASE@"
+#define SOL_VERSION_BUILDINFO "@SOL_VERSION_BUILDINFO@"
diff --git a/docs/contracts.rst b/docs/contracts.rst
index dfdcaf18..a22a3544 100644
--- a/docs/contracts.rst
+++ b/docs/contracts.rst
@@ -195,45 +195,47 @@ return parameter list for functions.
uint public data;
}
-An other contract ``D`` can call ``c.getData()`` to retrieve the value of data in state
-storage and is not able to call ``f``. Contract ``E`` is derived from ``C`` and can call
-``compute``.
+In the following example, ``D``, can call ``c.getData()`` to retrieve the value of
+``data`` in state storage, but is not able to call ``f``. Contract ``E`` is derived from
+``C`` and, thus, can call ``compute``.
::
contract C {
+ uint private data;
+
function f(uint a) private returns(uint b) { return a + 1; }
function setData(uint a) { data = a; }
- function getData() public returns(uint) {return data;}
- function compute(uint a, uint b) internal returns (uint) { return a+b;}
- uint private data;
+ function getData() public returns(uint) { return data; }
+ function compute(uint a, uint b) internal returns (uint) { return a+b; }
}
+
contract D {
function readData() {
C c = new C();
- local = c.f(7); // error: member "f" is not visible
+ uint local = c.f(7); // error: member "f" is not visible
c.setData(3);
- uint local = c.getData();
- local = c.compute(3,5); // error: member "compute" is not visible
+ local = c.getData();
+ local = c.compute(3, 5); // error: member "compute" is not visible
}
}
+
contract E is C {
function g() {
C c = new C();
- uint val = compute(3,5); // acces to internal member (from derivated to parent contract)
+ uint val = compute(3, 5); // acces to internal member (from derivated to parent contract)
}
}
-
.. index:: ! accessor;function, ! function;accessor
Accessor Functions
==================
The compiler automatically creates accessor functions for
-all public state variables. For the contract given below the compiler will
+all public state variables. For the contract given below, the compiler will
generate a function called ``data`` that does not take any
arguments and returns a ``uint``, the value of the state
variable ``data``. The initialization of state variables can
@@ -245,6 +247,7 @@ be done at declaration.
uint public data = 42;
}
+
contract Caller {
C c = new C();
function f() {
@@ -254,8 +257,8 @@ be done at declaration.
The accessor functions have external visibility. If the
symbol is accessed internally (i.e. without ``this.``),
-it is evaluated as state variable and if it is accessed externally
-(i.e. with ``this.``), it is evaluated as function.
+it is evaluated as a state variable and if it is accessed externally
+(i.e. with ``this.``), it is evaluated as a function.
::
@@ -444,6 +447,12 @@ In particular, the following operations will consume more gas than the stipend p
Please ensure you test your fallback function thoroughly to ensure the execution cost is less than 2300 gas before deploying a contract.
+.. warning::
+ Contracts that receive Ether but do not define a fallback function
+ throw an exception, sending back the Ether (this was different
+ before Solidity v0.4.0). So if you want your contract to receive Ether,
+ you have to implement a fallback function.
+
::
contract Test {
diff --git a/docs/contributing.rst b/docs/contributing.rst
new file mode 100644
index 00000000..cef6dfd2
--- /dev/null
+++ b/docs/contributing.rst
@@ -0,0 +1,55 @@
+############
+Contributing
+############
+
+Help is always appreciated!
+
+To get started, you can try :ref:`building-from-source` in order to familiarize
+yourself with the components of Solidity and the build process. Also, it may be
+useful to become well-versed at writing smart-contracts in Solidity.
+
+In particular, we need help in the following areas:
+
+* Improving the documentation
+* Responding to questions from other users on `StackExchange
+ <http://ethereum.stackexchange.com/>`_ and the `Solidity Gitter
+ <https://gitter.im/ethereum/solidity>`_
+* Fixing and responding to `Solidity's GitHub issues
+ <https://github.com/ethereum/solidity/issues>`_
+
+How to Report Issues
+====================
+
+To report an issue, please use the
+`GitHub issues tracker <https://github.com/ethereum/solidity/issues>`_. When
+reporting issues, please mention the following details:
+
+* Which version of Solidity you are using
+* Which platform are you running on
+* How to reproduce the issue
+* What was the result of the issue
+* What the expected behaviour is
+
+Workflow for Pull Requests
+==========================
+
+In order to contribute, please fork off of the ``develop`` branch and make your
+changes there. Your commit messages should detail *why* you made your change, as
+opposed to *what* you did.
+
+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.
+
+Additionally, if you are writing a new feature, please ensure you write appropriate
+Boost test cases and place them under ``test/``.
+
+However, if you are making a larger change, please consult with the Gitter
+channel, first.
+
+Finally, please make sure you respect the `coding standards
+<https://raw.githubusercontent.com/ethereum/cpp-ethereum/develop/CodingStandards.txt>`_
+for this project. Also, even though we do CI testing, please test your code and
+ensure that it builds locally before submitting a pull request.
+
+Thank you for your help!
diff --git a/docs/index.rst b/docs/index.rst
index a330172e..a5ab3f86 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -66,7 +66,7 @@ Discontinued:
Solidity Tools
--------------------------------
+--------------
* `Solidity REPL <https://github.com/raineorshine/solidity-repl>`_
Try Solidity instantly with a command-line Solidity console.
@@ -113,4 +113,5 @@ Contents
security-considerations.rst
style-guide.rst
common-patterns.rst
+ contributing.rst
frequently-asked-questions.rst
diff --git a/docs/installing-solidity.rst b/docs/installing-solidity.rst
index ba40c99f..ad27e528 100644
--- a/docs/installing-solidity.rst
+++ b/docs/installing-solidity.rst
@@ -1,3 +1,7 @@
+.. index:: ! installing
+
+.. _installing-solidity:
+
###################
Installing Solidity
###################
@@ -8,8 +12,10 @@ Browser-Solidity
If you just want to try Solidity for small contracts, you
can try `browser-solidity <https://ethereum.github.io/browser-solidity>`_
which does not need any installation. If you want to use it
-without connection to the Internet, you can also just save the page
-locally or clone http://github.com/ethereum/browser-solidity.
+without connection to the Internet, you can go to
+https://github.com/ethereum/browser-solidity/tree/gh-pages and
+download the .ZIP file as explained on that page.
+
npm / Node.js
=============
@@ -22,7 +28,7 @@ package available.
To install it, simply use
-::
+.. code:: bash
npm install solc
@@ -32,102 +38,151 @@ Details about the usage of the Node.js package can be found in the
Binary Packages
===============
-Binary packages of Solidity together with its IDE Mix are available through
-the `C++ bundle <https://github.com/ethereum/webthree-umbrella/releases>`_ of
-Ethereum.
+Binary packages of Solidity available at
+`solidity/releases <https://github.com/ethereum/solidity/releases>`_.
-Building from Source
-====================
+We also have PPAs for Ubuntu. For the latest stable version.
-Building Solidity is quite similar on MacOS X, Ubuntu and probably other Unices.
-This guide starts explaining how to install the dependencies for each platform
-and then shows how to build Solidity itself.
+.. code:: bash
-MacOS X
--------
+ sudo add-apt-repository ppa:ethereum/ethereum
+ sudo apt-get update
+ sudo apt-get install solc
+If you want to use the cutting edge developer version:
-Requirements:
+.. code:: bash
-- OS X Yosemite (10.10.5)
-- Homebrew
-- Xcode
+ sudo add-apt-repository ppa:ethereum/ethereum
+ sudo add-apt-repository ppa:ethereum/ethereum-dev
+ sudo apt-get update
+ sudo apt-get install solc
-Set up Homebrew:
+Homebrew is missing pre-built bottles at the time of writing,
+following a Jenkins to TravisCI migration, but Homebrew
+should still work just fine as a means to build-from-source.
+We will re-add the pre-built bottles soon.
-.. code-block:: bash
+.. code:: bash
brew update
brew upgrade
+ brew tap ethereum/ethereum
+ brew install solidity
+ brew linkapps solidity
+
+
+.. _building-from-source:
+
+Building from Source
+====================
+
+Clone the Repository
+--------------------
+
+To clone the source code, execute the following command:
+
+.. code:: bash
+
+ git clone --recursive https://github.com/ethereum/solidity.git
+ cd solidity
+
+If you want to help developing Solidity,
+you should fork Solidity and add your personal fork as a second remote:
+
+.. code:: bash
+
+ cd solidity
+ git remote add personal git@github.com:[username]/solidity.git
- brew install boost --c++11 # this takes a while
- brew install cmake cryptopp gmp jsoncpp
-Ubuntu Trusty (14.04)
+Prerequisites - macOS
---------------------
-Below are the instructions to install the minimal dependencies required
-to compile Solidity on Ubuntu 14.04 (Trusty Tahr).
+For macOS, ensure that you have the latest version of
+`Xcode installed <https://developer.apple.com/xcode/download/>`_.
+This contains the `Clang C++ compiler <https://en.wikipedia.org/wiki/Clang>`_, the
+`Xcode IDE <https://en.wikipedia.org/wiki/Xcode>`_ and other Apple development
+tools which are required for building C++ applications on OS X.
+If you are installing Xcode for the first time, or have just installed a new
+version then you will need to agree to the license before you can do
+command-line builds:
+
+.. code:: bash
+
+ sudo xcodebuild -license accept
+
+Our OS X builds require you to `install the Homebrew <http://brew.sh>`_
+package manager for installing external dependencies.
+Here's how to `uninstall Homebrew
+<https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/FAQ.md#how-do-i-uninstall-homebrew>`_,
+if you ever want to start again from scratch.
-.. code-block:: bash
- sudo apt-get -y install build-essential git cmake libgmp-dev libboost-all-dev \
- libjsoncpp-dev
+Prerequisites - Windows
+-----------------------
- sudo add-apt-repository -y ppa:ethereum/ethereum
- sudo add-apt-repository -y ppa:ethereum/ethereum-dev
- sudo apt-get -y update
- sudo apt-get -y upgrade # this will update cmake to version 3.x
- sudo apt-get -y install libcryptopp-dev libjsoncpp-dev
+You will need to install the following dependencies for Windows builds of Solidity:
-Ubuntu Xenial (16.04)
++------------------------------+-------------------------------------------------------+
+| Software | Notes |
++==============================+=======================================================+
+| `Git for Windows`_ | Command-line tool for retrieving source from Github. |
++------------------------------+-------------------------------------------------------+
+| `CMake`_ | Cross-platform build file generator. |
++------------------------------+-------------------------------------------------------+
+| `Visual Studio 2015`_ | C++ compiler and dev environment. |
++------------------------------+-------------------------------------------------------+
+
+.. _Git for Windows: https://git-scm.com/download/win
+.. _CMake: https://cmake.org/download/
+.. _Visual Studio 2015: https://www.visualstudio.com/products/vs-2015-product-editions
+
+
+External Dependencies
---------------------
-Below are the instructions to install the minimal dependencies required
-to compile Solidity on Ubuntu 16.04 (Xenial Xerus).
+We now have a "one button" script which installs all required external dependencies
+on macOS, Windows and on numerous Linux distros. This used to be a multi-step
+manual process, but is now a one-liner:
-One of the dependencies (Crypto++ Library, with version >= 5.6.2) can be
-installed either by adding the Ethereum PPA (Option 1) or by backporting
-``libcrypto++`` from Ubuntu Development to Ubuntu Xenial (Option 2).
+.. code:: bash
-.. code-block:: bash
+ ./scripts/install_deps.sh
- sudo apt-get -y install build-essential git cmake libgmp-dev libboost-all-dev \
- libjsoncpp-dev
+Or, on Windows:
- # (Option 1) For those willing to add the Ethereum PPA:
- sudo add-apt-repository -y ppa:ethereum/ethereum
- sudo add-apt-repository -y ppa:ethereum/ethereum-dev
- sudo apt-get -y update
- sudo apt-get -y upgrade
- sudo apt-get -y install libcryptopp-dev
+.. code:: bat
- ## (Option 2) For those willing to backport libcrypto++:
- #sudo apt-get -y install ubuntu-dev-tools
- #sudo pbuilder create
- #mkdir ubuntu
- #cd ubuntu
- #backportpackage --workdir=. --build --dont-sign libcrypto++
- #sudo dpkg -i buildresult/libcrypto++6_*.deb buildresult/libcrypto++-dev_*.deb
- #cd ..
+ scripts\install_deps.bat
-Building
---------
-Run this if you plan on installing Solidity only:
+Command-Line Build
+------------------
-.. code-block:: bash
+Building Solidity is quite similar on Linux, macOS and other Unices:
+
+.. code:: bash
- git clone --recursive https://github.com/ethereum/solidity.git
- cd solidity
mkdir build
cd build
cmake .. && make
-If you want to help developing Solidity,
-you should fork Solidity and add your personal fork as a second remote:
+And even on Windows:
-.. code-block:: bash
+.. code:: bash
- cd solidity
- git remote add personal git@github.com:username/solidity.git
+ mkdir build
+ cd build
+ cmake -G "Visual Studio 14 2015 Win64" ..
+
+This latter set of instructions should result in the creation of
+**solidity.sln** in that build directory. Double-clicking on that file
+should result in Visual Studio firing up. We suggest building
+**RelWithDebugInfo** configuration, but all others work.
+
+Alternatively, you can build for Windows on the command-line, like so:
+
+.. code:: bash
+
+ cmake --build . --config RelWithDebInfo
diff --git a/docs/introduction-to-smart-contracts.rst b/docs/introduction-to-smart-contracts.rst
index fbce4244..6fcd4854 100644
--- a/docs/introduction-to-smart-contracts.rst
+++ b/docs/introduction-to-smart-contracts.rst
@@ -220,7 +220,7 @@ only the person holding the keys to the account can transfer money from it.
Blocks
======
-One major obstacle to overcome is what, in Bitcoin terms, is called "double-spend attack":
+One major obstacle to overcome is what, in Bitcoin terms, is called a "double-spend attack":
What happens if two transactions exist in the network that both want to empty an account,
a so-called conflict?
@@ -444,13 +444,13 @@ receives the address of the new contract on the stack.
.. index:: selfdestruct
-Selfdestruct
-============
+``selfdestruct``
+================
The only possibility that code is removed from the blockchain is
-when a contract at that address performs the ``SELFDESTRUCT`` operation.
+when a contract at that address performs the ``selfdestruct`` operation.
The remaining Ether stored at that address is sent to a designated
target and then the storage and code is removed.
-Note that even if a contract's code does not contain the ``SELFDESTRUCT``
-opcode, it can still perform that operation using delegatecall or callcode.
+Note that even if a contract's code does not contain a call to ``selfdestruct``,
+it can still perform that operation using ``delegatecall`` or ``callcode``.
diff --git a/docs/security-considerations.rst b/docs/security-considerations.rst
index f8d099e4..7e846674 100644
--- a/docs/security-considerations.rst
+++ b/docs/security-considerations.rst
@@ -103,7 +103,9 @@ and stall those. Please be explicit about such cases in the documentation of you
Sending and Receiving Ether
===========================
-- If a contract receives Ether (without a function being called), the fallback function is executed. The contract can only rely
+- If a contract receives Ether (without a function being called), the fallback function is executed.
+ If it does not have a fallback function, the Ether will be rejected (by throwing an exception).
+ During the execution of the fallback function, the contract can only rely
on the "gas stipend" (2300 gas) being available to it at that time. This stipend is not enough to access storage in any way.
To be sure that your contract can receive Ether in that way, check the gas requirements of the fallback function
(for example in the "details" section in browser-solidity).
diff --git a/docs/types.rst b/docs/types.rst
index d6445ed9..737fbe7d 100644
--- a/docs/types.rst
+++ b/docs/types.rst
@@ -661,13 +661,18 @@ Explicit Conversions
--------------------
If the compiler does not allow implicit conversion but you know what you are
-doing, an explicit type conversion is sometimes possible::
+doing, an explicit type conversion is sometimes possible. Note that this may
+give you some unexpected behaviour so be sure to test to ensure that the
+result is what you want! Take the following example where you are converting
+a negative ``int8`` to a ``uint``:
+
+::
int8 y = -3;
uint x = uint(y);
At the end of this code snippet, ``x`` will have the value ``0xfffff..fd`` (64 hex
-characters), which is -3 in two's complement representation of 256 bits.
+characters), which is -3 in the two's complement representation of 256 bits.
If a type is explicitly converted to a smaller type, higher-order bits are
cut off::
diff --git a/docs/units-and-global-variables.rst b/docs/units-and-global-variables.rst
index d1d578ed..9ee334cf 100644
--- a/docs/units-and-global-variables.rst
+++ b/docs/units-and-global-variables.rst
@@ -18,7 +18,7 @@ Suffixes like ``seconds``, ``minutes``, ``hours``, ``days``, ``weeks`` and
``years`` after literal numbers can be used to convert between units of time where seconds are the base
unit and units are considered naively in the following way:
- * ``1 == 1 second``
+ * ``1 == 1 seconds``
* ``1 minutes == 60 seconds``
* ``1 hours == 60 minutes``
* ``1 days == 24 hours``
@@ -109,6 +109,10 @@ This means that the following are all identical::
If padding is needed, explicit type conversions can be used: ``sha3("\x00\x12")`` is the
same as ``sha3(uint16(0x12))``.
+Note that constants will be packed using the minimum number of bytes required to store them.
+This means that, for example, ``sha3(0) == sha3(uint8(0))`` and
+``sha3(0x12345678) == sha3(uint32(0x12345678))``.
+
It might be that you run into Out-of-Gas for ``sha256``, ``ripemd160`` or ``ecrecover`` on a *private blockchain*. The reason for this is that those are implemented as so-called precompiled contracts and these contracts only really exist after they received the first message (although their contract code is hardcoded). Messages to non-existing contracts are more expensive and thus the execution runs into an Out-of-Gas error. A workaround for this problem is to first send e.g. 1 Wei to each of the contracts before you use them in your actual contracts. This is not an issue on the official or test net.
.. _address_related:
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 235fcabd..bc03da01 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -92,6 +92,8 @@ bool TypeChecker::visit(ContractDefinition const& _contract)
else
{
fallbackFunction = function;
+ if (_contract.isLibrary())
+ typeError(fallbackFunction->location(), "Libraries cannot have fallback functions.");
if (!fallbackFunction->parameters().empty())
typeError(fallbackFunction->parameterList().location(), "Fallback function cannot take parameters.");
if (!fallbackFunction->returnParameters().empty())
diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp
index 715852be..9d77ccdc 100644
--- a/libsolidity/codegen/ContractCompiler.cpp
+++ b/libsolidity/codegen/ContractCompiler.cpp
@@ -247,11 +247,8 @@ void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contrac
m_context << returnTag;
appendReturnValuePacker(FunctionType(*fallback).returnParameterTypes(), _contract.isLibrary());
}
- else if (_contract.isLibrary())
- // Reject invalid library calls and ether sent to a library.
- m_context.appendJumpTo(m_context.errorTag());
else
- m_context << Instruction::STOP; // function not found
+ m_context.appendJumpTo(m_context.errorTag());
for (auto const& it: interfaceFunctions)
{
diff --git a/libsolidity/interface/InterfaceHandler.cpp b/libsolidity/interface/InterfaceHandler.cpp
index f5c10356..5d24e1bf 100644
--- a/libsolidity/interface/InterfaceHandler.cpp
+++ b/libsolidity/interface/InterfaceHandler.cpp
@@ -74,7 +74,15 @@ string InterfaceHandler::abiInterface(ContractDefinition const& _contractDef)
);
abi.append(method);
}
-
+ if (_contractDef.fallbackFunction())
+ {
+ auto externalFunctionType = FunctionType(*_contractDef.fallbackFunction()).interfaceFunctionType();
+ solAssert(!!externalFunctionType, "");
+ Json::Value method;
+ method["type"] = "fallback";
+ method["constant"] = externalFunctionType->isConstant();
+ abi.append(method);
+ }
for (auto const& it: _contractDef.interfaceEvents())
{
Json::Value event;
diff --git a/libsolidity/interface/Version.cpp b/libsolidity/interface/Version.cpp
index a846efea..31ba4afc 100644
--- a/libsolidity/interface/Version.cpp
+++ b/libsolidity/interface/Version.cpp
@@ -35,10 +35,8 @@ char const* dev::solidity::VersionNumber = ETH_PROJECT_VERSION;
string const dev::solidity::VersionString =
string(dev::solidity::VersionNumber) +
- "-" +
- string(DEV_QUOTED(ETH_COMMIT_HASH)).substr(0, 8) +
- (ETH_CLEAN_REPO ? "" : "*") +
- "/" DEV_QUOTED(ETH_BUILD_TYPE) "-" DEV_QUOTED(ETH_BUILD_PLATFORM);
+ (string(SOL_VERSION_PRERELEASE).empty() ? "" : "-" + string(SOL_VERSION_PRERELEASE)) +
+ (string(SOL_VERSION_BUILDINFO).empty() ? "" : "+" + string(SOL_VERSION_BUILDINFO));
bytes dev::solidity::binaryVersion()
diff --git a/lllc/main.cpp b/lllc/main.cpp
index a4c92d67..06611af0 100644
--- a/lllc/main.cpp
+++ b/lllc/main.cpp
@@ -22,6 +22,7 @@
#include <fstream>
#include <iostream>
+#include <clocale>
#include <liblll/Compiler.h>
#include <libdevcore/CommonIO.h>
#include <libdevcore/CommonData.h>
@@ -52,10 +53,34 @@ void version()
exit(0);
}
+/*
+The equivalent of setlocale(LC_ALL, "C") is called before any user code is run.
+If the user has an invalid environment setting then it is possible for the call
+to set locale to fail, so there are only two possible actions, the first is to
+throw a runtime exception and cause the program to quit (default behaviour),
+or the second is to modify the environment to something sensible (least
+surprising behaviour).
+
+The follow code produces the least surprising behaviour. It will use the user
+specified default locale if it is valid, and if not then it will modify the
+environment the process is running in to use a sensible default. This also means
+that users do not need to install language packs for their OS.
+*/
+void setDefaultOrCLocale()
+{
+#if __unix__
+ if (!std::setlocale(LC_ALL, ""))
+ {
+ setenv("LC_ALL", "C", 1);
+ }
+#endif
+}
+
enum Mode { Binary, Hex, Assembly, ParseTree, Disassemble };
int main(int argc, char** argv)
{
+ setDefaultOrCLocale();
unsigned optimise = 1;
string infile;
Mode mode = Hex;
diff --git a/scripts/build_emscripten.sh b/scripts/build_emscripten.sh
index 6046978e..da2c7df3 100755
--- a/scripts/build_emscripten.sh
+++ b/scripts/build_emscripten.sh
@@ -29,6 +29,7 @@
set -e
if [[ "$OSTYPE" != "darwin"* ]]; then
+ date -u +"nightly.%Y.%m.%d" > prerelease.txt
./scripts/travis-emscripten/install_deps.sh
docker run -v $(pwd):/src trzeci/emscripten:sdk-tag-1.35.4-64bit ./scripts/travis-emscripten/build_emscripten.sh
fi
diff --git a/scripts/install_deps.bat b/scripts/install_deps.bat
index 512a28df..bd68b07a 100644
--- a/scripts/install_deps.bat
+++ b/scripts/install_deps.bat
@@ -59,3 +59,4 @@ REM Copyright (c) 2016 solidity contributors.
REM ---------------------------------------------------------------------------
cmake -P deps\install_deps.cmake
+cmake -P scripts\install_eth.cmake
diff --git a/scripts/install_deps.sh b/scripts/install_deps.sh
index 4fb948ed..a67fea82 100755
--- a/scripts/install_deps.sh
+++ b/scripts/install_deps.sh
@@ -98,7 +98,7 @@ case $(uname -s) in
brew update
brew upgrade
-
+
brew install boost
brew install cmake
brew install jsoncpp
@@ -127,14 +127,14 @@ case $(uname -s) in
#------------------------------------------------------------------------------
# Linux
#------------------------------------------------------------------------------
-
+
Linux)
case $(detect_linux_distro) in
#------------------------------------------------------------------------------
# Arch Linux
#------------------------------------------------------------------------------
-
+
Arch)
#Arch
echo "Installing solidity dependencies on Arch Linux."
@@ -143,7 +143,7 @@ case $(uname -s) in
# See https://wiki.archlinux.org/index.php/Official_repositories
sudo pacman -Sy \
base-devel \
- boost \
+ boost \
cmake \
git \
;;
@@ -158,7 +158,7 @@ case $(uname -s) in
# All our dependencies can be found in the Alpine Linux official repositories.
# See https://pkgs.alpinelinux.org/
-
+
apk update
apk add boost-dev build-base cmake jsoncpp-dev
@@ -231,7 +231,7 @@ case $(uname -s) in
# Install "normal packages"
# See https://fedoraproject.org/wiki/Package_management_system.
dnf install \
- autoconf \
+ autoconf \
automake \
boost-devel \
cmake \
@@ -326,16 +326,6 @@ case $(uname -s) in
sudo apt-get -y update
sudo apt-get -y install eth
- # And install the English language package and reconfigure the locales.
- # We really shouldn't need to do this, and should instead force our locales to "C"
- # within our application runtimes, because this issue shows up on multiple Linux distros,
- # and each will need fixing in the install steps, where we should really just fix it once
- # in the code.
- #
- # See https://github.com/ethereum/webthree-umbrella/issues/169
- sudo apt-get -y install language-pack-en-base
- sudo dpkg-reconfigure locales
-
;;
*)
diff --git a/scripts/install_eth.cmake b/scripts/install_eth.cmake
new file mode 100644
index 00000000..25f449e0
--- /dev/null
+++ b/scripts/install_eth.cmake
@@ -0,0 +1,76 @@
+#------------------------------------------------------------------------------
+# Cmake script for installing pre-requisite package eth for solidity.
+#
+# The aim of this script is to simply download and unpack eth binaries to the deps folder.
+#
+# The documentation for solidity is hosted at:
+#
+# http://solidity.readthedocs.io/
+#
+# ------------------------------------------------------------------------------
+# 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 <http://www.gnu.org/licenses/>
+#
+# (c) 2016 solidity contributors.
+#------------------------------------------------------------------------------
+
+function(download URL DST_FILE STATUS)
+ set(TMP_FILE "${DST_FILE}.part")
+
+ get_filename_component(FILE_NAME ${DST_FILE} NAME)
+ if (NOT EXISTS ${DST_FILE})
+ message("Downloading ${FILE_NAME}")
+ file(DOWNLOAD ${URL} ${TMP_FILE} SHOW_PROGRESS STATUS DOWNLOAD_STATUS)
+ list(GET DOWNLOAD_STATUS 0 STATUS_CODE)
+ if (STATUS_CODE EQUAL 0)
+ file(RENAME ${TMP_FILE} ${DST_FILE})
+ else()
+ file(REMOVE ${TMP_FILE})
+ list(GET DOWNLOAD_STATUS 1 ERROR_MSG)
+
+ message("ERROR! Downloading '${FILE_NAME}' failed.")
+ message(STATUS "URL: ${URL}")
+ message(STATUS "Error: ${STATUS_CODE} ${ERROR_MSG}")
+ set(STATUS FALSE PARENT_SCOPE)
+ return()
+ endif()
+ else()
+ message("Using cached ${FILE_NAME}")
+ endif()
+ set(STATUS TRUE PARENT_SCOPE)
+endfunction(download)
+
+function(download_and_unpack PACKAGE_URL DST_DIR)
+ get_filename_component(FILE_NAME ${PACKAGE_URL} NAME)
+
+ set(DST_FILE "${CACHE_DIR}/${FILE_NAME}")
+ set(TMP_FILE "${DST_FILE}.part")
+
+ file(MAKE_DIRECTORY ${CACHE_DIR})
+ file(MAKE_DIRECTORY ${DST_DIR})
+
+ download(${PACKAGE_URL} ${DST_FILE} STATUS)
+
+ if (STATUS)
+ message("Unpacking ${FILE_NAME} to ${DST_DIR}")
+ execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xf ${DST_FILE}
+ WORKING_DIRECTORY ${DST_DIR})
+ endif()
+endfunction(download_and_unpack)
+
+get_filename_component(ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
+set(CACHE_DIR "${ROOT_DIR}/deps/cache")
+set(INSTALL_DIR "${ROOT_DIR}/deps/install/x64/eth")
+download_and_unpack("https://github.com/bobsummerwill/cpp-ethereum/releases/download/develop-v1.3.0.401/cpp-ethereum-develop-windows.zip" ${INSTALL_DIR})
diff --git a/scripts/release_ppa.sh b/scripts/release_ppa.sh
index 2fd286fd..8e9dc282 100755
--- a/scripts/release_ppa.sh
+++ b/scripts/release_ppa.sh
@@ -56,13 +56,13 @@ commithash=`git rev-parse --short HEAD`
committimestamp=`git show --format=%ci HEAD | head -n 1`
commitdate=`git show --format=%ci HEAD | head -n 1 | cut - -b1-10`
-# TODO store the commit hash in a file so that the build info mechanism can pick it up even without git
-
+echo "$commithash" > commit_hash.txt
if [ $branch = develop ]
then
debversion="$version-nightly-$commitdate-$commithash"
else
debversion="$version"
+ echo -n > prerelease.txt # proper release
fi
# gzip will create different tars all the time and we are not allowed
diff --git a/scripts/tests.sh b/scripts/tests.sh
index f3bcf65f..93afd2d2 100755
--- a/scripts/tests.sh
+++ b/scripts/tests.sh
@@ -53,7 +53,7 @@ $ETH_PATH --test -d /tmp/test &
while [ ! -S /tmp/test/geth.ipc ]; do sleep 2; done
# And then run the Solidity unit-tests, pointing to that IPC endpoint.
-"$REPO_ROOT"/build/test/soltest -- --ipc /tmp/test/geth.ipc
+"$REPO_ROOT"/build/test/soltest -- --ipcpath /tmp/test/geth.ipc
ERROR_CODE=$?
pkill eth || true
sleep 4
diff --git a/solc/main.cpp b/solc/main.cpp
index eaada1c4..26010716 100644
--- a/solc/main.cpp
+++ b/solc/main.cpp
@@ -21,13 +21,38 @@
*/
#include "CommandLineInterface.h"
+#include <clocale>
#include <iostream>
#include <boost/exception/all.hpp>
using namespace std;
+/*
+The equivalent of setlocale(LC_ALL, "C") is called before any user code is run.
+If the user has an invalid environment setting then it is possible for the call
+to set locale to fail, so there are only two possible actions, the first is to
+throw a runtime exception and cause the program to quit (default behaviour),
+or the second is to modify the environment to something sensible (least
+surprising behaviour).
+
+The follow code produces the least surprising behaviour. It will use the user
+specified default locale if it is valid, and if not then it will modify the
+environment the process is running in to use a sensible default. This also means
+that users do not need to install language packs for their OS.
+*/
+void setDefaultOrCLocale()
+{
+#if __unix__
+ if (!std::setlocale(LC_ALL, ""))
+ {
+ setenv("LC_ALL", "C", 1);
+ }
+#endif
+}
+
int main(int argc, char** argv)
{
+ setDefaultOrCLocale();
dev::solidity::CommandLineInterface cli;
if (!cli.parseArguments(argc, argv))
return 1;
diff --git a/test/RPCSession.cpp b/test/RPCSession.cpp
index de10b381..0a01ddb2 100644
--- a/test/RPCSession.cpp
+++ b/test/RPCSession.cpp
@@ -46,7 +46,7 @@ IPCSocket::IPCSocket(string const& _path): m_path(_path)
NULL); // no template file
if (m_socket == INVALID_HANDLE_VALUE)
- BOOST_FAIL("Error creating IPC socket object");
+ BOOST_FAIL("Error creating IPC socket object!");
#else
if (_path.length() >= sizeof(sockaddr_un::sun_path))
@@ -251,7 +251,7 @@ void RPCSession::test_mineBlocks(int _number)
unsigned sleepTime = m_sleepTime;
size_t polls = 0;
- for (; polls < 10 && !mined; ++polls)
+ for (; polls < 14 && !mined; ++polls)
{
std::this_thread::sleep_for(chrono::milliseconds(sleepTime));
if (fromBigEndian<u256>(fromHex(rpcCall("eth_blockNumber").asString())) >= startBlock + _number)
@@ -270,7 +270,8 @@ void RPCSession::test_mineBlocks(int _number)
if (m_successfulMineRuns > 5)
{
m_successfulMineRuns = 0;
- m_sleepTime--;
+ if (m_sleepTime > 2)
+ m_sleepTime--;
}
}
diff --git a/test/TestHelper.cpp b/test/TestHelper.cpp
index bfc5b54c..df35ff53 100644
--- a/test/TestHelper.cpp
+++ b/test/TestHelper.cpp
@@ -34,7 +34,7 @@ Options::Options()
{
auto const& suite = boost::unit_test::framework::master_test_suite();
for (auto i = 0; i < suite.argc; i++)
- if (string(suite.argv[i]) == "--ipc" && i + 1 < suite.argc)
+ if (string(suite.argv[i]) == "--ipcpath" && i + 1 < suite.argc)
{
ipcPath = suite.argv[i + 1];
i++;
diff --git a/test/libsolidity/Assembly.cpp b/test/libsolidity/Assembly.cpp
index 557d496a..81332f4f 100644
--- a/test/libsolidity/Assembly.cpp
+++ b/test/libsolidity/Assembly.cpp
@@ -114,7 +114,7 @@ BOOST_AUTO_TEST_CASE(location_test)
shared_ptr<string const> n = make_shared<string>("source");
AssemblyItems items = compileContract(sourceCode);
vector<SourceLocation> locations =
- vector<SourceLocation>(17, SourceLocation(2, 75, n)) +
+ vector<SourceLocation>(18, SourceLocation(2, 75, n)) +
vector<SourceLocation>(28, SourceLocation(20, 72, n)) +
vector<SourceLocation>{SourceLocation(42, 51, n), SourceLocation(65, 67, n)} +
vector<SourceLocation>(4, SourceLocation(58, 67, n)) +
diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp
index b21e03eb..cfc7b9bd 100644
--- a/test/libsolidity/SolidityABIJSON.cpp
+++ b/test/libsolidity/SolidityABIJSON.cpp
@@ -273,15 +273,6 @@ BOOST_AUTO_TEST_CASE(const_function)
checkInterface(sourceCode, interface);
}
-BOOST_AUTO_TEST_CASE(exclude_fallback_function)
-{
- char const* sourceCode = "contract test { function() {} }";
-
- char const* interface = "[]";
-
- checkInterface(sourceCode, interface);
-}
-
BOOST_AUTO_TEST_CASE(events)
{
char const* sourceCode = "contract test {\n"
@@ -626,6 +617,25 @@ BOOST_AUTO_TEST_CASE(library_function)
checkInterface(sourceCode, interface);
}
+BOOST_AUTO_TEST_CASE(include_fallback_function)
+{
+ char const* sourceCode = R"(
+ contract test {
+ function() {}
+ }
+ )";
+
+ char const* interface = R"(
+ [
+ {
+ "constant" : false,
+ "type" : "fallback"
+ }
+ ]
+ )";
+ checkInterface(sourceCode, interface);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 8f645170..35b7078d 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -2053,6 +2053,7 @@ BOOST_AUTO_TEST_CASE(contracts_as_addresses)
{
char const* sourceCode = R"(
contract helper {
+ function() { } // can receive ether
}
contract test {
helper h;
@@ -2540,6 +2541,19 @@ BOOST_AUTO_TEST_CASE(inherited_fallback_function)
BOOST_CHECK(callContractFunction("getData()") == encodeArgs(1));
}
+BOOST_AUTO_TEST_CASE(default_fallback_throws)
+{
+ char const* sourceCode = R"(
+ contract A {
+ function f() returns (bool) {
+ return this.call();
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ BOOST_CHECK(callContractFunction("f()") == encodeArgs(0));
+}
+
BOOST_AUTO_TEST_CASE(event)
{
char const* sourceCode = R"(
@@ -5944,6 +5958,7 @@ BOOST_AUTO_TEST_CASE(reject_ether_sent_to_library)
function f(address x) returns (bool) {
return x.send(1);
}
+ function () {}
}
)";
compileAndRun(sourceCode, 0, "lib");
diff --git a/test/libsolidity/SolidityExecutionFramework.cpp b/test/libsolidity/SolidityExecutionFramework.cpp
index d0ee13c6..02548121 100644
--- a/test/libsolidity/SolidityExecutionFramework.cpp
+++ b/test/libsolidity/SolidityExecutionFramework.cpp
@@ -39,7 +39,7 @@ string getIPCSocketPath()
{
string ipcPath = dev::test::Options::get().ipcPath;
if (ipcPath.empty())
- BOOST_FAIL("ERROR: ipcPath not set! (use --ipc <path> or the environment variable ETH_TEST_IPC)");
+ BOOST_FAIL("ERROR: ipcPath not set! (use --ipcpath <path> or the environment variable ETH_TEST_IPC)");
return ipcPath;
}
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index f0ab07c5..fdd8d7f4 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -1102,6 +1102,16 @@ BOOST_AUTO_TEST_CASE(fallback_function_with_arguments)
BOOST_CHECK(expectError(text) == Error::Type::TypeError);
}
+BOOST_AUTO_TEST_CASE(fallback_function_in_library)
+{
+ char const* text = R"(
+ library C {
+ function() {}
+ }
+ )";
+ BOOST_CHECK(expectError(text) == Error::Type::TypeError);
+}
+
BOOST_AUTO_TEST_CASE(fallback_function_with_return_parameters)
{
char const* text = R"(