aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Changelog.md9
-rw-r--r--docs/_static/theme_overrides.css13
-rw-r--r--docs/abi-spec.rst4
-rw-r--r--docs/assembly.rst28
-rw-r--r--docs/common-patterns.rst8
-rw-r--r--docs/conf.py13
-rw-r--r--docs/contracts.rst46
-rw-r--r--docs/contributing.rst1
-rw-r--r--docs/control-structures.rst4
-rw-r--r--docs/docs-css/custom.css14
-rw-r--r--docs/frequently-asked-questions.rst13
-rw-r--r--docs/grammar.txt7
-rw-r--r--docs/introduction-to-smart-contracts.rst4
-rw-r--r--docs/miscellaneous.rst7
-rw-r--r--docs/security-considerations.rst11
-rw-r--r--docs/style-guide.rst84
-rw-r--r--docs/types.rst33
-rw-r--r--libevmasm/KnownState.cpp21
-rw-r--r--libsolc/CMakeLists.txt2
-rw-r--r--libsolc/libsolc.cpp15
-rw-r--r--libsolc/libsolc.h4
-rw-r--r--libsolidity/analysis/StaticAnalyzer.cpp40
-rw-r--r--libsolidity/analysis/SyntaxChecker.cpp7
-rw-r--r--libsolidity/analysis/TypeChecker.cpp36
-rw-r--r--libsolidity/analysis/ViewPureChecker.cpp38
-rw-r--r--libsolidity/analysis/ViewPureChecker.h1
-rw-r--r--libsolidity/codegen/CompilerUtils.cpp80
-rw-r--r--libsolidity/codegen/CompilerUtils.h2
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp2
-rw-r--r--libsolidity/parsing/Parser.cpp11
-rw-r--r--scripts/bytecodecompare/storebytecode.bat1
-rwxr-xr-xscripts/tests.sh21
-rw-r--r--test/ExecutionFramework.cpp5
-rw-r--r--test/ExecutionFramework.h2
-rw-r--r--test/RPCSession.cpp12
-rw-r--r--test/RPCSession.h3
-rw-r--r--test/compilationTests/MultiSigWallet/Factory.sol2
-rw-r--r--test/compilationTests/MultiSigWallet/MultiSigWallet.sol12
-rw-r--r--test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol2
-rw-r--r--test/compilationTests/MultiSigWallet/TestToken.sol4
-rw-r--r--test/compilationTests/corion/ico.sol8
-rw-r--r--test/compilationTests/corion/module.sol4
-rw-r--r--test/compilationTests/corion/moduleHandler.sol18
-rw-r--r--test/compilationTests/corion/multiOwner.sol6
-rw-r--r--test/compilationTests/corion/premium.sol6
-rw-r--r--test/compilationTests/corion/provider.sol12
-rw-r--r--test/compilationTests/corion/publisher.sol4
-rw-r--r--test/compilationTests/corion/schelling.sol24
-rw-r--r--test/compilationTests/corion/token.sol8
-rw-r--r--test/compilationTests/corion/tokenDB.sol2
-rw-r--r--test/compilationTests/gnosis/Events/CategoricalEvent.sol2
-rw-r--r--test/compilationTests/gnosis/Events/Event.sol8
-rw-r--r--test/compilationTests/gnosis/Events/ScalarEvent.sol2
-rw-r--r--test/compilationTests/gnosis/MarketMakers/LMSRMarketMaker.sol12
-rw-r--r--test/compilationTests/gnosis/MarketMakers/MarketMaker.sol6
-rw-r--r--test/compilationTests/gnosis/Markets/Market.sol2
-rw-r--r--test/compilationTests/gnosis/Markets/StandardMarket.sol2
-rw-r--r--test/compilationTests/gnosis/Oracles/CentralizedOracle.sol4
-rw-r--r--test/compilationTests/gnosis/Oracles/DifficultyOracle.sol4
-rw-r--r--test/compilationTests/gnosis/Oracles/FutarchyOracle.sol4
-rw-r--r--test/compilationTests/gnosis/Oracles/MajorityOracle.sol5
-rw-r--r--test/compilationTests/gnosis/Oracles/Oracle.sol4
-rw-r--r--test/compilationTests/gnosis/Oracles/SignedMessageOracle.sol4
-rw-r--r--test/compilationTests/gnosis/Oracles/UltimateOracle.sol7
-rw-r--r--test/compilationTests/gnosis/Tokens/StandardToken.sol6
-rw-r--r--test/compilationTests/gnosis/Tokens/Token.sol6
-rw-r--r--test/compilationTests/gnosis/Utils/Math.sol32
-rw-r--r--test/compilationTests/milestonetracker/MilestoneTracker.sol2
-rw-r--r--test/compilationTests/milestonetracker/RLP.sol52
-rw-r--r--test/compilationTests/zeppelin/DayLimit.sol2
-rw-r--r--test/compilationTests/zeppelin/crowdsale/CappedCrowdsale.sol4
-rw-r--r--test/compilationTests/zeppelin/crowdsale/Crowdsale.sol4
-rw-r--r--test/compilationTests/zeppelin/crowdsale/RefundableCrowdsale.sol2
-rw-r--r--test/compilationTests/zeppelin/math/Math.sol8
-rw-r--r--test/compilationTests/zeppelin/math/SafeMath.sol8
-rw-r--r--test/compilationTests/zeppelin/ownership/Shareable.sol6
-rw-r--r--test/compilationTests/zeppelin/token/BasicToken.sol2
-rw-r--r--test/compilationTests/zeppelin/token/ERC20.sol2
-rw-r--r--test/compilationTests/zeppelin/token/ERC20Basic.sol2
-rw-r--r--test/compilationTests/zeppelin/token/LimitedTransferToken.sol4
-rw-r--r--test/compilationTests/zeppelin/token/StandardToken.sol2
-rw-r--r--test/compilationTests/zeppelin/token/VestedToken.sol14
-rw-r--r--test/contracts/AuctionRegistrar.cpp33
-rw-r--r--test/contracts/FixedFeeRegistrar.cpp21
-rw-r--r--test/contracts/LLL_ENS.cpp1
-rw-r--r--test/contracts/LLL_ERC20.cpp5
-rw-r--r--test/contracts/Wallet.cpp11
-rw-r--r--test/liblll/EndToEndTest.cpp3
-rw-r--r--test/libsolidity/ABIDecoderTests.cpp38
-rw-r--r--test/libsolidity/ASTJSON.cpp4
-rw-r--r--test/libsolidity/ASTLegacyJSON.cpp12
-rw-r--r--test/libsolidity/Assembly.cpp16
-rw-r--r--test/libsolidity/GasMeter.cpp3
-rw-r--r--test/libsolidity/LibSolc.cpp (renamed from test/libsolidity/JSONCompiler.cpp)24
-rw-r--r--test/libsolidity/SolidityABIJSON.cpp90
-rw-r--r--test/libsolidity/SolidityCompiler.cpp2
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp1728
-rw-r--r--test/libsolidity/SolidityExpressionCompiler.cpp49
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp12
-rw-r--r--test/libsolidity/SolidityNatspecJSON.cpp58
-rw-r--r--test/libsolidity/SolidityOptimizer.cpp42
-rw-r--r--test/libsolidity/SolidityParser.cpp16
-rw-r--r--test/libsolidity/StandardCompiler.cpp8
-rw-r--r--test/libsolidity/ViewPureChecker.cpp11
-rw-r--r--test/libsolidity/syntaxTests/constants/assign_constant_function_value.sol2
-rw-r--r--test/libsolidity/syntaxTests/constructor/constructor_no_visibility.sol2
-rw-r--r--test/libsolidity/syntaxTests/constructor/constructor_state_mutability_new.sol10
-rw-r--r--test/libsolidity/syntaxTests/constructor/constructor_state_mutability_old.sol17
-rw-r--r--test/libsolidity/syntaxTests/fallback/default_visibility.sol2
-rw-r--r--test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol2
-rw-r--r--test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol2
-rw-r--r--test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol2
-rw-r--r--test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol4
-rw-r--r--test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol2
-rw-r--r--test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol2
-rw-r--r--test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/040_functions_with_different_structs_in_interface.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/124_enum_member_access.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/165_assigning_state_to_const_variable.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/239_multi_variable_declaration_wildcards_fine.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/268_function_overload_array_type.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/275_inline_struct_declaration_arrays.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/403_return_structs.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/423_using_interface.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/498_msg_gas_deprecated.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/499_msg_gas_deprecated_v050.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/569_block_blockhash_deprecated.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/570_block_blockhash_deprecated_v050.sol6
-rw-r--r--test/libsolidity/syntaxTests/parsing/calling_function.sol4
-rw-r--r--test/libsolidity/syntaxTests/parsing/conditional_multiple.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/conditional_true_false_literal.sol9
-rw-r--r--test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol9
-rw-r--r--test/libsolidity/syntaxTests/parsing/conditional_with_variables.sol9
-rw-r--r--test/libsolidity/syntaxTests/parsing/constant_state_modifier.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol9
-rw-r--r--test/libsolidity/syntaxTests/parsing/else_if_statement.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/empty_function.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol4
-rw-r--r--test/libsolidity/syntaxTests/parsing/exp_expression.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/for_loop_simple_noexpr.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/for_loop_single_stmt_body.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/for_loop_vardef_initexpr.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/function_no_body.sol4
-rw-r--r--test/libsolidity/syntaxTests/parsing/function_normal_comments.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol14
-rw-r--r--test/libsolidity/syntaxTests/parsing/if_statement.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/interface_basic.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/library_simple.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol4
-rw-r--r--test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol11
-rw-r--r--test/libsolidity/syntaxTests/parsing/modifier_invocation.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol34
-rw-r--r--test/libsolidity/syntaxTests/parsing/no_function_params.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/overloaded_functions.sol10
-rw-r--r--test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/single_function_param.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/tuples.sol15
-rw-r--r--test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol11
-rw-r--r--test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol4
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol (renamed from test/libsolidity/syntaxTests/viewPureChecker/assembly_jump.sol)0
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol8
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_restrict_warning.sol21
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_view_fail.sol23
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/call_internal_functions_fail.sol9
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/constant_restrict_warning.sol12
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/creation_no_restrict_warning.sol (renamed from test/libsolidity/syntaxTests/viewPureChecker/creation.sol)0
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/creation_view_fail.sol6
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/function_types_fail.sol18
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/local_storage_variables_fail.sol15
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/modifiers_fail.sol12
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/overriding_fail.sol16
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/overriding_no_restrict_warning.sol (renamed from test/libsolidity/syntaxTests/viewPureChecker/overriding.sol)0
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/read_storage_pure_fail.sol8
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/returning_structs_fail.sol13
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/returning_structs_no_restrict_warning.sol (renamed from test/libsolidity/syntaxTests/viewPureChecker/returning_structs.sol)0
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/selector.sol4
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/write_storage_fail.sol2
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/write_storage_fail_v050.sol7
-rw-r--r--test/libsolidity/syntaxTests/visibility/function_no_visibility.sol (renamed from test/libsolidity/syntaxTests/nameAndTypeResolution/566_require_visibility_specifiers.sol)2
-rw-r--r--test/libsolidity/syntaxTests/visibility/function_no_visibility_050.sol6
185 files changed, 1841 insertions, 1859 deletions
diff --git a/Changelog.md b/Changelog.md
index b1f742bf..8cd0b4b7 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -8,12 +8,14 @@ How to update your code:
Breaking Changes:
* ABI Encoder: Properly pad data from calldata (``msg.data`` and external function parameters). Use ``abi.encodePacked`` for unpadded encoding.
* Code Generator: Signed right shift uses proper arithmetic shift, i.e. rounding towards negative infinity. Warning: this may silently change the semantics of existing code!
+ * Code Generator: Revert at runtime if calldata is too short or points out of bounds. This is done inside the ``ABI decoder`` and therefore also applies to ``abi.decode()``.
* Commandline interface: Remove obsolete ``--formal`` option.
* Commandline interface: Rename the ``--julia`` option to ``--yul``.
* Commandline interface: Require ``-`` if standard input is used as source.
* General: ``continue`` in a ``do...while`` loop jumps to the condition (it used to jump to the loop body). Warning: this may silently change the semantics of existing code.
* General: Disallow declaring empty structs.
* General: Disallow raw ``callcode`` (was already deprecated in 0.4.12). It is still possible to use it via inline assembly.
+ * General: Disallow ``var`` keyword.
* General: Disallow ``sha3`` and ``suicide`` aliases.
* General: Disallow the ``years`` unit denomination (was already deprecated in 0.4.24)
* General: Introduce ``emit`` as a keyword instead of parsing it as identifier.
@@ -25,11 +27,15 @@ Breaking Changes:
* General: C99-style scoping rules are enforced now. This was already the case in the experimental 0.5.0 mode.
* Optimizer: Remove the no-op ``PUSH1 0 NOT AND`` sequence.
* Parser: Disallow trailing dots that are not followed by a number.
+ * Parser: Remove ``constant`` as function state mutability modifer.
+ * Type Checker: Disallow values for constants that are not compile-time constants. This was already the case in the experimental 0.5.0 mode.
* Type Checker: Disallow arithmetic operations for boolean variables.
* Type Checker: Disallow conversions between ``bytesX`` and ``uintY`` of different size.
+ * Type Checker: Disallow specifying base constructor arguments multiple times in the same inheritance hierarchy. This was already the case in the experimental 0.5.0 mode.
* Type Checker: Only accept a single ``bytes`` type for ``.call()`` (and family), ``keccak256()``, ``sha256()`` and ``ripemd160()``.
* Remove obsolete ``std`` directory from the Solidity repository. This means accessing ``https://github.com/ethereum/soldity/blob/develop/std/*.sol`` (or ``https://github.com/ethereum/solidity/std/*.sol`` in Remix) will not be possible.
* Syntax Checker: Named return values in function types are an error.
+ * View Pure Checker: Strictly enfore state mutability. This was already the case in the experimental 0.5.0 mode.
Language Features:
* General: Allow appending ``calldata`` keyword to types, to explicitly specify data location for arguments of external functions.
@@ -37,10 +43,13 @@ Language Features:
* General: Scoping rules now follow the C99-style.
Compiler Features:
+ * C API (``libsolc``): Export the ``solidity_license``, ``solidity_version`` and ``solidity_compile`` methods.
* Type Checker: Show named argument in case of error.
+ * Tests: Determine transaction status during IPC calls.
Bugfixes:
* Tests: Fix chain parameters to make ipc tests work with newer versions of cpp-ethereum.
+ * Code Generator: Fix allocation of byte arrays (zeroed out too much memory).
### 0.4.24 (2018-05-16)
diff --git a/docs/_static/theme_overrides.css b/docs/_static/theme_overrides.css
deleted file mode 100644
index d750f4f1..00000000
--- a/docs/_static/theme_overrides.css
+++ /dev/null
@@ -1,13 +0,0 @@
-/* override table width restrictions */
-@media screen and (min-width: 767px) {
-
- .wy-table-responsive table td {
- /* !important prevents the common CSS stylesheets from overriding
- this as on sphinx_rtd_theme they are loaded after this stylesheet */
- white-space: normal !important;
- }
-
- .wy-table-responsive {
- overflow: visible !important;
- }
-}
diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst
index 9c5bddd5..62914c05 100644
--- a/docs/abi-spec.rst
+++ b/docs/abi-spec.rst
@@ -437,10 +437,10 @@ For example,
::
- pragma solidity ^0.4.0;
+ pragma solidity >0.4.24;
contract Test {
- function Test() public { b = 0x12345678901234567890123456789012; }
+ constructor() public { b = 0x12345678901234567890123456789012; }
event Event(uint indexed a, bytes32 b);
event Event2(uint indexed a, bytes32 b);
function foo(uint a) public { emit Event(a, b); }
diff --git a/docs/assembly.rst b/docs/assembly.rst
index edc826ac..3bab289e 100644
--- a/docs/assembly.rst
+++ b/docs/assembly.rst
@@ -232,9 +232,9 @@ In the grammar, opcodes are represented as pre-defined identifiers.
+-------------------------+-----+---+-----------------------------------------------------------------+
| swap1 ... swap16 | `*` | F | swap topmost and ith stack slot below it |
+-------------------------+-----+---+-----------------------------------------------------------------+
-| mload(p) | | F | mem[p..(p+32)) |
+| mload(p) | | F | mem[p...(p+32)) |
+-------------------------+-----+---+-----------------------------------------------------------------+
-| mstore(p, v) | `-` | F | mem[p..(p+32)) := v |
+| mstore(p, v) | `-` | F | mem[p...(p+32)) := v |
+-------------------------+-----+---+-----------------------------------------------------------------+
| mstore8(p, v) | `-` | F | mem[p] := v & 0xff (only modifies a single byte) |
+-------------------------+-----+---+-----------------------------------------------------------------+
@@ -272,16 +272,16 @@ In the grammar, opcodes are represented as pre-defined identifiers.
+-------------------------+-----+---+-----------------------------------------------------------------+
| returndatacopy(t, f, s) | `-` | B | copy s bytes from returndata at position f to mem at position t |
+-------------------------+-----+---+-----------------------------------------------------------------+
-| create(v, p, s) | | F | create new contract with code mem[p..(p+s)) and send v wei |
+| create(v, p, s) | | F | create new contract with code mem[p...(p+s)) and send v wei |
| | | | and return the new address |
+-------------------------+-----+---+-----------------------------------------------------------------+
-| create2(v, n, p, s) | | C | create new contract with code mem[p..(p+s)) at address |
-| | | | keccak256(<address> . n . keccak256(mem[p..(p+s))) and send v |
+| create2(v, n, p, s) | | C | create new contract with code mem[p...(p+s)) at address |
+| | | | keccak256(<address> . n . keccak256(mem[p...(p+s))) and send v |
| | | | wei and return the new address |
+-------------------------+-----+---+-----------------------------------------------------------------+
-| call(g, a, v, in, | | F | call contract at address a with input mem[in..(in+insize)) |
+| 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 |
-| | | | mem[out..(out+outsize)) returning 0 on error (eg. out of gas) |
+| | | | mem[out...(out+outsize)) returning 0 on error (eg. out of gas) |
| | | | and 1 on success |
+-------------------------+-----+---+-----------------------------------------------------------------+
| callcode(g, a, v, in, | | F | identical to ``call`` but only use the code from a and stay |
@@ -293,23 +293,23 @@ In the grammar, opcodes are represented as pre-defined identifiers.
| staticcall(g, a, in, | | B | identical to ``call(g, a, 0, in, insize, out, outsize)`` but do |
| insize, out, outsize) | | | not allow state modifications |
+-------------------------+-----+---+-----------------------------------------------------------------+
-| return(p, s) | `-` | F | end execution, return data mem[p..(p+s)) |
+| return(p, s) | `-` | F | end execution, return data mem[p...(p+s)) |
+-------------------------+-----+---+-----------------------------------------------------------------+
-| revert(p, s) | `-` | B | end execution, revert state changes, return data mem[p..(p+s)) |
+| revert(p, s) | `-` | B | end execution, revert state changes, return data mem[p...(p+s)) |
+-------------------------+-----+---+-----------------------------------------------------------------+
| selfdestruct(a) | `-` | F | end execution, destroy current contract and send funds to a |
+-------------------------+-----+---+-----------------------------------------------------------------+
| invalid | `-` | F | end execution with invalid instruction |
+-------------------------+-----+---+-----------------------------------------------------------------+
-| log0(p, s) | `-` | F | log without topics and data mem[p..(p+s)) |
+| log0(p, s) | `-` | F | log without topics and data mem[p...(p+s)) |
+-------------------------+-----+---+-----------------------------------------------------------------+
-| log1(p, s, t1) | `-` | F | log with topic t1 and data mem[p..(p+s)) |
+| log1(p, s, t1) | `-` | F | log with topic t1 and data mem[p...(p+s)) |
+-------------------------+-----+---+-----------------------------------------------------------------+
-| log2(p, s, t1, t2) | `-` | F | log with topics t1, t2 and data mem[p..(p+s)) |
+| log2(p, s, t1, t2) | `-` | F | log with topics t1, t2 and data mem[p...(p+s)) |
+-------------------------+-----+---+-----------------------------------------------------------------+
-| log3(p, s, t1, t2, t3) | `-` | F | log with topics t1, t2, t3 and data mem[p..(p+s)) |
+| log3(p, s, t1, t2, t3) | `-` | F | log with topics t1, t2, t3 and data mem[p...(p+s)) |
+-------------------------+-----+---+-----------------------------------------------------------------+
-| log4(p, s, t1, t2, t3, | `-` | F | log with topics t1, t2, t3, t4 and data mem[p..(p+s)) |
+| log4(p, s, t1, t2, t3, | `-` | F | log with topics t1, t2, t3, t4 and data mem[p...(p+s)) |
| t4) | | | |
+-------------------------+-----+---+-----------------------------------------------------------------+
| origin | | F | transaction sender |
diff --git a/docs/common-patterns.rst b/docs/common-patterns.rst
index 739e136f..7c38b0e7 100644
--- a/docs/common-patterns.rst
+++ b/docs/common-patterns.rst
@@ -28,7 +28,7 @@ become the new richest.
::
- pragma solidity ^0.4.11;
+ pragma solidity >0.4.24;
contract WithdrawalContract {
address public richest;
@@ -36,7 +36,7 @@ become the new richest.
mapping (address => uint) pendingWithdrawals;
- function WithdrawalContract() public payable {
+ constructor() public payable {
richest = msg.sender;
mostSent = msg.value;
}
@@ -65,13 +65,13 @@ This is as opposed to the more intuitive sending pattern:
::
- pragma solidity ^0.4.11;
+ pragma solidity >0.4.24;
contract SendContract {
address public richest;
uint public mostSent;
- function SendContract() public payable {
+ constructor() public payable {
richest = msg.sender;
mostSent = msg.value;
}
diff --git a/docs/conf.py b/docs/conf.py
index fcf46c11..55f4f1a8 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -27,6 +27,8 @@ def setup(sphinx):
from pygments_lexer_solidity import SolidityLexer
sphinx.add_lexer('Solidity', SolidityLexer())
+ sphinx.add_stylesheet('css/custom.css')
+
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
@@ -141,16 +143,7 @@ html_theme = 'sphinx_rtd_theme'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
-html_static_path = ['_static']
-
-# A dictionary of values to pass into the template engine’s context for
-# all pages. Single values can also be put in
-# this dictionary using the -A command-line option of sphinx-build.
-html_context = {
- 'css_files': [
- '_static/theme_overrides.css', # override wide tables in sphinx_rtd_theme
- ],
- }
+html_static_path = []
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
diff --git a/docs/contracts.rst b/docs/contracts.rst
index 845fd973..53e50656 100644
--- a/docs/contracts.rst
+++ b/docs/contracts.rst
@@ -301,10 +301,10 @@ inheritable properties of contracts and may be overridden by derived contracts.
::
- pragma solidity ^0.4.22;
+ pragma solidity >0.4.24;
contract owned {
- function owned() public { owner = msg.sender; }
+ constructor() public { owner = msg.sender; }
address owner;
// This contract only defines a modifier but does not use
@@ -346,7 +346,7 @@ inheritable properties of contracts and may be overridden by derived contracts.
mapping (address => bool) registeredAddresses;
uint price;
- function Register(uint initialPrice) public { price = initialPrice; }
+ constructor(uint initialPrice) public { price = initialPrice; }
// It is important to also provide the
// `payable` keyword here, otherwise the function will
@@ -473,7 +473,7 @@ The following statements are considered modifying the state:
}
.. note::
- ``constant`` on functions is an alias to ``view``, but this is deprecated and will be dropped in version 0.5.0.
+ ``constant`` on functions used to be an alias to ``view``, but this was dropped in version 0.5.0.
.. note::
Getter methods are marked ``view``.
@@ -485,9 +485,6 @@ The following statements are considered modifying the state:
prevent modifications to the state on the level of the EVM by adding
``pragma experimental "v0.5.0";``
-.. warning::
- The compiler does not enforce yet that a ``view`` method is not modifying state. It raises a warning though.
-
.. index:: ! pure function, function;pure
.. _pure-functions:
@@ -529,12 +526,15 @@ In addition to the list of state modifying statements explained above, the follo
It is a non-circumventable runtime checks done by the EVM.
.. warning::
- Before version 0.4.17 the compiler didn't enforce that ``pure`` is not reading the state.
+ Before version 0.4.17 the compiler did not enforce that ``pure`` is not reading the state.
It is a compile-time type check, which can be circumvented doing invalid explicit conversions
between contract types, because the compiler can verify that the type of the contract does
not do state-changing operations, but it cannot check that the contract that will be called
at runtime is actually of that type.
+.. warning::
+ Before version 0.5.0 the compiler did not enforce that ``view`` is not writing the state.
+
.. index:: ! fallback function, function;fallback
.. _fallback-function:
@@ -990,7 +990,7 @@ default constructor: ``contructor() public {}``.
::
- pragma solidity ^0.4.22;
+ pragma solidity >0.4.24;
contract A {
uint public a;
@@ -1006,24 +1006,8 @@ default constructor: ``contructor() public {}``.
A constructor set as ``internal`` causes the contract to be marked as :ref:`abstract <abstract-contract>`.
-.. note ::
- Prior to version 0.4.22, constructors were defined as functions with the same name as the contract. This syntax is now deprecated.
-
-::
-
- pragma solidity ^0.4.11;
-
- contract A {
- uint public a;
-
- function A(uint _a) internal {
- a = _a;
- }
- }
-
- contract B is A(1) {
- function B() public {}
- }
+.. warning ::
+ Prior to version 0.4.22, constructors were defined as functions with the same name as the contract. This syntax was deprecated and is not allowed anymore in version 0.5.0.
.. index:: ! base;constructor
@@ -1344,9 +1328,9 @@ custom types without the overhead of external function calls:
using BigInt for BigInt.bigint;
function f() public pure {
- var x = BigInt.fromUint(7);
- var y = BigInt.fromUint(uint(-1));
- var z = x.add(y);
+ BigInt.bigint memory x = BigInt.fromUint(7);
+ BigInt.bigint memory y = BigInt.fromUint(uint(-1));
+ BigInt.bigint memory z = x.add(y);
}
}
@@ -1402,7 +1386,7 @@ Using For
*********
The directive ``using A for B;`` can be used to attach library
-functions (from the library ``A``) to any type (``B``).
+functions (from the library ``A``) to any type (``B``).
These functions will receive the object they are called on
as their first parameter (like the ``self`` variable in Python).
diff --git a/docs/contributing.rst b/docs/contributing.rst
index 481aab1e..231cbdfc 100644
--- a/docs/contributing.rst
+++ b/docs/contributing.rst
@@ -209,6 +209,7 @@ At this stage you should be able to see a message similar to the following:
If the instrumentation messages did not appear, try switching the cmake flags pointing to AFL's clang binaries:
::
+
# if previously failed
make clean
cmake .. -DCMAKE_C_COMPILER=path/to/afl-clang -DCMAKE_CXX_COMPILER=path/to/afl-clang++
diff --git a/docs/control-structures.rst b/docs/control-structures.rst
index cc1f7ca5..8ced0fbc 100644
--- a/docs/control-structures.rst
+++ b/docs/control-structures.rst
@@ -225,11 +225,11 @@ creation-dependencies are not possible.
::
- pragma solidity ^0.4.0;
+ pragma solidity >0.4.24;
contract D {
uint x;
- function D(uint a) public payable {
+ constructor(uint a) public payable {
x = a;
}
}
diff --git a/docs/docs-css/custom.css b/docs/docs-css/custom.css
new file mode 100644
index 00000000..970148ed
--- /dev/null
+++ b/docs/docs-css/custom.css
@@ -0,0 +1,14 @@
+pre {
+ white-space: pre-wrap; /* css-3 */
+ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
+ white-space: -pre-wrap; /* Opera 4-6 */
+ white-space: -o-pre-wrap; /* Opera 7 */
+ word-wrap: break-word;
+}
+
+.wy-table-responsive table td, .wy-table-responsive table th {
+ white-space: pre-wrap;
+}
+.wy-table-responsive table td, .wy-table-responsive table th {
+ white-space: pre-wrap;
+}
diff --git a/docs/frequently-asked-questions.rst b/docs/frequently-asked-questions.rst
index ca5a1aee..0d6fa033 100644
--- a/docs/frequently-asked-questions.rst
+++ b/docs/frequently-asked-questions.rst
@@ -136,14 +136,9 @@ See `struct_and_for_loop_tester.sol <https://github.com/fivedogit/solidity-baby-
How do for loops work?
======================
-Very similar to JavaScript. There is one point to watch out for, though:
+Very similar to JavaScript. Such as the following example:
-If you use ``for (var i = 0; i < a.length; i ++) { a[i] = i; }``, then
-the type of ``i`` will be inferred only from ``0``, whose type is ``uint8``.
-This means that if ``a`` has more than ``255`` elements, your loop will
-not terminate because ``i`` can only hold values up to ``255``.
-
-Better use ``for (uint i = 0; i < a.length...``
+``for (uint i = 0; i < a.length; i ++) { a[i] = i; }``
See `struct_and_for_loop_tester.sol <https://github.com/fivedogit/solidity-baby-steps/blob/master/contracts/65_struct_and_for_loop_tester.sol>`_.
@@ -426,10 +421,10 @@ In the case of a ``contract A`` calling a new instance of ``contract B``, parent
You will need to make sure that you have both contracts aware of each other's presence and that ``contract B`` has a ``payable`` constructor.
In this example::
- pragma solidity ^0.4.0;
+ pragma solidity >0.4.24;
contract B {
- function B() public payable {}
+ constructor() public payable {}
}
contract A {
diff --git a/docs/grammar.txt b/docs/grammar.txt
index 5d977827..7b29fc62 100644
--- a/docs/grammar.txt
+++ b/docs/grammar.txt
@@ -58,7 +58,7 @@ ArrayTypeName = TypeName '[' Expression? ']'
FunctionTypeName = 'function' FunctionTypeParameterList ( 'internal' | 'external' | StateMutability )*
( 'returns' FunctionTypeParameterList )?
StorageLocation = 'memory' | 'storage' | 'calldata'
-StateMutability = 'pure' | 'constant' | 'view' | 'payable'
+StateMutability = 'pure' | 'view' | 'payable'
Block = '{' Statement* '}'
Statement = IfStatement | WhileStatement | ForStatement | Block | InlineAssemblyStatement |
@@ -78,7 +78,7 @@ Break = 'break'
Return = 'return' Expression?
Throw = 'throw'
EmitStatement = 'emit' FunctionCall
-VariableDefinition = ('var' IdentifierList | VariableDeclaration | '(' VariableDeclaration? (',' VariableDeclaration? )* ')' ) ( '=' Expression )?
+VariableDefinition = (VariableDeclaration | '(' VariableDeclaration? (',' VariableDeclaration? )* ')' ) ( '=' Expression )?
IdentifierList = '(' ( Identifier? ',' )* Identifier? ')'
// Precedence by order (see github.com/ethereum/solidity/pull/732)
@@ -140,8 +140,7 @@ TupleExpression = '(' ( Expression? ( ',' Expression? )* )? ')'
ElementaryTypeNameExpression = ElementaryTypeName
-ElementaryTypeName = 'address' | 'bool' | 'string' | 'var'
- | Int | Uint | Byte | Fixed | Ufixed
+ElementaryTypeName = 'address' | 'bool' | 'string' | Int | Uint | Byte | Fixed | Ufixed
Int = 'int' | 'int8' | 'int16' | 'int24' | 'int32' | 'int40' | 'int48' | 'int56' | 'int64' | 'int72' | 'int80' | 'int88' | 'int96' | 'int104' | 'int112' | 'int120' | 'int128' | 'int136' | 'int144' | 'int152' | 'int160' | 'int168' | 'int176' | 'int184' | 'int192' | 'int200' | 'int208' | 'int216' | 'int224' | 'int232' | 'int240' | 'int248' | 'int256'
diff --git a/docs/introduction-to-smart-contracts.rst b/docs/introduction-to-smart-contracts.rst
index 71f9bd8e..e1b61d8b 100644
--- a/docs/introduction-to-smart-contracts.rst
+++ b/docs/introduction-to-smart-contracts.rst
@@ -80,7 +80,7 @@ registering with username and password — all you need is an Ethereum keypair.
::
- pragma solidity ^0.4.21;
+ pragma solidity >0.4.24;
contract Coin {
// The keyword "public" makes those variables
@@ -94,7 +94,7 @@ registering with username and password — all you need is an Ethereum keypair.
// This is the constructor whose code is
// run only when the contract is created.
- function Coin() public {
+ constructor() public {
minter = msg.sender;
}
diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst
index 30ece7e1..1d5add9a 100644
--- a/docs/miscellaneous.rst
+++ b/docs/miscellaneous.rst
@@ -157,7 +157,7 @@ These steps are applied to each basic block and the newly generated code is used
::
- var x = 7;
+ uint x = 7;
data[7] = 9;
if (data[x] != x + 2)
return 2;
@@ -397,11 +397,10 @@ Function Visibility Specifiers
Modifiers
=========
-- ``pure`` for functions: Disallows modification or access of state - this is not enforced yet.
-- ``view`` for functions: Disallows modification of state - this is not enforced yet.
+- ``pure`` for functions: Disallows modification or access of state.
+- ``view`` for functions: Disallows modification of state.
- ``payable`` for functions: Allows them to receive Ether together with a call.
- ``constant`` for state variables: Disallows assignment (except initialisation), does not occupy storage slot.
-- ``constant`` for functions: Same as ``view``.
- ``anonymous`` for events: Does not store event signature as topic.
- ``indexed`` for event parameters: Stores the parameter as topic.
diff --git a/docs/security-considerations.rst b/docs/security-considerations.rst
index ec67773d..afdecb98 100644
--- a/docs/security-considerations.rst
+++ b/docs/security-considerations.rst
@@ -103,7 +103,7 @@ outlined further below:
mapping(address => uint) shares;
/// Withdraw your share.
function withdraw() public {
- var share = shares[msg.sender];
+ uint share = shares[msg.sender];
shares[msg.sender] = 0;
msg.sender.transfer(share);
}
@@ -180,13 +180,13 @@ Never use tx.origin for authorization. Let's say you have a wallet contract like
::
- pragma solidity ^0.4.11;
+ pragma solidity >0.4.24;
// THIS CONTRACT CONTAINS A BUG - DO NOT USE
contract TxUserWallet {
address owner;
- function TxUserWallet() public {
+ constructor() public {
owner = msg.sender;
}
@@ -200,7 +200,7 @@ Now someone tricks you into sending ether to the address of this attack wallet:
::
- pragma solidity ^0.4.11;
+ pragma solidity >0.4.24;
interface TxUserWallet {
function transferTo(address dest, uint amount) public;
@@ -209,7 +209,7 @@ Now someone tricks you into sending ether to the address of this attack wallet:
contract TxAttackWallet {
address owner;
- function TxAttackWallet() public {
+ constructor() public {
owner = msg.sender;
}
@@ -224,7 +224,6 @@ If your wallet had checked ``msg.sender`` for authorization, it would get the ad
Minor Details
=============
-- In ``for (var i = 0; i < arrayName.length; i++) { ... }``, the type of ``i`` will be ``uint8``, because this is the smallest type that is required to hold the value ``0``. If the array has more than 255 elements, the loop will not terminate.
- Types that do not occupy the full 32 bytes might contain "dirty higher order bits".
This is especially important if you access ``msg.data`` - it poses a malleability risk:
You can craft transactions that call a function ``f(uint8 x)`` with a raw byte argument
diff --git a/docs/style-guide.rst b/docs/style-guide.rst
index 792110e1..8311e925 100644
--- a/docs/style-guide.rst
+++ b/docs/style-guide.rst
@@ -114,15 +114,15 @@ No::
.. _maximum_line_length:
-Maximum Line Length
+Maximum Line Length
===================
-Keeping lines under the `PEP 8 recommendation <https://www.python.org/dev/peps/pep-0008/#maximum-line-length>`_ to a maximum of 79 (or 99)
+Keeping lines under the `PEP 8 recommendation <https://www.python.org/dev/peps/pep-0008/#maximum-line-length>`_ to a maximum of 79 (or 99)
characters helps readers easily parse the code.
Wrapped lines should conform to the following guidelines.
-1. The first argument should not be attached to the opening parenthesis.
+1. The first argument should not be attached to the opening parenthesis.
2. One, and only one, indent should be used.
3. Each argument should fall on its own line.
4. The terminating element, :code:`);`, should be placed on the final line by itself.
@@ -132,38 +132,38 @@ Function Calls
Yes::
thisFunctionCallIsReallyLong(
- longArgument1,
- longArgument2,
+ longArgument1,
+ longArgument2,
longArgument3
);
No::
- thisFunctionCallIsReallyLong(longArgument1,
- longArgument2,
+ thisFunctionCallIsReallyLong(longArgument1,
+ longArgument2,
longArgument3
);
-
- thisFunctionCallIsReallyLong(longArgument1,
- longArgument2,
+
+ thisFunctionCallIsReallyLong(longArgument1,
+ longArgument2,
longArgument3
- );
-
+ );
+
thisFunctionCallIsReallyLong(
longArgument1, longArgument2,
longArgument3
- );
+ );
thisFunctionCallIsReallyLong(
- longArgument1,
- longArgument2,
+ longArgument1,
+ longArgument2,
longArgument3
);
thisFunctionCallIsReallyLong(
- longArgument1,
- longArgument2,
- longArgument3);
+ longArgument1,
+ longArgument2,
+ longArgument3);
Assignment Statements
@@ -215,7 +215,7 @@ No::
recipient,
publicKey,
amount,
- options);
+ options);
Source File Encoding
====================
@@ -274,7 +274,7 @@ Within a grouping, place the ``view`` and ``pure`` functions last.
Yes::
contract A {
- function A() public {
+ constructor() public {
...
}
@@ -318,7 +318,7 @@ No::
// Public functions
// ...
- function A() public {
+ constructor() public {
...
}
@@ -529,7 +529,7 @@ No::
function increment(uint x) public pure returns (uint) {
return x + 1;}
-You should explicitly label the visibility of all functions, including constructors.
+You should explicitly label the visibility of all functions, including constructors.
Yes::
@@ -540,7 +540,7 @@ Yes::
No::
function implicitlyPublic(uint val) {
- doSomething();
+ doSomething();
}
The visibility modifier for a function should come before any custom
@@ -663,19 +663,19 @@ Yes::
address a,
address b,
address c
- )
- public
+ )
+ public
returns (
- address someAddressName,
- uint256 LongArgument,
+ address someAddressName,
+ uint256 LongArgument,
uint256 Argument
)
- {
+ {
doSomething()
-
+
return (
- veryLongReturnArg1,
- veryLongReturnArg2,
+ veryLongReturnArg1,
+ veryLongReturnArg2,
veryLongReturnArg3
);
}
@@ -686,16 +686,16 @@ No::
address a,
address b,
address c
- )
- public
- returns (address someAddressName,
- uint256 LongArgument,
+ )
+ public
+ returns (address someAddressName,
+ uint256 LongArgument,
uint256 Argument)
- {
+ {
doSomething()
-
- return (veryLongReturnArg1,
- veryLongReturnArg1,
+
+ return (veryLongReturnArg1,
+ veryLongReturnArg1,
veryLongReturnArg1);
}
@@ -706,7 +706,7 @@ manner as modifiers if the function declaration is long or hard to read.
Yes::
contract A is B, C, D {
- function A(uint param1, uint param2, uint param3, uint param4, uint param5)
+ constructor(uint param1, uint param2, uint param3, uint param4, uint param5)
B(param1)
C(param2, param3)
D(param4)
@@ -719,7 +719,7 @@ Yes::
No::
contract A is B, C, D {
- function A(uint param1, uint param2, uint param3, uint param4, uint param5)
+ constructor(uint param1, uint param2, uint param3, uint param4, uint param5)
B(param1)
C(param2, param3)
D(param4)
@@ -730,7 +730,7 @@ No::
}
contract A is B, C, D {
- function A(uint param1, uint param2, uint param3, uint param4, uint param5)
+ constructor(uint param1, uint param2, uint param3, uint param4, uint param5)
B(param1)
C(param2, param3)
D(param4)
diff --git a/docs/types.rst b/docs/types.rst
index 528807d9..217a2273 100644
--- a/docs/types.rst
+++ b/docs/types.rst
@@ -7,10 +7,8 @@ Types
*****
Solidity is a statically typed language, which means that the type of each
-variable (state and local) needs to be specified (or at least known -
-see :ref:`type-deduction` below) at
-compile-time. Solidity provides several elementary types which can be combined
-to form complex types.
+variable (state and local) needs to be specified.
+Solidity provides several elementary types which can be combined to form complex types.
In addition, types can interact with each other in expressions containing
operators. For a quick reference of the various operators, see :ref:`order`.
@@ -378,7 +376,7 @@ be passed via and returned from external function calls.
Function types are notated as follows::
- function (<parameter types>) {internal|external} [pure|constant|view|payable] [returns (<return types>)]
+ function (<parameter types>) {internal|external} [pure|view|payable] [returns (<return types>)]
In contrast to the parameter types, the return types cannot be empty - if the
function type should not return anything, the whole ``returns (<return types>)``
@@ -548,7 +546,7 @@ memory-stored reference type do not create a copy.
// the data location of memoryArray is memory
function f(uint[] memoryArray) public {
x = memoryArray; // works, copies the whole array to storage
- var y = x; // works, assigns a pointer, data location of y is storage
+ uint[] storage y = x; // works, assigns a pointer, data location of y is storage
y[7]; // fine, returns the 8th element
y.length = 2; // fine, modifies x through y
delete x; // fine, clears the array, also modifies y
@@ -986,26 +984,3 @@ converted to a matching size. This makes alignment and padding explicit::
bytes32(uint256(x)); // pad on the left
bytes32(bytes2(x)); // pad on the right
-.. index:: ! type;deduction, ! var
-
-.. _type-deduction:
-
-Type Deduction
-==============
-
-For convenience, it is not always necessary to explicitly specify the type of a
-variable, the compiler automatically infers it from the type of the first
-expression that is assigned to the variable::
-
- uint24 x = 0x123;
- var y = x;
-
-Here, the type of ``y`` will be ``uint24``. Using ``var`` is not possible for function
-parameters or return parameters.
-
-.. warning::
- The type is only deduced from the first assignment, so
- the loop in the following snippet is infinite, as ``i`` will have the type
- ``uint8`` and the highest value of this type is smaller than ``2000``.
- ``for (var i = 0; i < 2000; i++) { ... }``
-
diff --git a/libevmasm/KnownState.cpp b/libevmasm/KnownState.cpp
index e2f10f22..7c593fc9 100644
--- a/libevmasm/KnownState.cpp
+++ b/libevmasm/KnownState.cpp
@@ -121,28 +121,33 @@ KnownState::StoreOperation KnownState::feedItem(AssemblyItem const& _item, bool
vector<Id> arguments(info.args);
for (int i = 0; i < info.args; ++i)
arguments[i] = stackElement(m_stackHeight - i, _item.location());
-
- if (_item.instruction() == Instruction::SSTORE)
+ switch (_item.instruction())
+ {
+ case Instruction::SSTORE:
op = storeInStorage(arguments[0], arguments[1], _item.location());
- else if (_item.instruction() == Instruction::SLOAD)
+ break;
+ case Instruction::SLOAD:
setStackElement(
m_stackHeight + _item.deposit(),
loadFromStorage(arguments[0], _item.location())
);
- else if (_item.instruction() == Instruction::MSTORE)
+ break;
+ case Instruction::MSTORE:
op = storeInMemory(arguments[0], arguments[1], _item.location());
- else if (_item.instruction() == Instruction::MLOAD)
+ break;
+ case Instruction::MLOAD:
setStackElement(
m_stackHeight + _item.deposit(),
loadFromMemory(arguments[0], _item.location())
);
- else if (_item.instruction() == Instruction::KECCAK256)
+ break;
+ case Instruction::KECCAK256:
setStackElement(
m_stackHeight + _item.deposit(),
applyKeccak256(arguments.at(0), arguments.at(1), _item.location())
);
- else
- {
+ break;
+ default:
bool invMem = SemanticInformation::invalidatesMemory(_item.instruction());
bool invStor = SemanticInformation::invalidatesStorage(_item.instruction());
// We could be a bit more fine-grained here (CALL only invalidates part of
diff --git a/libsolc/CMakeLists.txt b/libsolc/CMakeLists.txt
index e67583dd..63fc1a83 100644
--- a/libsolc/CMakeLists.txt
+++ b/libsolc/CMakeLists.txt
@@ -1,5 +1,5 @@
if (EMSCRIPTEN)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s EXPORTED_FUNCTIONS='[\"_compileJSON\",\"_license\",\"_version\",\"_compileJSONMulti\",\"_compileJSONCallback\",\"_compileStandard\"]' -s RESERVED_FUNCTION_POINTERS=20")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s EXPORTED_FUNCTIONS='[\"_solidity_license\",\"_solidity_version\",\"_solidity_compile\",\"_license\",\"_version\",\"_compileJSON\",\"_compileJSONMulti\",\"_compileJSONCallback\",\"_compileStandard\"]' -s RESERVED_FUNCTION_POINTERS=20")
add_executable(soljson libsolc.cpp)
target_link_libraries(soljson PRIVATE solidity)
else()
diff --git a/libsolc/libsolc.cpp b/libsolc/libsolc.cpp
index 6c587e23..26ce98ce 100644
--- a/libsolc/libsolc.cpp
+++ b/libsolc/libsolc.cpp
@@ -299,4 +299,19 @@ extern char const* compileStandard(char const* _input, CStyleReadFileCallback _r
s_outputBuffer = compileStandardInternal(_input, _readCallback);
return s_outputBuffer.c_str();
}
+extern char const* solidity_license()
+{
+ /// todo: make this the default or an alias
+ return license();
+}
+extern char const* solidity_version()
+{
+ /// todo: make this the default or an alias
+ return version();
+}
+extern char const* solidity_compile(char const* _input, CStyleReadFileCallback _readCallback)
+{
+ /// todo: make this the default or an alias
+ return compileStandard(_input, _readCallback);
+}
}
diff --git a/libsolc/libsolc.h b/libsolc/libsolc.h
index c392ce93..2cc004d4 100644
--- a/libsolc/libsolc.h
+++ b/libsolc/libsolc.h
@@ -37,6 +37,10 @@ char const* compileJSONMulti(char const* _input, bool _optimize);
char const* compileJSONCallback(char const* _input, bool _optimize, CStyleReadFileCallback _readCallback);
char const* compileStandard(char const* _input, CStyleReadFileCallback _readCallback);
+char const* solidity_license();
+char const* solidity_version();
+char const* solidity_compile(char const* _input, CStyleReadFileCallback _readCallback);
+
#ifdef __cplusplus
}
#endif
diff --git a/libsolidity/analysis/StaticAnalyzer.cpp b/libsolidity/analysis/StaticAnalyzer.cpp
index dad4cc7f..323282ca 100644
--- a/libsolidity/analysis/StaticAnalyzer.cpp
+++ b/libsolidity/analysis/StaticAnalyzer.cpp
@@ -58,8 +58,8 @@ bool StaticAnalyzer::visit(FunctionDefinition const& _function)
_function.location(),
"No visibility specified. Defaulting to \"" +
Declaration::visibilityToString(_function.visibility()) +
- "\". " +
- (isInterface ? "In interfaces it defaults to external." : "")
+ "\"." +
+ (isInterface ? " In interfaces it defaults to external." : "")
);
if (_function.isImplemented())
m_currentFunction = &_function;
@@ -150,36 +150,18 @@ bool StaticAnalyzer::visit(ExpressionStatement const& _statement)
bool StaticAnalyzer::visit(MemberAccess const& _memberAccess)
{
- bool const v050 = m_currentContract->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050);
-
if (MagicType const* type = dynamic_cast<MagicType const*>(_memberAccess.expression().annotation().type.get()))
{
if (type->kind() == MagicType::Kind::Message && _memberAccess.memberName() == "gas")
- {
- if (v050)
- m_errorReporter.typeError(
- _memberAccess.location(),
- "\"msg.gas\" has been deprecated in favor of \"gasleft()\""
- );
- else
- m_errorReporter.warning(
- _memberAccess.location(),
- "\"msg.gas\" has been deprecated in favor of \"gasleft()\""
- );
- }
- if (type->kind() == MagicType::Kind::Block && _memberAccess.memberName() == "blockhash")
- {
- if (v050)
- m_errorReporter.typeError(
- _memberAccess.location(),
- "\"block.blockhash()\" has been deprecated in favor of \"blockhash()\""
- );
- else
- m_errorReporter.warning(
- _memberAccess.location(),
- "\"block.blockhash()\" has been deprecated in favor of \"blockhash()\""
- );
- }
+ m_errorReporter.typeError(
+ _memberAccess.location(),
+ "\"msg.gas\" has been deprecated in favor of \"gasleft()\""
+ );
+ else if (type->kind() == MagicType::Kind::Block && _memberAccess.memberName() == "blockhash")
+ m_errorReporter.typeError(
+ _memberAccess.location(),
+ "\"block.blockhash()\" has been deprecated in favor of \"blockhash()\""
+ );
}
if (m_nonPayablePublic && !m_library)
diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp
index c408b393..cd0dc2a4 100644
--- a/libsolidity/analysis/SyntaxChecker.cpp
+++ b/libsolidity/analysis/SyntaxChecker.cpp
@@ -262,14 +262,9 @@ bool SyntaxChecker::visit(FunctionTypeName const& _node)
bool SyntaxChecker::visit(VariableDeclaration const& _declaration)
{
- bool const v050 = m_sourceUnit->annotation().experimentalFeatures.count(ExperimentalFeature::V050);
-
if (!_declaration.typeName())
{
- if (v050)
- m_errorReporter.syntaxError(_declaration.location(), "Use of the \"var\" keyword is deprecated.");
- else
- m_errorReporter.warning(_declaration.location(), "Use of the \"var\" keyword is deprecated.");
+ m_errorReporter.syntaxError(_declaration.location(), "Use of the \"var\" keyword is disallowed.");
}
return true;
}
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index b9e3f8d0..676b3cd6 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -335,8 +335,6 @@ void TypeChecker::annotateBaseConstructorArguments(
ASTNode const* _argumentNode
)
{
- bool const v050 = _currentContract.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050);
-
solAssert(_baseConstructor, "");
solAssert(_argumentNode, "");
@@ -365,18 +363,11 @@ void TypeChecker::annotateBaseConstructorArguments(
ssl.append("Second constructor call is here: ", previousNode->location());
}
- if (v050)
- m_errorReporter.declarationError(
- *mainLocation,
- ssl,
- "Base constructor arguments given twice."
- );
- else
- m_errorReporter.warning(
- *mainLocation,
- "Base constructor arguments given twice.",
- ssl
- );
+ m_errorReporter.declarationError(
+ *mainLocation,
+ ssl,
+ "Base constructor arguments given twice."
+ );
}
}
@@ -758,19 +749,10 @@ bool TypeChecker::visit(VariableDeclaration const& _variable)
if (!_variable.value())
m_errorReporter.typeError(_variable.location(), "Uninitialized \"constant\" variable.");
else if (!_variable.value()->annotation().isPure)
- {
- if (_variable.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050))
- m_errorReporter.typeError(
- _variable.value()->location(),
- "Initial value for constant variable has to be compile-time constant."
- );
- else
- m_errorReporter.warning(
- _variable.value()->location(),
- "Initial value for constant variable has to be compile-time constant. "
- "This will fail to compile with the next breaking version change."
- );
- }
+ m_errorReporter.typeError(
+ _variable.value()->location(),
+ "Initial value for constant variable has to be compile-time constant."
+ );
}
if (!_variable.isStateVariable())
{
diff --git a/libsolidity/analysis/ViewPureChecker.cpp b/libsolidity/analysis/ViewPureChecker.cpp
index 107eb3aa..18c642c3 100644
--- a/libsolidity/analysis/ViewPureChecker.cpp
+++ b/libsolidity/analysis/ViewPureChecker.cpp
@@ -116,31 +116,22 @@ private:
bool ViewPureChecker::check()
{
- // The bool means "enforce view with errors".
- vector<pair<ContractDefinition const*, bool>> contracts;
+ vector<ContractDefinition const*> contracts;
for (auto const& node: m_ast)
{
SourceUnit const* source = dynamic_cast<SourceUnit const*>(node.get());
solAssert(source, "");
- bool enforceView = source->annotation().experimentalFeatures.count(ExperimentalFeature::V050);
- for (ContractDefinition const* c: source->filteredNodes<ContractDefinition>(source->nodes()))
- contracts.emplace_back(c, enforceView);
+ contracts += source->filteredNodes<ContractDefinition>(source->nodes());
}
// Check modifiers first to infer their state mutability.
for (auto const& contract: contracts)
- {
- m_enforceViewWithError = contract.second;
- for (ModifierDefinition const* mod: contract.first->functionModifiers())
+ for (ModifierDefinition const* mod: contract->functionModifiers())
mod->accept(*this);
- }
for (auto const& contract: contracts)
- {
- m_enforceViewWithError = contract.second;
- contract.first->accept(*this);
- }
+ contract->accept(*this);
return !m_errors;
}
@@ -232,17 +223,20 @@ void ViewPureChecker::reportMutability(StateMutability _mutability, SourceLocati
{
if (m_currentFunction && m_currentFunction->stateMutability() < _mutability)
{
- string text;
if (_mutability == StateMutability::View)
- text =
+ m_errorReporter.typeError(
+ _location,
"Function declared as pure, but this expression (potentially) reads from the "
- "environment or state and thus requires \"view\".";
+ "environment or state and thus requires \"view\"."
+ );
else if (_mutability == StateMutability::NonPayable)
- text =
+ m_errorReporter.typeError(
+ _location,
"Function declared as " +
stateMutabilityToString(m_currentFunction->stateMutability()) +
", but this expression (potentially) modifies the state and thus "
- "requires non-payable (the default) or payable.";
+ "requires non-payable (the default) or payable."
+ );
else
solAssert(false, "");
@@ -251,13 +245,7 @@ void ViewPureChecker::reportMutability(StateMutability _mutability, SourceLocati
m_currentFunction->stateMutability() == StateMutability::Pure,
""
);
- if (!m_enforceViewWithError && m_currentFunction->stateMutability() == StateMutability::View)
- m_errorReporter.warning(_location, text);
- else
- {
- m_errors = true;
- m_errorReporter.typeError(_location, text);
- }
+ m_errors = true;
}
if (_mutability > m_currentBestMutability)
m_currentBestMutability = _mutability;
diff --git a/libsolidity/analysis/ViewPureChecker.h b/libsolidity/analysis/ViewPureChecker.h
index 0b882cd8..3db52e7e 100644
--- a/libsolidity/analysis/ViewPureChecker.h
+++ b/libsolidity/analysis/ViewPureChecker.h
@@ -71,7 +71,6 @@ private:
ErrorReporter& m_errorReporter;
bool m_errors = false;
- bool m_enforceViewWithError = false;
StateMutability m_currentBestMutability = StateMutability::Payable;
FunctionDefinition const* m_currentFunction = nullptr;
std::map<ModifierDefinition const*, StateMutability> m_inferredMutability;
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp
index 3446be55..2f45765a 100644
--- a/libsolidity/codegen/CompilerUtils.cpp
+++ b/libsolidity/codegen/CompilerUtils.cpp
@@ -181,7 +181,7 @@ void CompilerUtils::storeInMemoryDynamic(Type const& _type, bool _padToWordBound
}
}
-void CompilerUtils::abiDecode(TypePointers const& _typeParameters, bool _fromMemory, bool _revertOnOutOfBounds)
+void CompilerUtils::abiDecode(TypePointers const& _typeParameters, bool _fromMemory)
{
/// Stack: <source_offset> <length>
if (m_context.experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2))
@@ -194,14 +194,10 @@ void CompilerUtils::abiDecode(TypePointers const& _typeParameters, bool _fromMem
}
//@todo this does not yet support nested dynamic arrays
-
- if (_revertOnOutOfBounds)
- {
- size_t encodedSize = 0;
- for (auto const& t: _typeParameters)
- encodedSize += t->decodingType()->calldataEncodedSize(true);
- m_context.appendInlineAssembly("{ if lt(len, " + to_string(encodedSize) + ") { revert(0, 0) } }", {"len"});
- }
+ size_t encodedSize = 0;
+ for (auto const& t: _typeParameters)
+ encodedSize += t->decodingType()->calldataEncodedSize(true);
+ m_context.appendInlineAssembly("{ if lt(len, " + to_string(encodedSize) + ") { revert(0, 0) } }", {"len"});
m_context << Instruction::DUP2 << Instruction::ADD;
m_context << Instruction::SWAP1;
@@ -231,26 +227,21 @@ void CompilerUtils::abiDecode(TypePointers const& _typeParameters, bool _fromMem
{
// compute data pointer
m_context << Instruction::DUP1 << Instruction::MLOAD;
- if (_revertOnOutOfBounds)
- {
- // Check that the data pointer is valid and that length times
- // item size is still inside the range.
- Whiskers templ(R"({
- if gt(ptr, 0x100000000) { revert(0, 0) }
- ptr := add(ptr, base_offset)
- let array_data_start := add(ptr, 0x20)
- if gt(array_data_start, input_end) { revert(0, 0) }
- let array_length := mload(ptr)
- if or(
- gt(array_length, 0x100000000),
- gt(add(array_data_start, mul(array_length, <item_size>)), input_end)
- ) { revert(0, 0) }
- })");
- templ("item_size", to_string(arrayType.isByteArray() ? 1 : arrayType.baseType()->calldataEncodedSize(true)));
- m_context.appendInlineAssembly(templ.render(), {"input_end", "base_offset", "offset", "ptr"});
- }
- else
- m_context << Instruction::DUP3 << Instruction::ADD;
+ // Check that the data pointer is valid and that length times
+ // item size is still inside the range.
+ Whiskers templ(R"({
+ if gt(ptr, 0x100000000) { revert(0, 0) }
+ ptr := add(ptr, base_offset)
+ let array_data_start := add(ptr, 0x20)
+ if gt(array_data_start, input_end) { revert(0, 0) }
+ let array_length := mload(ptr)
+ if or(
+ gt(array_length, 0x100000000),
+ gt(add(array_data_start, mul(array_length, <item_size>)), input_end)
+ ) { revert(0, 0) }
+ })");
+ templ("item_size", to_string(arrayType.isByteArray() ? 1 : arrayType.baseType()->calldataEncodedSize(true)));
+ m_context.appendInlineAssembly(templ.render(), {"input_end", "base_offset", "offset", "ptr"});
// stack: v1 v2 ... v(k-1) input_end base_offset current_offset v(k)
moveIntoStack(3);
m_context << u256(0x20) << Instruction::ADD;
@@ -273,30 +264,25 @@ void CompilerUtils::abiDecode(TypePointers const& _typeParameters, bool _fromMem
loadFromMemoryDynamic(IntegerType(256), !_fromMemory);
m_context << Instruction::SWAP1;
// stack: input_end base_offset next_pointer data_offset
- if (_revertOnOutOfBounds)
- m_context.appendInlineAssembly("{ if gt(data_offset, 0x100000000) { revert(0, 0) } }", {"data_offset"});
+ m_context.appendInlineAssembly("{ if gt(data_offset, 0x100000000) { revert(0, 0) } }", {"data_offset"});
m_context << Instruction::DUP3 << Instruction::ADD;
// stack: input_end base_offset next_pointer array_head_ptr
- if (_revertOnOutOfBounds)
- m_context.appendInlineAssembly(
- "{ if gt(add(array_head_ptr, 0x20), input_end) { revert(0, 0) } }",
- {"input_end", "base_offset", "next_ptr", "array_head_ptr"}
- );
+ m_context.appendInlineAssembly(
+ "{ if gt(add(array_head_ptr, 0x20), input_end) { revert(0, 0) } }",
+ {"input_end", "base_offset", "next_ptr", "array_head_ptr"}
+ );
// retrieve length
loadFromMemoryDynamic(IntegerType(256), !_fromMemory, true);
// stack: input_end base_offset next_pointer array_length data_pointer
m_context << Instruction::SWAP2;
// stack: input_end base_offset data_pointer array_length next_pointer
- if (_revertOnOutOfBounds)
- {
- unsigned itemSize = arrayType.isByteArray() ? 1 : arrayType.baseType()->calldataEncodedSize(true);
- m_context.appendInlineAssembly(R"({
- if or(
- gt(array_length, 0x100000000),
- gt(add(data_ptr, mul(array_length, )" + to_string(itemSize) + R"()), input_end)
- ) { revert(0, 0) }
- })", {"input_end", "base_offset", "data_ptr", "array_length", "next_ptr"});
- }
+ unsigned itemSize = arrayType.isByteArray() ? 1 : arrayType.baseType()->calldataEncodedSize(true);
+ m_context.appendInlineAssembly(R"({
+ if or(
+ gt(array_length, 0x100000000),
+ gt(add(data_ptr, mul(array_length, )" + to_string(itemSize) + R"()), input_end)
+ ) { revert(0, 0) }
+ })", {"input_end", "base_offset", "data_ptr", "array_length", "next_ptr"});
}
else
{
@@ -524,7 +510,7 @@ void CompilerUtils::zeroInitialiseMemoryArray(ArrayType const& _type)
codecopy(memptr, codesize(), size)
memptr := add(memptr, size)
})");
- templ("element_size", to_string(_type.baseType()->memoryHeadSize()));
+ templ("element_size", to_string(_type.isByteArray() ? 1 : _type.baseType()->memoryHeadSize()));
m_context.appendInlineAssembly(templ.render(), {"length", "memptr"});
}
else
diff --git a/libsolidity/codegen/CompilerUtils.h b/libsolidity/codegen/CompilerUtils.h
index 8e3a8a5d..0ff3ad7c 100644
--- a/libsolidity/codegen/CompilerUtils.h
+++ b/libsolidity/codegen/CompilerUtils.h
@@ -102,7 +102,7 @@ public:
/// area. Also has a hard cap of 0x100000000 for any given length/offset field.
/// Stack pre: <source_offset> <length>
/// Stack post: <value0> <value1> ... <valuen>
- void abiDecode(TypePointers const& _typeParameters, bool _fromMemory = false, bool _revertOnOutOfBounds = false);
+ void abiDecode(TypePointers const& _typeParameters, bool _fromMemory = false);
/// Copies values (of types @a _givenTypes) given on the stack to a location in memory given
/// at the stack top, encoding them according to the ABI as the given types @a _targetTypes.
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp
index ecbd0243..2e548e32 100644
--- a/libsolidity/codegen/ExpressionCompiler.cpp
+++ b/libsolidity/codegen/ExpressionCompiler.cpp
@@ -2049,7 +2049,7 @@ void ExpressionCompiler::appendExternalFunctionCall(
mstore(0x40, newMem)
})", {"start", "size"});
- utils().abiDecode(returnTypes, true, true);
+ utils().abiDecode(returnTypes, true);
}
}
diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp
index e9810fe3..e2bd6fb4 100644
--- a/libsolidity/parsing/Parser.cpp
+++ b/libsolidity/parsing/Parser.cpp
@@ -322,11 +322,18 @@ StateMutability Parser::parseStateMutability(Token::Value _token)
StateMutability stateMutability(StateMutability::NonPayable);
if (_token == Token::Payable)
stateMutability = StateMutability::Payable;
- // FIXME: constant should be removed at the next breaking release
- else if (_token == Token::View || _token == Token::Constant)
+ else if (_token == Token::View)
stateMutability = StateMutability::View;
else if (_token == Token::Pure)
stateMutability = StateMutability::Pure;
+ else if (_token == Token::Constant)
+ {
+ stateMutability = StateMutability::View;
+ parserError(
+ "The state mutability modifier \"constant\" was removed in version 0.5.0. "
+ "Use \"view\" or \"pure\" instead."
+ );
+ }
else
solAssert(false, "Invalid state mutability specifier.");
m_scanner->next();
diff --git a/scripts/bytecodecompare/storebytecode.bat b/scripts/bytecodecompare/storebytecode.bat
index e64e9276..ef20a320 100644
--- a/scripts/bytecodecompare/storebytecode.bat
+++ b/scripts/bytecodecompare/storebytecode.bat
@@ -39,4 +39,5 @@ set REPORT=%DIRECTORY%/windows.txt
cp ../report.txt %REPORT%
git add %REPORT%
git commit -a -m "Added report."
+git pull --rebase
git push origin 2>&1
diff --git a/scripts/tests.sh b/scripts/tests.sh
index d63c1fe4..7fb260bc 100755
--- a/scripts/tests.sh
+++ b/scripts/tests.sh
@@ -80,13 +80,13 @@ function download_eth()
mkdir -p /tmp/test
if grep -i trusty /etc/lsb-release >/dev/null 2>&1
then
- # built from 5ac09111bd0b6518365fe956e1bdb97a2db82af1 at 2018-04-05
- ETH_BINARY=eth_2018-04-05_trusty
- ETH_HASH="1e5e178b005e5b51f9d347df4452875ba9b53cc6"
+ # built from d661ac4fec0aeffbedcdc195f67f5ded0c798278 at 2018-06-20
+ ETH_BINARY=aleth_2018-06-20_trusty
+ ETH_HASH="54b8a5455e45b295e3a962f353ff8f1580ed106c"
else
- # built from 5ac09111bd0b6518365fe956e1bdb97a2db82af1 at 2018-04-05
- ETH_BINARY=eth_2018-04-05_artful
- ETH_HASH="eb2d0df022753bb2b442ba73e565a9babf6828d6"
+ # built from d661ac4fec0aeffbedcdc195f67f5ded0c798278 at 2018-06-20
+ ETH_BINARY=aleth_2018-06-20_artful
+ ETH_HASH="02e6c4b3d98299885e73f7db6c9e3fbe3d66d444"
fi
wget -q -O /tmp/test/eth https://github.com/ethereum/cpp-ethereum/releases/download/solidityTester/$ETH_BINARY
test "$(shasum /tmp/test/eth)" = "$ETH_HASH /tmp/test/eth"
@@ -109,9 +109,18 @@ function run_eth()
sleep 2
}
+function check_eth() {
+ printTask "Running IPC tests with $ETH_PATH..."
+ if ! hash $ETH_PATH 2>/dev/null; then
+ printError "$ETH_PATH not found"
+ exit 1
+ fi
+}
+
if [ "$IPC_ENABLED" = true ];
then
download_eth
+ check_eth
ETH_PID=$(run_eth /tmp/test)
fi
diff --git a/test/ExecutionFramework.cpp b/test/ExecutionFramework.cpp
index a24f78fb..00f5e697 100644
--- a/test/ExecutionFramework.cpp
+++ b/test/ExecutionFramework.cpp
@@ -142,6 +142,11 @@ void ExecutionFramework::sendMessage(bytes const& _data, bool _isCreation, u256
entry.data = fromHex(log.data, WhenError::Throw);
m_logs.push_back(entry);
}
+
+ if (!receipt.status.empty())
+ m_transactionSuccessful = (receipt.status == "1");
+ else
+ m_transactionSuccessful = (m_gas != m_gasUsed);
}
void ExecutionFramework::sendEther(Address const& _to, u256 const& _value)
diff --git a/test/ExecutionFramework.h b/test/ExecutionFramework.h
index 4525cbf9..cdbec81d 100644
--- a/test/ExecutionFramework.h
+++ b/test/ExecutionFramework.h
@@ -72,6 +72,7 @@ public:
)
{
compileAndRunWithoutCheck(_sourceCode, _value, _contractName, _arguments, _libraryAddresses);
+ BOOST_REQUIRE(m_transactionSuccessful);
BOOST_REQUIRE(!m_output.empty());
return m_output;
}
@@ -234,6 +235,7 @@ protected:
unsigned m_optimizeRuns = 200;
bool m_optimize = false;
bool m_showMessages = false;
+ bool m_transactionSuccessful = true;
Address m_sender;
Address m_contractAddress;
u256 m_blockNumber;
diff --git a/test/RPCSession.cpp b/test/RPCSession.cpp
index 160b0047..b9b19b2f 100644
--- a/test/RPCSession.cpp
+++ b/test/RPCSession.cpp
@@ -163,6 +163,11 @@ RPCSession::TransactionReceipt RPCSession::eth_getTransactionReceipt(string cons
receipt.gasUsed = result["gasUsed"].asString();
receipt.contractAddress = result["contractAddress"].asString();
receipt.blockNumber = result["blockNumber"].asString();
+ if (m_receiptHasStatusField)
+ {
+ BOOST_REQUIRE(!result["status"].isNull());
+ receipt.status = result["status"].asString();
+ }
for (auto const& log: result["logs"])
{
LogEntry entry;
@@ -225,7 +230,10 @@ void RPCSession::test_setChainParams(vector<string> const& _accounts)
if (test::Options::get().evmVersion() >= solidity::EVMVersion::spuriousDragon())
forks += "\"EIP158ForkBlock\": \"0x00\",\n";
if (test::Options::get().evmVersion() >= solidity::EVMVersion::byzantium())
+ {
forks += "\"byzantiumForkBlock\": \"0x00\",\n";
+ m_receiptHasStatusField = true;
+ }
if (test::Options::get().evmVersion() >= solidity::EVMVersion::constantinople())
forks += "\"constantinopleForkBlock\": \"0x00\",\n";
static string const c_configString = R"(
@@ -247,8 +255,8 @@ void RPCSession::test_setChainParams(vector<string> const& _accounts)
"gasLimit": "0x1000000000000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x0000000000000042",
- "difficulty": "1"
- },
+ "difficulty": "131072"
+ },
"accounts": {
"0000000000000000000000000000000000000001": { "wei": "1", "precompiled": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
"0000000000000000000000000000000000000002": { "wei": "1", "precompiled": { "name": "sha256", "linear": { "base": 60, "word": 12 } } },
diff --git a/test/RPCSession.h b/test/RPCSession.h
index 63f1dd21..5af2e26a 100644
--- a/test/RPCSession.h
+++ b/test/RPCSession.h
@@ -99,6 +99,8 @@ public:
std::string contractAddress;
std::vector<LogEntry> logEntries;
std::string blockNumber;
+ /// note: pre-byzantium the status field will be empty
+ std::string status;
};
static RPCSession& instance(std::string const& _path);
@@ -136,6 +138,7 @@ private:
unsigned m_maxMiningTime = 6000000; // 600 seconds
unsigned m_sleepTime = 10; // 10 milliseconds
unsigned m_successfulMineRuns = 0;
+ bool m_receiptHasStatusField = false;
std::vector<std::string> m_accounts;
};
diff --git a/test/compilationTests/MultiSigWallet/Factory.sol b/test/compilationTests/MultiSigWallet/Factory.sol
index f7a96cbd..f37d230f 100644
--- a/test/compilationTests/MultiSigWallet/Factory.sol
+++ b/test/compilationTests/MultiSigWallet/Factory.sol
@@ -10,7 +10,7 @@ contract Factory {
/// @return Returns number of instantiations by creator.
function getInstantiationCount(address creator)
public
- constant
+ view
returns (uint)
{
return instantiations[creator].length;
diff --git a/test/compilationTests/MultiSigWallet/MultiSigWallet.sol b/test/compilationTests/MultiSigWallet/MultiSigWallet.sol
index e534d09a..6b10f17e 100644
--- a/test/compilationTests/MultiSigWallet/MultiSigWallet.sol
+++ b/test/compilationTests/MultiSigWallet/MultiSigWallet.sol
@@ -241,7 +241,7 @@ contract MultiSigWallet {
/// @return Confirmation status.
function isConfirmed(uint transactionId)
public
- constant
+ view
returns (bool)
{
uint count = 0;
@@ -285,7 +285,7 @@ contract MultiSigWallet {
/// @return Number of confirmations.
function getConfirmationCount(uint transactionId)
public
- constant
+ view
returns (uint count)
{
for (uint i=0; i<owners.length; i++)
@@ -299,7 +299,7 @@ contract MultiSigWallet {
/// @return Total number of transactions after filters are applied.
function getTransactionCount(bool pending, bool executed)
public
- constant
+ view
returns (uint count)
{
for (uint i=0; i<transactionCount; i++)
@@ -312,7 +312,7 @@ contract MultiSigWallet {
/// @return List of owner addresses.
function getOwners()
public
- constant
+ view
returns (address[])
{
return owners;
@@ -323,7 +323,7 @@ contract MultiSigWallet {
/// @return Returns array of owner addresses.
function getConfirmations(uint transactionId)
public
- constant
+ view
returns (address[] _confirmations)
{
address[] memory confirmationsTemp = new address[](owners.length);
@@ -347,7 +347,7 @@ contract MultiSigWallet {
/// @return Returns array of transaction IDs.
function getTransactionIds(uint from, uint to, bool pending, bool executed)
public
- constant
+ view
returns (uint[] _transactionIds)
{
uint[] memory transactionIdsTemp = new uint[](transactionCount);
diff --git a/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol b/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol
index 0ca9fa54..3a68f662 100644
--- a/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol
+++ b/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol
@@ -85,7 +85,7 @@ contract MultiSigWalletWithDailyLimit is MultiSigWallet {
/// @return Returns amount.
function calcMaxWithdraw()
public
- constant
+ view
returns (uint)
{
if (now > lastDay + 24 hours)
diff --git a/test/compilationTests/MultiSigWallet/TestToken.sol b/test/compilationTests/MultiSigWallet/TestToken.sol
index 69727cbd..df195c58 100644
--- a/test/compilationTests/MultiSigWallet/TestToken.sol
+++ b/test/compilationTests/MultiSigWallet/TestToken.sol
@@ -59,7 +59,7 @@ contract TestToken {
}
function allowance(address _owner, address _spender)
- constant
+ view
public
returns (uint256 remaining)
{
@@ -67,7 +67,7 @@ contract TestToken {
}
function balanceOf(address _owner)
- constant
+ view
public
returns (uint256 balance)
{
diff --git a/test/compilationTests/corion/ico.sol b/test/compilationTests/corion/ico.sol
index 54305d41..b6d8e035 100644
--- a/test/compilationTests/corion/ico.sol
+++ b/test/compilationTests/corion/ico.sol
@@ -81,7 +81,7 @@ contract ico is safeMath {
}
}
- function ICObonus() public constant returns(uint256 bonus) {
+ function ICObonus() public view returns(uint256 bonus) {
/*
Query of current bonus
@@ -113,7 +113,7 @@ contract ico is safeMath {
return true;
}
- function checkInterest(address addr) public constant returns(uint256 amount) {
+ function checkInterest(address addr) public view returns(uint256 amount) {
/*
Query of compound interest
@@ -355,7 +355,7 @@ contract ico is safeMath {
}
}
- function getIcoReward(uint256 value) public constant returns (uint256 reward) {
+ function getIcoReward(uint256 value) public view returns (uint256 reward) {
/*
Expected token volume at token purchase
@@ -368,7 +368,7 @@ contract ico is safeMath {
if ( reward < 5e6) { return 0; }
}
- function isICO() public constant returns (bool success) {
+ function isICO() public view returns (bool success) {
return startBlock <= block.number && block.number <= icoDelay && ( ! aborted ) && ( ! closed );
}
diff --git a/test/compilationTests/corion/module.sol b/test/compilationTests/corion/module.sol
index 5f13215f..362283ef 100644
--- a/test/compilationTests/corion/module.sol
+++ b/test/compilationTests/corion/module.sol
@@ -2,7 +2,7 @@ pragma solidity ^0.4.11;
contract abstractModuleHandler {
function transfer(address from, address to, uint256 value, bool fee) external returns (bool success) {}
- function balanceOf(address owner) public constant returns (bool success, uint256 value) {}
+ function balanceOf(address owner) public view returns (bool success, uint256 value) {}
}
contract module {
@@ -127,7 +127,7 @@ contract module {
if ( moduleStatus != status.Connected ) { return false; }
return addr == moduleHandlerAddress;
}
- function isActive() public constant returns (bool success, bool active) {
+ function isActive() public view returns (bool success, bool active) {
/*
Check self for ready for functions or not.
diff --git a/test/compilationTests/corion/moduleHandler.sol b/test/compilationTests/corion/moduleHandler.sol
index e77d9e09..b3d03c2a 100644
--- a/test/compilationTests/corion/moduleHandler.sol
+++ b/test/compilationTests/corion/moduleHandler.sol
@@ -16,7 +16,7 @@ contract abstractModule {
function disconnectModule() external returns (bool success) {}
function replaceModule(address addr) external returns (bool success) {}
function disableModule(bool forever) external returns (bool success) {}
- function isActive() public constant returns (bool success) {}
+ function isActive() public view returns (bool success) {}
function replaceModuleHandler(address newHandler) external returns (bool success) {}
function transferEvent(address from, address to, uint256 value) external returns (bool success) {}
function newSchellingRoundEvent(uint256 roundID, uint256 reward) external returns (bool success) {}
@@ -81,7 +81,7 @@ contract moduleHandler is multiOwner, announcementTypes {
}
modules[id] = input;
}
- function getModuleAddressByName(string name) public constant returns( bool success, bool found, address addr ) {
+ function getModuleAddressByName(string name) public view returns( bool success, bool found, address addr ) {
/*
Search by name for module. The result is an Ethereum address.
@@ -94,7 +94,7 @@ contract moduleHandler is multiOwner, announcementTypes {
if ( _success && _found ) { return (true, true, modules[_id].addr); }
return (true, false, address(0x00));
}
- function getModuleIDByHash(bytes32 hashOfName) public constant returns( bool success, bool found, uint256 id ) {
+ function getModuleIDByHash(bytes32 hashOfName) public view returns( bool success, bool found, uint256 id ) {
/*
Search by hash of name in the module array. The result is an index array.
@@ -109,7 +109,7 @@ contract moduleHandler is multiOwner, announcementTypes {
}
return (true, false, 0);
}
- function getModuleIDByName(string name) public constant returns( bool success, bool found, uint256 id ) {
+ function getModuleIDByName(string name) public view returns( bool success, bool found, uint256 id ) {
/*
Search by name for module. The result is an index array.
@@ -125,7 +125,7 @@ contract moduleHandler is multiOwner, announcementTypes {
}
return (true, false, 0);
}
- function getModuleIDByAddress(address addr) public constant returns( bool success, bool found, uint256 id ) {
+ function getModuleIDByAddress(address addr) public view returns( bool success, bool found, uint256 id ) {
/*
Search by ethereum address for module. The result is an index array.
@@ -298,7 +298,7 @@ contract moduleHandler is multiOwner, announcementTypes {
}
return true;
}
- function balanceOf(address owner) public constant returns (bool success, uint256 value) {
+ function balanceOf(address owner) public view returns (bool success, uint256 value) {
/*
Query of token balance.
@@ -310,7 +310,7 @@ contract moduleHandler is multiOwner, announcementTypes {
require( _success && _found );
return (true, token(modules[_id].addr).balanceOf(owner));
}
- function totalSupply() public constant returns (bool success, uint256 value) {
+ function totalSupply() public view returns (bool success, uint256 value) {
/*
Query of the whole token amount.
@@ -321,7 +321,7 @@ contract moduleHandler is multiOwner, announcementTypes {
require( _success && _found );
return (true, token(modules[_id].addr).totalSupply());
}
- function isICO() public constant returns (bool success, bool ico) {
+ function isICO() public view returns (bool success, bool ico) {
/*
Query of ICO state
@@ -332,7 +332,7 @@ contract moduleHandler is multiOwner, announcementTypes {
require( _success && _found );
return (true, token(modules[_id].addr).isICO());
}
- function getCurrentSchellingRoundID() public constant returns (bool success, uint256 round) {
+ function getCurrentSchellingRoundID() public view returns (bool success, uint256 round) {
/*
Query of number of the actual Schelling round.
diff --git a/test/compilationTests/corion/multiOwner.sol b/test/compilationTests/corion/multiOwner.sol
index 2b8a46b9..78f7109c 100644
--- a/test/compilationTests/corion/multiOwner.sol
+++ b/test/compilationTests/corion/multiOwner.sol
@@ -38,13 +38,13 @@ contract multiOwner is safeMath {
/*
Constants
*/
- function ownersForChange() public constant returns (uint256 owners) {
+ function ownersForChange() public view returns (uint256 owners) {
return ownerCount * 75 / 100;
}
- function calcDoHash(string job, bytes32 data) public constant returns (bytes32 hash) {
+ function calcDoHash(string job, bytes32 data) public pure returns (bytes32 hash) {
return keccak256(abi.encodePacked(job, data));
}
- function validDoHash(bytes32 doHash) public constant returns (bool valid) {
+ function validDoHash(bytes32 doHash) public view returns (bool valid) {
return doDB[doHash].length > 0;
}
/*
diff --git a/test/compilationTests/corion/premium.sol b/test/compilationTests/corion/premium.sol
index 5a80ecc6..695dd344 100644
--- a/test/compilationTests/corion/premium.sol
+++ b/test/compilationTests/corion/premium.sol
@@ -140,7 +140,7 @@ contract premium is module, safeMath {
emit Approval(msg.sender, spender, amount);
}
- function allowance(address owner, address spender) constant returns (uint256 remaining, uint256 nonce) {
+ function allowance(address owner, address spender) view returns (uint256 remaining, uint256 nonce) {
/*
Get the quantity of tokens given to be used
@@ -319,7 +319,7 @@ contract premium is module, safeMath {
return _codeLength > 0;
}
- function balanceOf(address owner) constant returns (uint256 value) {
+ function balanceOf(address owner) view returns (uint256 value) {
/*
Token balance query
@@ -329,7 +329,7 @@ contract premium is module, safeMath {
return db.balanceOf(owner);
}
- function totalSupply() constant returns (uint256 value) {
+ function totalSupply() view returns (uint256 value) {
/*
Total token quantity query
diff --git a/test/compilationTests/corion/provider.sol b/test/compilationTests/corion/provider.sol
index 0c1f69e5..16546809 100644
--- a/test/compilationTests/corion/provider.sol
+++ b/test/compilationTests/corion/provider.sol
@@ -147,7 +147,7 @@ contract provider is module, safeMath, announcementTypes {
else { return false; }
return true;
}
- function getUserDetails(address addr, uint256 schellingRound) public constant returns (address ProviderAddress, uint256 ProviderHeight, uint256 ConnectedOn, uint256 value) {
+ function getUserDetails(address addr, uint256 schellingRound) public view returns (address ProviderAddress, uint256 ProviderHeight, uint256 ConnectedOn, uint256 value) {
/*
Collecting the datas of the client.
@@ -168,7 +168,7 @@ contract provider is module, safeMath, announcementTypes {
value = clients[addr].supply[schellingRound];
}
}
- function rightForInterest(uint256 value, bool priv) internal returns (bool) {
+ function rightForInterest(uint256 value, bool priv) internal view returns (bool) {
/*
the share from the token emission.
In case is a private provider it has to be checked if it has enough connected capital to be able to accept share from the token emission.
@@ -299,7 +299,7 @@ contract provider is module, safeMath, announcementTypes {
providers[addr].data[currHeight].currentRate = rate;
emit EProviderDetailsChanged(addr, currHeight, website, country, info, rate, admin);
}
- function getProviderInfo(address addr, uint256 height) public constant returns (string name, string website, string country, string info, uint256 create) {
+ function getProviderInfo(address addr, uint256 height) public view returns (string name, string website, string country, string info, uint256 create) {
/*
for the infos of the provider.
In case the height is unknown then the system will use the last known height.
@@ -321,7 +321,7 @@ contract provider is module, safeMath, announcementTypes {
info = providers[addr].data[height].info;
create = providers[addr].data[height].create;
}
- function getProviderDetails(address addr, uint256 height) public constant returns (uint8 rate, bool isForRent, uint256 clientsCount, bool priv, bool getInterest, bool valid) {
+ function getProviderDetails(address addr, uint256 height) public view returns (uint8 rate, bool isForRent, uint256 clientsCount, bool priv, bool getInterest, bool valid) {
/*
Asking for the datas of the provider.
In case the height is unknown then the system will use the last known height.
@@ -345,7 +345,7 @@ contract provider is module, safeMath, announcementTypes {
getInterest = rightForInterest(getProviderCurrentSupply(addr), providers[addr].data[height].priv );
valid = providers[addr].data[height].valid;
}
- function getProviderCurrentSupply(address addr) internal returns (uint256) {
+ function getProviderCurrentSupply(address addr) internal view returns (uint256) {
/*
Inner function for polling the current height and the current quantity of the connected capital of the schelling round.
@@ -469,7 +469,7 @@ contract provider is module, safeMath, announcementTypes {
delete clients[msg.sender].providerConnected;
emit EClientLost(msg.sender, provider, currHeight, bal);
}
- function checkReward(address addr) public constant returns (uint256 reward) {
+ function checkReward(address addr) public returns (uint256 reward) {
/*
Polling the share from the token emission for clients and for providers.
diff --git a/test/compilationTests/corion/publisher.sol b/test/compilationTests/corion/publisher.sol
index 0e8f825f..f7d8fdea 100644
--- a/test/compilationTests/corion/publisher.sol
+++ b/test/compilationTests/corion/publisher.sol
@@ -70,7 +70,7 @@ contract publisher is announcementTypes, module, safeMath {
super.registerModuleHandler(moduleHandler);
}
- function Announcements(uint256 id) public constant returns (uint256 Type, uint256 Start, uint256 End, bool Closed, string Announcement, string Link, bool Opposited, string _str, uint256 _uint, address _addr) {
+ function Announcements(uint256 id) public view returns (uint256 Type, uint256 Start, uint256 End, bool Closed, string Announcement, string Link, bool Opposited, string _str, uint256 _uint, address _addr) {
/*
Announcement data query
@@ -101,7 +101,7 @@ contract publisher is announcementTypes, module, safeMath {
_addr = announcements[id]._addr;
}
- function checkOpposited(uint256 weight, bool oppositable) public constant returns (bool success) {
+ function checkOpposited(uint256 weight, bool oppositable) public view returns (bool success) {
/*
Veto check
diff --git a/test/compilationTests/corion/schelling.sol b/test/compilationTests/corion/schelling.sol
index f8c36fc5..74f8af9d 100644
--- a/test/compilationTests/corion/schelling.sol
+++ b/test/compilationTests/corion/schelling.sol
@@ -54,7 +54,7 @@ contract schellingDB is safeMath, schellingVars {
Funds
*/
mapping(address => uint256) private funds;
- function getFunds(address _owner) constant returns(bool, uint256) {
+ function getFunds(address _owner) view returns(bool, uint256) {
return (true, funds[_owner]);
}
function setFunds(address _owner, uint256 _amount) isOwner external returns(bool) {
@@ -65,7 +65,7 @@ contract schellingDB is safeMath, schellingVars {
Rounds
*/
_rounds[] private rounds;
- function getRound(uint256 _id) constant returns(bool, uint256, uint256, uint256, uint256, bool) {
+ function getRound(uint256 _id) view returns(bool, uint256, uint256, uint256, uint256, bool) {
if ( rounds.length <= _id ) { return (false, 0, 0, 0, 0, false); }
else { return (true, rounds[_id].totalAboveWeight, rounds[_id].totalBelowWeight, rounds[_id].reward, rounds[_id].blockHeight, rounds[_id].voted); }
}
@@ -76,14 +76,14 @@ contract schellingDB is safeMath, schellingVars {
rounds[_id] = _rounds(_totalAboveWeight, _totalBelowWeight, _reward, _blockHeight, _voted);
return true;
}
- function getCurrentRound() constant returns(bool, uint256) {
+ function getCurrentRound() view returns(bool, uint256) {
return (true, rounds.length-1);
}
/*
Voter
*/
mapping(address => _voter) private voter;
- function getVoter(address _owner) constant returns(bool success, uint256 roundID,
+ function getVoter(address _owner) view returns(bool success, uint256 roundID,
bytes32 hash, voterStatus status, bool voteResult, uint256 rewards) {
roundID = voter[_owner].roundID;
hash = voter[_owner].hash;
@@ -106,7 +106,7 @@ contract schellingDB is safeMath, schellingVars {
Schelling Token emission
*/
mapping(uint256 => uint256) private schellingExpansion;
- function getSchellingExpansion(uint256 _id) constant returns(bool, uint256) {
+ function getSchellingExpansion(uint256 _id) view returns(bool, uint256) {
return (true, schellingExpansion[_id]);
}
function setSchellingExpansion(uint256 _id, uint256 _expansion) isOwner external returns(bool) {
@@ -121,7 +121,7 @@ contract schellingDB is safeMath, schellingVars {
currentSchellingRound = _id;
return true;
}
- function getCurrentSchellingRound() constant returns(bool, uint256) {
+ function getCurrentSchellingRound() view returns(bool, uint256) {
return (true, currentSchellingRound);
}
}
@@ -183,7 +183,7 @@ contract schelling is module, announcementTypes, schellingVars {
voter.rewards
) );
}
- function getVoter(address addr) internal returns (_voter) {
+ function getVoter(address addr) internal view returns (_voter) {
(bool a, uint256 b, bytes32 c, schellingVars.voterStatus d, bool e, uint256 f) = db.getVoter(addr);
require( a );
return _voter(b, c, d, e, f);
@@ -221,7 +221,7 @@ contract schelling is module, announcementTypes, schellingVars {
function setCurrentSchellingRound(uint256 id) internal {
require( db.setCurrentSchellingRound(id) );
}
- function getCurrentSchellingRound() internal returns(uint256) {
+ function getCurrentSchellingRound() internal view returns(uint256) {
(bool a, uint256 b) = db.getCurrentSchellingRound();
require( a );
return b;
@@ -229,7 +229,7 @@ contract schelling is module, announcementTypes, schellingVars {
function setSchellingExpansion(uint256 id, uint256 amount) internal {
require( db.setSchellingExpansion(id, amount) );
}
- function getSchellingExpansion(uint256 id) internal returns(uint256) {
+ function getSchellingExpansion(uint256 id) internal view returns(uint256) {
(bool a, uint256 b) = db.getSchellingExpansion(id);
require( a );
return b;
@@ -417,7 +417,7 @@ contract schelling is module, announcementTypes, schellingVars {
setVoter(msg.sender, voter);
}
- function checkReward() public constant returns (uint256 reward) {
+ function checkReward() public view returns (uint256 reward) {
/*
Withdraw of the amount of the prize (it’s only information).
@@ -496,7 +496,7 @@ contract schelling is module, announcementTypes, schellingVars {
require( moduleHandler(moduleHandlerAddress).transfer(address(this), msg.sender, funds, true) );
}
- function getCurrentSchellingRoundID() public constant returns (uint256) {
+ function getCurrentSchellingRoundID() public view returns (uint256) {
/*
Number of actual Schelling round.
@@ -504,7 +504,7 @@ contract schelling is module, announcementTypes, schellingVars {
*/
return getCurrentSchellingRound();
}
- function getSchellingRound(uint256 id) public constant returns (uint256 expansion) {
+ function getSchellingRound(uint256 id) public view returns (uint256 expansion) {
/*
Amount of token emission of the Schelling round.
diff --git a/test/compilationTests/corion/token.sol b/test/compilationTests/corion/token.sol
index 0709baca..fecbce3d 100644
--- a/test/compilationTests/corion/token.sol
+++ b/test/compilationTests/corion/token.sol
@@ -155,7 +155,7 @@ contract token is safeMath, module, announcementTypes {
emit Approval(msg.sender, spender, amount);
}
- function allowance(address owner, address spender) constant returns (uint256 remaining, uint256 nonce) {
+ function allowance(address owner, address spender) view returns (uint256 remaining, uint256 nonce) {
/*
Get the quantity of tokens given to be used
@@ -386,7 +386,7 @@ contract token is safeMath, module, announcementTypes {
}
}
- function getTransactionFee(uint256 value) public constant returns (bool success, uint256 fee) {
+ function getTransactionFee(uint256 value) public view returns (bool success, uint256 fee) {
/*
Transaction fee query.
@@ -472,7 +472,7 @@ contract token is safeMath, module, announcementTypes {
return _codeLength > 0;
}
- function balanceOf(address owner) constant returns (uint256 value) {
+ function balanceOf(address owner) view returns (uint256 value) {
/*
Token balance query
@@ -483,7 +483,7 @@ contract token is safeMath, module, announcementTypes {
return db.balanceOf(owner);
}
- function totalSupply() constant returns (uint256 value) {
+ function totalSupply() view returns (uint256 value) {
/*
Total token quantity query
diff --git a/test/compilationTests/corion/tokenDB.sol b/test/compilationTests/corion/tokenDB.sol
index 6de1b6c3..40304a54 100644
--- a/test/compilationTests/corion/tokenDB.sol
+++ b/test/compilationTests/corion/tokenDB.sol
@@ -61,7 +61,7 @@ contract tokenDB is safeMath, ownedDB {
return true;
}
- function getAllowance(address owner, address spender) constant returns(bool success, uint256 remaining, uint256 nonce) {
+ function getAllowance(address owner, address spender) view returns(bool success, uint256 remaining, uint256 nonce) {
/*
Get allowance from the database.
diff --git a/test/compilationTests/gnosis/Events/CategoricalEvent.sol b/test/compilationTests/gnosis/Events/CategoricalEvent.sol
index 0f5196e8..4815e315 100644
--- a/test/compilationTests/gnosis/Events/CategoricalEvent.sol
+++ b/test/compilationTests/gnosis/Events/CategoricalEvent.sol
@@ -45,7 +45,7 @@ contract CategoricalEvent is Event {
/// @return Event hash
function getEventHash()
public
- constant
+ view
returns (bytes32)
{
return keccak256(abi.encodePacked(collateralToken, oracle, outcomeTokens.length));
diff --git a/test/compilationTests/gnosis/Events/Event.sol b/test/compilationTests/gnosis/Events/Event.sol
index a6edb778..177f61df 100644
--- a/test/compilationTests/gnosis/Events/Event.sol
+++ b/test/compilationTests/gnosis/Events/Event.sol
@@ -90,7 +90,7 @@ contract Event {
/// @return Outcome count
function getOutcomeCount()
public
- constant
+ view
returns (uint8)
{
return uint8(outcomeTokens.length);
@@ -100,7 +100,7 @@ contract Event {
/// @return Outcome tokens
function getOutcomeTokens()
public
- constant
+ view
returns (OutcomeToken[])
{
return outcomeTokens;
@@ -110,7 +110,7 @@ contract Event {
/// @return Outcome token distribution
function getOutcomeTokenDistribution(address owner)
public
- constant
+ view
returns (uint[] outcomeTokenDistribution)
{
outcomeTokenDistribution = new uint[](outcomeTokens.length);
@@ -120,7 +120,7 @@ contract Event {
/// @dev Calculates and returns event hash
/// @return Event hash
- function getEventHash() public constant returns (bytes32);
+ function getEventHash() public view returns (bytes32);
/// @dev Exchanges sender's winning outcome tokens for collateral tokens
/// @return Sender's winnings
diff --git a/test/compilationTests/gnosis/Events/ScalarEvent.sol b/test/compilationTests/gnosis/Events/ScalarEvent.sol
index d5cbef14..832c2ab1 100644
--- a/test/compilationTests/gnosis/Events/ScalarEvent.sol
+++ b/test/compilationTests/gnosis/Events/ScalarEvent.sol
@@ -79,7 +79,7 @@ contract ScalarEvent is Event {
/// @return Event hash
function getEventHash()
public
- constant
+ view
returns (bytes32)
{
return keccak256(abi.encodePacked(collateralToken, oracle, lowerBound, upperBound));
diff --git a/test/compilationTests/gnosis/MarketMakers/LMSRMarketMaker.sol b/test/compilationTests/gnosis/MarketMakers/LMSRMarketMaker.sol
index 344dd8d2..cf4fcd7d 100644
--- a/test/compilationTests/gnosis/MarketMakers/LMSRMarketMaker.sol
+++ b/test/compilationTests/gnosis/MarketMakers/LMSRMarketMaker.sol
@@ -24,7 +24,7 @@ contract LMSRMarketMaker is MarketMaker {
/// @return Cost
function calcCost(Market market, uint8 outcomeTokenIndex, uint outcomeTokenCount)
public
- constant
+ view
returns (uint cost)
{
require(market.eventContract().getOutcomeCount() > 1);
@@ -59,7 +59,7 @@ contract LMSRMarketMaker is MarketMaker {
/// @return Profit
function calcProfit(Market market, uint8 outcomeTokenIndex, uint outcomeTokenCount)
public
- constant
+ view
returns (uint profit)
{
require(market.eventContract().getOutcomeCount() > 1);
@@ -85,7 +85,7 @@ contract LMSRMarketMaker is MarketMaker {
/// @return Marginal price of an outcome as a fixed point number
function calcMarginalPrice(Market market, uint8 outcomeTokenIndex)
public
- constant
+ view
returns (uint price)
{
require(market.eventContract().getOutcomeCount() > 1);
@@ -110,7 +110,7 @@ contract LMSRMarketMaker is MarketMaker {
/// @return Cost level
function calcCostLevel(int logN, int[] netOutcomeTokensSold, uint funding)
private
- constant
+ view
returns(int costLevel)
{
// The cost function is C = b * log(sum(exp(q/b) for q in quantities)).
@@ -131,7 +131,7 @@ contract LMSRMarketMaker is MarketMaker {
/// @return A result structure composed of the sum, the offset used, and the summand associated with the supplied index
function sumExpOffset(int logN, int[] netOutcomeTokensSold, uint funding, uint8 outcomeIndex)
private
- constant
+ view
returns (uint sum, int offset, uint outcomeExpTerm)
{
// Naive calculation of this causes an overflow
@@ -170,7 +170,7 @@ contract LMSRMarketMaker is MarketMaker {
/// @return Net outcome tokens sold by market
function getNetOutcomeTokensSold(Market market)
private
- constant
+ view
returns (int[] quantities)
{
quantities = new int[](market.eventContract().getOutcomeCount());
diff --git a/test/compilationTests/gnosis/MarketMakers/MarketMaker.sol b/test/compilationTests/gnosis/MarketMakers/MarketMaker.sol
index 3162ce64..ef5942cd 100644
--- a/test/compilationTests/gnosis/MarketMakers/MarketMaker.sol
+++ b/test/compilationTests/gnosis/MarketMakers/MarketMaker.sol
@@ -8,7 +8,7 @@ contract MarketMaker {
/*
* Public functions
*/
- function calcCost(Market market, uint8 outcomeTokenIndex, uint outcomeTokenCount) public constant returns (uint);
- function calcProfit(Market market, uint8 outcomeTokenIndex, uint outcomeTokenCount) public constant returns (uint);
- function calcMarginalPrice(Market market, uint8 outcomeTokenIndex) public constant returns (uint);
+ function calcCost(Market market, uint8 outcomeTokenIndex, uint outcomeTokenCount) public view returns (uint);
+ function calcProfit(Market market, uint8 outcomeTokenIndex, uint outcomeTokenCount) public view returns (uint);
+ function calcMarginalPrice(Market market, uint8 outcomeTokenIndex) public view returns (uint);
}
diff --git a/test/compilationTests/gnosis/Markets/Market.sol b/test/compilationTests/gnosis/Markets/Market.sol
index 635b14db..7bcecfe5 100644
--- a/test/compilationTests/gnosis/Markets/Market.sol
+++ b/test/compilationTests/gnosis/Markets/Market.sol
@@ -43,5 +43,5 @@ contract Market {
function buy(uint8 outcomeTokenIndex, uint outcomeTokenCount, uint maxCost) public returns (uint);
function sell(uint8 outcomeTokenIndex, uint outcomeTokenCount, uint minProfit) public returns (uint);
function shortSell(uint8 outcomeTokenIndex, uint outcomeTokenCount, uint minProfit) public returns (uint);
- function calcMarketFee(uint outcomeTokenCost) public constant returns (uint);
+ function calcMarketFee(uint outcomeTokenCost) public view returns (uint);
}
diff --git a/test/compilationTests/gnosis/Markets/StandardMarket.sol b/test/compilationTests/gnosis/Markets/StandardMarket.sol
index 84f30386..0a9f77db 100644
--- a/test/compilationTests/gnosis/Markets/StandardMarket.sol
+++ b/test/compilationTests/gnosis/Markets/StandardMarket.sol
@@ -186,7 +186,7 @@ contract StandardMarket is Market {
/// @return Fee for trade
function calcMarketFee(uint outcomeTokenCost)
public
- constant
+ view
returns (uint)
{
return outcomeTokenCost * fee / FEE_RANGE;
diff --git a/test/compilationTests/gnosis/Oracles/CentralizedOracle.sol b/test/compilationTests/gnosis/Oracles/CentralizedOracle.sol
index 362c514c..de182a61 100644
--- a/test/compilationTests/gnosis/Oracles/CentralizedOracle.sol
+++ b/test/compilationTests/gnosis/Oracles/CentralizedOracle.sol
@@ -72,7 +72,7 @@ contract CentralizedOracle is Oracle {
/// @return Is outcome set?
function isOutcomeSet()
public
- constant
+ view
returns (bool)
{
return isSet;
@@ -82,7 +82,7 @@ contract CentralizedOracle is Oracle {
/// @return Outcome
function getOutcome()
public
- constant
+ view
returns (int)
{
return outcome;
diff --git a/test/compilationTests/gnosis/Oracles/DifficultyOracle.sol b/test/compilationTests/gnosis/Oracles/DifficultyOracle.sol
index 94fc70ca..3d801da1 100644
--- a/test/compilationTests/gnosis/Oracles/DifficultyOracle.sol
+++ b/test/compilationTests/gnosis/Oracles/DifficultyOracle.sol
@@ -44,7 +44,7 @@ contract DifficultyOracle is Oracle {
/// @return Is outcome set?
function isOutcomeSet()
public
- constant
+ view
returns (bool)
{
// Difficulty is always bigger than 0
@@ -55,7 +55,7 @@ contract DifficultyOracle is Oracle {
/// @return Outcome
function getOutcome()
public
- constant
+ view
returns (int)
{
return int(difficulty);
diff --git a/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol b/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol
index 7105f247..cf851f5b 100644
--- a/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol
+++ b/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol
@@ -151,7 +151,7 @@ contract FutarchyOracle is Oracle {
/// @return Is outcome set?
function isOutcomeSet()
public
- constant
+ view
returns (bool)
{
return isSet;
@@ -161,7 +161,7 @@ contract FutarchyOracle is Oracle {
/// @return Outcome
function getOutcome()
public
- constant
+ view
returns (int)
{
return int(winningMarketIndex);
diff --git a/test/compilationTests/gnosis/Oracles/MajorityOracle.sol b/test/compilationTests/gnosis/Oracles/MajorityOracle.sol
index 24cf9dea..d8097370 100644
--- a/test/compilationTests/gnosis/Oracles/MajorityOracle.sol
+++ b/test/compilationTests/gnosis/Oracles/MajorityOracle.sol
@@ -32,6 +32,7 @@ contract MajorityOracle is Oracle {
/// @return Outcome
function getStatusAndOutcome()
public
+ view
returns (bool outcomeSet, int outcome)
{
uint i;
@@ -69,7 +70,7 @@ contract MajorityOracle is Oracle {
/// @return Is outcome set?
function isOutcomeSet()
public
- constant
+ view
returns (bool)
{
(bool outcomeSet, ) = getStatusAndOutcome();
@@ -80,7 +81,7 @@ contract MajorityOracle is Oracle {
/// @return Outcome
function getOutcome()
public
- constant
+ view
returns (int)
{
(, int winningOutcome) = getStatusAndOutcome();
diff --git a/test/compilationTests/gnosis/Oracles/Oracle.sol b/test/compilationTests/gnosis/Oracles/Oracle.sol
index cf96eb9f..450aff00 100644
--- a/test/compilationTests/gnosis/Oracles/Oracle.sol
+++ b/test/compilationTests/gnosis/Oracles/Oracle.sol
@@ -4,6 +4,6 @@ pragma solidity ^0.4.11;
/// @title Abstract oracle contract - Functions to be implemented by oracles
contract Oracle {
- function isOutcomeSet() public constant returns (bool);
- function getOutcome() public constant returns (int);
+ function isOutcomeSet() public view returns (bool);
+ function getOutcome() public view returns (int);
}
diff --git a/test/compilationTests/gnosis/Oracles/SignedMessageOracle.sol b/test/compilationTests/gnosis/Oracles/SignedMessageOracle.sol
index 121824ff..284f420e 100644
--- a/test/compilationTests/gnosis/Oracles/SignedMessageOracle.sol
+++ b/test/compilationTests/gnosis/Oracles/SignedMessageOracle.sol
@@ -84,7 +84,7 @@ contract SignedMessageOracle is Oracle {
/// @return Is outcome set?
function isOutcomeSet()
public
- constant
+ view
returns (bool)
{
return isSet;
@@ -94,7 +94,7 @@ contract SignedMessageOracle is Oracle {
/// @return Outcome
function getOutcome()
public
- constant
+ view
returns (int)
{
return outcome;
diff --git a/test/compilationTests/gnosis/Oracles/UltimateOracle.sol b/test/compilationTests/gnosis/Oracles/UltimateOracle.sol
index dd66c9ab..b7cc231c 100644
--- a/test/compilationTests/gnosis/Oracles/UltimateOracle.sol
+++ b/test/compilationTests/gnosis/Oracles/UltimateOracle.sol
@@ -144,6 +144,7 @@ contract UltimateOracle is Oracle {
/// @return Is challenge period over?
function isChallengePeriodOver()
public
+ view
returns (bool)
{
return forwardedOutcomeSetTimestamp != 0 && now.sub(forwardedOutcomeSetTimestamp) > challengePeriod;
@@ -153,6 +154,7 @@ contract UltimateOracle is Oracle {
/// @return Is front runner period over?
function isFrontRunnerPeriodOver()
public
+ view
returns (bool)
{
return frontRunnerSetTimestamp != 0 && now.sub(frontRunnerSetTimestamp) > frontRunnerPeriod;
@@ -162,6 +164,7 @@ contract UltimateOracle is Oracle {
/// @return Is challenged?
function isChallenged()
public
+ view
returns (bool)
{
return frontRunnerSetTimestamp != 0;
@@ -171,7 +174,7 @@ contract UltimateOracle is Oracle {
/// @return Is outcome set?
function isOutcomeSet()
public
- constant
+ view
returns (bool)
{
return isChallengePeriodOver() && !isChallenged()
@@ -182,7 +185,7 @@ contract UltimateOracle is Oracle {
/// @return Outcome
function getOutcome()
public
- constant
+ view
returns (int)
{
if (isFrontRunnerPeriodOver())
diff --git a/test/compilationTests/gnosis/Tokens/StandardToken.sol b/test/compilationTests/gnosis/Tokens/StandardToken.sol
index b7d0d37a..5fb20210 100644
--- a/test/compilationTests/gnosis/Tokens/StandardToken.sol
+++ b/test/compilationTests/gnosis/Tokens/StandardToken.sol
@@ -73,7 +73,7 @@ contract StandardToken is Token {
/// @return Remaining allowance for spender
function allowance(address owner, address spender)
public
- constant
+ view
returns (uint)
{
return allowances[owner][spender];
@@ -84,7 +84,7 @@ contract StandardToken is Token {
/// @return Balance of owner
function balanceOf(address owner)
public
- constant
+ view
returns (uint)
{
return balances[owner];
@@ -94,7 +94,7 @@ contract StandardToken is Token {
/// @return Total supply
function totalSupply()
public
- constant
+ view
returns (uint)
{
return totalTokens;
diff --git a/test/compilationTests/gnosis/Tokens/Token.sol b/test/compilationTests/gnosis/Tokens/Token.sol
index 19bb618b..70ecdff7 100644
--- a/test/compilationTests/gnosis/Tokens/Token.sol
+++ b/test/compilationTests/gnosis/Tokens/Token.sol
@@ -17,7 +17,7 @@ contract Token {
function transfer(address to, uint value) public returns (bool);
function transferFrom(address from, address to, uint value) public returns (bool);
function approve(address spender, uint value) public returns (bool);
- function balanceOf(address owner) public constant returns (uint);
- function allowance(address owner, address spender) public constant returns (uint);
- function totalSupply() public constant returns (uint);
+ function balanceOf(address owner) public view returns (uint);
+ function allowance(address owner, address spender) public view returns (uint);
+ function totalSupply() public view returns (uint);
}
diff --git a/test/compilationTests/gnosis/Utils/Math.sol b/test/compilationTests/gnosis/Utils/Math.sol
index 95d95346..93456c33 100644
--- a/test/compilationTests/gnosis/Utils/Math.sol
+++ b/test/compilationTests/gnosis/Utils/Math.sol
@@ -22,7 +22,7 @@ library Math {
/// @return e**x
function exp(int x)
public
- constant
+ pure
returns (uint)
{
// revert if x is > MAX_POWER, where
@@ -107,7 +107,7 @@ library Math {
/// @return ln(x)
function ln(uint x)
public
- constant
+ pure
returns (int)
{
require(x > 0);
@@ -157,7 +157,7 @@ library Math {
/// @return logarithmic value
function floorLog2(uint x)
public
- constant
+ pure
returns (int lo)
{
lo = -64;
@@ -178,7 +178,7 @@ library Math {
/// @return Maximum number
function max(int[] nums)
public
- constant
+ pure
returns (int max)
{
require(nums.length > 0);
@@ -194,7 +194,7 @@ library Math {
/// @return Did no overflow occur?
function safeToAdd(uint a, uint b)
public
- constant
+ pure
returns (bool)
{
return a + b >= a;
@@ -206,7 +206,7 @@ library Math {
/// @return Did no underflow occur?
function safeToSub(uint a, uint b)
public
- constant
+ pure
returns (bool)
{
return a >= b;
@@ -218,7 +218,7 @@ library Math {
/// @return Did no overflow occur?
function safeToMul(uint a, uint b)
public
- constant
+ pure
returns (bool)
{
return b == 0 || a * b / b == a;
@@ -230,7 +230,7 @@ library Math {
/// @return Sum
function add(uint a, uint b)
public
- constant
+ pure
returns (uint)
{
require(safeToAdd(a, b));
@@ -243,7 +243,7 @@ library Math {
/// @return Difference
function sub(uint a, uint b)
public
- constant
+ pure
returns (uint)
{
require(safeToSub(a, b));
@@ -256,7 +256,7 @@ library Math {
/// @return Product
function mul(uint a, uint b)
public
- constant
+ pure
returns (uint)
{
require(safeToMul(a, b));
@@ -269,7 +269,7 @@ library Math {
/// @return Did no overflow occur?
function safeToAdd(int a, int b)
public
- constant
+ pure
returns (bool)
{
return (b >= 0 && a + b >= a) || (b < 0 && a + b < a);
@@ -281,7 +281,7 @@ library Math {
/// @return Did no underflow occur?
function safeToSub(int a, int b)
public
- constant
+ pure
returns (bool)
{
return (b >= 0 && a - b <= a) || (b < 0 && a - b > a);
@@ -293,7 +293,7 @@ library Math {
/// @return Did no overflow occur?
function safeToMul(int a, int b)
public
- constant
+ pure
returns (bool)
{
return (b == 0) || (a * b / b == a);
@@ -305,7 +305,7 @@ library Math {
/// @return Sum
function add(int a, int b)
public
- constant
+ pure
returns (int)
{
require(safeToAdd(a, b));
@@ -318,7 +318,7 @@ library Math {
/// @return Difference
function sub(int a, int b)
public
- constant
+ pure
returns (int)
{
require(safeToSub(a, b));
@@ -331,7 +331,7 @@ library Math {
/// @return Product
function mul(int a, int b)
public
- constant
+ pure
returns (int)
{
require(safeToMul(a, b));
diff --git a/test/compilationTests/milestonetracker/MilestoneTracker.sol b/test/compilationTests/milestonetracker/MilestoneTracker.sol
index 56422169..378f7b73 100644
--- a/test/compilationTests/milestonetracker/MilestoneTracker.sol
+++ b/test/compilationTests/milestonetracker/MilestoneTracker.sol
@@ -124,7 +124,7 @@ contract MilestoneTracker {
/////////
/// @return The number of milestones ever created even if they were canceled
- function numberOfMilestones() constant returns (uint) {
+ function numberOfMilestones() view returns (uint) {
return milestones.length;
}
diff --git a/test/compilationTests/milestonetracker/RLP.sol b/test/compilationTests/milestonetracker/RLP.sol
index e71d567e..e96bb332 100644
--- a/test/compilationTests/milestonetracker/RLP.sol
+++ b/test/compilationTests/milestonetracker/RLP.sol
@@ -30,7 +30,7 @@ library RLP {
/* Iterator */
- function next(Iterator memory self) internal constant returns (RLPItem memory subItem) {
+ function next(Iterator memory self) internal view returns (RLPItem memory subItem) {
if(hasNext(self)) {
uint ptr = self._unsafe_nextPtr;
uint itemLength = _itemLength(ptr);
@@ -42,14 +42,14 @@ library RLP {
throw;
}
- function next(Iterator memory self, bool strict) internal constant returns (RLPItem memory subItem) {
+ function next(Iterator memory self, bool strict) internal view returns (RLPItem memory subItem) {
subItem = next(self);
if(strict && !_validate(subItem))
throw;
return;
}
- function hasNext(Iterator memory self) internal constant returns (bool) {
+ function hasNext(Iterator memory self) internal view returns (bool) {
RLPItem memory item = self._unsafe_item;
return self._unsafe_nextPtr < item._unsafe_memPtr + item._unsafe_length;
}
@@ -59,7 +59,7 @@ library RLP {
/// @dev Creates an RLPItem from an array of RLP encoded bytes.
/// @param self The RLP encoded bytes.
/// @return An RLPItem
- function toRLPItem(bytes memory self) internal constant returns (RLPItem memory) {
+ function toRLPItem(bytes memory self) internal view returns (RLPItem memory) {
uint len = self.length;
if (len == 0) {
return RLPItem(0, 0);
@@ -75,7 +75,7 @@ library RLP {
/// @param self The RLP encoded bytes.
/// @param strict Will throw if the data is not RLP encoded.
/// @return An RLPItem
- function toRLPItem(bytes memory self, bool strict) internal constant returns (RLPItem memory) {
+ function toRLPItem(bytes memory self, bool strict) internal view returns (RLPItem memory) {
RLPItem memory item = toRLPItem(self);
if(strict) {
uint len = self.length;
@@ -92,14 +92,14 @@ library RLP {
/// @dev Check if the RLP item is null.
/// @param self The RLP item.
/// @return 'true' if the item is null.
- function isNull(RLPItem memory self) internal constant returns (bool ret) {
+ function isNull(RLPItem memory self) internal view returns (bool ret) {
return self._unsafe_length == 0;
}
/// @dev Check if the RLP item is a list.
/// @param self The RLP item.
/// @return 'true' if the item is a list.
- function isList(RLPItem memory self) internal constant returns (bool ret) {
+ function isList(RLPItem memory self) internal view returns (bool ret) {
if (self._unsafe_length == 0)
return false;
uint memPtr = self._unsafe_memPtr;
@@ -111,7 +111,7 @@ library RLP {
/// @dev Check if the RLP item is data.
/// @param self The RLP item.
/// @return 'true' if the item is data.
- function isData(RLPItem memory self) internal constant returns (bool ret) {
+ function isData(RLPItem memory self) internal view returns (bool ret) {
if (self._unsafe_length == 0)
return false;
uint memPtr = self._unsafe_memPtr;
@@ -123,7 +123,7 @@ library RLP {
/// @dev Check if the RLP item is empty (string or list).
/// @param self The RLP item.
/// @return 'true' if the item is null.
- function isEmpty(RLPItem memory self) internal constant returns (bool ret) {
+ function isEmpty(RLPItem memory self) internal view returns (bool ret) {
if(isNull(self))
return false;
uint b0;
@@ -137,7 +137,7 @@ library RLP {
/// @dev Get the number of items in an RLP encoded list.
/// @param self The RLP item.
/// @return The number of items.
- function items(RLPItem memory self) internal constant returns (uint) {
+ function items(RLPItem memory self) internal view returns (uint) {
if (!isList(self))
return 0;
uint b0;
@@ -158,7 +158,7 @@ library RLP {
/// @dev Create an iterator.
/// @param self The RLP item.
/// @return An 'Iterator' over the item.
- function iterator(RLPItem memory self) internal constant returns (Iterator memory it) {
+ function iterator(RLPItem memory self) internal view returns (Iterator memory it) {
if (!isList(self))
throw;
uint ptr = self._unsafe_memPtr + _payloadOffset(self);
@@ -169,7 +169,7 @@ library RLP {
/// @dev Return the RLP encoded bytes.
/// @param self The RLPItem.
/// @return The bytes.
- function toBytes(RLPItem memory self) internal constant returns (bytes memory bts) {
+ function toBytes(RLPItem memory self) internal returns (bytes memory bts) {
uint len = self._unsafe_length;
if (len == 0)
return;
@@ -181,7 +181,7 @@ library RLP {
/// RLPItem is a list.
/// @param self The RLPItem.
/// @return The decoded string.
- function toData(RLPItem memory self) internal constant returns (bytes memory bts) {
+ function toData(RLPItem memory self) internal returns (bytes memory bts) {
if(!isData(self))
throw;
(uint rStartPos, uint len) = _decode(self);
@@ -193,7 +193,7 @@ library RLP {
/// Warning: This is inefficient, as it requires that the list is read twice.
/// @param self The RLP item.
/// @return Array of RLPItems.
- function toList(RLPItem memory self) internal constant returns (RLPItem[] memory list) {
+ function toList(RLPItem memory self) internal view returns (RLPItem[] memory list) {
if(!isList(self))
throw;
uint numItems = items(self);
@@ -210,7 +210,7 @@ library RLP {
/// RLPItem is a list.
/// @param self The RLPItem.
/// @return The decoded string.
- function toAscii(RLPItem memory self) internal constant returns (string memory str) {
+ function toAscii(RLPItem memory self) internal returns (string memory str) {
if(!isData(self))
throw;
(uint rStartPos, uint len) = _decode(self);
@@ -223,7 +223,7 @@ library RLP {
/// RLPItem is a list.
/// @param self The RLPItem.
/// @return The decoded string.
- function toUint(RLPItem memory self) internal constant returns (uint data) {
+ function toUint(RLPItem memory self) internal view returns (uint data) {
if(!isData(self))
throw;
(uint rStartPos, uint len) = _decode(self);
@@ -238,7 +238,7 @@ library RLP {
/// RLPItem is a list.
/// @param self The RLPItem.
/// @return The decoded string.
- function toBool(RLPItem memory self) internal constant returns (bool data) {
+ function toBool(RLPItem memory self) internal view returns (bool data) {
if(!isData(self))
throw;
(uint rStartPos, uint len) = _decode(self);
@@ -257,7 +257,7 @@ library RLP {
/// RLPItem is a list.
/// @param self The RLPItem.
/// @return The decoded string.
- function toByte(RLPItem memory self) internal constant returns (byte data) {
+ function toByte(RLPItem memory self) internal view returns (byte data) {
if(!isData(self))
throw;
(uint rStartPos, uint len) = _decode(self);
@@ -274,7 +274,7 @@ library RLP {
/// RLPItem is a list.
/// @param self The RLPItem.
/// @return The decoded string.
- function toInt(RLPItem memory self) internal constant returns (int data) {
+ function toInt(RLPItem memory self) internal view returns (int data) {
return int(toUint(self));
}
@@ -282,7 +282,7 @@ library RLP {
/// RLPItem is a list.
/// @param self The RLPItem.
/// @return The decoded string.
- function toBytes32(RLPItem memory self) internal constant returns (bytes32 data) {
+ function toBytes32(RLPItem memory self) internal view returns (bytes32 data) {
return bytes32(toUint(self));
}
@@ -290,7 +290,7 @@ library RLP {
/// RLPItem is a list.
/// @param self The RLPItem.
/// @return The decoded string.
- function toAddress(RLPItem memory self) internal constant returns (address data) {
+ function toAddress(RLPItem memory self) internal view returns (address data) {
if(!isData(self))
throw;
(uint rStartPos, uint len) = _decode(self);
@@ -302,7 +302,7 @@ library RLP {
}
// Get the payload offset.
- function _payloadOffset(RLPItem memory self) private constant returns (uint) {
+ function _payloadOffset(RLPItem memory self) private view returns (uint) {
if(self._unsafe_length == 0)
return 0;
uint b0;
@@ -320,7 +320,7 @@ library RLP {
}
// Get the full length of an RLP item.
- function _itemLength(uint memPtr) private constant returns (uint len) {
+ function _itemLength(uint memPtr) private view returns (uint len) {
uint b0;
assembly {
b0 := byte(0, mload(memPtr))
@@ -348,7 +348,7 @@ library RLP {
}
// Get start position and length of the data.
- function _decode(RLPItem memory self) private constant returns (uint memPtr, uint len) {
+ function _decode(RLPItem memory self) private view returns (uint memPtr, uint len) {
if(!isData(self))
throw;
uint b0;
@@ -376,7 +376,7 @@ library RLP {
}
// Assumes that enough memory has been allocated to store in target.
- function _copyToBytes(uint btsPtr, bytes memory tgt, uint btsLen) private constant {
+ function _copyToBytes(uint btsPtr, bytes memory tgt, uint btsLen) private {
// Exploiting the fact that 'tgt' was the last thing to be allocated,
// we can write entire words, and just overwrite any excess.
assembly {
@@ -400,7 +400,7 @@ library RLP {
}
// Check that an RLP item is valid.
- function _validate(RLPItem memory self) private constant returns (bool ret) {
+ function _validate(RLPItem memory self) private view returns (bool ret) {
// Check that RLP is well-formed.
uint b0;
uint b1;
diff --git a/test/compilationTests/zeppelin/DayLimit.sol b/test/compilationTests/zeppelin/DayLimit.sol
index 0bcb341a..e55076b7 100644
--- a/test/compilationTests/zeppelin/DayLimit.sol
+++ b/test/compilationTests/zeppelin/DayLimit.sol
@@ -59,7 +59,7 @@ contract DayLimit {
* @dev Private function to determine today's index
* @return uint256 of today's index.
*/
- function today() private constant returns (uint256) {
+ function today() private view returns (uint256) {
return now / 1 days;
}
diff --git a/test/compilationTests/zeppelin/crowdsale/CappedCrowdsale.sol b/test/compilationTests/zeppelin/crowdsale/CappedCrowdsale.sol
index afae79b7..d4066812 100644
--- a/test/compilationTests/zeppelin/crowdsale/CappedCrowdsale.sol
+++ b/test/compilationTests/zeppelin/crowdsale/CappedCrowdsale.sol
@@ -18,14 +18,14 @@ contract CappedCrowdsale is Crowdsale {
// overriding Crowdsale#validPurchase to add extra cap logic
// @return true if investors can buy at the moment
- function validPurchase() internal constant returns (bool) {
+ function validPurchase() internal view returns (bool) {
bool withinCap = weiRaised.add(msg.value) <= cap;
return super.validPurchase() && withinCap;
}
// overriding Crowdsale#hasEnded to add cap logic
// @return true if crowdsale event has ended
- function hasEnded() public constant returns (bool) {
+ function hasEnded() public view returns (bool) {
bool capReached = weiRaised >= cap;
return super.hasEnded() || capReached;
}
diff --git a/test/compilationTests/zeppelin/crowdsale/Crowdsale.sol b/test/compilationTests/zeppelin/crowdsale/Crowdsale.sol
index d798f41d..1f148a74 100644
--- a/test/compilationTests/zeppelin/crowdsale/Crowdsale.sol
+++ b/test/compilationTests/zeppelin/crowdsale/Crowdsale.sol
@@ -92,7 +92,7 @@ contract Crowdsale {
}
// @return true if the transaction can buy tokens
- function validPurchase() internal constant returns (bool) {
+ function validPurchase() internal view returns (bool) {
uint256 current = block.number;
bool withinPeriod = current >= startBlock && current <= endBlock;
bool nonZeroPurchase = msg.value != 0;
@@ -100,7 +100,7 @@ contract Crowdsale {
}
// @return true if crowdsale event has ended
- function hasEnded() public constant returns (bool) {
+ function hasEnded() public view returns (bool) {
return block.number > endBlock;
}
diff --git a/test/compilationTests/zeppelin/crowdsale/RefundableCrowdsale.sol b/test/compilationTests/zeppelin/crowdsale/RefundableCrowdsale.sol
index 5e798d45..bb6b5e17 100644
--- a/test/compilationTests/zeppelin/crowdsale/RefundableCrowdsale.sol
+++ b/test/compilationTests/zeppelin/crowdsale/RefundableCrowdsale.sol
@@ -52,7 +52,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
super.finalization();
}
- function goalReached() public constant returns (bool) {
+ function goalReached() public view returns (bool) {
return weiRaised >= goal;
}
diff --git a/test/compilationTests/zeppelin/math/Math.sol b/test/compilationTests/zeppelin/math/Math.sol
index 3d016c0a..9997998a 100644
--- a/test/compilationTests/zeppelin/math/Math.sol
+++ b/test/compilationTests/zeppelin/math/Math.sol
@@ -6,19 +6,19 @@ pragma solidity ^0.4.11;
*/
library Math {
- function max64(uint64 a, uint64 b) internal constant returns (uint64) {
+ function max64(uint64 a, uint64 b) internal pure returns (uint64) {
return a >= b ? a : b;
}
- function min64(uint64 a, uint64 b) internal constant returns (uint64) {
+ function min64(uint64 a, uint64 b) internal pure returns (uint64) {
return a < b ? a : b;
}
- function max256(uint256 a, uint256 b) internal constant returns (uint256) {
+ function max256(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
- function min256(uint256 a, uint256 b) internal constant returns (uint256) {
+ function min256(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
}
diff --git a/test/compilationTests/zeppelin/math/SafeMath.sol b/test/compilationTests/zeppelin/math/SafeMath.sol
index dc05ba28..a98635e2 100644
--- a/test/compilationTests/zeppelin/math/SafeMath.sol
+++ b/test/compilationTests/zeppelin/math/SafeMath.sol
@@ -6,25 +6,25 @@ pragma solidity ^0.4.11;
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
- function mul(uint256 a, uint256 b) internal returns (uint256) {
+ function mul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
- function div(uint256 a, uint256 b) internal returns (uint256) {
+ function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
- function sub(uint256 a, uint256 b) internal returns (uint256) {
+ function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
- function add(uint256 a, uint256 b) internal returns (uint256) {
+ function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
diff --git a/test/compilationTests/zeppelin/ownership/Shareable.sol b/test/compilationTests/zeppelin/ownership/Shareable.sol
index f8059650..c954052b 100644
--- a/test/compilationTests/zeppelin/ownership/Shareable.sol
+++ b/test/compilationTests/zeppelin/ownership/Shareable.sol
@@ -96,7 +96,7 @@ contract Shareable {
* @param ownerIndex uint256 The index of the owner
* @return The address of the owner
*/
- function getOwner(uint256 ownerIndex) external constant returns (address) {
+ function getOwner(uint256 ownerIndex) external view returns (address) {
return address(owners[ownerIndex + 1]);
}
@@ -105,7 +105,7 @@ contract Shareable {
* @param _addr address The address which you want to check.
* @return True if the address is an owner and fase otherwise.
*/
- function isOwner(address _addr) constant returns (bool) {
+ function isOwner(address _addr) view returns (bool) {
return ownerIndex[_addr] > 0;
}
@@ -115,7 +115,7 @@ contract Shareable {
* @param _owner The owner address.
* @return True if the owner has confirmed and false otherwise.
*/
- function hasConfirmed(bytes32 _operation, address _owner) constant returns (bool) {
+ function hasConfirmed(bytes32 _operation, address _owner) view returns (bool) {
PendingState memory pending = pendings[_operation];
uint256 index = ownerIndex[_owner];
diff --git a/test/compilationTests/zeppelin/token/BasicToken.sol b/test/compilationTests/zeppelin/token/BasicToken.sol
index 831f706e..8a3d8ead 100644
--- a/test/compilationTests/zeppelin/token/BasicToken.sol
+++ b/test/compilationTests/zeppelin/token/BasicToken.sol
@@ -30,7 +30,7 @@ contract BasicToken is ERC20Basic {
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
- function balanceOf(address _owner) constant returns (uint256 balance) {
+ function balanceOf(address _owner) view returns (uint256 balance) {
return balances[_owner];
}
diff --git a/test/compilationTests/zeppelin/token/ERC20.sol b/test/compilationTests/zeppelin/token/ERC20.sol
index 1045ac35..ae5aa624 100644
--- a/test/compilationTests/zeppelin/token/ERC20.sol
+++ b/test/compilationTests/zeppelin/token/ERC20.sol
@@ -9,7 +9,7 @@ import './ERC20Basic.sol';
* @dev see https://github.com/ethereum/EIPs/issues/20
*/
contract ERC20 is ERC20Basic {
- function allowance(address owner, address spender) constant returns (uint256);
+ function allowance(address owner, address spender) view returns (uint256);
function transferFrom(address from, address to, uint256 value);
function approve(address spender, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
diff --git a/test/compilationTests/zeppelin/token/ERC20Basic.sol b/test/compilationTests/zeppelin/token/ERC20Basic.sol
index 0e98779e..94fb7bcf 100644
--- a/test/compilationTests/zeppelin/token/ERC20Basic.sol
+++ b/test/compilationTests/zeppelin/token/ERC20Basic.sol
@@ -8,7 +8,7 @@ pragma solidity ^0.4.11;
*/
contract ERC20Basic {
uint256 public totalSupply;
- function balanceOf(address who) constant returns (uint256);
+ function balanceOf(address who) view returns (uint256);
function transfer(address to, uint256 value);
event Transfer(address indexed from, address indexed to, uint256 value);
}
diff --git a/test/compilationTests/zeppelin/token/LimitedTransferToken.sol b/test/compilationTests/zeppelin/token/LimitedTransferToken.sol
index ee5032c9..0ccd60b2 100644
--- a/test/compilationTests/zeppelin/token/LimitedTransferToken.sol
+++ b/test/compilationTests/zeppelin/token/LimitedTransferToken.sol
@@ -10,7 +10,7 @@ import "./ERC20.sol";
* LimitedTransferToken has been designed to allow for different limiting factors,
* this can be achieved by recursively calling super.transferableTokens() until the base class is
* hit. For example:
- * function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
+ * function transferableTokens(address holder, uint64 time) view public returns (uint256) {
* return min256(unlockedTokens, super.transferableTokens(holder, time));
* }
* A working example is VestedToken.sol:
@@ -51,7 +51,7 @@ contract LimitedTransferToken is ERC20 {
* @dev Overwriting transferableTokens(address holder, uint64 time) is the way to provide the
* specific logic for limiting token transferability for a holder over time.
*/
- function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
+ function transferableTokens(address holder, uint64 time) view public returns (uint256) {
return balanceOf(holder);
}
}
diff --git a/test/compilationTests/zeppelin/token/StandardToken.sol b/test/compilationTests/zeppelin/token/StandardToken.sol
index ab9f582e..900a9102 100644
--- a/test/compilationTests/zeppelin/token/StandardToken.sol
+++ b/test/compilationTests/zeppelin/token/StandardToken.sol
@@ -58,7 +58,7 @@ contract StandardToken is ERC20, BasicToken {
* @param _spender address The address which will spend the funds.
* @return A uint256 specifing the amount of tokens still avaible for the spender.
*/
- function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
+ function allowance(address _owner, address _spender) view returns (uint256 remaining) {
return allowed[_owner][_spender];
}
diff --git a/test/compilationTests/zeppelin/token/VestedToken.sol b/test/compilationTests/zeppelin/token/VestedToken.sol
index e9929018..3953612d 100644
--- a/test/compilationTests/zeppelin/token/VestedToken.sol
+++ b/test/compilationTests/zeppelin/token/VestedToken.sol
@@ -106,7 +106,7 @@ contract VestedToken is StandardToken, LimitedTransferToken {
* @param time uint64 The specific time.
* @return An uint256 representing a holder's total amount of transferable tokens.
*/
- function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
+ function transferableTokens(address holder, uint64 time) view public returns (uint256) {
uint256 grantIndex = tokenGrantsCount(holder);
if (grantIndex == 0) return balanceOf(holder); // shortcut for holder without grants
@@ -130,7 +130,7 @@ contract VestedToken is StandardToken, LimitedTransferToken {
* @param _holder The holder of the grants.
* @return A uint256 representing the total amount of grants.
*/
- function tokenGrantsCount(address _holder) constant returns (uint256 index) {
+ function tokenGrantsCount(address _holder) view returns (uint256 index) {
return grants[_holder].length;
}
@@ -163,7 +163,7 @@ contract VestedToken is StandardToken, LimitedTransferToken {
uint256 time,
uint256 start,
uint256 cliff,
- uint256 vesting) constant returns (uint256)
+ uint256 vesting) view returns (uint256)
{
// Shortcuts for before cliff and after vesting cases.
if (time < cliff) return 0;
@@ -192,7 +192,7 @@ contract VestedToken is StandardToken, LimitedTransferToken {
* @return Returns all the values that represent a TokenGrant(address, value, start, cliff,
* revokability, burnsOnRevoke, and vesting) plus the vested value at the current time.
*/
- function tokenGrant(address _holder, uint256 _grantId) constant returns (address granter, uint256 value, uint256 vested, uint64 start, uint64 cliff, uint64 vesting, bool revokable, bool burnsOnRevoke) {
+ function tokenGrant(address _holder, uint256 _grantId) view returns (address granter, uint256 value, uint256 vested, uint64 start, uint64 cliff, uint64 vesting, bool revokable, bool burnsOnRevoke) {
TokenGrant grant = grants[_holder][_grantId];
granter = grant.granter;
@@ -212,7 +212,7 @@ contract VestedToken is StandardToken, LimitedTransferToken {
* @param time The time to be checked
* @return An uint256 representing the amount of vested tokens of a specific grant at a specific time.
*/
- function vestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
+ function vestedTokens(TokenGrant grant, uint64 time) private view returns (uint256) {
return calculateVestedTokens(
grant.value,
uint256(time),
@@ -229,7 +229,7 @@ contract VestedToken is StandardToken, LimitedTransferToken {
* @return An uint256 representing the amount of non vested tokens of a specifc grant on the
* passed time frame.
*/
- function nonVestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
+ function nonVestedTokens(TokenGrant grant, uint64 time) private view returns (uint256) {
return grant.value.sub(vestedTokens(grant, time));
}
@@ -238,7 +238,7 @@ contract VestedToken is StandardToken, LimitedTransferToken {
* @param holder address The address of the holder
* @return An uint256 representing the date of the last transferable tokens.
*/
- function lastTokenIsTransferableDate(address holder) constant public returns (uint64 date) {
+ function lastTokenIsTransferableDate(address holder) view public returns (uint64 date) {
date = uint64(now);
uint256 grantIndex = grants[holder].length;
for (uint256 i = 0; i < grantIndex; i++) {
diff --git a/test/contracts/AuctionRegistrar.cpp b/test/contracts/AuctionRegistrar.cpp
index f5abb83d..3d759aa0 100644
--- a/test/contracts/AuctionRegistrar.cpp
+++ b/test/contracts/AuctionRegistrar.cpp
@@ -43,20 +43,20 @@ static char const* registrarCode = R"DELIMITER(
pragma solidity ^0.4.0;
contract NameRegister {
- function addr(string _name) constant returns (address o_owner);
- function name(address _owner) constant returns (string o_name);
+ function addr(string _name) view returns (address o_owner);
+ function name(address _owner) view returns (string o_name);
}
contract Registrar is NameRegister {
event Changed(string indexed name);
event PrimaryChanged(string indexed name, address indexed addr);
- function owner(string _name) constant returns (address o_owner);
- function addr(string _name) constant returns (address o_address);
- function subRegistrar(string _name) constant returns (address o_subRegistrar);
- function content(string _name) constant returns (bytes32 o_content);
+ function owner(string _name) view returns (address o_owner);
+ function addr(string _name) view returns (address o_address);
+ function subRegistrar(string _name) view returns (address o_subRegistrar);
+ function content(string _name) view returns (bytes32 o_content);
- function name(address _owner) constant returns (string o_name);
+ function name(address _owner) view returns (string o_name);
}
contract AuctionSystem {
@@ -67,7 +67,7 @@ contract AuctionSystem {
function onAuctionEnd(string _name) internal;
function bid(string _name, address _bidder, uint _value) internal {
- var auction = m_auctions[_name];
+ Auction storage auction = m_auctions[_name];
if (auction.endDate > 0 && now > auction.endDate)
{
emit AuctionEnded(_name, auction.highestBidder);
@@ -117,9 +117,9 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
}
function onAuctionEnd(string _name) internal {
- var auction = m_auctions[_name];
- var record = m_toRecord[_name];
- var previousOwner = record.owner;
+ Auction storage auction = m_auctions[_name];
+ Record storage record = m_toRecord[_name];
+ address previousOwner = record.owner;
record.renewalDate = now + c_renewalInterval;
record.owner = auction.highestBidder;
emit Changed(_name);
@@ -201,11 +201,11 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
return true;
}
- function owner(string _name) constant returns (address) { return m_toRecord[_name].owner; }
- function addr(string _name) constant returns (address) { return m_toRecord[_name].primary; }
- function subRegistrar(string _name) constant returns (address) { return m_toRecord[_name].subRegistrar; }
- function content(string _name) constant returns (bytes32) { return m_toRecord[_name].content; }
- function name(address _addr) constant returns (string o_name) { return m_toName[_addr]; }
+ function owner(string _name) view returns (address) { return m_toRecord[_name].owner; }
+ function addr(string _name) view returns (address) { return m_toRecord[_name].primary; }
+ function subRegistrar(string _name) view returns (address) { return m_toRecord[_name].subRegistrar; }
+ function content(string _name) view returns (bytes32) { return m_toRecord[_name].content; }
+ function name(address _addr) view returns (string o_name) { return m_toName[_addr]; }
mapping (address => string) m_toName;
mapping (string => Record) m_toRecord;
@@ -223,6 +223,7 @@ protected:
s_compiledRegistrar.reset(new bytes(compileContract(registrarCode, "GlobalRegistrar")));
sendMessage(*s_compiledRegistrar, true);
+ BOOST_REQUIRE(m_transactionSuccessful);
BOOST_REQUIRE(!m_output.empty());
}
diff --git a/test/contracts/FixedFeeRegistrar.cpp b/test/contracts/FixedFeeRegistrar.cpp
index 142f4144..87f801b0 100644
--- a/test/contracts/FixedFeeRegistrar.cpp
+++ b/test/contracts/FixedFeeRegistrar.cpp
@@ -58,10 +58,10 @@ pragma solidity ^0.4.0;
contract Registrar {
event Changed(string indexed name);
- function owner(string _name) constant returns (address o_owner);
- function addr(string _name) constant returns (address o_address);
- function subRegistrar(string _name) constant returns (address o_subRegistrar);
- function content(string _name) constant returns (bytes32 o_content);
+ function owner(string _name) view returns (address o_owner);
+ function addr(string _name) view returns (address o_address);
+ function subRegistrar(string _name) view returns (address o_subRegistrar);
+ function content(string _name) view returns (bytes32 o_content);
}
contract FixedFeeRegistrar is Registrar {
@@ -104,20 +104,20 @@ contract FixedFeeRegistrar is Registrar {
emit Changed(_name);
}
- function record(string _name) constant returns (address o_addr, address o_subRegistrar, bytes32 o_content, address o_owner) {
+ function record(string _name) view returns (address o_addr, address o_subRegistrar, bytes32 o_content, address o_owner) {
Record rec = m_record(_name);
o_addr = rec.addr;
o_subRegistrar = rec.subRegistrar;
o_content = rec.content;
o_owner = rec.owner;
}
- function addr(string _name) constant returns (address) { return m_record(_name).addr; }
- function subRegistrar(string _name) constant returns (address) { return m_record(_name).subRegistrar; }
- function content(string _name) constant returns (bytes32) { return m_record(_name).content; }
- function owner(string _name) constant returns (address) { return m_record(_name).owner; }
+ function addr(string _name) view returns (address) { return m_record(_name).addr; }
+ function subRegistrar(string _name) view returns (address) { return m_record(_name).subRegistrar; }
+ function content(string _name) view returns (bytes32) { return m_record(_name).content; }
+ function owner(string _name) view returns (address) { return m_record(_name).owner; }
Record[2**253] m_recordData;
- function m_record(string _name) constant internal returns (Record storage o_record) {
+ function m_record(string _name) view internal returns (Record storage o_record) {
return m_recordData[uint(keccak256(bytes(_name))) / 8];
}
uint constant c_fee = 69 ether;
@@ -135,6 +135,7 @@ protected:
s_compiledRegistrar.reset(new bytes(compileContract(registrarCode, "FixedFeeRegistrar")));
sendMessage(*s_compiledRegistrar, true);
+ BOOST_REQUIRE(m_transactionSuccessful);
BOOST_REQUIRE(!m_output.empty());
}
u256 const m_fee = u256("69000000000000000000");
diff --git a/test/contracts/LLL_ENS.cpp b/test/contracts/LLL_ENS.cpp
index 028d58c8..3461c577 100644
--- a/test/contracts/LLL_ENS.cpp
+++ b/test/contracts/LLL_ENS.cpp
@@ -349,6 +349,7 @@ protected:
BOOST_REQUIRE(errors.empty());
}
sendMessage(*s_compiledEns, true);
+ BOOST_REQUIRE(m_transactionSuccessful);
BOOST_REQUIRE(!m_output.empty());
}
diff --git a/test/contracts/LLL_ERC20.cpp b/test/contracts/LLL_ERC20.cpp
index 60b43e4f..89d1c4f0 100644
--- a/test/contracts/LLL_ERC20.cpp
+++ b/test/contracts/LLL_ERC20.cpp
@@ -400,6 +400,7 @@ protected:
BOOST_REQUIRE(errors.empty());
}
sendMessage(*s_compiledErc20, true);
+ BOOST_REQUIRE(m_transactionSuccessful);
BOOST_REQUIRE(!m_output.empty());
}
@@ -629,18 +630,22 @@ BOOST_AUTO_TEST_CASE(bad_data)
// Correct data: transfer(address _to, 1).
sendMessage((bytes)fromHex("a9059cbb") + (bytes)fromHex("000000000000000000000000123456789a123456789a123456789a123456789a") + encodeArgs(1), false, 0);
+ BOOST_CHECK(m_transactionSuccessful);
BOOST_CHECK(m_output == SUCCESS);
// Too little data (address is truncated by one byte).
sendMessage((bytes)fromHex("a9059cbb") + (bytes)fromHex("000000000000000000000000123456789a123456789a123456789a12345678") + encodeArgs(1), false, 0);
+ BOOST_CHECK(!m_transactionSuccessful);
BOOST_CHECK(m_output != SUCCESS);
// Too much data (address is extended with a zero byte).
sendMessage((bytes)fromHex("a9059cbb") + (bytes)fromHex("000000000000000000000000123456789a123456789a123456789a123456789a00") + encodeArgs(1), false, 0);
+ BOOST_CHECK(!m_transactionSuccessful);
BOOST_CHECK(m_output != SUCCESS);
// Invalid address (a bit above the 160th is set).
sendMessage((bytes)fromHex("a9059cbb") + (bytes)fromHex("000000000000000000000100123456789a123456789a123456789a123456789a") + encodeArgs(1), false, 0);
+ BOOST_CHECK(!m_transactionSuccessful);
BOOST_CHECK(m_output != SUCCESS);
}
diff --git a/test/contracts/Wallet.cpp b/test/contracts/Wallet.cpp
index 6328b518..fb104300 100644
--- a/test/contracts/Wallet.cpp
+++ b/test/contracts/Wallet.cpp
@@ -119,7 +119,7 @@ contract multiowned {
// make sure they're an owner
if (ownerIndex == 0) return;
uint ownerIndexBit = 2**ownerIndex;
- var pending = m_pending[_operation];
+ PendingState pending = m_pending[_operation];
if (pending.ownersDone & ownerIndexBit > 0) {
pending.yetNeeded++;
pending.ownersDone -= ownerIndexBit;
@@ -177,8 +177,8 @@ contract multiowned {
return m_ownerIndex[uint(_addr)] > 0;
}
- function hasConfirmed(bytes32 _operation, address _owner) constant returns (bool) {
- var pending = m_pending[_operation];
+ function hasConfirmed(bytes32 _operation, address _owner) view returns (bool) {
+ PendingState pending = m_pending[_operation];
uint ownerIndex = m_ownerIndex[uint(_owner)];
// make sure they're an owner
@@ -201,7 +201,7 @@ contract multiowned {
// make sure they're an owner
if (ownerIndex == 0) return;
- var pending = m_pending[_operation];
+ PendingState pending = m_pending[_operation];
// if we're not yet working on this operation, switch over and reset the confirmation status.
if (pending.yetNeeded == 0) {
// reset count of confirmations needed.
@@ -319,7 +319,7 @@ contract daylimit is multiowned {
return false;
}
// determines today's index.
- function today() private constant returns (uint) { return now / 1 days; }
+ function today() private view returns (uint) { return now / 1 days; }
// FIELDS
@@ -451,6 +451,7 @@ protected:
bytes args = encodeArgs(u256(0x60), _required, _dailyLimit, u256(_owners.size()), _owners);
sendMessage(*s_compiledWallet + args, true, _value);
+ BOOST_REQUIRE(m_transactionSuccessful);
BOOST_REQUIRE(!m_output.empty());
}
};
diff --git a/test/liblll/EndToEndTest.cpp b/test/liblll/EndToEndTest.cpp
index fd8099f2..ceaf450e 100644
--- a/test/liblll/EndToEndTest.cpp
+++ b/test/liblll/EndToEndTest.cpp
@@ -50,6 +50,7 @@ BOOST_AUTO_TEST_CASE(bare_panic)
{
char const* sourceCode = "(panic)";
compileAndRunWithoutCheck(sourceCode);
+ BOOST_REQUIRE(!m_transactionSuccessful);
BOOST_REQUIRE(m_output.empty());
}
@@ -57,6 +58,7 @@ BOOST_AUTO_TEST_CASE(panic)
{
char const* sourceCode = "{ (panic) }";
compileAndRunWithoutCheck(sourceCode);
+ BOOST_REQUIRE(!m_transactionSuccessful);
BOOST_REQUIRE(m_output.empty());
}
@@ -69,6 +71,7 @@ BOOST_AUTO_TEST_CASE(macro_zeroarg)
(zeroarg)))
)";
compileAndRun(sourceCode);
+ BOOST_CHECK(m_transactionSuccessful);
BOOST_CHECK(callFallback() == encodeArgs(u256(0x1234)));
}
diff --git a/test/libsolidity/ABIDecoderTests.cpp b/test/libsolidity/ABIDecoderTests.cpp
index c122d806..6504f6bc 100644
--- a/test/libsolidity/ABIDecoderTests.cpp
+++ b/test/libsolidity/ABIDecoderTests.cpp
@@ -266,7 +266,6 @@ BOOST_AUTO_TEST_CASE(calldata_arrays_too_large)
}
}
)";
- bool newEncoder = false;
BOTH_ENCODERS(
compileAndRun(sourceCode);
bytes args = encodeArgs(
@@ -275,9 +274,8 @@ BOOST_AUTO_TEST_CASE(calldata_arrays_too_large)
);
ABI_CHECK(
callContractFunction("f(uint256,uint256[],uint256)", args),
- newEncoder ? encodeArgs() : encodeArgs(7)
+ encodeArgs()
);
- newEncoder = true;
)
}
@@ -287,7 +285,7 @@ BOOST_AUTO_TEST_CASE(decode_from_memory_simple)
contract C {
uint public _a;
uint[] public _b;
- constructor(uint a, uint[] b) {
+ constructor(uint a, uint[] b) public {
_a = a;
_b = b;
}
@@ -312,24 +310,24 @@ BOOST_AUTO_TEST_CASE(decode_function_type)
string sourceCode = R"(
contract D {
function () external returns (uint) public _a;
- constructor(function () external returns (uint) a) {
+ constructor(function () external returns (uint) a) public {
_a = a;
}
}
contract C {
- function f() returns (uint) {
+ function f() public returns (uint) {
return 3;
}
- function g(function () external returns (uint) _f) returns (uint) {
+ function g(function () external returns (uint) _f) public returns (uint) {
return _f();
}
// uses "decode from memory"
- function test1() returns (uint) {
+ function test1() public returns (uint) {
D d = new D(this.f);
return d._a()();
}
// uses "decode from calldata"
- function test2() returns (uint) {
+ function test2() public returns (uint) {
return this.g(this.f);
}
}
@@ -346,13 +344,13 @@ BOOST_AUTO_TEST_CASE(decode_function_type_array)
string sourceCode = R"(
contract D {
function () external returns (uint)[] public _a;
- constructor(function () external returns (uint)[] a) {
+ constructor(function () external returns (uint)[] a) public {
_a = a;
}
}
contract E {
function () external returns (uint)[3] public _a;
- constructor(function () external returns (uint)[3] a) {
+ constructor(function () external returns (uint)[3] a) public {
_a = a;
}
}
@@ -374,7 +372,7 @@ BOOST_AUTO_TEST_CASE(decode_function_type_array)
}
// uses "decode from memory"
function test1_dynamic() public returns (uint) {
- var x = new function() external returns (uint)[](3);
+ function () external returns (uint)[] memory x = new function() external returns (uint)[](4);
x[0] = this.f1;
x[1] = this.f2;
x[2] = this.f3;
@@ -387,7 +385,7 @@ BOOST_AUTO_TEST_CASE(decode_function_type_array)
}
// uses "decode from calldata"
function test2_dynamic() public returns (uint) {
- var x = new function() external returns (uint)[](3);
+ function () external returns (uint)[] memory x = new function() external returns (uint)[](3);
x[0] = this.f1;
x[1] = this.f2;
x[2] = this.f3;
@@ -414,7 +412,7 @@ BOOST_AUTO_TEST_CASE(decode_from_memory_complex)
uint public _a;
uint[] public _b;
bytes[2] public _c;
- constructor(uint a, uint[] b, bytes[2] c) {
+ constructor(uint a, uint[] b, bytes[2] c) public {
_a = a;
_b = b;
_c = c;
@@ -449,13 +447,11 @@ BOOST_AUTO_TEST_CASE(short_input_value_type)
function f(uint a, uint b) public pure returns (uint) { return a; }
}
)";
- bool newDecoder = false;
BOTH_ENCODERS(
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("f(uint256,uint256)", 1, 2), encodeArgs(1));
ABI_CHECK(callContractFunctionNoEncoding("f(uint256,uint256)", bytes(64, 0)), encodeArgs(0));
- ABI_CHECK(callContractFunctionNoEncoding("f(uint256,uint256)", bytes(63, 0)), newDecoder ? encodeArgs() : encodeArgs(0));
- newDecoder = true;
+ ABI_CHECK(callContractFunctionNoEncoding("f(uint256,uint256)", bytes(63, 0)), encodeArgs());
)
}
@@ -466,15 +462,13 @@ BOOST_AUTO_TEST_CASE(short_input_array)
function f(uint[] a) public pure returns (uint) { return 7; }
}
)";
- bool newDecoder = false;
BOTH_ENCODERS(
compileAndRun(sourceCode);
ABI_CHECK(callContractFunctionNoEncoding("f(uint256[])", encodeArgs(0x20, 0)), encodeArgs(7));
- ABI_CHECK(callContractFunctionNoEncoding("f(uint256[])", encodeArgs(0x20, 1)), newDecoder ? encodeArgs() : encodeArgs(7));
- ABI_CHECK(callContractFunctionNoEncoding("f(uint256[])", encodeArgs(0x20, 1) + bytes(31, 0)), newDecoder ? encodeArgs() : encodeArgs(7));
+ ABI_CHECK(callContractFunctionNoEncoding("f(uint256[])", encodeArgs(0x20, 1)), encodeArgs());
+ ABI_CHECK(callContractFunctionNoEncoding("f(uint256[])", encodeArgs(0x20, 1) + bytes(31, 0)), encodeArgs());
ABI_CHECK(callContractFunctionNoEncoding("f(uint256[])", encodeArgs(0x20, 1) + bytes(32, 0)), encodeArgs(7));
ABI_CHECK(callContractFunctionNoEncoding("f(uint256[])", encodeArgs(0x20, 2, 5, 6)), encodeArgs(7));
- newDecoder = true;
)
}
@@ -558,7 +552,7 @@ BOOST_AUTO_TEST_CASE(storage_ptr)
r[2] = 3;
s.x = 11;
s.y = 12;
- var (a, b, c, d) = L.f(r, s);
+ (uint a, uint b, uint c, uint d) = L.f(r, s);
return (r[2], s.x, a, b, c, d);
}
}
diff --git a/test/libsolidity/ASTJSON.cpp b/test/libsolidity/ASTJSON.cpp
index 5d5b14e8..03e74097 100644
--- a/test/libsolidity/ASTJSON.cpp
+++ b/test/libsolidity/ASTJSON.cpp
@@ -44,7 +44,7 @@ BOOST_AUTO_TEST_SUITE(SolidityASTJSON)
BOOST_AUTO_TEST_CASE(short_type_name)
{
CompilerStack c;
- c.addSource("a", "contract c { function f() { uint[] memory x; } }");
+ c.addSource("a", "contract c { function f() public { uint[] memory x; } }");
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze();
map<string, unsigned> sourceIndices;
@@ -59,7 +59,7 @@ BOOST_AUTO_TEST_CASE(short_type_name)
BOOST_AUTO_TEST_CASE(short_type_name_ref)
{
CompilerStack c;
- c.addSource("a", "contract c { function f() { uint[][] memory rows; } }");
+ c.addSource("a", "contract c { function f() public { uint[][] memory rows; } }");
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze();
map<string, unsigned> sourceIndices;
diff --git a/test/libsolidity/ASTLegacyJSON.cpp b/test/libsolidity/ASTLegacyJSON.cpp
index 13148682..69cb1bb9 100644
--- a/test/libsolidity/ASTLegacyJSON.cpp
+++ b/test/libsolidity/ASTLegacyJSON.cpp
@@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE(enum_value)
BOOST_AUTO_TEST_CASE(modifier_definition)
{
CompilerStack c;
- c.addSource("a", "contract C { modifier M(uint i) { _; } function F() M(1) {} }");
+ c.addSource("a", "contract C { modifier M(uint i) { _; } function F() M(1) public {} }");
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze();
map<string, unsigned> sourceIndices;
@@ -139,7 +139,7 @@ BOOST_AUTO_TEST_CASE(modifier_definition)
BOOST_AUTO_TEST_CASE(modifier_invocation)
{
CompilerStack c;
- c.addSource("a", "contract C { modifier M(uint i) { _; } function F() M(1) {} }");
+ c.addSource("a", "contract C { modifier M(uint i) { _; } function F() M(1) public {} }");
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze();
map<string, unsigned> sourceIndices;
@@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE(array_type_name)
BOOST_AUTO_TEST_CASE(short_type_name)
{
CompilerStack c;
- c.addSource("a", "contract c { function f() { uint[] memory x; } }");
+ c.addSource("a", "contract c { function f() public { uint[] memory x; } }");
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze();
map<string, unsigned> sourceIndices;
@@ -202,7 +202,7 @@ BOOST_AUTO_TEST_CASE(short_type_name)
BOOST_AUTO_TEST_CASE(short_type_name_ref)
{
CompilerStack c;
- c.addSource("a", "contract c { function f() { uint[][] memory rows; } }");
+ c.addSource("a", "contract c { function f() public { uint[][] memory rows; } }");
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze();
map<string, unsigned> sourceIndices;
@@ -230,7 +230,7 @@ BOOST_AUTO_TEST_CASE(placeholder_statement)
BOOST_AUTO_TEST_CASE(non_utf8)
{
CompilerStack c;
- c.addSource("a", "contract C { function f() { var x = hex\"ff\"; } }");
+ c.addSource("a", "contract C { function f() public { var x = hex\"ff\"; } }");
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze();
map<string, unsigned> sourceIndices;
@@ -252,7 +252,7 @@ BOOST_AUTO_TEST_CASE(function_type)
CompilerStack c;
c.addSource("a",
"contract C { function f(function() external payable returns (uint) x) "
- "returns (function() external constant returns (uint)) {} }"
+ "returns (function() external view returns (uint)) {} }"
);
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.parseAndAnalyze();
diff --git a/test/libsolidity/Assembly.cpp b/test/libsolidity/Assembly.cpp
index 7b3df043..e815d7d5 100644
--- a/test/libsolidity/Assembly.cpp
+++ b/test/libsolidity/Assembly.cpp
@@ -152,7 +152,7 @@ BOOST_AUTO_TEST_CASE(location_test)
{
char const* sourceCode = R"(
contract test {
- function f() returns (uint256 a) {
+ function f() public returns (uint256 a) {
return 16;
}
}
@@ -160,19 +160,19 @@ BOOST_AUTO_TEST_CASE(location_test)
AssemblyItems items = compileContract(sourceCode);
bool hasShifts = dev::test::Options::get().evmVersion().hasBitwiseShifting();
vector<SourceLocation> locations =
- vector<SourceLocation>(hasShifts ? 23 : 24, SourceLocation(2, 75, make_shared<string>(""))) +
- vector<SourceLocation>(2, SourceLocation(20, 72, make_shared<string>(""))) +
+ vector<SourceLocation>(hasShifts ? 23 : 24, SourceLocation(2, 82, make_shared<string>(""))) +
+ vector<SourceLocation>(2, SourceLocation(20, 79, make_shared<string>(""))) +
vector<SourceLocation>(1, SourceLocation(8, 17, make_shared<string>("--CODEGEN--"))) +
vector<SourceLocation>(3, SourceLocation(5, 7, make_shared<string>("--CODEGEN--"))) +
vector<SourceLocation>(1, SourceLocation(30, 31, make_shared<string>("--CODEGEN--"))) +
vector<SourceLocation>(1, SourceLocation(27, 28, make_shared<string>("--CODEGEN--"))) +
vector<SourceLocation>(1, SourceLocation(20, 32, make_shared<string>("--CODEGEN--"))) +
vector<SourceLocation>(1, SourceLocation(5, 7, make_shared<string>("--CODEGEN--"))) +
- vector<SourceLocation>(24, SourceLocation(20, 72, make_shared<string>(""))) +
- vector<SourceLocation>(1, SourceLocation(42, 51, make_shared<string>(""))) +
- vector<SourceLocation>(1, SourceLocation(65, 67, make_shared<string>(""))) +
- vector<SourceLocation>(2, SourceLocation(58, 67, make_shared<string>(""))) +
- vector<SourceLocation>(2, SourceLocation(20, 72, make_shared<string>("")));
+ vector<SourceLocation>(24, SourceLocation(20, 79, make_shared<string>(""))) +
+ vector<SourceLocation>(1, SourceLocation(49, 58, make_shared<string>(""))) +
+ vector<SourceLocation>(1, SourceLocation(72, 74, make_shared<string>(""))) +
+ vector<SourceLocation>(2, SourceLocation(65, 74, make_shared<string>(""))) +
+ vector<SourceLocation>(2, SourceLocation(20, 79, make_shared<string>("")));
checkAssemblyLocations(items, locations);
}
diff --git a/test/libsolidity/GasMeter.cpp b/test/libsolidity/GasMeter.cpp
index 42965582..a404c072 100644
--- a/test/libsolidity/GasMeter.cpp
+++ b/test/libsolidity/GasMeter.cpp
@@ -87,6 +87,7 @@ public:
for (bytes const& arguments: _argumentVariants)
{
sendMessage(hash.asBytes() + arguments, false, 0);
+ BOOST_CHECK(m_transactionSuccessful);
gasUsed = max(gasUsed, m_gasUsed);
gas = max(gas, gasForTransaction(hash.asBytes() + arguments, false));
}
@@ -315,7 +316,7 @@ BOOST_AUTO_TEST_CASE(complex_control_flow)
// we previously considered. This of course reduces accuracy.
char const* sourceCode = R"(
contract log {
- function ln(int128 x) constant returns (int128 result) {
+ function ln(int128 x) pure returns (int128 result) {
int128 t = x / 256;
int128 y = 5545177;
x = t;
diff --git a/test/libsolidity/JSONCompiler.cpp b/test/libsolidity/LibSolc.cpp
index 2b3df3a7..9d5ffa27 100644
--- a/test/libsolidity/JSONCompiler.cpp
+++ b/test/libsolidity/LibSolc.cpp
@@ -16,7 +16,7 @@
*/
/**
* @date 2017
- * Unit tests for solc/jsonCompiler.cpp.
+ * Unit tests for libsolc/libsolc.cpp.
*/
#include <string>
@@ -70,7 +70,7 @@ Json::Value compile(string const& _input)
} // end anonymous namespace
-BOOST_AUTO_TEST_SUITE(JSONCompiler)
+BOOST_AUTO_TEST_SUITE(LibSolc)
BOOST_AUTO_TEST_CASE(read_version)
{
@@ -201,6 +201,26 @@ BOOST_AUTO_TEST_CASE(standard_compilation)
BOOST_CHECK(result.isMember("contracts"));
}
+BOOST_AUTO_TEST_CASE(new_api)
+{
+ char const* input = R"(
+ {
+ "language": "Solidity",
+ "sources": {
+ "fileA": {
+ "content": "contract A { }"
+ }
+ }
+ }
+ )";
+ BOOST_CHECK_EQUAL(string(version()), string(solidity_version()));
+ BOOST_CHECK_EQUAL(string(license()), string(solidity_license()));
+ BOOST_CHECK_EQUAL(
+ string(compileStandard(input, nullptr)),
+ string(solidity_compile(input, nullptr))
+ );
+}
+
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp
index a3ebd139..c366e866 100644
--- a/test/libsolidity/SolidityABIJSON.cpp
+++ b/test/libsolidity/SolidityABIJSON.cpp
@@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(basic_test)
{
char const* sourceCode = R"(
contract test {
- function f(uint a) returns(uint d) { return a * 7; }
+ function f(uint a) public returns (uint d) { return a * 7; }
}
)";
@@ -111,8 +111,8 @@ BOOST_AUTO_TEST_CASE(multiple_methods)
{
char const* sourceCode = R"(
contract test {
- function f(uint a) returns(uint d) { return a * 7; }
- function g(uint b) returns(uint e) { return b * 8; }
+ function f(uint a) public returns (uint d) { return a * 7; }
+ function g(uint b) public returns (uint e) { return b * 8; }
}
)";
@@ -164,7 +164,7 @@ BOOST_AUTO_TEST_CASE(multiple_params)
{
char const* sourceCode = R"(
contract test {
- function f(uint a, uint b) returns(uint d) { return a + b; }
+ function f(uint a, uint b) public returns (uint d) { return a + b; }
}
)";
@@ -202,8 +202,8 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order)
// methods are expected to be in alpabetical order
char const* sourceCode = R"(
contract test {
- function f(uint a) returns(uint d) { return a * 7; }
- function c(uint b) returns(uint e) { return b * 8; }
+ function f(uint a) public returns (uint d) { return a * 7; }
+ function c(uint b) public returns (uint e) { return b * 8; }
}
)";
@@ -255,7 +255,7 @@ BOOST_AUTO_TEST_CASE(view_function)
{
char const* sourceCode = R"(
contract test {
- function foo(uint a, uint b) returns(uint d) { return a + b; }
+ function foo(uint a, uint b) public returns (uint d) { return a + b; }
function boo(uint32 a) view returns(uint b) { return a * 4; }
}
)";
@@ -306,67 +306,11 @@ BOOST_AUTO_TEST_CASE(view_function)
checkInterface(sourceCode, interface);
}
-// constant is an alias to view above
-BOOST_AUTO_TEST_CASE(constant_function)
-{
- char const* sourceCode = R"(
- contract test {
- function foo(uint a, uint b) returns(uint d) { return a + b; }
- function boo(uint32 a) constant returns(uint b) { return a * 4; }
- }
- )";
-
- char const* interface = R"([
- {
- "name": "foo",
- "constant": false,
- "payable" : false,
- "stateMutability": "nonpayable",
- "type": "function",
- "inputs": [
- {
- "name": "a",
- "type": "uint256"
- },
- {
- "name": "b",
- "type": "uint256"
- }
- ],
- "outputs": [
- {
- "name": "d",
- "type": "uint256"
- }
- ]
- },
- {
- "name": "boo",
- "constant": true,
- "payable" : false,
- "stateMutability": "view",
- "type": "function",
- "inputs": [{
- "name": "a",
- "type": "uint32"
- }],
- "outputs": [
- {
- "name": "b",
- "type": "uint256"
- }
- ]
- }
- ])";
-
- checkInterface(sourceCode, interface);
-}
-
BOOST_AUTO_TEST_CASE(pure_function)
{
char const* sourceCode = R"(
contract test {
- function foo(uint a, uint b) returns(uint d) { return a + b; }
+ function foo(uint a, uint b) public returns (uint d) { return a + b; }
function boo(uint32 a) pure returns(uint b) { return a * 4; }
}
)";
@@ -421,7 +365,7 @@ BOOST_AUTO_TEST_CASE(events)
{
char const* sourceCode = R"(
contract test {
- function f(uint a) returns(uint d) { return a * 7; }
+ function f(uint a) public returns (uint d) { return a * 7; }
event e1(uint b, address indexed c);
event e2();
event e2(uint a);
@@ -519,11 +463,11 @@ BOOST_AUTO_TEST_CASE(inherited)
{
char const* sourceCode = R"(
contract Base {
- function baseFunction(uint p) returns (uint i) { return p; }
+ function baseFunction(uint p) public returns (uint i) { return p; }
event baseEvent(bytes32 indexed evtArgBase);
}
contract Derived is Base {
- function derivedFunction(bytes32 p) returns (bytes32 i) { return p; }
+ function derivedFunction(bytes32 p) public returns (bytes32 i) { return p; }
event derivedEvent(uint indexed evtArgDerived);
}
)";
@@ -593,7 +537,7 @@ BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one)
{
char const* sourceCode = R"(
contract test {
- function f(uint, uint k) returns(uint ret_k, uint ret_g) {
+ function f(uint, uint k) public returns (uint ret_k, uint ret_g) {
uint g = 8;
ret_k = k;
ret_g = g;
@@ -638,7 +582,7 @@ BOOST_AUTO_TEST_CASE(empty_name_return_parameter)
{
char const* sourceCode = R"(
contract test {
- function f(uint k) returns(uint) {
+ function f(uint k) public returns (uint) {
return k;
}
}
@@ -739,7 +683,7 @@ BOOST_AUTO_TEST_CASE(return_param_in_abi)
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
constructor(ActionChoices param) {}
- function ret() returns(ActionChoices) {
+ function ret() public returns (ActionChoices) {
ActionChoices action = ActionChoices.GoLeft;
return action;
}
@@ -812,7 +756,7 @@ BOOST_AUTO_TEST_CASE(library_function)
char const* sourceCode = R"(
library test {
struct StructType { uint a; }
- function f(StructType storage b, uint[] storage c, test d) returns (uint[] e, StructType storage f) {}
+ function f(StructType storage b, uint[] storage c, test d) public returns (uint[] e, StructType storage f) {}
}
)";
@@ -947,7 +891,7 @@ BOOST_AUTO_TEST_CASE(return_structs)
contract C {
struct S { uint a; T[] sub; }
struct T { uint[2] x; }
- function f() returns (uint x, S s) {
+ function f() public returns (uint x, S s) {
}
}
)";
@@ -996,7 +940,7 @@ BOOST_AUTO_TEST_CASE(return_structs_with_contracts)
pragma experimental ABIEncoderV2;
contract C {
struct S { C[] x; C y; }
- function f() returns (S s, C c) {
+ function f() public returns (S s, C c) {
}
}
)";
diff --git a/test/libsolidity/SolidityCompiler.cpp b/test/libsolidity/SolidityCompiler.cpp
index 3348bac5..0cc80dd8 100644
--- a/test/libsolidity/SolidityCompiler.cpp
+++ b/test/libsolidity/SolidityCompiler.cpp
@@ -38,7 +38,7 @@ BOOST_AUTO_TEST_CASE(does_not_include_creation_time_only_internal_functions)
char const* sourceCode = R"(
contract C {
uint x;
- constructor() { f(); }
+ constructor() public { f(); }
function f() internal { for (uint i = 0; i < 10; ++i) x += 3 + i; }
}
)";
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 7ea6cf98..bc613868 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -49,11 +49,30 @@ namespace test
BOOST_FIXTURE_TEST_SUITE(SolidityEndToEndTest, SolidityExecutionFramework)
+BOOST_AUTO_TEST_CASE(transaction_status)
+{
+ char const* sourceCode = R"(
+ contract test {
+ function f() { }
+ function g() { revert(); }
+ function h() { assert(false); }
+ }
+ )";
+ compileAndRun(sourceCode);
+ callContractFunction("f()");
+ BOOST_CHECK(m_transactionSuccessful);
+ callContractFunction("g()");
+ BOOST_CHECK(!m_transactionSuccessful);
+ callContractFunction("h()");
+ BOOST_CHECK(!m_transactionSuccessful);
+}
+
+
BOOST_AUTO_TEST_CASE(smoke_test)
{
char const* sourceCode = R"(
contract test {
- function f(uint a) returns(uint d) { return a * 7; }
+ function f(uint a) public returns(uint d) { return a * 7; }
}
)";
compileAndRun(sourceCode);
@@ -73,7 +92,7 @@ BOOST_AUTO_TEST_CASE(exp_operator)
{
char const* sourceCode = R"(
contract test {
- function f(uint a) returns(uint d) { return 2 ** a; }
+ function f(uint a) public returns(uint d) { return 2 ** a; }
}
)";
compileAndRun(sourceCode);
@@ -84,7 +103,7 @@ BOOST_AUTO_TEST_CASE(exp_operator_const)
{
char const* sourceCode = R"(
contract test {
- function f() returns(uint d) { return 2 ** 3; }
+ function f() public returns(uint d) { return 2 ** 3; }
}
)";
compileAndRun(sourceCode);
@@ -95,7 +114,7 @@ BOOST_AUTO_TEST_CASE(exp_operator_const_signed)
{
char const* sourceCode = R"(
contract test {
- function f() returns(int d) { return (-2) ** 3; }
+ function f() public returns(int d) { return (-2) ** 3; }
}
)";
compileAndRun(sourceCode);
@@ -106,7 +125,7 @@ BOOST_AUTO_TEST_CASE(exp_zero)
{
char const* sourceCode = R"(
contract test {
- function f(uint a) returns(uint d) { return a ** 0; }
+ function f(uint a) public returns(uint d) { return a ** 0; }
}
)";
compileAndRun(sourceCode);
@@ -117,7 +136,7 @@ BOOST_AUTO_TEST_CASE(exp_zero_literal)
{
char const* sourceCode = R"(
contract test {
- function f() returns(uint d) { return 0 ** 0; }
+ function f() public returns(uint d) { return 0 ** 0; }
}
)";
compileAndRun(sourceCode);
@@ -129,7 +148,7 @@ BOOST_AUTO_TEST_CASE(conditional_expression_true_literal)
{
char const* sourceCode = R"(
contract test {
- function f() returns(uint d) {
+ function f() public returns(uint d) {
return true ? 5 : 10;
}
}
@@ -142,7 +161,7 @@ BOOST_AUTO_TEST_CASE(conditional_expression_false_literal)
{
char const* sourceCode = R"(
contract test {
- function f() returns(uint d) {
+ function f() public returns(uint d) {
return false ? 5 : 10;
}
}
@@ -155,7 +174,7 @@ BOOST_AUTO_TEST_CASE(conditional_expression_multiple)
{
char const* sourceCode = R"(
contract test {
- function f(uint x) returns(uint d) {
+ function f(uint x) public returns(uint d) {
return x > 100 ?
x > 1000 ? 1000 : 100
:
@@ -174,7 +193,7 @@ BOOST_AUTO_TEST_CASE(conditional_expression_with_return_values)
{
char const* sourceCode = R"(
contract test {
- function f(bool cond, uint v) returns (uint a, uint b) {
+ function f(bool cond, uint v) public returns (uint a, uint b) {
cond ? a = v : b = v;
}
}
@@ -189,7 +208,7 @@ BOOST_AUTO_TEST_CASE(conditional_expression_storage_memory_1)
char const* sourceCode = R"(
contract test {
bytes2[2] data1;
- function f(bool cond) returns (uint) {
+ function f(bool cond) public returns (uint) {
bytes2[2] memory x;
x[0] = "aa";
bytes2[2] memory y;
@@ -222,7 +241,7 @@ BOOST_AUTO_TEST_CASE(conditional_expression_storage_memory_2)
char const* sourceCode = R"(
contract test {
bytes2[2] data1;
- function f(bool cond) returns (uint) {
+ function f(bool cond) public returns (uint) {
data1[0] = "cc";
bytes2[2] memory x;
@@ -255,7 +274,7 @@ BOOST_AUTO_TEST_CASE(conditional_expression_different_types)
{
char const* sourceCode = R"(
contract test {
- function f(bool cond) returns (uint) {
+ function f(bool cond) public returns (uint) {
uint8 x = 0xcd;
uint16 y = 0xabab;
return cond ? x : y;
@@ -272,7 +291,7 @@ BOOST_AUTO_TEST_CASE(conditional_expression_string_literal)
{
char const* sourceCode = R"(
contract test {
- function f(bool cond) returns (bytes32) {
+ function f(bool cond) public returns (bytes32) {
return cond ? "true" : "false";
}
}
@@ -287,7 +306,7 @@ BOOST_AUTO_TEST_CASE(conditional_expression_tuples)
{
char const* sourceCode = R"(
contract test {
- function f(bool cond) returns (uint, uint) {
+ function f(bool cond) public returns (uint, uint) {
return cond ? (1, 2) : (3, 4);
}
}
@@ -301,11 +320,11 @@ BOOST_AUTO_TEST_CASE(conditional_expression_functions)
{
char const* sourceCode = R"(
contract test {
- function x() returns (uint) { return 1; }
- function y() returns (uint) { return 2; }
+ function x() public returns (uint) { return 1; }
+ function y() public returns (uint) { return 2; }
- function f(bool cond) returns (uint) {
- var z = cond ? x : y;
+ function f(bool cond) public returns (uint) {
+ function () returns (uint) z = cond ? x : y;
return z();
}
}
@@ -367,7 +386,7 @@ BOOST_AUTO_TEST_CASE(recursive_calls)
{
char const* sourceCode = R"(
contract test {
- function f(uint n) returns(uint nfac) {
+ function f(uint n) public returns(uint nfac) {
if (n <= 1) return 1;
else return n * f(n - 1);
}
@@ -389,10 +408,10 @@ BOOST_AUTO_TEST_CASE(multiple_functions)
{
char const* sourceCode = R"(
contract test {
- function a() returns(uint n) { return 0; }
- function b() returns(uint n) { return 1; }
- function c() returns(uint n) { return 2; }
- function f() returns(uint n) { return 3; }
+ function a() public returns(uint n) { return 0; }
+ function b() public returns(uint n) { return 1; }
+ function c() public returns(uint n) { return 2; }
+ function f() public returns(uint n) { return 3; }
}
)";
compileAndRun(sourceCode);
@@ -407,8 +426,8 @@ BOOST_AUTO_TEST_CASE(named_args)
{
char const* sourceCode = R"(
contract test {
- function a(uint a, uint b, uint c) returns (uint r) { r = a * 100 + b * 10 + c * 1; }
- function b() returns (uint r) { r = a({a: 1, b: 2, c: 3}); }
+ function a(uint a, uint b, uint c) public returns (uint r) { r = a * 100 + b * 10 + c * 1; }
+ function b() public returns (uint r) { r = a({a: 1, b: 2, c: 3}); }
}
)";
compileAndRun(sourceCode);
@@ -419,8 +438,8 @@ BOOST_AUTO_TEST_CASE(disorder_named_args)
{
char const* sourceCode = R"(
contract test {
- function a(uint a, uint b, uint c) returns (uint r) { r = a * 100 + b * 10 + c * 1; }
- function b() returns (uint r) { r = a({c: 3, a: 1, b: 2}); }
+ function a(uint a, uint b, uint c) public returns (uint r) { r = a * 100 + b * 10 + c * 1; }
+ function b() public returns (uint r) { r = a({c: 3, a: 1, b: 2}); }
}
)";
compileAndRun(sourceCode);
@@ -431,9 +450,9 @@ BOOST_AUTO_TEST_CASE(while_loop)
{
char const* sourceCode = R"(
contract test {
- function f(uint n) returns(uint nfac) {
+ function f(uint n) public returns(uint nfac) {
nfac = 1;
- var i = 2;
+ uint i = 2;
while (i <= n) nfac *= i++;
}
}
@@ -458,9 +477,9 @@ BOOST_AUTO_TEST_CASE(do_while_loop)
{
char const* sourceCode = R"(
contract test {
- function f(uint n) returns(uint nfac) {
+ function f(uint n) public returns(uint nfac) {
nfac = 1;
- var i = 2;
+ uint i = 2;
do { nfac *= i++; } while (i <= n);
}
}
@@ -509,7 +528,7 @@ BOOST_AUTO_TEST_CASE(nested_loops)
// tests that break and continue statements in nested loops jump to the correct place
char const* sourceCode = R"(
contract test {
- function f(uint x) returns(uint y) {
+ function f(uint x) public returns(uint y) {
while (x > 1) {
if (x == 10) break;
while (x > 5) {
@@ -559,9 +578,10 @@ BOOST_AUTO_TEST_CASE(for_loop)
{
char const* sourceCode = R"(
contract test {
- function f(uint n) returns(uint nfac) {
+ function f(uint n) public returns(uint nfac) {
nfac = 1;
- for (var i = 2; i <= n; i++)
+ uint i;
+ for (i = 2; i <= n; i++)
nfac *= i;
}
}
@@ -583,7 +603,7 @@ BOOST_AUTO_TEST_CASE(for_loop_empty)
{
char const* sourceCode = R"(
contract test {
- function f() returns(uint ret) {
+ function f() public returns(uint ret) {
ret = 1;
for (;;) {
ret += 1;
@@ -612,7 +632,7 @@ BOOST_AUTO_TEST_CASE(for_loop_simple_init_expr)
{
char const* sourceCode = R"(
contract test {
- function f(uint n) returns(uint nfac) {
+ function f(uint n) public returns(uint nfac) {
nfac = 1;
uint256 i;
for (i = 2; i <= n; i++)
@@ -638,7 +658,7 @@ BOOST_AUTO_TEST_CASE(for_loop_break_continue)
{
char const* sourceCode = R"(
contract test {
- function f(uint n) returns (uint r)
+ function f(uint n) public returns (uint r)
{
uint i = 1;
uint k = 0;
@@ -684,16 +704,16 @@ BOOST_AUTO_TEST_CASE(calling_other_functions)
{
char const* sourceCode = R"(
contract collatz {
- function run(uint x) returns(uint y) {
+ function run(uint x) public returns(uint y) {
while ((y = x) > 1) {
if (x % 2 == 0) x = evenStep(x);
else x = oddStep(x);
}
}
- function evenStep(uint x) returns(uint y) {
+ function evenStep(uint x) public returns(uint y) {
return x / 2;
}
- function oddStep(uint x) returns(uint y) {
+ function oddStep(uint x) public returns(uint y) {
return 3 * x + 1;
}
}
@@ -734,8 +754,8 @@ BOOST_AUTO_TEST_CASE(many_local_variables)
{
char const* sourceCode = R"(
contract test {
- function run(uint x1, uint x2, uint x3) returns(uint y) {
- var a = 0x1; var b = 0x10; var c = 0x100;
+ function run(uint x1, uint x2, uint x3) public returns(uint y) {
+ uint8 a = 0x1; uint8 b = 0x10; uint16 c = 0x100;
y = a + b + c + x1 + x2 + x3;
y += b + x2;
}
@@ -757,7 +777,7 @@ BOOST_AUTO_TEST_CASE(packing_unpacking_types)
{
char const* sourceCode = R"(
contract test {
- function run(bool a, uint32 b, uint64 c) returns(uint256 y) {
+ function run(bool a, uint32 b, uint64 c) public returns(uint256 y) {
if (a) y = 1;
y = y * 0x100000000 | ~b;
y = y * 0x10000000000000000 | ~c;
@@ -775,7 +795,7 @@ BOOST_AUTO_TEST_CASE(packing_signed_types)
{
char const* sourceCode = R"(
contract test {
- function run() returns(int8 y) {
+ function run() public returns(int8 y) {
uint8 x = 0xfa;
return int8(x);
}
@@ -792,7 +812,7 @@ BOOST_AUTO_TEST_CASE(multiple_return_values)
{
char const* sourceCode = R"(
contract test {
- function run(bool x1, uint x2) returns(uint y1, bool y2, uint y3) {
+ function run(bool x1, uint x2) public returns(uint y1, bool y2, uint y3) {
y1 = x2; y2 = x1;
}
}
@@ -805,7 +825,7 @@ BOOST_AUTO_TEST_CASE(short_circuiting)
{
char const* sourceCode = R"(
contract test {
- function run(uint x) returns(uint y) {
+ function run(uint x) public returns(uint y) {
x == 0 || ((x = 8) > 0);
return x;
}
@@ -826,7 +846,7 @@ BOOST_AUTO_TEST_CASE(high_bits_cleaning)
{
char const* sourceCode = R"(
contract test {
- function run() returns(uint256 y) {
+ function run() public returns(uint256 y) {
uint32 t = uint32(0xffffffff);
uint32 x = t + 10;
if (x >= 0xffffffff) return 0;
@@ -850,7 +870,7 @@ BOOST_AUTO_TEST_CASE(sign_extension)
{
char const* sourceCode = R"(
contract test {
- function run() returns(uint256 y) {
+ function run() public returns(uint256 y) {
int64 x = -int32(0xff);
if (x >= 0xff) return 0;
return -uint256(x);
@@ -872,7 +892,7 @@ BOOST_AUTO_TEST_CASE(small_unsigned_types)
{
char const* sourceCode = R"(
contract test {
- function run() returns(uint256 y) {
+ function run() public returns(uint256 y) {
uint32 t = uint32(0xffffff);
uint32 x = t * 0xffffff;
return x / 0x100;
@@ -893,7 +913,7 @@ BOOST_AUTO_TEST_CASE(small_signed_types)
{
char const* sourceCode = R"(
contract test {
- function run() returns(int256 y) {
+ function run() public returns(int256 y) {
return -int32(10) * -int64(20);
}
}
@@ -910,10 +930,10 @@ BOOST_AUTO_TEST_CASE(strings)
{
char const* sourceCode = R"(
contract test {
- function fixedBytes() returns(bytes32 ret) {
+ function fixedBytes() public returns(bytes32 ret) {
return "abc\x00\xff__";
}
- function pipeThrough(bytes2 small, bool one) returns(bytes16 large, bool oneRet) {
+ function pipeThrough(bytes2 small, bool one) public returns(bytes16 large, bool oneRet) {
oneRet = one;
large = small;
}
@@ -930,7 +950,7 @@ BOOST_AUTO_TEST_CASE(inc_dec_operators)
contract test {
uint8 x;
uint v;
- function f() returns (uint r) {
+ function f() public returns (uint r) {
uint a = 6;
r = a;
r += (a++) * 0x10;
@@ -949,7 +969,7 @@ BOOST_AUTO_TEST_CASE(bytes_comparison)
{
char const* sourceCode = R"(
contract test {
- function f() returns (bool) {
+ function f() public returns (bool) {
bytes2 a = "a";
bytes2 x = "aa";
bytes2 b = "b";
@@ -967,7 +987,7 @@ BOOST_AUTO_TEST_CASE(state_smoke_test)
contract test {
uint256 value1;
uint256 value2;
- function get(uint8 which) returns (uint256 value) {
+ function get(uint8 which) public returns (uint256 value) {
if (which == 0) return value1;
else return value2;
}
@@ -994,7 +1014,7 @@ BOOST_AUTO_TEST_CASE(compound_assign)
contract test {
uint value1;
uint value2;
- function f(uint x, uint y) returns (uint w) {
+ function f(uint x, uint y) public returns (uint w) {
uint value3 = y;
value1 += x;
value3 *= x;
@@ -1030,7 +1050,7 @@ BOOST_AUTO_TEST_CASE(simple_mapping)
char const* sourceCode = R"(
contract test {
mapping(uint8 => uint8) table;
- function get(uint8 k) returns (uint8 v) {
+ function get(uint8 k) public returns (uint8 v) {
return table[k];
}
function set(uint8 k, uint8 v) {
@@ -1064,13 +1084,13 @@ BOOST_AUTO_TEST_CASE(mapping_state)
mapping(address => bool) canVote;
mapping(address => uint) voteCount;
mapping(address => bool) voted;
- function getVoteCount(address addr) returns (uint retVoteCount) {
+ function getVoteCount(address addr) public returns (uint retVoteCount) {
return voteCount[addr];
}
function grantVoteRight(address addr) {
canVote[addr] = true;
}
- function vote(address voter, address vote) returns (bool success) {
+ function vote(address voter, address vote) public returns (bool success) {
if (!canVote[voter] || voted[voter]) return false;
voted[voter] = true;
voteCount[vote] = voteCount[vote] + 1;
@@ -1140,7 +1160,7 @@ BOOST_AUTO_TEST_CASE(mapping_state_inc_dec)
contract test {
uint value;
mapping(uint => uint) table;
- function f(uint x) returns (uint y) {
+ function f(uint x) public returns (uint y) {
value = x;
if (x > 0) table[++value] = 8;
if (x > 1) value--;
@@ -1172,7 +1192,7 @@ BOOST_AUTO_TEST_CASE(multi_level_mapping)
char const* sourceCode = R"(
contract test {
mapping(uint => mapping(uint => uint)) table;
- function f(uint x, uint y, uint z) returns (uint w) {
+ function f(uint x, uint y, uint z) public returns (uint w) {
if (z == 0) return table[x][y];
else return table[x][y] = z;
}
@@ -1210,7 +1230,7 @@ BOOST_AUTO_TEST_CASE(structs)
mapping(uint8 => s2) recursive;
}
s2 data;
- function check() returns (bool ok) {
+ function check() public returns (bool ok) {
return data.z == 1 && data.s1data.x == 2 &&
data.s1data.y == true &&
data.recursive[3].recursive[4].z == 5 &&
@@ -1218,7 +1238,7 @@ BOOST_AUTO_TEST_CASE(structs)
data.recursive[0].s1data.y == false &&
data.recursive[4].z == 9;
}
- function set() {
+ function set() public {
data.z = 1;
data.s1data.x = 2;
data.s1data.y = true;
@@ -1244,15 +1264,15 @@ BOOST_AUTO_TEST_CASE(struct_reference)
mapping(uint8 => s2) recursive;
}
s2 data;
- function check() returns (bool ok) {
+ function check() public returns (bool ok) {
return data.z == 2 &&
data.recursive[0].z == 3 &&
data.recursive[0].recursive[1].z == 0 &&
data.recursive[0].recursive[0].z == 1;
}
- function set() {
+ function set() public {
data.z = 2;
- var map = data.recursive;
+ mapping(uint8 => s2) map = data.recursive;
s2 inner = map[0];
inner.z = 3;
inner.recursive[0].z = inner.recursive[1].z + 1;
@@ -1292,19 +1312,19 @@ BOOST_AUTO_TEST_CASE(deleteStruct)
delete str;
delete toDelete;
}
- function getToDelete() returns (uint res){
+ function getToDelete() public returns (uint res){
res = toDelete;
}
- function getTopValue() returns(uint topValue){
+ function getTopValue() public returns(uint topValue){
topValue = str.topValue;
}
- function getNestedValue() returns(uint nestedValue){
+ function getNestedValue() public returns(uint nestedValue){
nestedValue = str.nstr.nestedValue;
}
- function getTopMapping(uint index) returns(uint ret) {
+ function getTopMapping(uint index) public returns(uint ret) {
ret = str.topMapping[index];
}
- function getNestedMapping(uint index) returns(bool ret) {
+ function getNestedMapping(uint index) public returns(bool ret) {
return str.nstr.nestedMapping[index];
}
}
@@ -1324,7 +1344,7 @@ BOOST_AUTO_TEST_CASE(deleteLocal)
{
char const* sourceCode = R"(
contract test {
- function delLocal() returns (uint res){
+ function delLocal() public returns (uint res){
uint v = 5;
delete v;
res = v;
@@ -1339,7 +1359,7 @@ BOOST_AUTO_TEST_CASE(deleteLocals)
{
char const* sourceCode = R"(
contract test {
- function delLocal() returns (uint res1, uint res2){
+ function delLocal() public returns (uint res1, uint res2){
uint v = 5;
uint w = 6;
uint x = 7;
@@ -1358,10 +1378,10 @@ BOOST_AUTO_TEST_CASE(constructor)
char const* sourceCode = R"(
contract test {
mapping(uint => uint) data;
- constructor() {
+ constructor() public {
data[7] = 8;
}
- function get(uint key) returns (uint value) {
+ function get(uint key) public returns (uint value) {
return data[key];
}
}
@@ -1382,7 +1402,7 @@ BOOST_AUTO_TEST_CASE(simple_accessor)
char const* sourceCode = R"(
contract test {
uint256 public data;
- constructor() {
+ constructor() public {
data = 8;
}
}
@@ -1401,7 +1421,7 @@ BOOST_AUTO_TEST_CASE(array_accessor)
struct st { uint a; uint[] finalArray; }
mapping(uint256 => mapping(uint256 => st[5])) public multiple_map;
- constructor() {
+ constructor() public {
data[0] = 8;
dynamicData.length = 3;
dynamicData[2] = 8;
@@ -1431,7 +1451,7 @@ BOOST_AUTO_TEST_CASE(accessors_mapping_for_array)
contract test {
mapping(uint => uint[8]) public data;
mapping(uint => uint[]) public dynamicData;
- constructor() {
+ constructor() public {
data[2][2] = 8;
dynamicData[2].length = 3;
dynamicData[2][2] = 8;
@@ -1453,7 +1473,7 @@ BOOST_AUTO_TEST_CASE(multiple_elementary_accessors)
bytes6 public name;
bytes32 public a_hash;
address public an_address;
- constructor() {
+ constructor() public {
data = 8;
name = "Celina";
a_hash = keccak256("\x7b");
@@ -1479,7 +1499,7 @@ BOOST_AUTO_TEST_CASE(complex_accessors)
mapping(uint256 => bool) public to_bool_map;
mapping(uint256 => uint256) public to_uint_map;
mapping(uint256 => mapping(uint256 => uint256)) public to_multiple_map;
- constructor() {
+ constructor() public {
to_string_map[42] = "24";
to_bool_map[42] = false;
to_uint_map[42] = 12;
@@ -1500,7 +1520,7 @@ BOOST_AUTO_TEST_CASE(struct_accessor)
contract test {
struct Data { uint a; uint8 b; mapping(uint => uint) c; bool d; }
mapping(uint => Data) public data;
- constructor() {
+ constructor() public {
data[7].a = 1;
data[7].b = 2;
data[7].c[0] = 3;
@@ -1516,8 +1536,8 @@ BOOST_AUTO_TEST_CASE(balance)
{
char const* sourceCode = R"(
contract test {
- constructor() payable {}
- function getBalance() returns (uint256 balance) {
+ constructor() public payable {}
+ function getBalance() public returns (uint256 balance) {
return address(this).balance;
}
}
@@ -1530,8 +1550,8 @@ BOOST_AUTO_TEST_CASE(blockchain)
{
char const* sourceCode = R"(
contract test {
- constructor() payable {}
- function someInfo() payable returns (uint256 value, address coinbase, uint256 blockNumber) {
+ constructor() public payable {}
+ function someInfo() public payable returns (uint256 value, address coinbase, uint256 blockNumber) {
value = msg.value;
coinbase = block.coinbase;
blockNumber = block.number;
@@ -1548,7 +1568,7 @@ BOOST_AUTO_TEST_CASE(msg_sig)
{
char const* sourceCode = R"(
contract test {
- function foo(uint256 a) returns (bytes4 value) {
+ function foo(uint256 a) public returns (bytes4 value) {
return msg.sig;
}
}
@@ -1561,10 +1581,10 @@ BOOST_AUTO_TEST_CASE(msg_sig_after_internal_call_is_same)
{
char const* sourceCode = R"(
contract test {
- function boo() returns (bytes4 value) {
+ function boo() public returns (bytes4 value) {
return msg.sig;
}
- function foo(uint256 a) returns (bytes4 value) {
+ function foo(uint256 a) public returns (bytes4 value) {
return boo();
}
}
@@ -1577,7 +1597,7 @@ BOOST_AUTO_TEST_CASE(now)
{
char const* sourceCode = R"(
contract test {
- function someInfo() returns (bool equal, uint val) {
+ function someInfo() public returns (bool equal, uint val) {
equal = block.timestamp == now;
val = now;
}
@@ -1600,7 +1620,7 @@ BOOST_AUTO_TEST_CASE(type_conversions_cleanup)
// integer should drop the first two bytes
char const* sourceCode = R"(
contract Test {
- function test() returns (uint ret) { return uint(address(Test(address(0x11223344556677889900112233445566778899001122)))); }
+ function test() public returns (uint ret) { return uint(address(Test(address(0x11223344556677889900112233445566778899001122)))); }
}
)";
compileAndRun(sourceCode);
@@ -1613,7 +1633,7 @@ BOOST_AUTO_TEST_CASE(convert_fixed_bytes_to_fixed_bytes_smaller_size)
{
char const* sourceCode = R"(
contract Test {
- function bytesToBytes(bytes4 input) returns (bytes2 ret) {
+ function bytesToBytes(bytes4 input) public returns (bytes2 ret) {
return bytes2(input);
}
}
@@ -1626,7 +1646,7 @@ BOOST_AUTO_TEST_CASE(convert_fixed_bytes_to_fixed_bytes_greater_size)
{
char const* sourceCode = R"(
contract Test {
- function bytesToBytes(bytes2 input) returns (bytes4 ret) {
+ function bytesToBytes(bytes2 input) public returns (bytes4 ret) {
return bytes4(input);
}
}
@@ -1639,7 +1659,7 @@ BOOST_AUTO_TEST_CASE(convert_fixed_bytes_to_fixed_bytes_same_size)
{
char const* sourceCode = R"(
contract Test {
- function bytesToBytes(bytes4 input) returns (bytes4 ret) {
+ function bytesToBytes(bytes4 input) public returns (bytes4 ret) {
return bytes4(input);
}
}
@@ -1653,7 +1673,7 @@ BOOST_AUTO_TEST_CASE(convert_fixed_bytes_to_uint_same_size)
{
char const* sourceCode = R"(
contract Test {
- function bytesToUint(bytes32 s) returns (uint256 h) {
+ function bytesToUint(bytes32 s) public returns (uint256 h) {
return uint(s);
}
}
@@ -1669,7 +1689,7 @@ BOOST_AUTO_TEST_CASE(convert_fixed_bytes_to_uint_same_min_size)
{
char const* sourceCode = R"(
contract Test {
- function bytesToUint(bytes1 s) returns (uint8 h) {
+ function bytesToUint(bytes1 s) public returns (uint8 h) {
return uint8(s);
}
}
@@ -1685,7 +1705,7 @@ BOOST_AUTO_TEST_CASE(convert_fixed_bytes_to_uint_smaller_size)
{
char const* sourceCode = R"(
contract Test {
- function bytesToUint(bytes4 s) returns (uint16 h) {
+ function bytesToUint(bytes4 s) public returns (uint16 h) {
return uint16(uint32(s));
}
}
@@ -1701,7 +1721,7 @@ BOOST_AUTO_TEST_CASE(convert_fixed_bytes_to_uint_greater_size)
{
char const* sourceCode = R"(
contract Test {
- function bytesToUint(bytes4 s) returns (uint64 h) {
+ function bytesToUint(bytes4 s) public returns (uint64 h) {
return uint64(uint32(s));
}
}
@@ -1718,7 +1738,7 @@ BOOST_AUTO_TEST_CASE(convert_uint_to_fixed_bytes_same_size)
{
char const* sourceCode = R"(
contract Test {
- function uintToBytes(uint256 h) returns (bytes32 s) {
+ function uintToBytes(uint256 h) public returns (bytes32 s) {
return bytes32(h);
}
}
@@ -1732,7 +1752,7 @@ BOOST_AUTO_TEST_CASE(convert_uint_to_fixed_bytes_same_min_size)
{
char const* sourceCode = R"(
contract Test {
- function UintToBytes(uint8 h) returns (bytes1 s) {
+ function UintToBytes(uint8 h) public returns (bytes1 s) {
return bytes1(h);
}
}
@@ -1748,7 +1768,7 @@ BOOST_AUTO_TEST_CASE(convert_uint_to_fixed_bytes_smaller_size)
{
char const* sourceCode = R"(
contract Test {
- function uintToBytes(uint32 h) returns (bytes2 s) {
+ function uintToBytes(uint32 h) public returns (bytes2 s) {
return bytes2(uint16(h));
}
}
@@ -1764,7 +1784,7 @@ BOOST_AUTO_TEST_CASE(convert_uint_to_fixed_bytes_greater_size)
{
char const* sourceCode = R"(
contract Test {
- function UintToBytes(uint16 h) returns (bytes8 s) {
+ function UintToBytes(uint16 h) public returns (bytes8 s) {
return bytes8(uint64(h));
}
}
@@ -1780,8 +1800,8 @@ BOOST_AUTO_TEST_CASE(send_ether)
{
char const* sourceCode = R"(
contract test {
- constructor() payable {}
- function a(address addr, uint amount) returns (uint ret) {
+ constructor() payable public {}
+ function a(address addr, uint amount) public returns (uint ret) {
addr.send(amount);
return address(this).balance;
}
@@ -1798,8 +1818,8 @@ BOOST_AUTO_TEST_CASE(transfer_ether)
{
char const* sourceCode = R"(
contract A {
- constructor() payable {}
- function a(address addr, uint amount) returns (uint) {
+ constructor() public payable {}
+ function a(address addr, uint amount) public returns (uint) {
addr.transfer(amount);
return this.balance;
}
@@ -1836,8 +1856,7 @@ BOOST_AUTO_TEST_CASE(uncalled_blockhash)
contract C {
function f() public view returns (bytes32)
{
- var x = block.blockhash;
- return x(block.number - 1);
+ return (blockhash)(block.number - 1);
}
}
)";
@@ -1863,7 +1882,7 @@ BOOST_AUTO_TEST_CASE(log0)
{
char const* sourceCode = R"(
contract test {
- function a() {
+ function a() public {
log0(1);
}
}
@@ -1880,7 +1899,7 @@ BOOST_AUTO_TEST_CASE(log1)
{
char const* sourceCode = R"(
contract test {
- function a() {
+ function a() public {
log1(1, 2);
}
}
@@ -1898,7 +1917,7 @@ BOOST_AUTO_TEST_CASE(log2)
{
char const* sourceCode = R"(
contract test {
- function a() {
+ function a() public {
log2(1, 2, 3);
}
}
@@ -1917,7 +1936,7 @@ BOOST_AUTO_TEST_CASE(log3)
{
char const* sourceCode = R"(
contract test {
- function a() {
+ function a() public {
log3(1, 2, 3, 4);
}
}
@@ -1936,7 +1955,7 @@ BOOST_AUTO_TEST_CASE(log4)
{
char const* sourceCode = R"(
contract test {
- function a() {
+ function a() public {
log4(1, 2, 3, 4, 5);
}
}
@@ -1955,7 +1974,7 @@ BOOST_AUTO_TEST_CASE(log_in_constructor)
{
char const* sourceCode = R"(
contract test {
- constructor() {
+ constructor() public {
log1(1, 2);
}
}
@@ -1972,8 +1991,8 @@ BOOST_AUTO_TEST_CASE(selfdestruct)
{
char const* sourceCode = R"(
contract test {
- constructor() payable {}
- function a(address receiver) returns (uint ret) {
+ constructor() public payable {}
+ function a(address receiver) public returns (uint ret) {
selfdestruct(receiver);
return 10;
}
@@ -1991,7 +2010,7 @@ BOOST_AUTO_TEST_CASE(keccak256)
{
char const* sourceCode = R"(
contract test {
- function a(bytes32 input) returns (bytes32 hash) {
+ function a(bytes32 input) public returns (bytes32 hash) {
return keccak256(abi.encodePacked(input));
}
}
@@ -2010,7 +2029,7 @@ BOOST_AUTO_TEST_CASE(sha256)
{
char const* sourceCode = R"(
contract test {
- function a(bytes32 input) returns (bytes32 sha256hash) {
+ function a(bytes32 input) public returns (bytes32 sha256hash) {
return sha256(abi.encodePacked(input));
}
}
@@ -2035,7 +2054,7 @@ BOOST_AUTO_TEST_CASE(ripemd)
{
char const* sourceCode = R"(
contract test {
- function a(bytes32 input) returns (bytes32 sha256hash) {
+ function a(bytes32 input) public returns (bytes32 sha256hash) {
return ripemd160(abi.encodePacked(input));
}
}
@@ -2060,8 +2079,8 @@ BOOST_AUTO_TEST_CASE(packed_keccak256)
{
char const* sourceCode = R"(
contract test {
- function a(bytes32 input) returns (bytes32 hash) {
- var b = 65536;
+ function a(bytes32 input) public returns (bytes32 hash) {
+ uint24 b = 65536;
uint c = 256;
return keccak256(abi.encodePacked(8, input, b, input, c));
}
@@ -2088,7 +2107,7 @@ BOOST_AUTO_TEST_CASE(packed_keccak256_complex_types)
char const* sourceCode = R"(
contract test {
uint120[3] x;
- function f() returns (bytes32 hash1, bytes32 hash2, bytes32 hash3) {
+ function f() public returns (bytes32 hash1, bytes32 hash2, bytes32 hash3) {
uint120[] memory y = new uint120[](3);
x[0] = y[0] = uint120(-2);
x[1] = y[1] = uint120(-3);
@@ -2112,8 +2131,8 @@ BOOST_AUTO_TEST_CASE(packed_sha256)
{
char const* sourceCode = R"(
contract test {
- function a(bytes32 input) returns (bytes32 hash) {
- var b = 65536;
+ function a(bytes32 input) public returns (bytes32 hash) {
+ uint24 b = 65536;
uint c = 256;
return sha256(abi.encodePacked(8, input, b, input, c));
}
@@ -2139,8 +2158,8 @@ BOOST_AUTO_TEST_CASE(packed_ripemd160)
{
char const* sourceCode = R"(
contract test {
- function a(bytes32 input) returns (bytes32 hash) {
- var b = 65536;
+ function a(bytes32 input) public returns (bytes32 hash) {
+ uint24 b = 65536;
uint c = 256;
return ripemd160(abi.encodePacked(8, input, b, input, c));
}
@@ -2166,7 +2185,7 @@ BOOST_AUTO_TEST_CASE(ecrecover)
{
char const* sourceCode = R"(
contract test {
- function a(bytes32 h, uint8 v, bytes32 r, bytes32 s) returns (address addr) {
+ function a(bytes32 h, uint8 v, bytes32 r, bytes32 s) public returns (address addr) {
return ecrecover(h, v, r, s);
}
}
@@ -2184,16 +2203,16 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls)
{
char const* sourceCode = R"(
contract Helper {
- function multiply(uint a, uint b) returns (uint c) {
+ function multiply(uint a, uint b) public returns (uint c) {
return a * b;
}
}
contract Main {
Helper h;
- function callHelper(uint a, uint b) returns (uint c) {
+ function callHelper(uint a, uint b) public returns (uint c) {
return h.multiply(a, b);
}
- function getHelper() returns (address haddress) {
+ function getHelper() public returns (address haddress) {
return address(h);
}
function setHelper(address haddress) {
@@ -2215,16 +2234,16 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_with_complex_parameters)
{
char const* sourceCode = R"(
contract Helper {
- function sel(uint a, bool select, uint b) returns (uint c) {
+ function sel(uint a, bool select, uint b) public returns (uint c) {
if (select) return a; else return b;
}
}
contract Main {
Helper h;
- function callHelper(uint a, bool select, uint b) returns (uint c) {
+ function callHelper(uint a, bool select, uint b) public returns (uint c) {
return h.sel(a, select, b) * 3;
}
- function getHelper() returns (address haddress) {
+ function getHelper() public returns (address haddress) {
return address(h);
}
function setHelper(address haddress) {
@@ -2247,16 +2266,16 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_accessing_this)
{
char const* sourceCode = R"(
contract Helper {
- function getAddress() returns (address addr) {
+ function getAddress() public returns (address addr) {
return address(this);
}
}
contract Main {
Helper h;
- function callHelper() returns (address addr) {
+ function callHelper() public returns (address addr) {
return h.getAddress();
}
- function getHelper() returns (address addr) {
+ function getHelper() public returns (address addr) {
return address(h);
}
function setHelper(address addr) {
@@ -2276,19 +2295,19 @@ BOOST_AUTO_TEST_CASE(calls_to_this)
{
char const* sourceCode = R"(
contract Helper {
- function invoke(uint a, uint b) returns (uint c) {
+ function invoke(uint a, uint b) public returns (uint c) {
return this.multiply(a, b, 10);
}
- function multiply(uint a, uint b, uint8 c) returns (uint ret) {
+ function multiply(uint a, uint b, uint8 c) public returns (uint ret) {
return a * b + c;
}
}
contract Main {
Helper h;
- function callHelper(uint a, uint b) returns (uint ret) {
+ function callHelper(uint a, uint b) public returns (uint ret) {
return h.invoke(a, b);
}
- function getHelper() returns (address addr) {
+ function getHelper() public returns (address addr) {
return address(h);
}
function setHelper(address addr) {
@@ -2312,19 +2331,18 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_with_local_vars)
// so this tests correct stack slot allocation
char const* sourceCode = R"(
contract Helper {
- function multiply(uint a, uint b) returns (uint c) {
+ function multiply(uint a, uint b) public returns (uint c) {
return a * b;
}
}
contract Main {
Helper h;
- function callHelper(uint a, uint b) returns (uint c) {
- var fu = h.multiply;
- var y = 9;
- var ret = fu(a, b);
+ function callHelper(uint a, uint b) public returns (uint c) {
+ uint8 y = 9;
+ uint256 ret = h.multiply(a, b);
return ret + y;
}
- function getHelper() returns (address haddress) {
+ function getHelper() public returns (address haddress) {
return address(h);
}
function setHelper(address haddress) {
@@ -2346,16 +2364,16 @@ BOOST_AUTO_TEST_CASE(fixed_bytes_in_calls)
{
char const* sourceCode = R"(
contract Helper {
- function invoke(bytes3 x, bool stop) returns (bytes4 ret) {
+ function invoke(bytes3 x, bool stop) public returns (bytes4 ret) {
return x;
}
}
contract Main {
Helper h;
- function callHelper(bytes2 x, bool stop) returns (bytes5 ret) {
+ function callHelper(bytes2 x, bool stop) public returns (bytes5 ret) {
return h.invoke(x, stop);
}
- function getHelper() returns (address addr) {
+ function getHelper() public returns (address addr) {
return address(h);
}
function setHelper(address addr) {
@@ -2378,20 +2396,20 @@ BOOST_AUTO_TEST_CASE(constructor_arguments_internal)
bytes3 name;
bool flag;
- constructor(bytes3 x, bool f) {
+ constructor(bytes3 x, bool f) public {
name = x;
flag = f;
}
- function getName() returns (bytes3 ret) { return name; }
- function getFlag() returns (bool ret) { return flag; }
+ function getName() public returns (bytes3 ret) { return name; }
+ function getFlag() public returns (bool ret) { return flag; }
}
contract Main {
Helper h;
- constructor() {
+ constructor() public {
h = new Helper("abc", true);
}
- function getFlag() returns (bool ret) { return h.getFlag(); }
- function getName() returns (bytes3 ret) { return h.getName(); }
+ function getFlag() public returns (bool ret) { return h.getFlag(); }
+ function getName() public returns (bytes3 ret) { return h.getName(); }
}
)";
compileAndRun(sourceCode, 0, "Main");
@@ -2406,12 +2424,12 @@ BOOST_AUTO_TEST_CASE(constructor_arguments_external)
bytes3 name;
bool flag;
- constructor(bytes3 x, bool f) {
+ constructor(bytes3 x, bool f) public {
name = x;
flag = f;
}
- function getName() returns (bytes3 ret) { return name; }
- function getFlag() returns (bool ret) { return flag; }
+ function getName() public returns (bytes3 ret) { return name; }
+ function getFlag() public returns (bool ret) { return flag; }
}
)";
compileAndRun(sourceCode, 0, "Main", encodeArgs("abc", true));
@@ -2426,7 +2444,7 @@ BOOST_AUTO_TEST_CASE(constructor_with_long_arguments)
string public a;
string public b;
- constructor(string _a, string _b) {
+ constructor(string _a, string _b) public {
a = _a;
b = _b;
}
@@ -2454,7 +2472,7 @@ BOOST_AUTO_TEST_CASE(constructor_static_array_argument)
uint public a;
uint[3] public b;
- constructor(uint _a, uint[3] _b) {
+ constructor(uint _a, uint[3] _b) public {
a = _a;
b = _b;
}
@@ -2474,7 +2492,7 @@ BOOST_AUTO_TEST_CASE(constant_var_as_array_length)
uint constant LEN = 3;
uint[LEN] public a;
- constructor(uint[LEN] _a) {
+ constructor(uint[LEN] _a) public {
a = _a;
}
}
@@ -2491,10 +2509,10 @@ BOOST_AUTO_TEST_CASE(functions_called_by_constructor)
contract Test {
bytes3 name;
bool flag;
- constructor() {
+ constructor() public {
setName("abc");
}
- function getName() returns (bytes3 ret) { return name; }
+ function getName() public returns (bytes3 ret) { return name; }
function setName(bytes3 _name) private { name = _name; }
}
)";
@@ -2510,8 +2528,8 @@ BOOST_AUTO_TEST_CASE(contracts_as_addresses)
}
contract test {
helper h;
- constructor() payable { h = new helper(); h.send(5); }
- function getBalance() returns (uint256 myBalance, uint256 helperBalance) {
+ constructor() public payable { h = new helper(); h.send(5); }
+ function getBalance() public returns (uint256 myBalance, uint256 helperBalance) {
myBalance = this.balance;
helperBalance = h.balance;
}
@@ -2527,23 +2545,23 @@ BOOST_AUTO_TEST_CASE(gas_and_value_basic)
char const* sourceCode = R"(
contract helper {
bool flag;
- function getBalance() payable returns (uint256 myBalance) {
+ function getBalance() payable public returns (uint256 myBalance) {
return this.balance;
}
- function setFlag() { flag = true; }
- function getFlag() returns (bool fl) { return flag; }
+ function setFlag() public { flag = true; }
+ function getFlag() public returns (bool fl) { return flag; }
}
contract test {
helper h;
- constructor() payable { h = new helper(); }
- function sendAmount(uint amount) payable returns (uint256 bal) {
+ constructor() public payable { h = new helper(); }
+ function sendAmount(uint amount) public payable returns (uint256 bal) {
return h.getBalance.value(amount)();
}
- function outOfGas() returns (bool ret) {
+ function outOfGas() public returns (bool ret) {
h.setFlag.gas(2)(); // should fail due to OOG
return true;
}
- function checkState() returns (bool flagAfter, uint myBal) {
+ function checkState() public returns (bool flagAfter, uint myBal) {
flagAfter = h.getFlag();
myBal = this.balance;
}
@@ -2560,18 +2578,16 @@ BOOST_AUTO_TEST_CASE(value_complex)
{
char const* sourceCode = R"(
contract helper {
- function getBalance() payable returns (uint256 myBalance) {
+ function getBalance() payable public returns (uint256 myBalance) {
return this.balance;
}
}
contract test {
helper h;
- constructor() payable { h = new helper(); }
+ constructor() public payable { h = new helper(); }
function sendAmount(uint amount) payable returns (uint256 bal) {
- var x1 = h.getBalance.value(amount);
uint someStackElement = 20;
- var x2 = x1.gas(1000);
- return x2.value(amount + 3)();// overwrite value
+ return h.getBalance.value(amount).gas(1000).value(amount + 3)();
}
}
)";
@@ -2583,18 +2599,15 @@ BOOST_AUTO_TEST_CASE(value_insane)
{
char const* sourceCode = R"(
contract helper {
- function getBalance() payable returns (uint256 myBalance) {
+ function getBalance() payable public returns (uint256 myBalance) {
return this.balance;
}
}
contract test {
helper h;
- constructor() payable { h = new helper(); }
- function sendAmount(uint amount) returns (uint256 bal) {
- var x1 = h.getBalance.value;
- var x2 = x1(amount).gas;
- var x3 = x2(1000).value;
- return x3(amount + 3)();// overwrite value
+ constructor() public payable { h = new helper(); }
+ function sendAmount(uint amount) public returns (uint256 bal) {
+ return h.getBalance.value(amount).gas(1000).value(amount + 3)();// overwrite value
}
}
)";
@@ -2612,17 +2625,17 @@ BOOST_AUTO_TEST_CASE(value_for_constructor)
name = x;
flag = f;
}
- function getName() returns (bytes3 ret) { return name; }
- function getFlag() returns (bool ret) { return flag; }
+ function getName() public returns (bytes3 ret) { return name; }
+ function getFlag() public returns (bool ret) { return flag; }
}
contract Main {
Helper h;
constructor() payable {
h = (new Helper).value(10)("abc", true);
}
- function getFlag() returns (bool ret) { return h.getFlag(); }
- function getName() returns (bytes3 ret) { return h.getName(); }
- function getBalances() returns (uint me, uint them) { me = this.balance; them = h.balance;}
+ function getFlag() public returns (bool ret) { return h.getFlag(); }
+ function getName() public returns (bytes3 ret) { return h.getName(); }
+ function getBalances() public returns (uint me, uint them) { me = this.balance; them = h.balance;}
}
)";
compileAndRun(sourceCode, 22, "Main");
@@ -2635,11 +2648,11 @@ BOOST_AUTO_TEST_CASE(virtual_function_calls)
{
char const* sourceCode = R"(
contract Base {
- function f() returns (uint i) { return g(); }
- function g() returns (uint i) { return 1; }
+ function f() public returns (uint i) { return g(); }
+ function g() public returns (uint i) { return 1; }
}
contract Derived is Base {
- function g() returns (uint i) { return 2; }
+ function g() public returns (uint i) { return 2; }
}
)";
compileAndRun(sourceCode, 0, "Derived");
@@ -2652,16 +2665,16 @@ BOOST_AUTO_TEST_CASE(access_base_storage)
char const* sourceCode = R"(
contract Base {
uint dataBase;
- function getViaBase() returns (uint i) { return dataBase; }
+ function getViaBase() public returns (uint i) { return dataBase; }
}
contract Derived is Base {
uint dataDerived;
- function setData(uint base, uint derived) returns (bool r) {
+ function setData(uint base, uint derived) public returns (bool r) {
dataBase = base;
dataDerived = derived;
return true;
}
- function getViaDerived() returns (uint base, uint derived) {
+ function getViaDerived() public returns (uint base, uint derived) {
base = dataBase;
derived = dataDerived;
}
@@ -2679,10 +2692,10 @@ BOOST_AUTO_TEST_CASE(single_copy_with_multiple_inheritance)
contract Base {
uint data;
function setData(uint i) { data = i; }
- function getViaBase() returns (uint i) { return data; }
+ function getViaBase() public returns (uint i) { return data; }
}
contract A is Base { function setViaA(uint i) { setData(i); } }
- contract B is Base { function getViaB() returns (uint i) { return getViaBase(); } }
+ contract B is Base { function getViaB() public returns (uint i) { return getViaBase(); } }
contract Derived is Base, B, A { }
)";
compileAndRun(sourceCode, 0, "Derived");
@@ -2694,11 +2707,11 @@ BOOST_AUTO_TEST_CASE(single_copy_with_multiple_inheritance)
BOOST_AUTO_TEST_CASE(explicit_base_class)
{
char const* sourceCode = R"(
- contract BaseBase { function g() returns (uint r) { return 1; } }
- contract Base is BaseBase { function g() returns (uint r) { return 2; } }
+ contract BaseBase { function g() public returns (uint r) { return 1; } }
+ contract Base is BaseBase { function g() public returns (uint r) { return 2; } }
contract Derived is Base {
- function f() returns (uint r) { return BaseBase.g(); }
- function g() returns (uint r) { return 3; }
+ function f() public returns (uint r) { return BaseBase.g(); }
+ function g() public returns (uint r) { return 3; }
}
)";
compileAndRun(sourceCode, 0, "Derived");
@@ -2711,17 +2724,17 @@ BOOST_AUTO_TEST_CASE(base_constructor_arguments)
char const* sourceCode = R"(
contract BaseBase {
uint m_a;
- constructor(uint a) {
+ constructor(uint a) public {
m_a = a;
}
}
contract Base is BaseBase(7) {
- constructor() {
+ constructor() public {
m_a *= m_a;
}
}
contract Derived is Base() {
- function getA() returns (uint r) { return m_a; }
+ function getA() public returns (uint r) { return m_a; }
}
)";
compileAndRun(sourceCode, 0, "Derived");
@@ -2733,15 +2746,15 @@ BOOST_AUTO_TEST_CASE(function_usage_in_constructor_arguments)
char const* sourceCode = R"(
contract BaseBase {
uint m_a;
- constructor(uint a) {
+ constructor(uint a) public {
m_a = a;
}
- function g() returns (uint r) { return 2; }
+ function g() public returns (uint r) { return 2; }
}
contract Base is BaseBase(BaseBase.g()) {
}
contract Derived is Base() {
- function getA() returns (uint r) { return m_a; }
+ function getA() public returns (uint r) { return m_a; }
}
)";
compileAndRun(sourceCode, 0, "Derived");
@@ -2753,41 +2766,23 @@ BOOST_AUTO_TEST_CASE(virtual_function_usage_in_constructor_arguments)
char const* sourceCode = R"(
contract BaseBase {
uint m_a;
- constructor(uint a) {
+ constructor(uint a) public {
m_a = a;
}
- function overridden() returns (uint r) { return 1; }
- function g() returns (uint r) { return overridden(); }
+ function overridden() public returns (uint r) { return 1; }
+ function g() public returns (uint r) { return overridden(); }
}
contract Base is BaseBase(BaseBase.g()) {
}
contract Derived is Base() {
- function getA() returns (uint r) { return m_a; }
- function overridden() returns (uint r) { return 2; }
+ function getA() public returns (uint r) { return m_a; }
+ function overridden() public returns (uint r) { return 2; }
}
)";
compileAndRun(sourceCode, 0, "Derived");
ABI_CHECK(callContractFunction("getA()"), encodeArgs(2));
}
-BOOST_AUTO_TEST_CASE(constructor_argument_overriding)
-{
- char const* sourceCode = R"(
- contract BaseBase {
- uint m_a;
- constructor(uint a) {
- m_a = a;
- }
- }
- contract Base is BaseBase(2) { }
- contract Derived is BaseBase(3), Base {
- function getA() returns (uint r) { return m_a; }
- }
- )";
- compileAndRun(sourceCode, 0, "Derived");
- ABI_CHECK(callContractFunction("getA()"), encodeArgs(3));
-}
-
BOOST_AUTO_TEST_CASE(internal_constructor)
{
char const* sourceCode = R"(
@@ -2802,7 +2797,7 @@ BOOST_AUTO_TEST_CASE(function_modifier)
{
char const* sourceCode = R"(
contract C {
- function getOne() payable nonFree returns (uint r) { return 1; }
+ function getOne() payable nonFree public returns (uint r) { return 1; }
modifier nonFree { if (msg.value > 0) _; }
}
)";
@@ -2815,9 +2810,9 @@ BOOST_AUTO_TEST_CASE(function_modifier_local_variables)
{
char const* sourceCode = R"(
contract C {
- modifier mod1 { var a = 1; var b = 2; _; }
+ modifier mod1 { uint8 a = 1; uint8 b = 2; _; }
modifier mod2(bool a) { if (a) return; else _; }
- function f(bool a) mod1 mod2(a) returns (uint r) { return 3; }
+ function f(bool a) mod1 mod2(a) public returns (uint r) { return 3; }
}
)";
compileAndRun(sourceCode);
@@ -2829,8 +2824,8 @@ BOOST_AUTO_TEST_CASE(function_modifier_loop)
{
char const* sourceCode = R"(
contract C {
- modifier repeat(uint count) { for (var i = 0; i < count; ++i) _; }
- function f() repeat(10) returns (uint r) { r += 1; }
+ modifier repeat(uint count) { uint i; for (i = 0; i < count; ++i) _; }
+ function f() repeat(10) public returns (uint r) { r += 1; }
}
)";
compileAndRun(sourceCode);
@@ -2842,7 +2837,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_multi_invocation)
char const* sourceCode = R"(
contract C {
modifier repeat(bool twice) { if (twice) _; _; }
- function f(bool twice) repeat(twice) returns (uint r) { r += 1; }
+ function f(bool twice) repeat(twice) public returns (uint r) { r += 1; }
}
)";
compileAndRun(sourceCode);
@@ -2857,7 +2852,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_multi_with_return)
char const* sourceCode = R"(
contract C {
modifier repeat(bool twice) { if (twice) _; _; }
- function f(bool twice) repeat(twice) returns (uint r) { r += 1; return r; }
+ function f(bool twice) repeat(twice) public returns (uint r) { r += 1; return r; }
}
)";
compileAndRun(sourceCode);
@@ -2869,7 +2864,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_overriding)
{
char const* sourceCode = R"(
contract A {
- function f() mod returns (bool r) { return true; }
+ function f() mod public returns (bool r) { return true; }
modifier mod { _; }
}
contract C is A {
@@ -2885,18 +2880,18 @@ BOOST_AUTO_TEST_CASE(function_modifier_calling_functions_in_creation_context)
char const* sourceCode = R"(
contract A {
uint data;
- constructor() mod1 { f1(); }
- function f1() mod2 { data |= 0x1; }
- function f2() { data |= 0x20; }
- function f3() { }
+ constructor() mod1 public { f1(); }
+ function f1() mod2 public { data |= 0x1; }
+ function f2() public { data |= 0x20; }
+ function f3() public { }
modifier mod1 { f2(); _; }
modifier mod2 { f3(); if (false) _; }
- function getData() returns (uint r) { return data; }
+ function getData() public returns (uint r) { return data; }
}
contract C is A {
modifier mod1 { f4(); _; }
- function f3() { data |= 0x300; }
- function f4() { data |= 0x4000; }
+ function f3() public { data |= 0x300; }
+ function f4() public { data |= 0x4000; }
}
)";
compileAndRun(sourceCode);
@@ -2910,7 +2905,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_for_constructor)
uint data;
constructor() mod1 { data |= 2; }
modifier mod1 { data |= 1; _; }
- function getData() returns (uint r) { return data; }
+ function getData() public returns (uint r) { return data; }
}
contract C is A {
modifier mod1 { data |= 4; _; }
@@ -2926,7 +2921,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_multiple_times)
contract C {
uint public a;
modifier mod(uint x) { a += x; _; }
- function f(uint x) mod(2) mod(5) mod(x) returns(uint) { return a; }
+ function f(uint x) mod(2) mod(5) mod(x) public returns(uint) { return a; }
}
)";
compileAndRun(sourceCode);
@@ -2940,7 +2935,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_multiple_times_local_vars)
contract C {
uint public a;
modifier mod(uint x) { uint b = x; a += b; _; a -= b; assert(b == x); }
- function f(uint x) mod(2) mod(5) mod(x) returns(uint) { return a; }
+ function f(uint x) mod(2) mod(5) mod(x) public returns(uint) { return a; }
}
)";
compileAndRun(sourceCode);
@@ -3004,11 +2999,10 @@ BOOST_AUTO_TEST_CASE(crazy_elementary_typenames_on_stack)
{
char const* sourceCode = R"(
contract C {
- function f() returns (uint r) {
+ function f() public returns (uint r) {
uint; uint; uint; uint;
int x = -7;
- var a = uint;
- return a(x);
+ return uint(x);
}
}
)";
@@ -3019,10 +3013,10 @@ BOOST_AUTO_TEST_CASE(crazy_elementary_typenames_on_stack)
BOOST_AUTO_TEST_CASE(super)
{
char const* sourceCode = R"(
- contract A { function f() returns (uint r) { return 1; } }
- contract B is A { function f() returns (uint r) { return super.f() | 2; } }
- contract C is A { function f() returns (uint r) { return super.f() | 4; } }
- contract D is B, C { function f() returns (uint r) { return super.f() | 8; } }
+ contract A { function f() public returns (uint r) { return 1; } }
+ contract B is A { function f() public returns (uint r) { return super.f() | 2; } }
+ contract C is A { function f() public returns (uint r) { return super.f() | 4; } }
+ contract D is B, C { function f() public returns (uint r) { return super.f() | 8; } }
)";
compileAndRun(sourceCode, 0, "D");
ABI_CHECK(callContractFunction("f()"), encodeArgs(1 | 2 | 4 | 8));
@@ -3031,10 +3025,10 @@ BOOST_AUTO_TEST_CASE(super)
BOOST_AUTO_TEST_CASE(super_in_constructor)
{
char const* sourceCode = R"(
- contract A { function f() returns (uint r) { return 1; } }
- contract B is A { function f() returns (uint r) { return super.f() | 2; } }
- contract C is A { function f() returns (uint r) { return super.f() | 4; } }
- contract D is B, C { uint data; constructor() { data = super.f() | 8; } function f() returns (uint r) { return data; } }
+ contract A { function f() public returns (uint r) { return 1; } }
+ contract B is A { function f() public returns (uint r) { return super.f() | 2; } }
+ contract C is A { function f() public returns (uint r) { return super.f() | 4; } }
+ contract D is B, C { uint data; constructor() public { data = super.f() | 8; } function f() public returns (uint r) { return data; } }
)";
compileAndRun(sourceCode, 0, "D");
ABI_CHECK(callContractFunction("f()"), encodeArgs(1 | 2 | 4 | 8));
@@ -3043,7 +3037,7 @@ BOOST_AUTO_TEST_CASE(super_in_constructor)
BOOST_AUTO_TEST_CASE(super_alone)
{
char const* sourceCode = R"(
- contract A { function f() { super; } }
+ contract A { function f() public { super; } }
)";
compileAndRun(sourceCode, 0, "A");
ABI_CHECK(callContractFunction("f()"), encodeArgs());
@@ -3055,7 +3049,7 @@ BOOST_AUTO_TEST_CASE(fallback_function)
contract A {
uint data;
function() external { data = 1; }
- function getData() returns (uint r) { return data; }
+ function getData() public returns (uint r) { return data; }
}
)";
compileAndRun(sourceCode);
@@ -3070,7 +3064,7 @@ BOOST_AUTO_TEST_CASE(inherited_fallback_function)
contract A {
uint data;
function() external { data = 1; }
- function getData() returns (uint r) { return data; }
+ function getData() public returns (uint r) { return data; }
}
contract B is A {}
)";
@@ -3084,7 +3078,7 @@ BOOST_AUTO_TEST_CASE(default_fallback_throws)
{
char const* sourceCode = R"YY(
contract A {
- function f() returns (bool) {
+ function f() public returns (bool) {
return this.call("");
}
}
@@ -3099,16 +3093,18 @@ BOOST_AUTO_TEST_CASE(short_data_calls_fallback)
contract A {
uint public x;
// Signature is d88e0b00
- function fow() { x = 3; }
+ function fow() public { x = 3; }
function () external { x = 2; }
}
)";
compileAndRun(sourceCode);
// should call fallback
sendMessage(asBytes("\xd8\x8e\x0b"), false, 0);
+ BOOST_CHECK(m_transactionSuccessful);
ABI_CHECK(callContractFunction("x()"), encodeArgs(2));
// should call function
sendMessage(asBytes(string("\xd8\x8e\x0b") + string(1, 0)), false, 0);
+ BOOST_CHECK(m_transactionSuccessful);
ABI_CHECK(callContractFunction("x()"), encodeArgs(3));
}
@@ -3171,7 +3167,7 @@ BOOST_AUTO_TEST_CASE(event_no_arguments)
char const* sourceCode = R"(
contract ClientReceipt {
event Deposit();
- function deposit() {
+ function deposit() public {
emit Deposit();
}
}
@@ -3193,7 +3189,7 @@ BOOST_AUTO_TEST_CASE(event_access_through_base_name_emit)
event x();
}
contract B is A {
- function f() returns (uint) {
+ function f() public returns (uint) {
emit A.x();
return 1;
}
@@ -3215,15 +3211,15 @@ BOOST_AUTO_TEST_CASE(events_with_same_name)
event Deposit();
event Deposit(address _addr);
event Deposit(address _addr, uint _amount);
- function deposit() returns (uint) {
+ function deposit() public returns (uint) {
emit Deposit();
return 1;
}
- function deposit(address _addr) returns (uint) {
+ function deposit(address _addr) public returns (uint) {
emit Deposit(_addr);
return 1;
}
- function deposit(address _addr, uint _amount) returns (uint) {
+ function deposit(address _addr, uint _amount) public returns (uint) {
emit Deposit(_addr, _amount);
return 1;
}
@@ -3267,15 +3263,15 @@ BOOST_AUTO_TEST_CASE(events_with_same_name_inherited_emit)
contract ClientReceipt is A, B {
event Deposit(address _addr, uint _amount);
- function deposit() returns (uint) {
+ function deposit() public returns (uint) {
emit Deposit();
return 1;
}
- function deposit(address _addr) returns (uint) {
+ function deposit(address _addr) public returns (uint) {
emit Deposit(_addr);
return 1;
}
- function deposit(address _addr, uint _amount) returns (uint) {
+ function deposit(address _addr, uint _amount) public returns (uint) {
emit Deposit(_addr, _amount);
return 1;
}
@@ -3311,7 +3307,7 @@ BOOST_AUTO_TEST_CASE(event_anonymous)
char const* sourceCode = R"(
contract ClientReceipt {
event Deposit() anonymous;
- function deposit() {
+ function deposit() public {
emit Deposit();
}
}
@@ -3371,7 +3367,7 @@ BOOST_AUTO_TEST_CASE(event_really_lots_of_data)
char const* sourceCode = R"(
contract ClientReceipt {
event Deposit(uint fixeda, bytes dynx, uint fixedb);
- function deposit() {
+ function deposit() public {
emit Deposit(10, msg.data, 15);
}
}
@@ -3391,7 +3387,7 @@ BOOST_AUTO_TEST_CASE(event_really_lots_of_data_from_storage)
contract ClientReceipt {
bytes x;
event Deposit(uint fixeda, bytes dynx, uint fixedb);
- function deposit() {
+ function deposit() public {
x.length = 3;
x[0] = "A";
x[1] = "B";
@@ -3415,7 +3411,7 @@ BOOST_AUTO_TEST_CASE(event_really_really_lots_of_data_from_storage)
contract ClientReceipt {
bytes x;
event Deposit(uint fixeda, bytes dynx, uint fixedb);
- function deposit() {
+ function deposit() public {
x.length = 31;
x[0] = "A";
x[1] = "B";
@@ -3441,7 +3437,7 @@ BOOST_AUTO_TEST_CASE(event_indexed_string)
string x;
uint[4] y;
event E(string indexed r, uint[4] indexed t);
- function deposit() {
+ function deposit() public {
bytes(x).length = 90;
for (uint8 i = 0; i < 90; i++)
bytes(x)[i] = byte(i);
@@ -3473,7 +3469,7 @@ BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one)
{
char const* sourceCode = R"(
contract test {
- function f(uint, uint k) returns(uint ret_k, uint ret_g){
+ function f(uint, uint k) public returns(uint ret_k, uint ret_g){
uint g = 8;
ret_k = k;
ret_g = g;
@@ -3489,7 +3485,7 @@ BOOST_AUTO_TEST_CASE(empty_name_return_parameter)
{
char const* sourceCode = R"(
contract test {
- function f(uint k) returns(uint){
+ function f(uint k) public returns(uint){
return k;
}
}
@@ -3502,7 +3498,7 @@ BOOST_AUTO_TEST_CASE(sha256_empty)
{
char const* sourceCode = R"(
contract C {
- function f() returns (bytes32) {
+ function f() public returns (bytes32) {
return sha256("");
}
}
@@ -3515,7 +3511,7 @@ BOOST_AUTO_TEST_CASE(ripemd160_empty)
{
char const* sourceCode = R"(
contract C {
- function f() returns (bytes20) {
+ function f() public returns (bytes20) {
return ripemd160("");
}
}
@@ -3528,7 +3524,7 @@ BOOST_AUTO_TEST_CASE(keccak256_empty)
{
char const* sourceCode = R"(
contract C {
- function f() returns (bytes32) {
+ function f() public returns (bytes32) {
return keccak256("");
}
}
@@ -3541,7 +3537,7 @@ BOOST_AUTO_TEST_CASE(keccak256_multiple_arguments)
{
char const* sourceCode = R"(
contract c {
- function foo(uint a, uint b, uint c) returns (bytes32 d)
+ function foo(uint a, uint b, uint c) public returns (bytes32 d)
{
d = keccak256(abi.encodePacked(a, b, c));
}
@@ -3562,7 +3558,7 @@ BOOST_AUTO_TEST_CASE(keccak256_multiple_arguments_with_numeric_literals)
{
char const* sourceCode = R"(
contract c {
- function foo(uint a, uint16 b) returns (bytes32 d)
+ function foo(uint a, uint16 b) public returns (bytes32 d)
{
d = keccak256(abi.encodePacked(a, b, 145));
}
@@ -3583,11 +3579,11 @@ BOOST_AUTO_TEST_CASE(keccak256_multiple_arguments_with_string_literals)
{
char const* sourceCode = R"(
contract c {
- function foo() returns (bytes32 d)
+ function foo() public returns (bytes32 d)
{
d = keccak256("foo");
}
- function bar(uint a, uint16 b) returns (bytes32 d)
+ function bar(uint a, uint16 b) public returns (bytes32 d)
{
d = keccak256(abi.encodePacked(a, b, 145, "foo"));
}
@@ -3612,7 +3608,7 @@ BOOST_AUTO_TEST_CASE(keccak256_with_bytes)
char const* sourceCode = R"(
contract c {
bytes data;
- function foo() returns (bool)
+ function foo() public returns (bool)
{
data.length = 3;
data[0] = "f";
@@ -3631,7 +3627,7 @@ BOOST_AUTO_TEST_CASE(iterated_keccak256_with_bytes)
char const* sourceCode = R"ABC(
contract c {
bytes data;
- function foo() returns (bytes32)
+ function foo() public returns (bytes32)
{
data.length = 3;
data[0] = "x";
@@ -3655,8 +3651,8 @@ BOOST_AUTO_TEST_CASE(generic_call)
function receive(uint256 x) payable { received = x; }
}
contract sender {
- constructor() payable {}
- function doSend(address rec) returns (uint d)
+ constructor() public payable {}
+ function doSend(address rec) public returns (uint d)
{
bytes4 signature = bytes4(bytes32(keccak256("receive(uint256)")));
rec.call.value(2)(abi.encodeWithSelector(signature, 23));
@@ -3715,10 +3711,10 @@ BOOST_AUTO_TEST_CASE(generic_delegatecall)
BOOST_AUTO_TEST_CASE(library_call_in_homestead)
{
char const* sourceCode = R"(
- library Lib { function m() returns (address) { return msg.sender; } }
+ library Lib { function m() public returns (address) { return msg.sender; } }
contract Test {
address public sender;
- function f() {
+ function f() public {
sender = Lib.m();
}
}
@@ -3767,7 +3763,7 @@ BOOST_AUTO_TEST_CASE(store_bytes)
// this test just checks that the copy loop does not mess up the stack
char const* sourceCode = R"(
contract C {
- function save() returns (uint r) {
+ function save() public returns (uint r) {
r = 23;
savedData = msg.data;
r = 24;
@@ -3785,7 +3781,7 @@ BOOST_AUTO_TEST_CASE(bytes_from_calldata_to_memory)
{
char const* sourceCode = R"(
contract C {
- function f() returns (bytes32) {
+ function f() public returns (bytes32) {
return keccak256(abi.encodePacked("abc", msg.data));
}
}
@@ -3793,6 +3789,7 @@ BOOST_AUTO_TEST_CASE(bytes_from_calldata_to_memory)
compileAndRun(sourceCode);
bytes calldata1 = FixedHash<4>(dev::keccak256("f()")).asBytes() + bytes(61, 0x22) + bytes(12, 0x12);
sendMessage(calldata1, false);
+ BOOST_CHECK(m_transactionSuccessful);
BOOST_CHECK(m_output == encodeArgs(dev::keccak256(bytes{'a', 'b', 'c'} + calldata1)));
}
@@ -3801,15 +3798,15 @@ BOOST_AUTO_TEST_CASE(call_forward_bytes)
char const* sourceCode = R"(
contract receiver {
uint public received;
- function receive(uint x) { received += x + 1; }
+ function receive(uint x) public { received += x + 1; }
function() external { received = 0x80; }
}
contract sender {
- constructor() { rec = new receiver(); }
+ constructor() public { rec = new receiver(); }
function() external { savedData = msg.data; }
- function forward() returns (bool) { !rec.call(savedData); return true; }
- function clear() returns (bool) { delete savedData; return true; }
- function val() returns (uint) { return rec.received(); }
+ function forward() public returns (bool) { !rec.call(savedData); return true; }
+ function clear() public returns (bool) { delete savedData; return true; }
+ function val() public returns (uint) { return rec.received(); }
receiver rec;
bytes savedData;
}
@@ -3834,18 +3831,18 @@ BOOST_AUTO_TEST_CASE(call_forward_bytes_length)
}
contract sender {
receiver rec;
- constructor() { rec = new receiver(); }
- function viaCalldata() returns (uint) {
+ constructor() public { rec = new receiver(); }
+ function viaCalldata() public returns (uint) {
require(rec.call(msg.data));
return rec.calledLength();
}
- function viaMemory() returns (uint) {
+ function viaMemory() public returns (uint) {
bytes memory x = msg.data;
require(rec.call(x));
return rec.calledLength();
}
bytes s;
- function viaStorage() returns (uint) {
+ function viaStorage() public returns (uint) {
s = msg.data;
require(rec.call(s));
return rec.calledLength();
@@ -3875,14 +3872,14 @@ BOOST_AUTO_TEST_CASE(copying_bytes_multiassign)
function() external { received = 0x80; }
}
contract sender {
- constructor() { rec = new receiver(); }
+ constructor() public { rec = new receiver(); }
function() external { savedData1 = savedData2 = msg.data; }
- function forward(bool selector) returns (bool) {
+ function forward(bool selector) public returns (bool) {
if (selector) { rec.call(savedData1); delete savedData1; }
else { rec.call(savedData2); delete savedData2; }
return true;
}
- function val() returns (uint) { return rec.received(); }
+ function val() public returns (uint) { return rec.received(); }
receiver rec;
bytes savedData1;
bytes savedData2;
@@ -3904,7 +3901,7 @@ BOOST_AUTO_TEST_CASE(delete_removes_bytes_data)
char const* sourceCode = R"(
contract c {
function() external { data = msg.data; }
- function del() returns (bool) { delete data; return true; }
+ function del() public returns (bool) { delete data; return true; }
bytes data;
}
)";
@@ -3919,7 +3916,7 @@ BOOST_AUTO_TEST_CASE(copy_from_calldata_removes_bytes_data)
{
char const* sourceCode = R"(
contract c {
- function set() returns (bool) { data = msg.data; return true; }
+ function set() public returns (bool) { data = msg.data; return true; }
function() external { data = msg.data; }
bytes data;
}
@@ -3928,7 +3925,8 @@ BOOST_AUTO_TEST_CASE(copy_from_calldata_removes_bytes_data)
ABI_CHECK(callContractFunction("set()", 1, 2, 3, 4, 5), encodeArgs(true));
BOOST_CHECK(!storageEmpty(m_contractAddress));
sendMessage(bytes(), false);
- BOOST_CHECK(m_output == bytes());
+ BOOST_CHECK(m_transactionSuccessful);
+ BOOST_CHECK(m_output.empty());
BOOST_CHECK(storageEmpty(m_contractAddress));
}
@@ -3936,8 +3934,8 @@ BOOST_AUTO_TEST_CASE(copy_removes_bytes_data)
{
char const* sourceCode = R"(
contract c {
- function set() returns (bool) { data1 = msg.data; return true; }
- function reset() returns (bool) { data1 = data2; return true; }
+ function set() public returns (bool) { data1 = msg.data; return true; }
+ function reset() public returns (bool) { data1 = data2; return true; }
bytes data1;
bytes data2;
}
@@ -3953,8 +3951,8 @@ BOOST_AUTO_TEST_CASE(bytes_inside_mappings)
{
char const* sourceCode = R"(
contract c {
- function set(uint key) returns (bool) { data[key] = msg.data; return true; }
- function copy(uint from, uint to) returns (bool) { data[to] = data[from]; return true; }
+ function set(uint key) public returns (bool) { data[key] = msg.data; return true; }
+ function copy(uint from, uint to) public returns (bool) { data[to] = data[from]; return true; }
mapping(uint => bytes) data;
}
)";
@@ -3977,8 +3975,8 @@ BOOST_AUTO_TEST_CASE(bytes_length_member)
{
char const* sourceCode = R"(
contract c {
- function set() returns (bool) { data = msg.data; return true; }
- function getLength() returns (uint) { return data.length; }
+ function set() public returns (bool) { data = msg.data; return true; }
+ function getLength() public returns (uint) { return data.length; }
bytes data;
}
)";
@@ -3995,18 +3993,18 @@ BOOST_AUTO_TEST_CASE(struct_copy)
struct Nested { uint x; uint y; }
struct Struct { uint a; mapping(uint => Struct) b; Nested nested; uint c; }
mapping(uint => Struct) data;
- function set(uint k) returns (bool) {
+ function set(uint k) public returns (bool) {
data[k].a = 1;
data[k].nested.x = 3;
data[k].nested.y = 4;
data[k].c = 2;
return true;
}
- function copy(uint from, uint to) returns (bool) {
+ function copy(uint from, uint to) public returns (bool) {
data[to] = data[from];
return true;
}
- function retrieve(uint k) returns (uint a, uint x, uint y, uint c)
+ function retrieve(uint k) public returns (uint a, uint x, uint y, uint c)
{
a = data[k].a;
x = data[k].nested.x;
@@ -4041,11 +4039,11 @@ BOOST_AUTO_TEST_CASE(struct_containing_bytes_copy_and_delete)
data1.data = _data;
return true;
}
- function copy() returns (bool) {
+ function copy() public returns (bool) {
data1 = data2;
return true;
}
- function del() returns (bool) {
+ function del() public returns (bool) {
delete data1;
return true;
}
@@ -4071,10 +4069,10 @@ BOOST_AUTO_TEST_CASE(struct_copy_via_local)
struct Struct { uint a; uint b; }
Struct data1;
Struct data2;
- function test() returns (bool) {
+ function test() public returns (bool) {
data1.a = 1;
data1.b = 2;
- var x = data1;
+ Struct memory x = data1;
data2 = x;
return data2.a == data1.a && data2.b == data1.b;
}
@@ -4093,7 +4091,7 @@ BOOST_AUTO_TEST_CASE(using_enums)
{
choices = ActionChoices.GoStraight;
}
- function getChoice() returns (uint d)
+ function getChoice() public returns (uint d)
{
d = uint256(choices);
}
@@ -4112,17 +4110,17 @@ BOOST_AUTO_TEST_CASE(enum_explicit_overflow)
constructor()
{
}
- function getChoiceExp(uint x) returns (uint d)
+ function getChoiceExp(uint x) public returns (uint d)
{
choice = ActionChoices(x);
d = uint256(choice);
}
- function getChoiceFromSigned(int x) returns (uint d)
+ function getChoiceFromSigned(int x) public returns (uint d)
{
choice = ActionChoices(x);
d = uint256(choice);
}
- function getChoiceFromNegativeLiteral() returns (uint d)
+ function getChoiceFromNegativeLiteral() public returns (uint d)
{
choice = ActionChoices(-1);
d = uint256(choice);
@@ -4146,7 +4144,7 @@ BOOST_AUTO_TEST_CASE(storing_invalid_boolean)
contract C {
event Ev(bool);
bool public perm;
- function set() returns(uint) {
+ function set() public returns(uint) {
bool tmp;
assembly {
tmp := 5
@@ -4154,14 +4152,14 @@ BOOST_AUTO_TEST_CASE(storing_invalid_boolean)
perm = tmp;
return 1;
}
- function ret() returns(bool) {
+ function ret() public returns(bool) {
bool tmp;
assembly {
tmp := 5
}
return tmp;
}
- function ev() returns(uint) {
+ function ev() public returns(uint) {
bool tmp;
assembly {
tmp := 5
@@ -4189,7 +4187,7 @@ BOOST_AUTO_TEST_CASE(using_contract_enums_with_explicit_contract_name)
char const* sourceCode = R"(
contract test {
enum Choice { A, B, C }
- function answer () returns (test.Choice _ret)
+ function answer () public returns (test.Choice _ret)
{
_ret = test.Choice.B;
}
@@ -4207,7 +4205,7 @@ BOOST_AUTO_TEST_CASE(using_inherited_enum)
}
contract test is base {
- function answer () returns (Choice _ret)
+ function answer () public returns (Choice _ret)
{
_ret = Choice.B;
}
@@ -4225,7 +4223,7 @@ BOOST_AUTO_TEST_CASE(using_inherited_enum_excplicitly)
}
contract test is base {
- function answer () returns (base.Choice _ret)
+ function answer () public returns (base.Choice _ret)
{
_ret = base.Choice.B;
}
@@ -4240,7 +4238,7 @@ BOOST_AUTO_TEST_CASE(constructing_enums_from_ints)
char const* sourceCode = R"(
contract c {
enum Truth { False, True }
- function test() returns (uint)
+ function test() public returns (uint)
{
return uint(Truth(uint8(0x701)));
}
@@ -4261,7 +4259,7 @@ BOOST_AUTO_TEST_CASE(inline_member_init)
uint m_a = 5;
uint m_b;
uint m_c = 7;
- function get() returns (uint a, uint b, uint c){
+ function get() public returns (uint a, uint b, uint c){
a = m_a;
b = m_b;
c = m_c;
@@ -4278,12 +4276,12 @@ BOOST_AUTO_TEST_CASE(inline_member_init_inheritence)
contract Base {
constructor(){}
uint m_base = 5;
- function getBMember() returns (uint i) { return m_base; }
+ function getBMember() public returns (uint i) { return m_base; }
}
contract Derived is Base {
constructor(){}
uint m_derived = 6;
- function getDMember() returns (uint i) { return m_derived; }
+ function getDMember() public returns (uint i) { return m_derived; }
}
)";
compileAndRun(sourceCode);
@@ -4296,11 +4294,11 @@ BOOST_AUTO_TEST_CASE(inline_member_init_inheritence_without_constructor)
char const* sourceCode = R"(
contract Base {
uint m_base = 5;
- function getBMember() returns (uint i) { return m_base; }
+ function getBMember() public returns (uint i) { return m_base; }
}
contract Derived is Base {
uint m_derived = 6;
- function getDMember() returns (uint i) { return m_derived; }
+ function getDMember() public returns (uint i) { return m_derived; }
}
)";
compileAndRun(sourceCode);
@@ -4312,7 +4310,7 @@ BOOST_AUTO_TEST_CASE(external_function)
{
char const* sourceCode = R"(
contract c {
- function f(uint a) returns (uint) { return a; }
+ function f(uint a) public returns (uint) { return a; }
function test(uint a, uint b) external returns (uint r_a, uint r_b) {
r_a = f(a + 7);
r_b = b;
@@ -4364,9 +4362,9 @@ BOOST_AUTO_TEST_CASE(fixed_arrays_in_storage)
function setIDStatic(uint id) { ids[2] = id; }
function setID(uint index, uint id) { ids[index] = id; }
function setData(uint index, uint x, uint y) { data[index].x = x; data[index].y = y; }
- function getID(uint index) returns (uint) { return ids[index]; }
- function getData(uint index) returns (uint x, uint y) { x = data[index].x; y = data[index].y; }
- function getLengths() returns (uint l1, uint l2) { l1 = data.length; l2 = ids.length; }
+ function getID(uint index) public returns (uint) { return ids[index]; }
+ function getData(uint index) public returns (uint x, uint y) { x = data[index].x; y = data[index].y; }
+ function getLengths() public returns (uint l1, uint l2) { l1 = data.length; l2 = ids.length; }
}
)";
compileAndRun(sourceCode);
@@ -4391,9 +4389,9 @@ BOOST_AUTO_TEST_CASE(dynamic_arrays_in_storage)
function setIDStatic(uint id) { ids[2] = id; }
function setID(uint index, uint id) { ids[index] = id; }
function setData(uint index, uint x, uint y) { data[index].x = x; data[index].y = y; }
- function getID(uint index) returns (uint) { return ids[index]; }
- function getData(uint index) returns (uint x, uint y) { x = data[index].x; y = data[index].y; }
- function getLengths() returns (uint l1, uint l2) { l1 = data.length; l2 = ids.length; }
+ function getID(uint index) public returns (uint) { return ids[index]; }
+ function getData(uint index) public returns (uint x, uint y) { x = data[index].x; y = data[index].y; }
+ function getLengths() public returns (uint l1, uint l2) { l1 = data.length; l2 = ids.length; }
function setLengths(uint l1, uint l2) { data.length = l1; ids.length = l2; }
}
)";
@@ -4416,9 +4414,9 @@ BOOST_AUTO_TEST_CASE(fixed_out_of_bounds_array_access)
char const* sourceCode = R"(
contract c {
uint[4] data;
- function set(uint index, uint value) returns (bool) { data[index] = value; return true; }
- function get(uint index) returns (uint) { return data[index]; }
- function length() returns (uint) { return data.length; }
+ function set(uint index, uint value) public returns (bool) { data[index] = value; return true; }
+ function get(uint index) public returns (uint) { return data[index]; }
+ function length() public returns (uint) { return data.length; }
}
)";
compileAndRun(sourceCode);
@@ -4437,10 +4435,10 @@ BOOST_AUTO_TEST_CASE(dynamic_out_of_bounds_array_access)
char const* sourceCode = R"(
contract c {
uint[] data;
- function enlarge(uint amount) returns (uint) { return data.length += amount; }
- function set(uint index, uint value) returns (bool) { data[index] = value; return true; }
- function get(uint index) returns (uint) { return data[index]; }
- function length() returns (uint) { return data.length; }
+ function enlarge(uint amount) public returns (uint) { return data.length += amount; }
+ function set(uint index, uint value) public returns (bool) { data[index] = value; return true; }
+ function get(uint index) public returns (uint) { return data[index]; }
+ function length() public returns (uint) { return data.length; }
}
)";
compileAndRun(sourceCode);
@@ -4462,10 +4460,10 @@ BOOST_AUTO_TEST_CASE(fixed_array_cleanup)
uint spacer1;
uint spacer2;
uint[20] data;
- function fill() {
+ function fill() public {
for (uint i = 0; i < data.length; ++i) data[i] = i+1;
}
- function clear() { delete data; }
+ function clear() public { delete data; }
}
)";
compileAndRun(sourceCode);
@@ -4483,10 +4481,10 @@ BOOST_AUTO_TEST_CASE(short_fixed_array_cleanup)
uint spacer1;
uint spacer2;
uint[3] data;
- function fill() {
+ function fill() public {
for (uint i = 0; i < data.length; ++i) data[i] = i+1;
}
- function clear() { delete data; }
+ function clear() public { delete data; }
}
)";
compileAndRun(sourceCode);
@@ -4503,12 +4501,12 @@ BOOST_AUTO_TEST_CASE(dynamic_array_cleanup)
contract c {
uint[20] spacer;
uint[] dynamic;
- function fill() {
+ function fill() public {
dynamic.length = 21;
for (uint i = 0; i < dynamic.length; ++i) dynamic[i] = i+1;
}
- function halfClear() { dynamic.length = 5; }
- function fullClear() { delete dynamic; }
+ function halfClear() public { dynamic.length = 5; }
+ function fullClear() public { delete dynamic; }
}
)";
compileAndRun(sourceCode);
@@ -4527,14 +4525,14 @@ BOOST_AUTO_TEST_CASE(dynamic_multi_array_cleanup)
contract c {
struct s { uint[][] d; }
s[] data;
- function fill() returns (uint) {
+ function fill() public returns (uint) {
data.length = 3;
data[2].d.length = 4;
data[2].d[3].length = 5;
data[2].d[3][4] = 8;
return data[2].d[3][4];
}
- function clear() { delete data; }
+ function clear() public { delete data; }
}
)";
compileAndRun(sourceCode);
@@ -4554,8 +4552,8 @@ BOOST_AUTO_TEST_CASE(array_copy_storage_storage_dyn_dyn)
function setData1(uint length, uint index, uint value) {
data1.length = length; if (index < length) data1[index] = value;
}
- function copyStorageStorage() { data2 = data1; }
- function getData2(uint index) returns (uint len, uint val) {
+ function copyStorageStorage() public { data2 = data1; }
+ function getData2(uint index) public returns (uint len, uint val) {
len = data2.length; if (index < len) val = data2[index];
}
}
@@ -4576,7 +4574,7 @@ BOOST_AUTO_TEST_CASE(array_copy_storage_storage_static_static)
contract c {
uint[40] data1;
uint[20] data2;
- function test() returns (uint x, uint y){
+ function test() public returns (uint x, uint y){
data1[30] = 4;
data1[2] = 7;
data1[3] = 9;
@@ -4597,7 +4595,7 @@ BOOST_AUTO_TEST_CASE(array_copy_storage_storage_static_dynamic)
contract c {
uint[9] data1;
uint[] data2;
- function test() returns (uint x, uint y){
+ function test() public returns (uint x, uint y){
data1[8] = 4;
data2 = data1;
x = data2.length;
@@ -4615,7 +4613,7 @@ BOOST_AUTO_TEST_CASE(array_copy_different_packing)
contract c {
bytes8[] data1; // 4 per slot
bytes10[] data2; // 3 per slot
- function test() returns (bytes10 a, bytes10 b, bytes10 c, bytes10 d, bytes10 e) {
+ function test() public returns (bytes10 a, bytes10 b, bytes10 c, bytes10 d, bytes10 e) {
data1.length = 9;
for (uint i = 0; i < data1.length; ++i)
data1[i] = bytes8(uint64(i));
@@ -4644,7 +4642,7 @@ BOOST_AUTO_TEST_CASE(array_copy_target_simple)
contract c {
bytes8[9] data1; // 4 per slot
bytes17[10] data2; // 1 per slot, no offset counter
- function test() returns (bytes17 a, bytes17 b, bytes17 c, bytes17 d, bytes17 e) {
+ function test() public returns (bytes17 a, bytes17 b, bytes17 c, bytes17 d, bytes17 e) {
for (uint i = 0; i < data1.length; ++i)
data1[i] = bytes8(uint64(i));
data2[8] = data2[9] = 2;
@@ -4674,7 +4672,7 @@ BOOST_AUTO_TEST_CASE(array_copy_target_leftover)
contract c {
byte[10] data1;
bytes2[32] data2;
- function test() returns (uint check, uint res1, uint res2) {
+ function test() public returns (uint check, uint res1, uint res2) {
uint i;
for (i = 0; i < data2.length; ++i)
data2[i] = 0xffff;
@@ -4705,7 +4703,7 @@ BOOST_AUTO_TEST_CASE(array_copy_target_leftover2)
contract c {
bytes8[4] data1; // fits into one slot
bytes10[6] data2; // 4 elements need two slots
- function test() returns (bytes10 r1, bytes10 r2, bytes10 r3) {
+ function test() public returns (bytes10 r1, bytes10 r2, bytes10 r3) {
data1[0] = 1;
data1[1] = 2;
data1[2] = 3;
@@ -4734,7 +4732,7 @@ BOOST_AUTO_TEST_CASE(array_copy_storage_storage_struct)
struct Data { uint x; uint y; }
Data[] data1;
Data[] data2;
- function test() returns (uint x, uint y) {
+ function test() public returns (uint x, uint y) {
data1.length = 9;
data1[8].x = 4;
data1[8].y = 5;
@@ -4762,22 +4760,22 @@ BOOST_AUTO_TEST_CASE(array_copy_storage_abi)
uint16[] y;
uint24[] z;
uint24[][] w;
- function test1() returns (uint8[]) {
+ function test1() public returns (uint8[]) {
for (uint i = 0; i < 101; ++i)
x.push(uint8(i));
return x;
}
- function test2() returns (uint16[]) {
+ function test2() public returns (uint16[]) {
for (uint i = 0; i < 101; ++i)
y.push(uint16(i));
return y;
}
- function test3() returns (uint24[]) {
+ function test3() public returns (uint24[]) {
for (uint i = 0; i < 101; ++i)
z.push(uint24(i));
return z;
}
- function test4() returns (uint24[][]) {
+ function test4() public returns (uint24[][]) {
w.length = 5;
for (uint i = 0; i < 5; ++i)
for (uint j = 0; j < 101; ++j)
@@ -4810,7 +4808,7 @@ BOOST_AUTO_TEST_CASE(array_copy_storage_abi_signed)
char const* sourceCode = R"(
contract c {
int16[] x;
- function test() returns (int16[]) {
+ function test() public returns (int16[]) {
x.push(int16(-1));
x.push(int16(-1));
x.push(int16(8));
@@ -4842,7 +4840,7 @@ BOOST_AUTO_TEST_CASE(array_push)
char const* sourceCode = R"(
contract c {
uint[] data;
- function test() returns (uint x, uint y, uint z, uint l) {
+ function test() public returns (uint x, uint y, uint z, uint l) {
data.push(5);
x = data[0];
data.push(4);
@@ -4862,7 +4860,7 @@ BOOST_AUTO_TEST_CASE(array_push_struct)
contract c {
struct S { uint16 a; uint16 b; uint16[3] c; uint16[] d; }
S[] data;
- function test() returns (uint16, uint16, uint16, uint16) {
+ function test() public returns (uint16, uint16, uint16, uint16) {
S memory s;
s.a = 2;
s.b = 3;
@@ -4883,7 +4881,7 @@ BOOST_AUTO_TEST_CASE(array_push_packed_array)
char const* sourceCode = R"(
contract c {
uint80[] x;
- function test() returns (uint80, uint80, uint80, uint80) {
+ function test() public returns (uint80, uint80, uint80, uint80) {
x.push(1);
x.push(2);
x.push(3);
@@ -4903,7 +4901,7 @@ BOOST_AUTO_TEST_CASE(byte_array_push)
char const* sourceCode = R"(
contract c {
bytes data;
- function test() returns (bool x) {
+ function test() public returns (bool x) {
if (data.push(5) != 1) return true;
if (data[0] != 5) return true;
data.push(4);
@@ -4924,7 +4922,7 @@ BOOST_AUTO_TEST_CASE(byte_array_push_transition)
char const* sourceCode = R"(
contract c {
bytes data;
- function test() returns (uint) {
+ function test() public returns (uint) {
for (uint8 i = 1; i < 40; i++)
{
data.push(byte(i));
@@ -5354,7 +5352,7 @@ BOOST_AUTO_TEST_CASE(array_copy_calldata_storage)
m_byte_data = b;
return b[3][1]; // note that access and declaration are reversed to each other
}
- function retrieve() returns (uint a, uint b, uint c, uint d, uint e, uint f, uint g) {
+ function retrieve() public returns (uint a, uint b, uint c, uint d, uint e, uint f, uint g) {
a = m_data.length;
b = m_data[7];
c = m_data_dyn.length;
@@ -5410,7 +5408,7 @@ BOOST_AUTO_TEST_CASE(array_copy_including_mapping)
contract c {
mapping(uint=>uint)[90][] large;
mapping(uint=>uint)[3][] small;
- function test() returns (uint r) {
+ function test() public returns (uint r) {
large.length = small.length = 7;
large[3][2][0] = 2;
large[1] = large[3];
@@ -5424,7 +5422,7 @@ BOOST_AUTO_TEST_CASE(array_copy_including_mapping)
delete small;
delete large;
}
- function clear() returns (uint r) {
+ function clear() public returns (uint r) {
large.length = small.length = 7;
small[3][2][0] = 0;
large[3][2][0] = 0;
@@ -5453,11 +5451,11 @@ BOOST_AUTO_TEST_CASE(swap_in_storage_overwrite)
struct S { uint a; uint b; }
S public x;
S public y;
- function set() {
+ function set() public {
x.a = 1; x.b = 2;
y.a = 3; y.b = 4;
}
- function swap() {
+ function swap() public {
(x, y) = (y, x);
}
}
@@ -5498,17 +5496,17 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base_base)
{
char const* sourceCode = R"(
contract Base {
- constructor(uint j)
+ constructor(uint j) public
{
m_i = j;
}
uint public m_i;
}
contract Base1 is Base {
- constructor(uint k) Base(k*k) {}
+ constructor(uint k) Base(k) public {}
}
contract Derived is Base, Base1 {
- constructor(uint i) Base(i) Base1(i)
+ constructor(uint i) Base1(i) public
{}
}
contract Final is Derived(4) {
@@ -5528,9 +5526,11 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base_base_with_gap)
}
uint public m_i;
}
- contract Base1 is Base(3) {}
+ contract Base1 is Base {
+ constructor(uint k) {}
+ }
contract Derived is Base, Base1 {
- constructor(uint i) Base(i) {}
+ constructor(uint i) Base(i) Base1(7) public {}
}
contract Final is Derived(4) {
}
@@ -5543,7 +5543,7 @@ BOOST_AUTO_TEST_CASE(simple_constant_variables_test)
{
char const* sourceCode = R"(
contract Foo {
- function getX() returns (uint r) { return x; }
+ function getX() public returns (uint r) { return x; }
uint constant x = 56;
}
)";
@@ -5569,7 +5569,7 @@ BOOST_AUTO_TEST_CASE(assignment_to_const_var_involving_expression)
char const* sourceCode = R"(
contract C {
uint constant x = 0x123 + 0x456;
- function f() returns (uint) { return x + 1; }
+ function f() public returns (uint) { return x + 1; }
}
)";
compileAndRun(sourceCode);
@@ -5581,7 +5581,7 @@ BOOST_AUTO_TEST_CASE(assignment_to_const_var_involving_keccak)
char const* sourceCode = R"(
contract C {
bytes32 constant x = keccak256("abc");
- function f() returns (bytes32) { return x; }
+ function f() public returns (bytes32) { return x; }
}
)";
compileAndRun(sourceCode);
@@ -5595,7 +5595,7 @@ BOOST_AUTO_TEST_CASE(assignment_to_const_var_involving_keccak)
// contract C {
// uint[3] constant x = [uint(1), 2, 3];
// uint constant y = x[0] + x[1] + x[2];
-// function f() returns (uint) { return y; }
+// function f() public returns (uint) { return y; }
// }
// )";
// compileAndRun(sourceCode);
@@ -5609,7 +5609,7 @@ BOOST_AUTO_TEST_CASE(assignment_to_const_var_involving_keccak)
// contract C {
// struct S { uint x; uint[] y; }
// S constant x = S(5, new uint[](4));
-// function f() returns (uint) { return x.x; }
+// function f() public returns (uint) { return x.x; }
// }
// )";
// compileAndRun(sourceCode);
@@ -5622,7 +5622,7 @@ BOOST_AUTO_TEST_CASE(packed_storage_structs_uint)
contract C {
struct str { uint8 a; uint16 b; uint248 c; }
str data;
- function test() returns (uint) {
+ function test() public returns (uint) {
data.a = 2;
if (data.a != 2) return 2;
data.b = 0xabcd;
@@ -5654,7 +5654,7 @@ BOOST_AUTO_TEST_CASE(packed_storage_structs_enum)
enum larger { A, B, C, D, E}
struct str { small a; small b; larger c; larger d; }
str data;
- function test() returns (uint) {
+ function test() public returns (uint) {
data.a = small.B;
if (data.a != small.B) return 2;
data.b = small.C;
@@ -5687,7 +5687,7 @@ BOOST_AUTO_TEST_CASE(packed_storage_structs_bytes)
byte x;
s2 data;
byte y;
- function test() returns (bool) {
+ function test() public returns (bool) {
x = 1;
data.a = 2;
data.inner.a = 3;
@@ -5716,7 +5716,7 @@ BOOST_AUTO_TEST_CASE(packed_storage_structs_delete)
uint8 x;
uint16 y;
str data;
- function test() returns (uint) {
+ function test() public returns (uint) {
x = 1;
y = 2;
data.a = 2;
@@ -5743,9 +5743,9 @@ BOOST_AUTO_TEST_CASE(overloaded_function_call_resolve_to_first)
{
char const* sourceCode = R"(
contract test {
- function f(uint k) returns(uint d) { return k; }
- function f(uint a, uint b) returns(uint d) { return a + b; }
- function g() returns(uint d) { return f(3); }
+ function f(uint k) public returns(uint d) { return k; }
+ function f(uint a, uint b) public returns(uint d) { return a + b; }
+ function g() public returns(uint d) { return f(3); }
}
)";
compileAndRun(sourceCode);
@@ -5756,9 +5756,9 @@ BOOST_AUTO_TEST_CASE(overloaded_function_call_resolve_to_second)
{
char const* sourceCode = R"(
contract test {
- function f(uint a, uint b) returns(uint d) { return a + b; }
- function f(uint k) returns(uint d) { return k; }
- function g() returns(uint d) { return f(3, 7); }
+ function f(uint a, uint b) public returns(uint d) { return a + b; }
+ function f(uint k) public returns(uint d) { return k; }
+ function g() public returns(uint d) { return f(3, 7); }
}
)";
compileAndRun(sourceCode);
@@ -5769,9 +5769,9 @@ BOOST_AUTO_TEST_CASE(overloaded_function_call_with_if_else)
{
char const* sourceCode = R"(
contract test {
- function f(uint a, uint b) returns(uint d) { return a + b; }
- function f(uint k) returns(uint d) { return k; }
- function g(bool flag) returns(uint d) {
+ function f(uint a, uint b) public returns(uint d) { return a + b; }
+ function f(uint k) public returns(uint d) { return k; }
+ function g(bool flag) public returns(uint d) {
if (flag)
return f(3);
else
@@ -5787,10 +5787,10 @@ BOOST_AUTO_TEST_CASE(overloaded_function_call_with_if_else)
BOOST_AUTO_TEST_CASE(derived_overload_base_function_direct)
{
char const* sourceCode = R"(
- contract B { function f() returns(uint) { return 10; } }
+ contract B { function f() public returns(uint) { return 10; } }
contract C is B {
- function f(uint i) returns(uint) { return 2 * i; }
- function g() returns(uint) { return f(1); }
+ function f(uint i) public returns(uint) { return 2 * i; }
+ function g() public returns(uint) { return f(1); }
}
)";
compileAndRun(sourceCode, 0, "C");
@@ -5800,11 +5800,11 @@ BOOST_AUTO_TEST_CASE(derived_overload_base_function_direct)
BOOST_AUTO_TEST_CASE(derived_overload_base_function_indirect)
{
char const* sourceCode = R"(
- contract A { function f(uint a) returns(uint) { return 2 * a; } }
- contract B { function f() returns(uint) { return 10; } }
+ contract A { function f(uint a) public returns(uint) { return 2 * a; } }
+ contract B { function f() public returns(uint) { return 10; } }
contract C is A, B {
- function g() returns(uint) { return f(); }
- function h() returns(uint) { return f(1); }
+ function g() public returns(uint) { return f(); }
+ function h() public returns(uint) { return f(1); }
}
)";
compileAndRun(sourceCode, 0, "C");
@@ -5815,11 +5815,11 @@ BOOST_AUTO_TEST_CASE(derived_overload_base_function_indirect)
BOOST_AUTO_TEST_CASE(super_overload)
{
char const* sourceCode = R"(
- contract A { function f(uint a) returns(uint) { return 2 * a; } }
- contract B { function f(bool b) returns(uint) { return 10; } }
+ contract A { function f(uint a) public returns(uint) { return 2 * a; } }
+ contract B { function f(bool b) public returns(uint) { return 10; } }
contract C is A, B {
- function g() returns(uint) { return super.f(true); }
- function h() returns(uint) { return super.f(1); }
+ function g() public returns(uint) { return super.f(true); }
+ function h() public returns(uint) { return super.f(1); }
}
)";
compileAndRun(sourceCode, 0, "C");
@@ -5831,8 +5831,8 @@ BOOST_AUTO_TEST_CASE(gasleft_shadow_resolution)
{
char const* sourceCode = R"(
contract C {
- function gasleft() returns(uint256) { return 0; }
- function f() returns(uint256) { return gasleft(); }
+ function gasleft() public returns(uint256) { return 0; }
+ function f() public returns(uint256) { return gasleft(); }
}
)";
compileAndRun(sourceCode, 0, "C");
@@ -5843,13 +5843,13 @@ BOOST_AUTO_TEST_CASE(bool_conversion)
{
char const* sourceCode = R"(
contract C {
- function f(bool _b) returns(uint) {
+ function f(bool _b) public returns(uint) {
if (_b)
return 1;
else
return 0;
}
- function g(bool _in) returns (bool _out) {
+ function g(bool _in) public returns (bool _out) {
_out = _in;
}
}
@@ -5875,7 +5875,7 @@ BOOST_AUTO_TEST_CASE(packed_storage_signed)
uint8 b;
int8 c;
uint8 d;
- function test() returns (uint x1, uint x2, uint x3, uint x4) {
+ function test() public returns (uint x1, uint x2, uint x3, uint x4) {
a = -2;
b = -uint8(a) * 2;
c = a * int8(120) * int8(121);
@@ -5893,15 +5893,15 @@ BOOST_AUTO_TEST_CASE(packed_storage_signed)
BOOST_AUTO_TEST_CASE(external_types_in_calls)
{
char const* sourceCode = R"(
- contract C1 { C1 public bla; constructor(C1 x) { bla = x; } }
+ contract C1 { C1 public bla; constructor(C1 x) public { bla = x; } }
contract C {
- function test() returns (C1 x, C1 y) {
+ function test() public returns (C1 x, C1 y) {
C1 c = new C1(C1(9));
x = c.bla();
y = this.t1(C1(7));
}
- function t1(C1 a) returns (C1) { return a; }
- function t2() returns (C1) { return C1(9); }
+ function t1(C1 a) public returns (C1) { return a; }
+ function t2() public returns (C1) { return C1(9); }
}
)";
compileAndRun(sourceCode, 0, "C");
@@ -5915,18 +5915,18 @@ BOOST_AUTO_TEST_CASE(invalid_enum_compared)
contract C {
enum X { A, B }
- function test_eq() returns (bool) {
+ function test_eq() public returns (bool) {
X garbled;
assembly {
garbled := 5
}
return garbled == garbled;
}
- function test_eq_ok() returns (bool) {
+ function test_eq_ok() public returns (bool) {
X garbled = X.A;
return garbled == garbled;
}
- function test_neq() returns (bool) {
+ function test_neq() public returns (bool) {
X garbled;
assembly {
garbled := 5
@@ -5949,7 +5949,7 @@ BOOST_AUTO_TEST_CASE(invalid_enum_logged)
enum X { A, B }
event Log(X);
- function test_log() returns (uint) {
+ function test_log() public returns (uint) {
X garbled = X.A;
assembly {
garbled := 5
@@ -5957,7 +5957,7 @@ BOOST_AUTO_TEST_CASE(invalid_enum_logged)
emit Log(garbled);
return 1;
}
- function test_log_ok() returns (uint) {
+ function test_log_ok() public returns (uint) {
X x = X.A;
emit Log(x);
return 1;
@@ -5983,7 +5983,7 @@ BOOST_AUTO_TEST_CASE(invalid_enum_stored)
enum X { A, B }
X public x;
- function test_store() returns (uint) {
+ function test_store() public returns (uint) {
X garbled = X.A;
assembly {
garbled := 5
@@ -5991,7 +5991,7 @@ BOOST_AUTO_TEST_CASE(invalid_enum_stored)
x = garbled;
return 1;
}
- function test_store_ok() returns (uint) {
+ function test_store_ok() public returns (uint) {
x = X.A;
return 1;
}
@@ -6011,19 +6011,19 @@ BOOST_AUTO_TEST_CASE(invalid_enum_as_external_ret)
contract C {
enum X { A, B }
- function test_return() returns (X) {
+ function test_return() public returns (X) {
X garbled;
assembly {
garbled := 5
}
return garbled;
}
- function test_inline_assignment() returns (X _ret) {
+ function test_inline_assignment() public returns (X _ret) {
assembly {
_ret := 5
}
}
- function test_assignment() returns (X _ret) {
+ function test_assignment() public returns (X _ret) {
X tmp;
assembly {
tmp := 5
@@ -6045,11 +6045,11 @@ BOOST_AUTO_TEST_CASE(invalid_enum_as_external_arg)
contract C {
enum X { A, B }
- function tested (X x) returns (uint) {
+ function tested (X x) public returns (uint) {
return 1;
}
- function test() returns (uint) {
+ function test() public returns (uint) {
X garbled;
assembly {
@@ -6071,19 +6071,19 @@ BOOST_AUTO_TEST_CASE(proper_order_of_overwriting_of_attributes)
// bug #1798
char const* sourceCode = R"(
contract init {
- function isOk() returns (bool) { return false; }
+ function isOk() public returns (bool) { return false; }
bool public ok = false;
}
contract fix {
- function isOk() returns (bool) { return true; }
+ function isOk() public returns (bool) { return true; }
bool public ok = true;
}
contract init_fix is init, fix {
- function checkOk() returns (bool) { return ok; }
+ function checkOk() public returns (bool) { return ok; }
}
contract fix_init is fix, init {
- function checkOk() returns (bool) { return ok; }
+ function checkOk() public returns (bool) { return ok; }
}
)";
compileAndRun(sourceCode, 0, "init_fix");
@@ -6110,7 +6110,7 @@ BOOST_AUTO_TEST_CASE(struct_assign_reference_to_struct)
{
data1.m_value = 2;
}
- function assign() returns (uint ret_local, uint ret_global, uint ret_global3, uint ret_global1)
+ function assign() public returns (uint ret_local, uint ret_global, uint ret_global3, uint ret_global1)
{
testStruct x = data1; //x is a reference data1.m_value == 2 as well as x.m_value = 2
data2 = data1; // should copy data. data2.m_value == 2
@@ -6142,7 +6142,7 @@ BOOST_AUTO_TEST_CASE(struct_delete_member)
{
data1.m_value = 2;
}
- function deleteMember() returns (uint ret_value)
+ function deleteMember() public returns (uint ret_value)
{
testStruct x = data1; //should not copy the data. data1.m_value == 2 but x.m_value = 0
x.m_value = 4;
@@ -6169,7 +6169,7 @@ BOOST_AUTO_TEST_CASE(struct_delete_struct_in_mapping)
{
campaigns[0].m_value = 2;
}
- function deleteIt() returns (uint)
+ function deleteIt() public returns (uint)
{
delete campaigns[0];
return campaigns[0].m_value;
@@ -6186,11 +6186,11 @@ BOOST_AUTO_TEST_CASE(evm_exceptions_out_of_band_access)
contract A {
uint[3] arr;
bool public test = false;
- function getElement(uint i) returns (uint)
+ function getElement(uint i) public returns (uint)
{
return arr[i];
}
- function testIt() returns (bool)
+ function testIt() public returns (bool)
{
uint i = this.getElement(5);
test = true;
@@ -6243,6 +6243,7 @@ BOOST_AUTO_TEST_CASE(evm_exceptions_in_constructor_out_of_baund)
}
)";
ABI_CHECK(compileAndRunWithoutCheck(sourceCode, 0, "A"), encodeArgs());
+ BOOST_CHECK(!m_transactionSuccessful);
}
BOOST_AUTO_TEST_CASE(positive_integers_to_signed)
@@ -6270,8 +6271,8 @@ BOOST_AUTO_TEST_CASE(failing_send)
}
}
contract Main {
- constructor() payable {}
- function callHelper(address _a) returns (bool r, uint bal) {
+ constructor() public payable {}
+ function callHelper(address _a) public returns (bool r, uint bal) {
r = !_a.send(5);
bal = this.balance;
}
@@ -6293,9 +6294,9 @@ BOOST_AUTO_TEST_CASE(send_zero_ether)
}
}
contract Main {
- constructor() payable {}
- function s() returns (bool) {
- var r = new Receiver();
+ constructor() public payable {}
+ function s() public returns (bool) {
+ Receiver r = new Receiver();
return r.send(0);
}
}
@@ -6310,17 +6311,17 @@ BOOST_AUTO_TEST_CASE(reusing_memory)
char const* sourceCode = R"(
contract Helper {
uint public flag;
- constructor(uint x) {
+ constructor(uint x) public {
flag = x;
}
}
contract Main {
mapping(uint => uint) map;
- function f(uint x) returns (uint) {
+ function f(uint x) public returns (uint) {
map[x] = x;
return (new Helper(uint(keccak256(abi.encodePacked(this.g(map[x])))))).flag();
}
- function g(uint a) returns (uint)
+ function g(uint a) public returns (uint)
{
return map[a];
}
@@ -6338,10 +6339,10 @@ BOOST_AUTO_TEST_CASE(return_string)
function set(string _s) external {
s = _s;
}
- function get1() returns (string r) {
+ function get1() public returns (string r) {
return s;
}
- function get2() returns (string r) {
+ function get2() public returns (string r) {
r = s;
}
}
@@ -6366,7 +6367,7 @@ BOOST_AUTO_TEST_CASE(return_multiple_strings_of_various_sizes)
s2 = _s2;
return x;
}
- function get() returns (string r1, string r2) {
+ function get() public returns (string r1, string r2) {
r1 = s1;
r2 = s2;
}
@@ -6439,12 +6440,12 @@ BOOST_AUTO_TEST_CASE(bytes_in_function_calls)
contract Main {
string public s1;
string public s2;
- function set(string _s1, uint x, string _s2) returns (uint) {
+ function set(string _s1, uint x, string _s2) public returns (uint) {
s1 = _s1;
s2 = _s2;
return x;
}
- function setIndirectFromMemory(string _s1, uint x, string _s2) returns (uint) {
+ function setIndirectFromMemory(string _s1, uint x, string _s2) public returns (uint) {
return this.set(_s1, x, _s2);
}
function setIndirectFromCalldata(string _s1, uint x, string _s2) external returns (uint) {
@@ -6484,7 +6485,7 @@ BOOST_AUTO_TEST_CASE(return_bytes_internal)
char const* sourceCode = R"(
contract Main {
bytes s1;
- function doSet(bytes _s1) returns (bytes _r1) {
+ function doSet(bytes _s1) public returns (bytes _r1) {
s1 = _s1;
_r1 = s1;
}
@@ -6512,15 +6513,15 @@ BOOST_AUTO_TEST_CASE(bytes_index_access_memory)
{
char const* sourceCode = R"(
contract Main {
- function f(bytes _s1, uint i1, uint i2, uint i3) returns (byte c1, byte c2, byte c3) {
+ function f(bytes _s1, uint i1, uint i2, uint i3) public returns (byte c1, byte c2, byte c3) {
c1 = _s1[i1];
c2 = intern(_s1, i2);
c3 = internIndirect(_s1)[i3];
}
- function intern(bytes _s1, uint i) returns (byte c) {
+ function intern(bytes _s1, uint i) public returns (byte c) {
return _s1[i];
}
- function internIndirect(bytes _s1) returns (bytes) {
+ function internIndirect(bytes _s1) public returns (bytes) {
return _s1;
}
}
@@ -6541,7 +6542,7 @@ BOOST_AUTO_TEST_CASE(bytes_in_constructors_unpacker)
contract Test {
uint public m_x;
bytes public m_s;
- constructor(uint x, bytes s) {
+ constructor(uint x, bytes s) public {
m_x = x;
m_s = s;
}
@@ -6562,23 +6563,23 @@ BOOST_AUTO_TEST_CASE(bytes_in_constructors_packer)
contract Base {
uint public m_x;
bytes m_s;
- constructor(uint x, bytes s) {
+ constructor(uint x, bytes s) public {
m_x = x;
m_s = s;
}
- function part(uint i) returns (byte) {
+ function part(uint i) public returns (byte) {
return m_s[i];
}
}
contract Main is Base {
- constructor(bytes s, uint x) Base(x, f(s)) {}
- function f(bytes s) returns (bytes) {
+ constructor(bytes s, uint x) Base(x, f(s)) public {}
+ function f(bytes s) public returns (bytes) {
return s;
}
}
contract Creator {
- function f(uint x, bytes s) returns (uint r, byte ch) {
- var c = new Main(s, x);
+ function f(uint x, bytes s) public returns (uint r, byte ch) {
+ Main c = new Main(s, x);
r = c.m_x();
ch = c.part(x);
}
@@ -6601,23 +6602,23 @@ BOOST_AUTO_TEST_CASE(arrays_in_constructors)
contract Base {
uint public m_x;
address[] m_s;
- constructor(uint x, address[] s) {
+ constructor(uint x, address[] s) public {
m_x = x;
m_s = s;
}
- function part(uint i) returns (address) {
+ function part(uint i) public returns (address) {
return m_s[i];
}
}
contract Main is Base {
- constructor(address[] s, uint x) Base(x, f(s)) {}
- function f(address[] s) returns (address[]) {
+ constructor(address[] s, uint x) Base(x, f(s)) public {}
+ function f(address[] s) public returns (address[]) {
return s;
}
}
contract Creator {
- function f(uint x, address[] s) returns (uint r, address ch) {
- var c = new Main(s, x);
+ function f(uint x, address[] s) public returns (uint r, address ch) {
+ Main c = new Main(s, x);
r = c.m_x();
ch = c.part(x);
}
@@ -6640,7 +6641,7 @@ BOOST_AUTO_TEST_CASE(fixed_arrays_in_constructors)
contract Creator {
uint public r;
address public ch;
- constructor(address[3] s, uint x) {
+ constructor(address[3] s, uint x) public {
r = x;
ch = s[2];
}
@@ -6656,11 +6657,11 @@ BOOST_AUTO_TEST_CASE(arrays_from_and_to_storage)
char const* sourceCode = R"(
contract Test {
uint24[] public data;
- function set(uint24[] _data) returns (uint) {
+ function set(uint24[] _data) public returns (uint) {
data = _data;
return data.length;
}
- function get() returns (uint24[]) {
+ function get() public returns (uint24[]) {
return data;
}
}
@@ -6683,11 +6684,11 @@ BOOST_AUTO_TEST_CASE(arrays_complex_from_and_to_storage)
char const* sourceCode = R"(
contract Test {
uint24[3][] public data;
- function set(uint24[3][] _data) returns (uint) {
+ function set(uint24[3][] _data) public returns (uint) {
data = _data;
return data.length;
}
- function get() returns (uint24[3][]) {
+ function get() public returns (uint24[3][]) {
return data;
}
}
@@ -6709,7 +6710,7 @@ BOOST_AUTO_TEST_CASE(arrays_complex_memory_index_access)
{
char const* sourceCode = R"(
contract Test {
- function set(uint24[3][] _data, uint a, uint b) returns (uint l, uint e) {
+ function set(uint24[3][] _data, uint a, uint b) public returns (uint l, uint e) {
l = _data.length;
e = _data[a][b];
}
@@ -6732,7 +6733,7 @@ BOOST_AUTO_TEST_CASE(bytes_memory_index_access)
{
char const* sourceCode = R"(
contract Test {
- function set(bytes _data, uint i) returns (uint l, byte c) {
+ function set(bytes _data, uint i) public returns (uint l, byte c) {
l = _data.length;
c = _data[i];
}
@@ -6779,7 +6780,7 @@ BOOST_AUTO_TEST_CASE(storage_array_ref)
data.length++;
data[data.length - 1] = v;
}
- function find(uint v) returns (uint) {
+ function find(uint v) public returns (uint) {
return find(data, v);
}
}
@@ -6808,13 +6809,13 @@ BOOST_AUTO_TEST_CASE(memory_types_initialisation)
char const* sourceCode = R"(
contract Test {
mapping(uint=>uint) data;
- function stat() returns (uint[5])
+ function stat() public returns (uint[5])
{
data[2] = 3; // make sure to use some memory
}
- function dyn() returns (uint[]) { stat(); }
- function nested() returns (uint[3][]) { stat(); }
- function nestedStat() returns (uint[3][7]) { stat(); }
+ function dyn() public returns (uint[]) { stat(); }
+ function nested() public returns (uint[3][]) { stat(); }
+ function nestedStat() public returns (uint[3][7]) { stat(); }
}
)";
compileAndRun(sourceCode, 0, "Test");
@@ -6829,7 +6830,7 @@ BOOST_AUTO_TEST_CASE(memory_arrays_delete)
{
char const* sourceCode = R"(
contract Test {
- function del() returns (uint24[3][4]) {
+ function del() public returns (uint24[3][4]) {
uint24[3][4] memory x;
for (uint24 i = 0; i < x.length; i ++)
for (uint24 j = 0; j < x[i].length; j ++)
@@ -6862,7 +6863,7 @@ BOOST_AUTO_TEST_CASE(memory_arrays_index_access_write)
x[2][2] = 1;
x[3][2] = 7;
}
- function f() returns (uint24[3][4]){
+ function f() public returns (uint24[3][4]){
uint24[3][4] memory data;
set(data);
return data;
@@ -6887,7 +6888,7 @@ BOOST_AUTO_TEST_CASE(memory_arrays_dynamic_index_access_write)
x[1][3][2] = 7;
return x;
}
- function f() returns (uint24[3][]) {
+ function f() public returns (uint24[3][]) {
data[1].length = 4;
return set(data)[1];
}
@@ -6907,7 +6908,7 @@ BOOST_AUTO_TEST_CASE(memory_structs_read_write)
contract Test {
struct S { uint8 x; uint16 y; uint z; uint8[2] a; }
S[5] data;
- function testInit() returns (uint8 x, uint16 y, uint z, uint8 a, bool flag) {
+ function testInit() public returns (uint8 x, uint16 y, uint z, uint8 a, bool flag) {
S[2] memory d;
x = d[0].x;
y = d[0].y;
@@ -6915,7 +6916,7 @@ BOOST_AUTO_TEST_CASE(memory_structs_read_write)
a = d[0].a[1];
flag = true;
}
- function testCopyRead() returns (uint8 x, uint16 y, uint z, uint8 a) {
+ function testCopyRead() public returns (uint8 x, uint16 y, uint z, uint8 a) {
data[2].x = 1;
data[2].y = 2;
data[2].z = 3;
@@ -6926,7 +6927,7 @@ BOOST_AUTO_TEST_CASE(memory_structs_read_write)
z = s.z;
a = s.a[1];
}
- function testAssign() returns (uint8 x, uint16 y, uint z, uint8 a) {
+ function testAssign() public returns (uint8 x, uint16 y, uint z, uint8 a) {
S memory s;
s.x = 1;
s.y = 2;
@@ -6951,7 +6952,7 @@ BOOST_AUTO_TEST_CASE(memory_structs_as_function_args)
char const* sourceCode = R"(
contract Test {
struct S { uint8 x; uint16 y; uint z; }
- function test() returns (uint x, uint y, uint z) {
+ function test() public returns (uint x, uint y, uint z) {
S memory data = combine(1, 2, 3);
x = extract(data, 0);
y = extract(data, 1);
@@ -6980,7 +6981,7 @@ BOOST_AUTO_TEST_CASE(memory_structs_nested)
contract Test {
struct S { uint8 x; uint16 y; uint z; }
struct X { uint8 x; S s; }
- function test() returns (uint a, uint x, uint y, uint z) {
+ function test() public returns (uint a, uint x, uint y, uint z) {
X memory d = combine(1, 2, 3, 4);
a = extract(d, 0);
x = extract(d, 1);
@@ -7013,7 +7014,7 @@ BOOST_AUTO_TEST_CASE(memory_structs_nested_load)
struct S { uint8 x; uint16 y; uint z; }
struct X { uint8 x; S s; uint8[2] a; }
X m_x;
- function load() returns (uint a, uint x, uint y, uint z, uint a1, uint a2) {
+ function load() public returns (uint a, uint x, uint y, uint z, uint a1, uint a2) {
m_x.x = 1;
m_x.s.x = 2;
m_x.s.y = 3;
@@ -7028,7 +7029,7 @@ BOOST_AUTO_TEST_CASE(memory_structs_nested_load)
a1 = d.a[0];
a2 = d.a[1];
}
- function store() returns (uint a, uint x, uint y, uint z, uint a1, uint a2) {
+ function store() public returns (uint a, uint x, uint y, uint z, uint a1, uint a2) {
X memory d;
d.x = 1;
d.s.x = 2;
@@ -7060,12 +7061,12 @@ BOOST_AUTO_TEST_CASE(struct_constructor_nested)
struct X { uint x1; uint x2; }
struct S { uint s1; uint[3] s2; X s3; }
S s;
- constructor() {
+ constructor() public {
uint[3] memory s2;
s2[1] = 9;
s = S(1, s2, X(4, 5));
}
- function get() returns (uint s1, uint[3] s2, uint x1, uint x2)
+ function get() public returns (uint s1, uint[3] s2, uint x1, uint x2)
{
s1 = s.s1;
s2 = s.s2;
@@ -7086,7 +7087,7 @@ BOOST_AUTO_TEST_CASE(struct_named_constructor)
contract C {
struct S { uint a; bool x; }
S public s;
- constructor() {
+ constructor() public {
s = S({a: 1, x: true});
}
}
@@ -7104,7 +7105,7 @@ BOOST_AUTO_TEST_CASE(literal_strings)
string public medium;
string public short;
string public empty;
- function f() returns (string) {
+ function f() public returns (string) {
long = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
medium = "01234567890123456789012345678901234567890123456789012345678901234567890123456789";
short = "123";
@@ -7148,7 +7149,7 @@ BOOST_AUTO_TEST_CASE(memory_structs_with_mappings)
contract Test {
struct S { uint8 a; mapping(uint => uint) b; uint8 c; }
S s;
- function f() returns (uint) {
+ function f() public returns (uint) {
S memory x;
if (x.a != 0 || x.c != 0) return 1;
x.a = 4; x.c = 5;
@@ -7171,12 +7172,12 @@ BOOST_AUTO_TEST_CASE(string_bytes_conversion)
contract Test {
string s;
bytes b;
- function f(string _s, uint n) returns (byte) {
+ function f(string _s, uint n) public returns (byte) {
b = bytes(_s);
s = string(b);
return bytes(s)[n];
}
- function l() returns (uint) { return bytes(s).length; }
+ function l() public returns (uint) { return bytes(s).length; }
}
)";
compileAndRun(sourceCode, 0, "Test");
@@ -7196,7 +7197,7 @@ BOOST_AUTO_TEST_CASE(string_as_mapping_key)
contract Test {
mapping(string => uint) data;
function set(string _s, uint _v) { data[_s] = _v; }
- function get(string _s) returns (uint) { return data[_s]; }
+ function get(string _s) public returns (uint) { return data[_s]; }
}
)";
compileAndRun(sourceCode, 0, "Test");
@@ -7253,7 +7254,7 @@ BOOST_AUTO_TEST_CASE(state_variable_under_contract_name)
contract Scope {
uint stateVar = 42;
- function getStateVar() view returns (uint stateVar) {
+ function getStateVar() public view returns (uint stateVar) {
stateVar = Scope.stateVar;
}
}
@@ -7268,7 +7269,7 @@ BOOST_AUTO_TEST_CASE(state_variable_local_variable_mixture)
contract A {
uint x = 1;
uint y = 2;
- function a() returns (uint x) {
+ function a() public returns (uint x) {
x = A.y;
}
}
@@ -7283,7 +7284,7 @@ BOOST_AUTO_TEST_CASE(inherited_function) {
contract A { function f() internal returns (uint) { return 1; } }
contract B is A {
function f() internal returns (uint) { return 2; }
- function g() returns (uint) {
+ function g() public returns (uint) {
return A.f();
}
}
@@ -7298,7 +7299,7 @@ BOOST_AUTO_TEST_CASE(inherited_function_from_a_library) {
library A { function f() internal returns (uint) { return 1; } }
contract B {
function f() internal returns (uint) { return 2; }
- function g() returns (uint) {
+ function g() public returns (uint) {
return A.f();
}
}
@@ -7315,7 +7316,7 @@ BOOST_AUTO_TEST_CASE(inherited_constant_state_var)
uint constant x = 7;
}
contract B is A {
- function f() returns (uint) {
+ function f() public returns (uint) {
return A.x;
}
}
@@ -7335,17 +7336,17 @@ BOOST_AUTO_TEST_CASE(multiple_inherited_state_vars)
uint x = 9;
}
contract C is A, B {
- function a() returns (uint) {
+ function a() public returns (uint) {
return A.x;
}
- function b() returns (uint) {
+ function b() public returns (uint) {
return B.x;
}
- function a_set(uint _x) returns (uint) {
+ function a_set(uint _x) public returns (uint) {
A.x = _x;
return 1;
}
- function b_set(uint _x) returns (uint) {
+ function b_set(uint _x) public returns (uint) {
B.x = _x;
return 1;
}
@@ -7368,14 +7369,14 @@ BOOST_AUTO_TEST_CASE(constant_string_literal)
bytes32 constant public b = "abcdefghijklmnopq";
string constant public x = "abefghijklmnopqabcdefghijklmnopqabcdefghijklmnopqabca";
- constructor() {
- var xx = x;
- var bb = b;
+ constructor() public {
+ string memory xx = x;
+ bytes32 bb = b;
}
- function getB() returns (bytes32) { return b; }
- function getX() returns (string) { return x; }
- function getX2() returns (string r) { r = x; }
- function unused() returns (uint) {
+ function getB() public returns (bytes32) { return b; }
+ function getX() public returns (string) { return x; }
+ function getX2() public returns (string r) { r = x; }
+ function unused() public returns (uint) {
"unusedunusedunusedunusedunusedunusedunusedunusedunusedunusedunusedunused";
return 2;
}
@@ -7398,7 +7399,7 @@ BOOST_AUTO_TEST_CASE(storage_string_as_mapping_key_without_variable)
char const* sourceCode = R"(
contract Test {
mapping(string => uint) data;
- function f() returns (uint) {
+ function f() public returns (uint) {
data["abc"] = 2;
return data["abc"];
}
@@ -7411,9 +7412,9 @@ BOOST_AUTO_TEST_CASE(storage_string_as_mapping_key_without_variable)
BOOST_AUTO_TEST_CASE(library_call)
{
char const* sourceCode = R"(
- library Lib { function m(uint x, uint y) returns (uint) { return x * y; } }
+ library Lib { function m(uint x, uint y) public returns (uint) { return x * y; } }
contract Test {
- function f(uint x) returns (uint) {
+ function f(uint x) public returns (uint) {
return Lib.m(x, 9);
}
}
@@ -7441,9 +7442,9 @@ BOOST_AUTO_TEST_CASE(library_function_external)
BOOST_AUTO_TEST_CASE(library_stray_values)
{
char const* sourceCode = R"(
- library Lib { function m(uint x, uint y) returns (uint) { return x * y; } }
+ library Lib { function m(uint x, uint y) public returns (uint) { return x * y; } }
contract Test {
- function f(uint x) returns (uint) {
+ function f(uint x) public returns (uint) {
Lib;
Lib.m;
return x + 9;
@@ -7460,8 +7461,8 @@ BOOST_AUTO_TEST_CASE(cross_contract_types)
char const* sourceCode = R"(
contract Lib { struct S {uint a; uint b; } }
contract Test {
- function f() returns (uint r) {
- var x = Lib.S({a: 2, b: 3});
+ function f() public returns (uint r) {
+ Lib.S memory x = Lib.S({a: 2, b: 3});
r = x.b;
}
}
@@ -7474,7 +7475,7 @@ BOOST_AUTO_TEST_CASE(simple_throw)
{
char const* sourceCode = R"(
contract Test {
- function f(uint x) returns (uint) {
+ function f(uint x) public returns (uint) {
if (x > 10)
return x + 10;
else
@@ -7504,19 +7505,19 @@ BOOST_AUTO_TEST_CASE(strings_in_struct)
constructor(){
bug = Buggy(10, 20, 30, "asdfghjkl");
}
- function getFirst() returns (uint)
+ function getFirst() public returns (uint)
{
return bug.first;
}
- function getSecond() returns (uint)
+ function getSecond() public returns (uint)
{
return bug.second;
}
- function getThird() returns (uint)
+ function getThird() public returns (uint)
{
return bug.third;
}
- function getLast() returns (string)
+ function getLast() public returns (string)
{
return bug.last;
}
@@ -7534,7 +7535,7 @@ BOOST_AUTO_TEST_CASE(fixed_arrays_as_return_type)
{
char const* sourceCode = R"(
contract A {
- function f(uint16 input) pure returns (uint16[5] arr)
+ function f(uint16 input) public pure returns (uint16[5] arr)
{
arr[0] = input;
arr[1] = ++input;
@@ -7544,9 +7545,9 @@ BOOST_AUTO_TEST_CASE(fixed_arrays_as_return_type)
}
}
contract B {
- function f() returns (uint16[5] res, uint16[5] res2)
+ function f() public returns (uint16[5] res, uint16[5] res2)
{
- var a = new A();
+ A a = new A();
res = a.f(2);
res2 = a.f(1000);
}
@@ -7563,7 +7564,7 @@ BOOST_AUTO_TEST_CASE(internal_types_in_library)
{
char const* sourceCode = R"(
library Lib {
- function find(uint16[] storage _haystack, uint16 _needle) view returns (uint)
+ function find(uint16[] storage _haystack, uint16 _needle) public view returns (uint)
{
for (uint i = 0; i < _haystack.length; ++i)
if (_haystack[i] == _needle)
@@ -7573,7 +7574,7 @@ BOOST_AUTO_TEST_CASE(internal_types_in_library)
}
contract Test {
mapping(string => uint16[]) data;
- function f() returns (uint a, uint b)
+ function f() public returns (uint a, uint b)
{
data["abc"].length = 20;
data["abc"][4] = 9;
@@ -7602,7 +7603,7 @@ BOOST_AUTO_TEST_CASE(using_library_structs)
}
contract Test {
mapping(string => Lib.Data) data;
- function f() returns (uint a, uint b)
+ function f() public returns (uint a, uint b)
{
Lib.set(data["abc"]);
a = data["abc"].a;
@@ -7626,7 +7627,7 @@ BOOST_AUTO_TEST_CASE(library_struct_as_an_expression)
}
contract Tsra {
- function f() returns(uint) {
+ function f() public returns(uint) {
Arst.Foo;
return 1;
}
@@ -7647,7 +7648,7 @@ BOOST_AUTO_TEST_CASE(library_enum_as_an_expression)
}
contract Tsra {
- function f() returns(uint) {
+ function f() public returns(uint) {
Arst.Foo;
return 1;
}
@@ -7665,7 +7666,7 @@ BOOST_AUTO_TEST_CASE(short_strings)
contract A {
bytes public data1 = "123";
bytes data2;
- function lengthChange() returns (uint)
+ function lengthChange() public returns (uint)
{
// store constant in short and long string
data1 = "123";
@@ -7707,7 +7708,7 @@ BOOST_AUTO_TEST_CASE(short_strings)
data1.length = 0;
data2.length = 0;
}
- function copy() returns (uint) {
+ function copy() public returns (uint) {
bytes memory x = "123";
bytes memory y = "012345678901234567890123456789012345678901234567890123456789";
bytes memory z = "1234567";
@@ -7740,7 +7741,7 @@ BOOST_AUTO_TEST_CASE(short_strings)
data1 = "";
data2 = "";
}
- function deleteElements() returns (uint) {
+ function deleteElements() public returns (uint) {
data1 = "01234";
delete data1[2];
if (data1[2] != 0) return 1;
@@ -7789,9 +7790,9 @@ BOOST_AUTO_TEST_CASE(calldata_offset)
BOOST_AUTO_TEST_CASE(contract_binary_dependencies)
{
char const* sourceCode = R"(
- contract A { function f() { new B(); } }
- contract B { function f() { } }
- contract C { function f() { new B(); } }
+ contract A { function f() public { new B(); } }
+ contract B { function f() public { } }
+ contract C { function f() public { new B(); } }
)";
compileAndRun(sourceCode);
}
@@ -7801,8 +7802,8 @@ BOOST_AUTO_TEST_CASE(reject_ether_sent_to_library)
char const* sourceCode = R"(
library lib {}
contract c {
- constructor() payable {}
- function f(address x) returns (bool) {
+ constructor() public payable {}
+ function f(address x) public returns (bool) {
return x.send(1);
}
function () external payable {}
@@ -7825,17 +7826,17 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration)
{
char const* sourceCode = R"(
contract C {
- function g() returns (uint a, uint b, uint c) {
+ function g() public returns (uint a, uint b, uint c) {
a = 1; b = 2; c = 3;
}
- function f() returns (bool) {
- var (x, y, z) = g();
+ function f() public returns (bool) {
+ (uint x, uint y, uint z) = g();
if (x != 1 || y != 2 || z != 3) return false;
- var (, a,) = g();
+ (, uint a,) = g();
if (a != 2) return false;
- var (b,) = g();
+ (uint b,) = g();
if (b != 1) return false;
- var (,c) = g();
+ (, uint c) = g();
if (c != 3) return false;
return true;
}
@@ -7855,7 +7856,7 @@ BOOST_AUTO_TEST_CASE(typed_multi_variable_declaration)
s.x = 7;
return (1, s, 2);
}
- function f() returns (bool) {
+ function f() public returns (bool) {
(uint x1, S storage y1, uint z1) = g();
if (x1 != 1 || y1.x != 7 || z1 != 2) return false;
(, S storage y2,) = g();
@@ -7883,7 +7884,7 @@ BOOST_AUTO_TEST_CASE(tuples)
function h() external returns (uint a, uint b) {
return (5, 6);
}
- function f() returns (uint) {
+ function f() public returns (uint) {
data.length = 1;
data[0] = 3;
uint a; uint b;
@@ -7907,13 +7908,13 @@ BOOST_AUTO_TEST_CASE(string_tuples)
{
char const* sourceCode = R"(
contract C {
- function f() returns (string, uint) {
+ function f() public returns (string, uint) {
return ("abc", 8);
}
- function g() returns (string, string) {
+ function g() public returns (string, string) {
return (h(), "def");
}
- function h() returns (string) {
+ function h() public returns (string) {
return ("abc",);
}
}
@@ -7927,7 +7928,7 @@ BOOST_AUTO_TEST_CASE(decayed_tuple)
{
char const* sourceCode = R"(
contract C {
- function f() returns (uint) {
+ function f() public returns (uint) {
uint x = 1;
(x) = 2;
return x;
@@ -7942,7 +7943,7 @@ BOOST_AUTO_TEST_CASE(inline_tuple_with_rational_numbers)
{
char const* sourceCode = R"(
contract c {
- function f() returns (int8) {
+ function f() public returns (int8) {
int8[5] memory foo3 = [int8(1), -1, 0, 0, 0];
return foo3[0];
}
@@ -7960,13 +7961,13 @@ BOOST_AUTO_TEST_CASE(destructuring_assignment)
bytes data;
uint[] y;
uint[] arrayData;
- function returnsArray() returns (uint[]) {
+ function returnsArray() public returns (uint[]) {
arrayData.length = 9;
arrayData[2] = 5;
arrayData[7] = 4;
return arrayData;
}
- function f(bytes s) returns (uint) {
+ function f(bytes s) public returns (uint) {
uint loc;
uint[] memory memArray;
(loc, x, y, data, arrayData[3]) = (8, 4, returnsArray(), s, 2);
@@ -7995,7 +7996,7 @@ BOOST_AUTO_TEST_CASE(destructuring_assignment_wildcard)
{
char const* sourceCode = R"(
contract C {
- function f() returns (uint) {
+ function f() public returns (uint) {
uint a;
uint b;
uint c;
@@ -8021,7 +8022,7 @@ BOOST_AUTO_TEST_CASE(lone_struct_array_type)
char const* sourceCode = R"(
contract C {
struct s { uint a; uint b;}
- function f() returns (uint) {
+ function f() public returns (uint) {
s[7][]; // This is only the type, should not have any effect
return 3;
}
@@ -8036,12 +8037,12 @@ BOOST_AUTO_TEST_CASE(create_memory_array)
char const* sourceCode = R"(
contract C {
struct S { uint[2] a; bytes b; }
- function f() returns (byte, uint, uint, byte) {
- var x = new bytes(200);
+ function f() public returns (byte, uint, uint, byte) {
+ bytes memory x = new bytes(200);
x[199] = 'A';
- var y = new uint[2][](300);
+ uint[2][] memory y = new uint[2][](300);
y[203][1] = 8;
- var z = new S[](180);
+ S[] memory z = new S[](180);
z[170].a[1] = 4;
z[170].b = new bytes(102);
z[170].b[99] = 'B';
@@ -8059,7 +8060,7 @@ BOOST_AUTO_TEST_CASE(create_memory_array_allocation_size)
// multiple of 32
char const* sourceCode = R"(
contract C {
- function f() pure returns (uint d1, uint d2, uint d3) {
+ function f() public pure returns (uint d1, uint d2, uint d3, uint memsize) {
bytes memory b1 = new bytes(31);
bytes memory b2 = new bytes(32);
bytes memory b3 = new bytes(256);
@@ -8068,12 +8069,13 @@ BOOST_AUTO_TEST_CASE(create_memory_array_allocation_size)
d1 := sub(b2, b1)
d2 := sub(b3, b2)
d3 := sub(b4, b3)
+ memsize := msize()
}
}
}
)";
compileAndRun(sourceCode);
- ABI_CHECK(callContractFunction("f()"), encodeArgs(0x40, 0x40, 0x20 + 256));
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(0x40, 0x40, 0x20 + 256, 0x260));
}
BOOST_AUTO_TEST_CASE(memory_arrays_of_various_sizes)
@@ -8081,7 +8083,7 @@ BOOST_AUTO_TEST_CASE(memory_arrays_of_various_sizes)
// Computes binomial coefficients the chinese way
char const* sourceCode = R"(
contract C {
- function f(uint n, uint k) returns (uint) {
+ function f(uint n, uint k) public returns (uint) {
uint[][] memory rows = new uint[][](n + 1);
for (uint i = 1; i <= n; i++) {
rows[i] = new uint[](i);
@@ -8102,7 +8104,7 @@ BOOST_AUTO_TEST_CASE(create_multiple_dynamic_arrays)
{
char const* sourceCode = R"(
contract C {
- function f() returns (uint) {
+ function f() public returns (uint) {
uint[][] memory x = new uint[][](42);
assert(x[0].length == 0);
x[0] = new uint[](1);
@@ -8137,7 +8139,7 @@ BOOST_AUTO_TEST_CASE(memory_overwrite)
{
char const* sourceCode = R"(
contract C {
- function f() returns (bytes x) {
+ function f() public returns (bytes x) {
x = "12345";
x[3] = 0x61;
x[0] = 0x62;
@@ -8152,7 +8154,7 @@ BOOST_AUTO_TEST_CASE(addmod_mulmod)
{
char const* sourceCode = R"(
contract C {
- function test() returns (uint) {
+ function test() public returns (uint) {
// Note that this only works because computation on literals is done using
// unbounded integers.
if ((2**255 + 2**255) % 7 != addmod(2**255, 2**255, 7))
@@ -8171,15 +8173,15 @@ BOOST_AUTO_TEST_CASE(addmod_mulmod_zero)
{
char const* sourceCode = R"(
contract C {
- function f(uint d) pure returns (uint) {
+ function f(uint d) public pure returns (uint) {
addmod(1, 2, d);
return 2;
}
- function g(uint d) pure returns (uint) {
+ function g(uint d) public pure returns (uint) {
mulmod(1, 2, d);
return 2;
}
- function h() pure returns (uint) {
+ function h() public pure returns (uint) {
mulmod(0, 1, 2);
mulmod(1, 0, 2);
addmod(0, 1, 2);
@@ -8198,10 +8200,10 @@ BOOST_AUTO_TEST_CASE(divisiod_by_zero)
{
char const* sourceCode = R"(
contract C {
- function div(uint a, uint b) returns (uint) {
+ function div(uint a, uint b) public returns (uint) {
return a / b;
}
- function mod(uint a, uint b) returns (uint) {
+ function mod(uint a, uint b) public returns (uint) {
return a % b;
}
}
@@ -8222,7 +8224,7 @@ BOOST_AUTO_TEST_CASE(string_allocation_bug)
{
struct s { uint16 x; uint16 y; string a; string b;}
s[2] public p;
- constructor() {
+ constructor() public {
s memory m;
m.x = 0xbbbb;
m.y = 0xcccc;
@@ -8248,10 +8250,10 @@ BOOST_AUTO_TEST_CASE(string_allocation_bug)
BOOST_AUTO_TEST_CASE(using_for_function_on_int)
{
char const* sourceCode = R"(
- library D { function double(uint self) returns (uint) { return 2*self; } }
+ library D { function double(uint self) public returns (uint) { return 2*self; } }
contract C {
using D for uint;
- function f(uint a) returns (uint) {
+ function f(uint a) public returns (uint) {
return a.double();
}
}
@@ -8264,11 +8266,11 @@ BOOST_AUTO_TEST_CASE(using_for_function_on_int)
BOOST_AUTO_TEST_CASE(using_for_function_on_struct)
{
char const* sourceCode = R"(
- library D { struct s { uint a; } function mul(s storage self, uint x) returns (uint) { return self.a *= x; } }
+ library D { struct s { uint a; } function mul(s storage self, uint x) public returns (uint) { return self.a *= x; } }
contract C {
using D for D.s;
D.s public x;
- function f(uint a) returns (uint) {
+ function f(uint a) public returns (uint) {
x.a = 3;
return x.mul(a);
}
@@ -8285,13 +8287,13 @@ BOOST_AUTO_TEST_CASE(using_for_overload)
char const* sourceCode = R"(
library D {
struct s { uint a; }
- function mul(s storage self, uint x) returns (uint) { return self.a *= x; }
- function mul(s storage self, bytes32 x) returns (bytes32) { }
+ function mul(s storage self, uint x) public returns (uint) { return self.a *= x; }
+ function mul(s storage self, bytes32 x) public returns (bytes32) { }
}
contract C {
using D for D.s;
D.s public x;
- function f(uint a) returns (uint) {
+ function f(uint a) public returns (uint) {
x.a = 6;
return x.mul(a);
}
@@ -8306,11 +8308,11 @@ BOOST_AUTO_TEST_CASE(using_for_overload)
BOOST_AUTO_TEST_CASE(using_for_by_name)
{
char const* sourceCode = R"(
- library D { struct s { uint a; } function mul(s storage self, uint x) returns (uint) { return self.a *= x; } }
+ library D { struct s { uint a; } function mul(s storage self, uint x) public returns (uint) { return self.a *= x; } }
contract C {
using D for D.s;
D.s public x;
- function f(uint a) returns (uint) {
+ function f(uint a) public returns (uint) {
x.a = 6;
return x.mul({x: a});
}
@@ -8325,14 +8327,13 @@ BOOST_AUTO_TEST_CASE(using_for_by_name)
BOOST_AUTO_TEST_CASE(bound_function_in_var)
{
char const* sourceCode = R"(
- library D { struct s { uint a; } function mul(s storage self, uint x) returns (uint) { return self.a *= x; } }
+ library D { struct s { uint a; } function mul(s storage self, uint x) public returns (uint) { return self.a *= x; } }
contract C {
using D for D.s;
D.s public x;
- function f(uint a) returns (uint) {
+ function f(uint a) public returns (uint) {
x.a = 6;
- var g = x.mul;
- return g({x: a});
+ return (x.mul)({x: a});
}
}
)";
@@ -8345,15 +8346,15 @@ BOOST_AUTO_TEST_CASE(bound_function_in_var)
BOOST_AUTO_TEST_CASE(bound_function_to_string)
{
char const* sourceCode = R"(
- library D { function length(string memory self) returns (uint) { return bytes(self).length; } }
+ library D { function length(string memory self) public returns (uint) { return bytes(self).length; } }
contract C {
using D for string;
string x;
- function f() returns (uint) {
+ function f() public returns (uint) {
x = "abc";
return x.length();
}
- function g() returns (uint) {
+ function g() public returns (uint) {
string memory s = "abc";
return s.length();
}
@@ -8370,7 +8371,7 @@ BOOST_AUTO_TEST_CASE(inline_array_storage_to_memory_conversion_strings)
char const* sourceCode = R"(
contract C {
string s = "doh";
- function f() returns (string, string) {
+ function f() public returns (string, string) {
string memory t = "ray";
string[3] memory x = [s, t, "mi"];
return (x[1], x[2]);
@@ -8385,7 +8386,7 @@ BOOST_AUTO_TEST_CASE(inline_array_strings_from_document)
{
char const* sourceCode = R"(
contract C {
- function f(uint i) returns (string) {
+ function f(uint i) public returns (string) {
string[4] memory x = ["This", "is", "an", "array"];
return (x[i]);
}
@@ -8402,7 +8403,7 @@ BOOST_AUTO_TEST_CASE(inline_array_storage_to_memory_conversion_ints)
{
char const* sourceCode = R"(
contract C {
- function f() returns (uint x, uint y) {
+ function f() public returns (uint x, uint y) {
x = 3;
y = 6;
uint[2] memory z = [x, y];
@@ -8418,7 +8419,7 @@ BOOST_AUTO_TEST_CASE(inline_array_index_access_ints)
{
char const* sourceCode = R"(
contract C {
- function f() returns (uint) {
+ function f() public returns (uint) {
return ([1, 2, 3, 4][2]);
}
}
@@ -8432,10 +8433,10 @@ BOOST_AUTO_TEST_CASE(inline_array_index_access_strings)
char const* sourceCode = R"(
contract C {
string public tester;
- function f() returns (string) {
+ function f() public returns (string) {
return (["abc", "def", "g"][0]);
}
- function test() {
+ function test() public {
tester = f();
}
}
@@ -8450,10 +8451,10 @@ BOOST_AUTO_TEST_CASE(inline_array_return)
char const* sourceCode = R"(
contract C {
uint8[] tester;
- function f() returns (uint8[5]) {
+ function f() public returns (uint8[5]) {
return ([1,2,3,4,5]);
}
- function test() returns (uint8, uint8, uint8, uint8, uint8) {
+ function test() public returns (uint8, uint8, uint8, uint8, uint8) {
tester = f();
return (tester[0], tester[1], tester[2], tester[3], tester[4]);
}
@@ -8469,7 +8470,7 @@ BOOST_AUTO_TEST_CASE(inline_array_singleton)
// This caused a failure since the type was not converted to its mobile type.
char const* sourceCode = R"(
contract C {
- function f() returns (uint) {
+ function f() public returns (uint) {
return [4][0];
}
}
@@ -8482,7 +8483,7 @@ BOOST_AUTO_TEST_CASE(inline_long_string_return)
{
char const* sourceCode = R"(
contract C {
- function f() returns (string) {
+ function f() public returns (string) {
return (["somethingShort", "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"][1]);
}
}
@@ -8498,10 +8499,10 @@ BOOST_AUTO_TEST_CASE(fixed_bytes_index_access)
char const* sourceCode = R"(
contract C {
bytes16[] public data;
- function f(bytes32 x) returns (byte) {
+ function f(bytes32 x) public returns (byte) {
return x[2];
}
- function g(bytes32 x) returns (uint) {
+ function g(bytes32 x) public returns (uint) {
data = [x[0], x[1], x[2]];
data[0] = "12345";
return uint(uint8(data[0][4]));
@@ -8519,7 +8520,7 @@ BOOST_AUTO_TEST_CASE(fixed_bytes_length_access)
char const* sourceCode = R"(
contract C {
byte a;
- function f(bytes32 x) returns (uint, uint, uint) {
+ function f(bytes32 x) public returns (uint, uint, uint) {
return (x.length, bytes16(2).length, a.length + 7);
}
}
@@ -8532,7 +8533,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_write_to_stack)
{
char const* sourceCode = R"(
contract C {
- function f() returns (uint r, bytes32 r2) {
+ function f() public returns (uint r, bytes32 r2) {
assembly { r := 7 r2 := "abcdef" }
}
}
@@ -8545,7 +8546,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_read_and_write_stack)
{
char const* sourceCode = R"(
contract C {
- function f() returns (uint r) {
+ function f() public returns (uint r) {
for (uint x = 0; x < 10; ++x)
assembly { r := add(r, x) }
}
@@ -8559,7 +8560,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_memory_access)
{
char const* sourceCode = R"(
contract C {
- function test() returns (bytes) {
+ function test() public returns (bytes) {
bytes memory x = new bytes(5);
for (uint i = 0; i < x.length; ++i)
x[i] = byte(uint8(i + 1));
@@ -8579,7 +8580,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_storage_access)
uint16 x;
uint16 public y;
uint public z;
- function f() returns (bool) {
+ function f() public returns (bool) {
uint off1;
uint off2;
assembly {
@@ -8605,7 +8606,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_storage_access_inside_function)
uint16 x;
uint16 public y;
uint public z;
- function f() returns (bool) {
+ function f() public returns (bool) {
uint off1;
uint off2;
assembly {
@@ -8633,7 +8634,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_storage_access_via_pointer)
uint public separator;
Data public a;
uint public separator2;
- function f() returns (bool) {
+ function f() public returns (bool) {
Data x = a;
uint off;
assembly {
@@ -8656,7 +8657,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_jumps)
{
char const* sourceCode = R"(
contract C {
- function f() {
+ function f() public {
assembly {
let n := calldataload(4)
let a := 1
@@ -8702,7 +8703,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_function_call)
{
char const* sourceCode = R"(
contract C {
- function f() {
+ function f() public {
assembly {
function asmfun(a, b, c) -> x, y, z {
x := a
@@ -8726,7 +8727,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_function_call_assignment)
{
char const* sourceCode = R"(
contract C {
- function f() {
+ function f() public {
assembly {
let a1, b1, c1
function asmfun(a, b, c) -> x, y, z {
@@ -8751,7 +8752,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_function_call2)
{
char const* sourceCode = R"(
contract C {
- function f() {
+ function f() public {
assembly {
let d := 0x10
function asmfun(a, b, c) -> x, y, z {
@@ -8777,7 +8778,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_embedded_function_call)
{
char const* sourceCode = R"(
contract C {
- function f() {
+ function f() public {
assembly {
let d := 0x10
function asmfun(a, b, c) -> x, y, z {
@@ -8804,7 +8805,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_if)
{
char const* sourceCode = R"(
contract C {
- function f(uint a) returns (uint b) {
+ function f(uint a) public returns (uint b) {
assembly {
if gt(a, 1) { b := 2 }
}
@@ -8822,7 +8823,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_switch)
{
char const* sourceCode = R"(
contract C {
- function f(uint a) returns (uint b) {
+ function f(uint a) public returns (uint b) {
assembly {
switch a
case 1 { b := 8 }
@@ -8843,7 +8844,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_recursion)
{
char const* sourceCode = R"(
contract C {
- function f(uint a) returns (uint b) {
+ function f(uint a) public returns (uint b) {
assembly {
function fac(n) -> nf {
switch n
@@ -8868,7 +8869,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_for)
{
char const* sourceCode = R"(
contract C {
- function f(uint a) returns (uint b) {
+ function f(uint a) public returns (uint b) {
assembly {
function fac(n) -> nf {
nf := 1
@@ -8894,7 +8895,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_for2)
char const* sourceCode = R"(
contract C {
uint st;
- function f(uint a) returns (uint b, uint c, uint d) {
+ function f(uint a) public returns (uint b, uint c, uint d) {
st = 0;
assembly {
function sideeffect(r) -> x { sstore(0, add(sload(0), r)) x := 1}
@@ -8918,7 +8919,7 @@ BOOST_AUTO_TEST_CASE(index_access_with_type_conversion)
// Test for a bug where higher order bits cleanup was not done for array index access.
char const* sourceCode = R"(
contract C {
- function f(uint x) returns (uint[256] r){
+ function f(uint x) public returns (uint[256] r){
r[uint8(x)] = 2;
}
}
@@ -8936,7 +8937,7 @@ BOOST_AUTO_TEST_CASE(delete_on_array_of_structs)
contract C {
struct S { uint x; uint[] y; }
S[] data;
- function f() returns (bool) {
+ function f() public returns (bool) {
data.length = 2;
data[0].x = 2**200;
data[1].x = 2**200;
@@ -8963,7 +8964,7 @@ BOOST_AUTO_TEST_CASE(internal_library_function)
}
}
contract C {
- function f() returns (uint) {
+ function f() public returns (uint) {
uint[] memory x = new uint[](7);
x[3] = 8;
L.f(x);
@@ -8991,7 +8992,7 @@ BOOST_AUTO_TEST_CASE(internal_library_function_calling_private)
}
}
contract C {
- function f() returns (uint) {
+ function f() public returns (uint) {
uint[] memory x = new uint[](7);
x[3] = 8;
L.f(x);
@@ -9015,7 +9016,7 @@ BOOST_AUTO_TEST_CASE(internal_library_function_bound)
}
contract C {
using L for L.S;
- function f() returns (uint) {
+ function f() public returns (uint) {
L.S memory x;
x.data = new uint[](7);
x.data[3] = 8;
@@ -9041,7 +9042,7 @@ BOOST_AUTO_TEST_CASE(internal_library_function_return_var_size)
}
contract C {
using L for L.S;
- function f() returns (uint) {
+ function f() public returns (uint) {
L.S memory x;
x.data = new uint[](7);
x.data[3] = 8;
@@ -9060,7 +9061,7 @@ BOOST_AUTO_TEST_CASE(iszero_bnot_correct)
// "iszero" and "not".
char const* sourceCode = R"(
contract C {
- function f() returns (bool) {
+ function f() public returns (bool) {
bytes32 x = 1;
assembly { x := not(x) }
if (x != ~bytes32(1)) return false;
@@ -9079,7 +9080,7 @@ BOOST_AUTO_TEST_CASE(cleanup_bytes_types)
// Checks that bytesXX types are properly cleaned before they are compared.
char const* sourceCode = R"(
contract C {
- function f(bytes2 a, uint16 x) returns (uint) {
+ function f(bytes2 a, uint16 x) public returns (uint) {
if (a != "ab") return 1;
if (x != 0x0102) return 2;
if (bytes3(uint24(x)) != 0x0102) return 3;
@@ -9096,7 +9097,7 @@ BOOST_AUTO_TEST_CASE(cleanup_bytes_types_shortening)
{
char const* sourceCode = R"(
contract C {
- function f() pure returns (bytes32 r) {
+ function f() public pure returns (bytes32 r) {
bytes4 x = 0xffffffff;
bytes2 y = bytes2(x);
assembly { r := y }
@@ -9115,12 +9116,12 @@ BOOST_AUTO_TEST_CASE(skip_dynamic_types)
// The EVM cannot provide access to dynamically-sized return values, so we have to skip them.
char const* sourceCode = R"(
contract C {
- function f() returns (uint, uint[], uint) {
+ function f() public returns (uint, uint[], uint) {
return (7, new uint[](2), 8);
}
- function g() returns (uint, uint) {
+ function g() public returns (uint, uint) {
// Previous implementation "moved" b to the second place and did not skip.
- var (a, _, b) = this.f();
+ (uint a,, uint b) = this.f();
return (a, b);
}
}
@@ -9141,12 +9142,12 @@ BOOST_AUTO_TEST_CASE(skip_dynamic_types_for_structs)
uint y;
}
S public s;
- function g() returns (uint, uint) {
+ function g() public returns (uint, uint) {
s.x = 2;
s.a = "abc";
s.b = [7, 8, 9];
s.y = 6;
- var (x, a, y) = this.s();
+ (uint x,, uint y) = this.s();
return (x, y);
}
}
@@ -9161,12 +9162,12 @@ BOOST_AUTO_TEST_CASE(failed_create)
contract D { constructor() payable {} }
contract C {
uint public x;
- constructor() payable {}
- function f(uint amount) returns (address) {
+ constructor() public payable {}
+ function f(uint amount) public returns (address) {
x++;
return (new D).value(amount)();
}
- function stack(uint depth) returns (address) {
+ function stack(uint depth) public returns (address) {
if (depth < 1024)
return this.stack(depth - 1);
else
@@ -9187,8 +9188,8 @@ BOOST_AUTO_TEST_CASE(create_dynamic_array_with_zero_length)
{
char const* sourceCode = R"(
contract C {
- function f() returns (uint) {
- var a = new uint[][](0);
+ function f() public returns (uint) {
+ uint[][] memory a = new uint[][](0);
return 7;
}
}
@@ -9232,7 +9233,7 @@ BOOST_AUTO_TEST_CASE(return_does_not_skip_modifier)
_;
x = 9;
}
- function f() setsx returns (uint) {
+ function f() setsx public returns (uint) {
return 2;
}
}
@@ -9310,7 +9311,7 @@ BOOST_AUTO_TEST_CASE(mutex)
shares -= amount;
return shares;
}
- function withdrawUnprotected(uint amount) returns (uint) {
+ function withdrawUnprotected(uint amount) public returns (uint) {
// NOTE: It is very bad practice to write this function this way.
// Please refer to the documentation of how to do this properly.
if (amount > shares) throw;
@@ -9324,8 +9325,8 @@ BOOST_AUTO_TEST_CASE(mutex)
uint callDepth;
bool protected;
function setProtected(bool _protected) { protected = _protected; }
- constructor(Fund _fund) { fund = _fund; }
- function attack() returns (uint) {
+ constructor(Fund _fund) public { fund = _fund; }
+ function attack() public returns (uint) {
callDepth = 0;
return attackInternal();
}
@@ -9361,7 +9362,7 @@ BOOST_AUTO_TEST_CASE(failing_ecrecover_invalid_input)
// Note that the precompile does not return zero but returns nothing.
char const* sourceCode = R"(
contract C {
- function f() returns (address) {
+ function f() public returns (address) {
return ecrecover(bytes32(uint(-1)), 1, 2, 3);
}
}
@@ -9374,7 +9375,7 @@ BOOST_AUTO_TEST_CASE(failing_ecrecover_invalid_input_proper)
{
char const* sourceCode = R"(
contract C {
- function f() returns (address) {
+ function f() public returns (address) {
return recover(
0x77e5189111eb6557e8a637b27ef8fbb15bc61d61c2f00cc48878f3a296e5e0ca,
0, // invalid v value
@@ -9385,7 +9386,7 @@ BOOST_AUTO_TEST_CASE(failing_ecrecover_invalid_input_proper)
);
}
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s, uint blockExpired, bytes32 salt)
- returns (address)
+ public returns (address)
{
require(hash == keccak256(abi.encodePacked(blockExpired, salt)));
return ecrecover(hash, v, r, s);
@@ -9400,7 +9401,7 @@ BOOST_AUTO_TEST_CASE(failing_ecrecover_invalid_input_asm)
{
char const* sourceCode = R"(
contract C {
- function f() returns (address) {
+ function f() public returns (address) {
assembly {
mstore(mload(0x40), 0xca35b7d915458ef540ade6068dfe2f44e8fa733c)
}
@@ -9423,15 +9424,15 @@ BOOST_AUTO_TEST_CASE(calling_nonexisting_contract_throws)
contract D { function g(); }
contract C {
D d = D(0x1212);
- function f() returns (uint) {
+ function f() public returns (uint) {
d.g();
return 7;
}
- function g() returns (uint) {
+ function g() public returns (uint) {
d.g.gas(200)();
return 7;
}
- function h() returns (uint) {
+ function h() public returns (uint) {
d.call(""); // this does not throw (low-level)
return 7;
}
@@ -9458,7 +9459,7 @@ BOOST_AUTO_TEST_CASE(payable_function)
char const* sourceCode = R"(
contract C {
uint public a;
- function f() payable returns (uint) {
+ function f() payable public returns (uint) {
return msg.value;
}
function() external payable {
@@ -9479,10 +9480,10 @@ BOOST_AUTO_TEST_CASE(payable_function_calls_library)
{
char const* sourceCode = R"(
library L {
- function f() returns (uint) { return 7; }
+ function f() public returns (uint) { return 7; }
}
contract C {
- function f() payable returns (uint) {
+ function f() payable public returns (uint) {
return L.f();
}
}
@@ -9497,7 +9498,7 @@ BOOST_AUTO_TEST_CASE(non_payable_throw)
char const* sourceCode = R"(
contract C {
uint public a;
- function f() returns (uint) {
+ function f() public returns (uint) {
return msg.value;
}
function() external {
@@ -9524,7 +9525,7 @@ BOOST_AUTO_TEST_CASE(no_nonpayable_circumvention_by_modifier)
modifier tryCircumvent {
if (false) _; // avoid the function, we should still not accept ether
}
- function f() tryCircumvent returns (uint) {
+ function f() tryCircumvent public returns (uint) {
return msg.value;
}
}
@@ -9542,10 +9543,10 @@ BOOST_AUTO_TEST_CASE(mem_resize_is_not_paid_at_call)
// Tests that this also survives the optimizer.
char const* sourceCode = R"(
contract C {
- function f() returns (uint[200]) {}
+ function f() public returns (uint[200]) {}
}
contract D {
- function f(C c) returns (uint) { c.f(); return 7; }
+ function f(C c) public returns (uint) { c.f(); return 7; }
}
)";
@@ -9559,12 +9560,12 @@ BOOST_AUTO_TEST_CASE(calling_uninitialized_function)
{
char const* sourceCode = R"(
contract C {
- function intern() returns (uint) {
+ function intern() public returns (uint) {
function (uint) internal returns (uint) x;
x(2);
return 7;
}
- function extern() returns (uint) {
+ function extern() public returns (uint) {
function (uint) external returns (uint) x;
x(2);
return 7;
@@ -9584,7 +9585,7 @@ BOOST_AUTO_TEST_CASE(calling_uninitialized_function_in_detail)
contract C {
function() internal returns (uint) x;
int mutex;
- function t() returns (uint) {
+ function t() public returns (uint) {
if (mutex > 0)
{ assembly { mstore(0, 7) return(0, 0x20) } }
mutex = 1;
@@ -9604,7 +9605,7 @@ BOOST_AUTO_TEST_CASE(calling_uninitialized_function_through_array)
char const* sourceCode = R"(
contract C {
int mutex;
- function t() returns (uint) {
+ function t() public returns (uint) {
if (mutex > 0)
{ assembly { mstore(0, 7) return(0, 0x20) } }
mutex = 1;
@@ -9624,13 +9625,13 @@ BOOST_AUTO_TEST_CASE(pass_function_types_internally)
{
char const* sourceCode = R"(
contract C {
- function f(uint x) returns (uint) {
+ function f(uint x) public returns (uint) {
return eval(g, x);
}
- function eval(function(uint) returns (uint) x, uint a) internal returns (uint) {
+ function eval(function(uint) internal returns (uint) x, uint a) internal returns (uint) {
return x(a);
}
- function g(uint x) returns (uint) { return x + 1; }
+ function g(uint x) public returns (uint) { return x + 1; }
}
)";
@@ -9642,16 +9643,16 @@ BOOST_AUTO_TEST_CASE(pass_function_types_externally)
{
char const* sourceCode = R"(
contract C {
- function f(uint x) returns (uint) {
+ function f(uint x) public returns (uint) {
return this.eval(this.g, x);
}
- function f2(uint x) returns (uint) {
+ function f2(uint x) public returns (uint) {
return eval(this.g, x);
}
- function eval(function(uint) external returns (uint) x, uint a) returns (uint) {
+ function eval(function(uint) external returns (uint) x, uint a) public returns (uint) {
return x(a);
}
- function g(uint x) returns (uint) { return x + 1; }
+ function g(uint x) public returns (uint) { return x + 1; }
}
)";
@@ -9664,8 +9665,8 @@ BOOST_AUTO_TEST_CASE(receive_external_function_type)
{
char const* sourceCode = R"(
contract C {
- function g() returns (uint) { return 7; }
- function f(function() external returns (uint) g) returns (uint) {
+ function g() public returns (uint) { return 7; }
+ function f(function() external returns (uint) g) public returns (uint) {
return g();
}
}
@@ -9682,8 +9683,8 @@ BOOST_AUTO_TEST_CASE(return_external_function_type)
{
char const* sourceCode = R"(
contract C {
- function g() {}
- function f() returns (function() external) {
+ function g() public {}
+ function f() public returns (function() external) {
return this.g;
}
}
@@ -9700,18 +9701,18 @@ BOOST_AUTO_TEST_CASE(store_function)
{
char const* sourceCode = R"(
contract Other {
- function addTwo(uint x) returns (uint) { return x + 2; }
+ function addTwo(uint x) public returns (uint) { return x + 2; }
}
contract C {
- function (function (uint) external returns (uint)) returns (uint) ev;
+ function (function (uint) external returns (uint)) internal returns (uint) ev;
function (uint) external returns (uint) x;
function store(function(uint) external returns (uint) y) {
x = y;
}
- function eval(function(uint) external returns (uint) y) returns (uint) {
+ function eval(function(uint) external returns (uint) y) public returns (uint) {
return y(7);
}
- function t() returns (uint) {
+ function t() public returns (uint) {
ev = eval;
this.store((new Other()).addTwo);
return ev(x);
@@ -9729,14 +9730,14 @@ BOOST_AUTO_TEST_CASE(store_function_in_constructor)
contract C {
uint public result_in_constructor;
function (uint) internal returns (uint) x;
- constructor() {
+ constructor() public {
x = double;
result_in_constructor = use(2);
}
- function double(uint _arg) returns (uint _ret) {
+ function double(uint _arg) public returns (uint _ret) {
_ret = _arg * 2;
}
- function use(uint _arg) returns (uint) {
+ function use(uint _arg) public returns (uint) {
return x(_arg);
}
}
@@ -9754,13 +9755,13 @@ BOOST_AUTO_TEST_CASE(store_internal_unused_function_in_constructor)
char const* sourceCode = R"(
contract C {
function () internal returns (uint) x;
- constructor() {
+ constructor() public {
x = unused;
}
function unused() internal returns (uint) {
return 7;
}
- function t() returns (uint) {
+ function t() public returns (uint) {
return x();
}
}
@@ -9776,10 +9777,10 @@ BOOST_AUTO_TEST_CASE(store_internal_unused_library_function_in_constructor)
library L { function x() internal returns (uint) { return 7; } }
contract C {
function () internal returns (uint) x;
- constructor() {
+ constructor() public {
x = L.x;
}
- function t() returns (uint) {
+ function t() public returns (uint) {
return x();
}
}
@@ -9794,13 +9795,13 @@ BOOST_AUTO_TEST_CASE(same_function_in_construction_and_runtime)
char const* sourceCode = R"(
contract C {
uint public initial;
- constructor() {
+ constructor() public {
initial = double(2);
}
- function double(uint _arg) returns (uint _ret) {
+ function double(uint _arg) public returns (uint _ret) {
_ret = _arg * 2;
}
- function runtime(uint _arg) returns (uint) {
+ function runtime(uint _arg) public returns (uint) {
return double(_arg);
}
}
@@ -9816,13 +9817,13 @@ BOOST_AUTO_TEST_CASE(same_function_in_construction_and_runtime_equality_check)
char const* sourceCode = R"(
contract C {
function (uint) internal returns (uint) x;
- constructor() {
+ constructor() public {
x = double;
}
- function test() returns (bool) {
+ function test() public returns (bool) {
return x == double;
}
- function double(uint _arg) returns (uint _ret) {
+ function double(uint _arg) public returns (uint _ret) {
_ret = _arg * 2;
}
}
@@ -9836,7 +9837,7 @@ BOOST_AUTO_TEST_CASE(function_type_library_internal)
{
char const* sourceCode = R"(
library Utils {
- function reduce(uint[] memory array, function(uint, uint) returns (uint) f, uint init) internal returns (uint) {
+ function reduce(uint[] memory array, function(uint, uint) internal returns (uint) f, uint init) internal returns (uint) {
for (uint i = 0; i < array.length; i++) {
init = f(array[i], init);
}
@@ -9847,7 +9848,7 @@ BOOST_AUTO_TEST_CASE(function_type_library_internal)
}
}
contract C {
- function f(uint[] x) returns (uint) {
+ function f(uint[] x) public returns (uint) {
return Utils.reduce(x, Utils.sum, 0);
}
}
@@ -9862,21 +9863,21 @@ BOOST_AUTO_TEST_CASE(call_function_returning_function)
{
char const* sourceCode = R"(
contract test {
- function f0() returns (uint) {
+ function f0() public returns (uint) {
return 2;
}
- function f1() internal returns (function() returns (uint)) {
+ function f1() internal returns (function() internal returns (uint)) {
return f0;
}
- function f2() internal returns (function() returns (function () returns (uint))) {
+ function f2() internal returns (function() internal returns (function () internal returns (uint))) {
return f1;
}
- function f3() internal returns (function() returns (function () returns (function () returns (uint))))
+ function f3() internal returns (function() internal returns (function () internal returns (function () internal returns (uint))))
{
return f2;
}
- function f() returns (uint) {
- function() returns(function() returns(function() returns(function() returns(uint)))) x;
+ function f() public returns (uint) {
+ function() internal returns(function() internal returns(function() internal returns(function() internal returns(uint)))) x;
x = f3;
return x()()()();
}
@@ -9907,11 +9908,11 @@ BOOST_AUTO_TEST_CASE(mapping_of_functions)
success = true;
}
- constructor() {
+ constructor() public {
stages[msg.sender] = stage0;
}
- function f() returns (uint) {
+ function f() public returns (uint) {
stages[msg.sender]();
return 7;
}
@@ -9932,35 +9933,35 @@ BOOST_AUTO_TEST_CASE(packed_functions)
char const* sourceCode = R"(
contract C {
// these should take the same slot
- function() returns (uint) a;
+ function() internal returns (uint) a;
function() external returns (uint) b;
function() external returns (uint) c;
- function() returns (uint) d;
+ function() internal returns (uint) d;
uint8 public x;
- function set() {
+ function set() public {
x = 2;
d = g;
c = this.h;
b = this.h;
a = g;
}
- function t1() returns (uint) {
+ function t1() public returns (uint) {
return a();
}
- function t2() returns (uint) {
+ function t2() public returns (uint) {
return b();
}
- function t3() returns (uint) {
+ function t3() public returns (uint) {
return a();
}
- function t4() returns (uint) {
+ function t4() public returns (uint) {
return b();
}
- function g() returns (uint) {
+ function g() public returns (uint) {
return 7;
}
- function h() returns (uint) {
+ function h() public returns (uint) {
return 8;
}
}
@@ -9979,12 +9980,12 @@ BOOST_AUTO_TEST_CASE(function_memory_array)
{
char const* sourceCode = R"(
contract C {
- function a(uint x) returns (uint) { return x + 1; }
- function b(uint x) returns (uint) { return x + 2; }
- function c(uint x) returns (uint) { return x + 3; }
- function d(uint x) returns (uint) { return x + 5; }
- function e(uint x) returns (uint) { return x + 8; }
- function test(uint x, uint i) returns (uint) {
+ function a(uint x) public returns (uint) { return x + 1; }
+ function b(uint x) public returns (uint) { return x + 2; }
+ function c(uint x) public returns (uint) { return x + 3; }
+ function d(uint x) public returns (uint) { return x + 5; }
+ function e(uint x) public returns (uint) { return x + 8; }
+ function test(uint x, uint i) public returns (uint) {
function(uint) internal returns (uint)[] memory arr =
new function(uint) internal returns (uint)[](10);
arr[0] = a;
@@ -10010,17 +10011,17 @@ BOOST_AUTO_TEST_CASE(function_delete_storage)
{
char const* sourceCode = R"(
contract C {
- function a() returns (uint) { return 7; }
+ function a() public returns (uint) { return 7; }
function() internal returns (uint) y;
- function set() returns (uint) {
+ function set() public returns (uint) {
y = a;
return y();
}
- function d() returns (uint) {
+ function d() public returns (uint) {
delete y;
return 1;
}
- function ca() returns (uint) {
+ function ca() public returns (uint) {
return y();
}
}
@@ -10037,9 +10038,9 @@ BOOST_AUTO_TEST_CASE(function_delete_stack)
{
char const* sourceCode = R"(
contract C {
- function a() returns (uint) { return 7; }
- function test() returns (uint) {
- var y = a;
+ function a() public returns (uint) { return 7; }
+ function test() public returns (uint) {
+ function () returns (uint) y = a;
delete y;
y();
}
@@ -10056,13 +10057,13 @@ BOOST_AUTO_TEST_CASE(copy_function_storage_array)
contract C {
function() internal returns (uint)[] x;
function() internal returns (uint)[] y;
- function test() returns (uint) {
+ function test() public returns (uint) {
x.length = 10;
x[9] = a;
y = x;
return y[9]();
}
- function a() returns (uint) {
+ function a() public returns (uint) {
return 7;
}
}
@@ -10077,7 +10078,7 @@ BOOST_AUTO_TEST_CASE(function_array_cross_calls)
char const* sourceCode = R"(
contract D {
function f(function() external returns (function() external returns (uint))[] x)
- returns (function() external returns (uint)[3] r)
+ public returns (function() external returns (uint)[3] r)
{
r[0] = x[0]();
r[1] = x[1]();
@@ -10085,23 +10086,23 @@ BOOST_AUTO_TEST_CASE(function_array_cross_calls)
}
}
contract C {
- function test() returns (uint, uint, uint) {
+ function test() public returns (uint, uint, uint) {
function() external returns (function() external returns (uint))[] memory x =
new function() external returns (function() external returns (uint))[](10);
for (uint i = 0; i < x.length; i ++)
x[i] = this.h;
x[0] = this.htwo;
- var y = (new D()).f(x);
+ function() external returns (uint)[3] memory y = (new D()).f(x);
return (y[0](), y[1](), y[2]());
}
- function e() returns (uint) { return 5; }
- function f() returns (uint) { return 6; }
- function g() returns (uint) { return 7; }
+ function e() public returns (uint) { return 5; }
+ function f() public returns (uint) { return 6; }
+ function g() public returns (uint) { return 7; }
uint counter;
- function h() returns (function() external returns (uint)) {
+ function h() public returns (function() external returns (uint)) {
return counter++ == 0 ? this.f : this.g;
}
- function htwo() returns (function() external returns (uint)) {
+ function htwo() public returns (function() external returns (uint)) {
return this.e;
}
}
@@ -10115,10 +10116,10 @@ BOOST_AUTO_TEST_CASE(external_function_to_address)
{
char const* sourceCode = R"(
contract C {
- function f() returns (bool) {
+ function f() public returns (bool) {
return address(this.f) == address(this);
}
- function g(function() external cb) returns (address) {
+ function g(function() external cb) public returns (address) {
return address(cb);
}
}
@@ -10136,12 +10137,12 @@ BOOST_AUTO_TEST_CASE(copy_internal_function_array_to_storage)
contract C {
function() internal returns (uint)[20] x;
int mutex;
- function one() returns (uint) {
+ function one() public returns (uint) {
function() internal returns (uint)[20] xmem;
x = xmem;
return 3;
}
- function two() returns (uint) {
+ function two() public returns (uint) {
if (mutex > 0)
return 7;
mutex = 1;
@@ -10205,7 +10206,7 @@ BOOST_AUTO_TEST_CASE(shift_left)
{
char const* sourceCode = R"(
contract C {
- function f(uint a, uint b) returns (uint) {
+ function f(uint a, uint b) public returns (uint) {
return a << b;
}
}
@@ -10223,7 +10224,7 @@ BOOST_AUTO_TEST_CASE(shift_left_uint32)
{
char const* sourceCode = R"(
contract C {
- function f(uint32 a, uint32 b) returns (uint) {
+ function f(uint32 a, uint32 b) public returns (uint) {
return a << b;
}
}
@@ -10240,7 +10241,7 @@ BOOST_AUTO_TEST_CASE(shift_left_uint8)
{
char const* sourceCode = R"(
contract C {
- function f(uint8 a, uint8 b) returns (uint) {
+ function f(uint8 a, uint8 b) public returns (uint) {
return a << b;
}
}
@@ -10255,7 +10256,7 @@ BOOST_AUTO_TEST_CASE(shift_left_larger_type)
// This basically tests proper cleanup and conversion. It should not convert x to int8.
char const* sourceCode = R"(
contract C {
- function f() returns (int8) {
+ function f() public returns (int8) {
uint8 x = 254;
int8 y = 1;
return y << x;
@@ -10270,7 +10271,7 @@ BOOST_AUTO_TEST_CASE(shift_left_assignment)
{
char const* sourceCode = R"(
contract C {
- function f(uint a, uint b) returns (uint) {
+ function f(uint a, uint b) public returns (uint) {
a <<= b;
return a;
}
@@ -10289,7 +10290,7 @@ BOOST_AUTO_TEST_CASE(shift_left_assignment_different_type)
{
char const* sourceCode = R"(
contract C {
- function f(uint a, uint8 b) returns (uint) {
+ function f(uint a, uint8 b) public returns (uint) {
a <<= b;
return a;
}
@@ -10307,7 +10308,7 @@ BOOST_AUTO_TEST_CASE(shift_right)
{
char const* sourceCode = R"(
contract C {
- function f(uint a, uint b) returns (uint) {
+ function f(uint a, uint b) public returns (uint) {
return a >> b;
}
}
@@ -10324,7 +10325,7 @@ BOOST_AUTO_TEST_CASE(shift_right_garbled)
{
char const* sourceCode = R"(
contract C {
- function f(uint8 a, uint8 b) returns (uint) {
+ function f(uint8 a, uint8 b) public returns (uint) {
assembly {
a := 0xffffffff
}
@@ -10342,14 +10343,14 @@ BOOST_AUTO_TEST_CASE(shift_right_garbled_signed)
{
char const* sourceCode = R"(
contract C {
- function f(int8 a, uint8 b) returns (int) {
+ function f(int8 a, uint8 b) public returns (int) {
assembly {
a := 0xfffffff0
}
// Higher bits should be signextended before the shift
return a >> b;
}
- function g(int8 a, uint8 b) returns (int) {
+ function g(int8 a, uint8 b) public returns (int) {
assembly {
a := 0xf0
}
@@ -10375,7 +10376,7 @@ BOOST_AUTO_TEST_CASE(shift_right_uint32)
{
char const* sourceCode = R"(
contract C {
- function f(uint32 a, uint32 b) returns (uint) {
+ function f(uint32 a, uint32 b) public returns (uint) {
return a >> b;
}
}
@@ -10391,7 +10392,7 @@ BOOST_AUTO_TEST_CASE(shift_right_uint8)
{
char const* sourceCode = R"(
contract C {
- function f(uint8 a, uint8 b) returns (uint) {
+ function f(uint8 a, uint8 b) public returns (uint) {
return a >> b;
}
}
@@ -10405,7 +10406,7 @@ BOOST_AUTO_TEST_CASE(shift_right_assignment)
{
char const* sourceCode = R"(
contract C {
- function f(uint a, uint b) returns (uint) {
+ function f(uint a, uint b) public returns (uint) {
a >>= b;
return a;
}
@@ -10422,7 +10423,7 @@ BOOST_AUTO_TEST_CASE(shift_right_assignment_signed)
{
char const* sourceCode = R"(
contract C {
- function f(int a, int b) returns (int) {
+ function f(int a, int b) public returns (int) {
a >>= b;
return a;
}
@@ -10439,7 +10440,7 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue)
{
char const* sourceCode = R"(
contract C {
- function f(int a, int b) returns (int) {
+ function f(int a, int b) public returns (int) {
return a >> b;
}
}
@@ -10463,40 +10464,40 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_literal)
{
char const* sourceCode = R"(
contract C {
- function f1() pure returns (bool) {
+ function f1() public pure returns (bool) {
return (-4266 >> 0) == -4266;
}
- function f2() pure returns (bool) {
+ function f2() public pure returns (bool) {
return (-4266 >> 1) == -2133;
}
- function f3() pure returns (bool) {
+ function f3() public pure returns (bool) {
return (-4266 >> 4) == -267;
}
- function f4() pure returns (bool) {
+ function f4() public pure returns (bool) {
return (-4266 >> 8) == -17;
}
- function f5() pure returns (bool) {
+ function f5() public pure returns (bool) {
return (-4266 >> 16) == -1;
}
- function f6() pure returns (bool) {
+ function f6() public pure returns (bool) {
return (-4266 >> 17) == -1;
}
- function g1() pure returns (bool) {
+ function g1() public pure returns (bool) {
return (-4267 >> 0) == -4267;
}
- function g2() pure returns (bool) {
+ function g2() public pure returns (bool) {
return (-4267 >> 1) == -2134;
}
- function g3() pure returns (bool) {
+ function g3() public pure returns (bool) {
return (-4267 >> 4) == -267;
}
- function g4() pure returns (bool) {
+ function g4() public pure returns (bool) {
return (-4267 >> 8) == -17;
}
- function g5() pure returns (bool) {
+ function g5() public pure returns (bool) {
return (-4267 >> 16) == -1;
}
- function g6() pure returns (bool) {
+ function g6() public pure returns (bool) {
return (-4267 >> 17) == -1;
}
}
@@ -10520,7 +10521,7 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_int8)
{
char const* sourceCode = R"(
contract C {
- function f(int8 a, int8 b) returns (int) {
+ function f(int8 a, int8 b) public returns (int) {
return a >> b;
}
}
@@ -10544,7 +10545,7 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int8)
{
char const* sourceCode = R"(
contract C {
- function f(int8 a, int8 b) returns (int8) {
+ function f(int8 a, int8 b) public returns (int8) {
return a >> b;
}
}
@@ -10561,7 +10562,7 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int16)
{
char const* sourceCode = R"(
contract C {
- function f(int16 a, int16 b) returns (int16) {
+ function f(int16 a, int16 b) public returns (int16) {
return a >> b;
}
}
@@ -10578,7 +10579,7 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int32)
{
char const* sourceCode = R"(
contract C {
- function f(int32 a, int32 b) returns (int32) {
+ function f(int32 a, int32 b) public returns (int32) {
return a >> b;
}
}
@@ -10596,7 +10597,7 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_int16)
{
char const* sourceCode = R"(
contract C {
- function f(int16 a, int16 b) returns (int) {
+ function f(int16 a, int16 b) public returns (int) {
return a >> b;
}
}
@@ -10620,7 +10621,7 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_int32)
{
char const* sourceCode = R"(
contract C {
- function f(int32 a, int32 b) returns (int) {
+ function f(int32 a, int32 b) public returns (int) {
return a >> b;
}
}
@@ -10644,7 +10645,7 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_assignment)
{
char const* sourceCode = R"(
contract C {
- function f(int a, int b) returns (int) {
+ function f(int a, int b) public returns (int) {
a >>= b;
return a;
}
@@ -10669,10 +10670,10 @@ BOOST_AUTO_TEST_CASE(shift_negative_rvalue)
{
char const* sourceCode = R"(
contract C {
- function f(int a, int b) returns (int) {
+ function f(int a, int b) public returns (int) {
return a << b;
}
- function g(int a, int b) returns (int) {
+ function g(int a, int b) public returns (int) {
return a >> b;
}
}
@@ -10686,11 +10687,11 @@ BOOST_AUTO_TEST_CASE(shift_negative_rvalue_assignment)
{
char const* sourceCode = R"(
contract C {
- function f(int a, int b) returns (int) {
+ function f(int a, int b) public returns (int) {
a <<= b;
return a;
}
- function g(int a, int b) returns (int) {
+ function g(int a, int b) public returns (int) {
a >>= b;
return a;
}
@@ -10705,7 +10706,7 @@ BOOST_AUTO_TEST_CASE(shift_constant_left_assignment)
{
char const* sourceCode = R"(
contract C {
- function f() returns (uint a) {
+ function f() public returns (uint a) {
a = 0x42;
a <<= 8;
}
@@ -10719,7 +10720,7 @@ BOOST_AUTO_TEST_CASE(shift_constant_right_assignment)
{
char const* sourceCode = R"(
contract C {
- function f() returns (uint a) {
+ function f() public returns (uint a) {
a = 0x4200;
a >>= 8;
}
@@ -10733,7 +10734,7 @@ BOOST_AUTO_TEST_CASE(shift_cleanup)
{
char const* sourceCode = R"(
contract C {
- function f() returns (uint16 x) {
+ function f() public returns (uint16 x) {
x = 0xffff;
x += 32;
x <<= 8;
@@ -10749,7 +10750,7 @@ BOOST_AUTO_TEST_CASE(shift_cleanup_garbled)
{
char const* sourceCode = R"(
contract C {
- function f() returns (uint8 x) {
+ function f() public returns (uint8 x) {
assembly {
x := 0xffff
}
@@ -10765,10 +10766,10 @@ BOOST_AUTO_TEST_CASE(shift_overflow)
{
char const* sourceCode = R"(
contract C {
- function leftU(uint8 x, uint8 y) returns (uint8) {
+ function leftU(uint8 x, uint8 y) public returns (uint8) {
return x << y;
}
- function leftS(int8 x, int8 y) returns (int8) {
+ function leftS(int8 x, int8 y) public returns (int8) {
return x << y;
}
}
@@ -10787,10 +10788,10 @@ BOOST_AUTO_TEST_CASE(shift_bytes)
{
char const* sourceCode = R"(
contract C {
- function left(bytes20 x, uint8 y) returns (bytes20) {
+ function left(bytes20 x, uint8 y) public returns (bytes20) {
return x << y;
}
- function right(bytes20 x, uint8 y) returns (bytes20) {
+ function right(bytes20 x, uint8 y) public returns (bytes20) {
return x >> y;
}
}
@@ -10804,12 +10805,12 @@ BOOST_AUTO_TEST_CASE(shift_bytes_cleanup)
{
char const* sourceCode = R"(
contract C {
- function left(uint8 y) returns (bytes20) {
+ function left(uint8 y) public returns (bytes20) {
bytes20 x;
assembly { x := "12345678901234567890abcde" }
return x << y;
}
- function right(uint8 y) returns (bytes20) {
+ function right(uint8 y) public returns (bytes20) {
bytes20 x;
assembly { x := "12345678901234567890abcde" }
return x >> y;
@@ -10825,7 +10826,7 @@ BOOST_AUTO_TEST_CASE(cleanup_in_compound_assign)
{
char const* sourceCode = R"(
contract C {
- function test() returns (uint, uint) {
+ function test() public returns (uint, uint) {
uint32 a = 0xffffffff;
uint16 x = uint16(a);
uint16 y = x;
@@ -10852,7 +10853,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_in_modifiers)
throw;
_;
}
- function f() m returns (bool) {
+ function f() m public returns (bool) {
return true;
}
}
@@ -10868,7 +10869,7 @@ BOOST_AUTO_TEST_CASE(packed_storage_overflow)
uint16 x = 0x1234;
uint16 a = 0xffff;
uint16 b;
- function f() returns (uint, uint, uint, uint) {
+ function f() public returns (uint, uint, uint, uint) {
a++;
uint c = b;
delete b;
@@ -10900,18 +10901,18 @@ BOOST_AUTO_TEST_CASE(include_creation_bytecode_only_once)
contract D {
bytes a = hex"1237651237125387136581271652831736512837126583171583712358126123765123712538713658127165283173651283712658317158371235812612376512371253871365812716528317365128371265831715837123581261237651237125387136581271652831736512837126583171583712358126";
bytes b = hex"1237651237125327136581271252831736512837126583171383712358126123765125712538713658127165253173651283712658357158371235812612376512371a5387136581271652a317365128371265a317158371235812612a765123712538a13658127165a83173651283712a58317158371235a126";
- constructor(uint) {}
+ constructor(uint) public {}
}
contract Double {
- function f() {
+ function f() public {
new D(2);
}
- function g() {
+ function g() public {
new D(3);
}
}
contract Single {
- function f() {
+ function f() public {
new D(2);
}
}
@@ -10931,7 +10932,7 @@ BOOST_AUTO_TEST_CASE(recursive_structs)
S[] x;
}
S sstorage;
- function f() returns (uint) {
+ function f() public returns (uint) {
S memory s;
s.x = new S[](10);
delete s;
@@ -10949,7 +10950,7 @@ BOOST_AUTO_TEST_CASE(invalid_instruction)
{
char const* sourceCode = R"(
contract C {
- function f() {
+ function f() public {
assembly {
invalid
}
@@ -10964,14 +10965,14 @@ BOOST_AUTO_TEST_CASE(assert_require)
{
char const* sourceCode = R"(
contract C {
- function f() {
+ function f() public {
assert(false);
}
- function g(bool val) returns (bool) {
+ function g(bool val) public returns (bool) {
assert(val == true);
return true;
}
- function h(bool val) returns (bool) {
+ function h(bool val) public returns (bool) {
require(val);
return true;
}
@@ -10990,11 +10991,11 @@ BOOST_AUTO_TEST_CASE(revert)
char const* sourceCode = R"(
contract C {
uint public a = 42;
- function f() {
+ function f() public {
a = 1;
revert();
}
- function g() {
+ function g() public {
a = 1;
assembly {
revert(0, 0)
@@ -11089,7 +11090,7 @@ BOOST_AUTO_TEST_CASE(require_with_message)
bool flagCopy = flag;
require(flagCopy == false, internalFun());
}
- function internalFun() returns (string) {
+ function internalFun() public returns (string) {
flag = true;
return "only on second run";
}
@@ -11224,13 +11225,13 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages_through_create)
{
char const* sourceCode = R"(
contract E {
- constructor() {
+ constructor() public {
revert("message");
}
}
contract D {
function f() public {
- var x = new E();
+ E x = new E();
}
}
contract C {
@@ -11288,7 +11289,7 @@ BOOST_AUTO_TEST_CASE(literal_empty_string)
x = _x;
a = _a;
}
- function g() {
+ function g() public {
this.f("", 2);
}
}
@@ -11305,22 +11306,22 @@ BOOST_AUTO_TEST_CASE(scientific_notation)
{
char const* sourceCode = R"(
contract C {
- function f() returns (uint) {
+ function f() public returns (uint) {
return 2e10 wei;
}
- function g() returns (uint) {
+ function g() public returns (uint) {
return 200e-2 wei;
}
- function h() returns (uint) {
+ function h() public returns (uint) {
return 2.5e1;
}
- function i() returns (int) {
+ function i() public returns (int) {
return -2e10;
}
- function j() returns (int) {
+ function j() public returns (int) {
return -200e-2;
}
- function k() returns (int) {
+ function k() public returns (int) {
return -2.5e1;
}
}
@@ -11339,16 +11340,16 @@ BOOST_AUTO_TEST_CASE(interface_contract)
char const* sourceCode = R"(
interface I {
event A();
- function f() returns (bool);
+ function f() public returns (bool);
function() external payable;
}
contract A is I {
- function f() returns (bool) {
+ function f() public returns (bool) {
return g();
}
- function g() returns (bool) {
+ function g() public returns (bool) {
return true;
}
@@ -11357,7 +11358,7 @@ BOOST_AUTO_TEST_CASE(interface_contract)
}
contract C {
- function f(address _interfaceAddress) returns (bool) {
+ function f(address _interfaceAddress) public returns (bool) {
I i = I(_interfaceAddress);
return i.f();
}
@@ -11373,12 +11374,12 @@ BOOST_AUTO_TEST_CASE(keccak256_assembly)
{
char const* sourceCode = R"(
contract C {
- function f() pure returns (bytes32 ret) {
+ function f() public pure returns (bytes32 ret) {
assembly {
ret := keccak256(0, 0)
}
}
- function g() pure returns (bytes32 ret) {
+ function g() public pure returns (bytes32 ret) {
assembly {
0
0
@@ -11405,10 +11406,10 @@ BOOST_AUTO_TEST_CASE(multi_modifiers)
x++;
_;
}
- function f1() m1() {
+ function f1() m1() public {
x += 7;
}
- function f2() m1() {
+ function f2() m1() public {
x += 3;
}
}
@@ -11424,7 +11425,7 @@ BOOST_AUTO_TEST_CASE(inlineasm_empty_let)
{
char const* sourceCode = R"(
contract C {
- function f() pure returns (uint a, uint b) {
+ function f() public pure returns (uint a, uint b) {
assembly {
let x
let y, z
@@ -11497,19 +11498,18 @@ BOOST_AUTO_TEST_CASE(function_types_sig)
char const* sourceCode = R"(
contract C {
uint public x;
- function f() pure returns (bytes4) {
+ function f() public pure returns (bytes4) {
return this.f.selector;
}
- function g() returns (bytes4) {
+ function g() public returns (bytes4) {
function () pure external returns (bytes4) fun = this.f;
return fun.selector;
}
- function h() returns (bytes4) {
+ function h() public returns (bytes4) {
function () pure external returns (bytes4) fun = this.f;
- var funvar = fun;
- return funvar.selector;
+ return fun.selector;
}
- function i() pure returns (bytes4) {
+ function i() public pure returns (bytes4) {
return this.x.selector;
}
}
@@ -11528,13 +11528,13 @@ BOOST_AUTO_TEST_CASE(constant_string)
bytes constant a = "\x03\x01\x02";
bytes constant b = hex"030102";
string constant c = "hello";
- function f() returns (bytes) {
+ function f() public returns (bytes) {
return a;
}
- function g() returns (bytes) {
+ function g() public returns (bytes) {
return b;
}
- function h() returns (bytes) {
+ function h() public returns (bytes) {
return bytes(c);
}
}
@@ -11549,18 +11549,18 @@ BOOST_AUTO_TEST_CASE(address_overload_resolution)
{
char const* sourceCode = R"(
contract C {
- function balance() returns (uint) {
+ function balance() public returns (uint) {
return 1;
}
- function transfer(uint amount) returns (uint) {
+ function transfer(uint amount) public returns (uint) {
return amount;
}
}
contract D {
- function f() returns (uint) {
+ function f() public returns (uint) {
return (new C()).balance();
}
- function g() returns (uint) {
+ function g() public returns (uint) {
return (new C()).transfer(5);
}
}
@@ -11734,22 +11734,22 @@ BOOST_AUTO_TEST_CASE(snark)
Pairing.G1Point K;
Pairing.G1Point H;
}
- function f() returns (bool) {
+ function f() public returns (bool) {
Pairing.G1Point memory p1;
Pairing.G1Point memory p2;
p1.X = 1; p1.Y = 2;
p2.X = 1; p2.Y = 2;
- var explict_sum = Pairing.add(p1, p2);
- var scalar_prod = Pairing.mul(p1, 2);
+ Pairing.G1Point memory explict_sum = Pairing.add(p1, p2);
+ Pairing.G1Point memory scalar_prod = Pairing.mul(p1, 2);
return (explict_sum.X == scalar_prod.X &&
explict_sum.Y == scalar_prod.Y);
}
- function g() returns (bool) {
+ function g() public returns (bool) {
Pairing.G1Point memory x = Pairing.add(Pairing.P1(), Pairing.negate(Pairing.P1()));
// should be zero
return (x.X == 0 && x.Y == 0);
}
- function testMul() returns (bool) {
+ function testMul() public returns (bool) {
Pairing.G1Point memory p;
// @TODO The points here are reported to be not well-formed
p.X = 14125296762497065001182820090155008161146766663259912659363835465243039841726;
@@ -11759,7 +11759,7 @@ BOOST_AUTO_TEST_CASE(snark)
p.X == 18256332256630856740336504687838346961237861778318632856900758565550522381207 &&
p.Y == 6976682127058094634733239494758371323697222088503263230319702770853579280803;
}
- function pair() returns (bool) {
+ function pair() public returns (bool) {
Pairing.G2Point memory fiveTimesP2 = Pairing.G2Point(
[4540444681147253467785307942530223364530218361853237193970751657229138047649, 20954117799226682825035885491234530437475518021362091509513177301640194298072],
[11631839690097995216017572651900167465857396346217730511548857041925508482915, 21508930868448350162258892668132814424284302804699005394342512102884055673846]
@@ -11829,7 +11829,7 @@ BOOST_AUTO_TEST_CASE(snark)
return 0;
}
event Verified(string);
- function verifyTx() returns (bool) {
+ function verifyTx() public returns (bool) {
uint[] memory input = new uint[](9);
Proof memory proof;
proof.A = Pairing.G1Point(12873740738727497448187997291915224677121726020054032516825496230827252793177, 21804419174137094775122804775419507726154084057848719988004616848382402162497);
@@ -11875,17 +11875,17 @@ BOOST_AUTO_TEST_CASE(abi_encode)
{
char const* sourceCode = R"(
contract C {
- function f0() returns (bytes) {
+ function f0() public returns (bytes) {
return abi.encode();
}
- function f1() returns (bytes) {
+ function f1() public returns (bytes) {
return abi.encode(1, 2);
}
- function f2() returns (bytes) {
+ function f2() public returns (bytes) {
string memory x = "abc";
return abi.encode(1, x, 2);
}
- function f3() returns (bytes r) {
+ function f3() public returns (bytes r) {
// test that memory is properly allocated
string memory x = "abc";
r = abi.encode(1, x, 2);
@@ -11894,7 +11894,7 @@ BOOST_AUTO_TEST_CASE(abi_encode)
y[0] = "e";
require(y[0] == "e");
}
- function f4() returns (bytes) {
+ function f4() public returns (bytes) {
bytes4 x = "abcd";
return abi.encode(bytes2(x));
}
@@ -12243,7 +12243,7 @@ BOOST_AUTO_TEST_CASE(swap_peephole_optimisation)
{
char const* sourceCode = R"(
contract C {
- function lt(uint a, uint b) returns (bool c) {
+ function lt(uint a, uint b) public returns (bool c) {
assembly {
a
b
@@ -12252,7 +12252,7 @@ BOOST_AUTO_TEST_CASE(swap_peephole_optimisation)
=: c
}
}
- function add(uint a, uint b) returns (uint c) {
+ function add(uint a, uint b) public returns (uint c) {
assembly {
a
b
@@ -12261,7 +12261,7 @@ BOOST_AUTO_TEST_CASE(swap_peephole_optimisation)
=: c
}
}
- function div(uint a, uint b) returns (uint c) {
+ function div(uint a, uint b) public returns (uint c) {
assembly {
a
b
@@ -12289,7 +12289,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople)
return;
char const* sourceCode = R"(
contract C {
- function shl(uint a, uint b) returns (uint c) {
+ function shl(uint a, uint b) public returns (uint c) {
assembly {
a
b
@@ -12297,7 +12297,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople)
=: c
}
}
- function shr(uint a, uint b) returns (uint c) {
+ function shr(uint a, uint b) public returns (uint c) {
assembly {
a
b
@@ -12305,7 +12305,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople)
=: c
}
}
- function sar(uint a, uint b) returns (uint c) {
+ function sar(uint a, uint b) public returns (uint c) {
assembly {
a
b
@@ -12335,7 +12335,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
return;
char const* sourceCode = R"(
contract C {
- function shl_1() returns (bool) {
+ function shl_1() public returns (bool) {
uint c;
assembly {
1
@@ -12346,7 +12346,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
assert(c == 4);
return true;
}
- function shl_2() returns (bool) {
+ function shl_2() public returns (bool) {
uint c;
assembly {
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
@@ -12357,7 +12357,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
assert(c == 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe);
return true;
}
- function shl_3() returns (bool) {
+ function shl_3() public returns (bool) {
uint c;
assembly {
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
@@ -12368,7 +12368,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
assert(c == 0);
return true;
}
- function shr_1() returns (bool) {
+ function shr_1() public returns (bool) {
uint c;
assembly {
3
@@ -12379,7 +12379,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
assert(c == 1);
return true;
}
- function shr_2() returns (bool) {
+ function shr_2() public returns (bool) {
uint c;
assembly {
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
@@ -12390,7 +12390,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
assert(c == 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
return true;
}
- function shr_3() returns (bool) {
+ function shr_3() public returns (bool) {
uint c;
assembly {
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp
index 5d5fb218..949045ea 100644
--- a/test/libsolidity/SolidityExpressionCompiler.cpp
+++ b/test/libsolidity/SolidityExpressionCompiler.cpp
@@ -175,7 +175,7 @@ BOOST_AUTO_TEST_CASE(literal_true)
{
char const* sourceCode = R"(
contract test {
- function f() { var x = true; }
+ function f() public { bool x = true; }
}
)";
bytes code = compileFirstExpression(sourceCode);
@@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE(literal_false)
{
char const* sourceCode = R"(
contract test {
- function f() { var x = false; }
+ function f() { bool x = false; }
}
)";
bytes code = compileFirstExpression(sourceCode);
@@ -201,7 +201,7 @@ BOOST_AUTO_TEST_CASE(int_literal)
{
char const* sourceCode = R"(
contract test {
- function f() { var x = 0x12345678901234567890; }
+ function f() { uint x = 0x12345678901234567890; }
}
)";
bytes code = compileFirstExpression(sourceCode);
@@ -216,7 +216,7 @@ BOOST_AUTO_TEST_CASE(int_with_wei_ether_subdenomination)
char const* sourceCode = R"(
contract test {
constructor() {
- var x = 1 wei;
+ uint x = 1 wei;
}
}
)";
@@ -230,8 +230,8 @@ BOOST_AUTO_TEST_CASE(int_with_szabo_ether_subdenomination)
{
char const* sourceCode = R"(
contract test {
- constructor() {
- var x = 1 szabo;
+ function test () {
+ uint x = 1 szabo;
}
}
)";
@@ -247,7 +247,7 @@ BOOST_AUTO_TEST_CASE(int_with_finney_ether_subdenomination)
contract test {
constructor()
{
- var x = 1 finney;
+ uint x = 1 finney;
}
}
)";
@@ -262,7 +262,7 @@ BOOST_AUTO_TEST_CASE(int_with_ether_ether_subdenomination)
char const* sourceCode = R"(
contract test {
constructor() {
- var x = 1 ether;
+ uint x = 1 ether;
}
}
)";
@@ -276,7 +276,7 @@ BOOST_AUTO_TEST_CASE(comparison)
{
char const* sourceCode = R"(
contract test {
- function f() { var x = (0x10aa < 0x11aa) != true; }
+ function f() { bool x = (0x10aa < 0x11aa) != true; }
}
)";
bytes code = compileFirstExpression(sourceCode);
@@ -294,7 +294,7 @@ BOOST_AUTO_TEST_CASE(short_circuiting)
{
char const* sourceCode = R"(
contract test {
- function f() { var x = true != (4 <= 8 + 10 || 9 != 2); }
+ function f() { bool x = true != (4 <= 8 + 10 || 9 != 2); }
}
)";
bytes code = compileFirstExpression(sourceCode);
@@ -384,7 +384,7 @@ BOOST_AUTO_TEST_CASE(unary_inc_dec)
{
char const* sourceCode = R"(
contract test {
- function f(uint a) returns (uint x) { x = --a ^ (a-- ^ (++a ^ a++)); }
+ function f(uint a) public returns (uint x) { x = --a ^ (a-- ^ (++a ^ a++)); }
}
)";
bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "a"}, {"test", "f", "x"}});
@@ -490,7 +490,7 @@ BOOST_AUTO_TEST_CASE(intermediately_overflowing_literals)
// have been applied
char const* sourceCode = R"(
contract test {
- function f() { var x = (0x00ffffffffffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffff01) & 0xbf; }
+ function f() { uint8 x = (0x00ffffffffffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffff01) & 0xbf; }
}
)";
bytes code = compileFirstExpression(sourceCode);
@@ -509,9 +509,9 @@ BOOST_AUTO_TEST_CASE(blockhash)
}
)";
- auto blockhashFun = make_shared<FunctionType>(strings{"uint256"}, strings{"bytes32"},
+ auto blockhashFun = make_shared<FunctionType>(strings{"uint256"}, strings{"bytes32"},
FunctionType::Kind::BlockHash, false, StateMutability::View);
-
+
bytes code = compileFirstExpression(sourceCode, {}, {}, {make_shared<MagicVariableDeclaration>("blockhash", blockhashFun)});
bytes expectation({byte(Instruction::PUSH1), 0x03,
@@ -523,32 +523,17 @@ BOOST_AUTO_TEST_CASE(gas_left)
{
char const* sourceCode = R"(
contract test {
- function f() returns (uint256 val) {
- return msg.gas;
- }
- }
- )";
- bytes code = compileFirstExpression(
- sourceCode, {}, {},
- {make_shared<MagicVariableDeclaration>("msg", make_shared<MagicType>(MagicType::Kind::Message))}
- );
-
- bytes expectation({byte(Instruction::GAS)});
- BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end());
-
- sourceCode = R"(
- contract test {
- function f() returns (uint256 val) {
+ function f() public returns (uint256 val) {
return gasleft();
}
}
)";
- code = compileFirstExpression(
+ bytes code = compileFirstExpression(
sourceCode, {}, {},
{make_shared<MagicVariableDeclaration>("gasleft", make_shared<FunctionType>(strings(), strings{"uint256"}, FunctionType::Kind::GasLeft))}
);
- expectation = bytes({byte(Instruction::GAS)});
+ bytes expectation = bytes({byte(Instruction::GAS)});
BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end());
}
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 153a7afb..e6d93b36 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -63,7 +63,7 @@ BOOST_AUTO_TEST_CASE(abstract_contract)
{
SourceUnit const* sourceUnit = nullptr;
char const* text = R"(
- contract base { function foo(); }
+ contract base { function foo() public; }
contract derived is base { function foo() public {} }
)";
sourceUnit = parseAndAnalyse(text);
@@ -82,7 +82,7 @@ BOOST_AUTO_TEST_CASE(abstract_contract_with_overload)
{
SourceUnit const* sourceUnit = nullptr;
char const* text = R"(
- contract base { function foo(bool); }
+ contract base { function foo(bool) public; }
contract derived is base { function foo(uint) public {} }
)";
sourceUnit = parseAndAnalyse(text);
@@ -99,7 +99,7 @@ BOOST_AUTO_TEST_CASE(implement_abstract_via_constructor)
{
SourceUnit const* sourceUnit = nullptr;
char const* text = R"(
- contract base { function foo(); }
+ contract base { function foo() public; }
contract foo is base { constructor() public {} }
)";
sourceUnit = parseAndAnalyse(text);
@@ -352,16 +352,16 @@ BOOST_AUTO_TEST_CASE(dynamic_return_types_not_possible)
contract C {
function f(uint) public returns (string);
function g() public {
- var x = this.f(2);
+ string memory x = this.f(2);
// we can assign to x but it is not usable.
bytes(x).length;
}
}
)";
if (dev::test::Options::get().evmVersion() == EVMVersion::homestead())
- CHECK_ERROR(sourceCode, TypeError, "Explicit type conversion not allowed from \"inaccessible dynamic type\" to \"bytes storage pointer\".");
+ CHECK_ERROR(sourceCode, TypeError, "Type inaccessible dynamic type is not implicitly convertible to expected type string memory.");
else
- CHECK_WARNING(sourceCode, "Use of the \"var\" keyword is deprecated");
+ CHECK_SUCCESS_NO_WARNINGS(sourceCode);
}
BOOST_AUTO_TEST_CASE(warn_nonpresent_pragma)
diff --git a/test/libsolidity/SolidityNatspecJSON.cpp b/test/libsolidity/SolidityNatspecJSON.cpp
index eeebeb74..98a3bba9 100644
--- a/test/libsolidity/SolidityNatspecJSON.cpp
+++ b/test/libsolidity/SolidityNatspecJSON.cpp
@@ -84,7 +84,7 @@ BOOST_AUTO_TEST_CASE(user_basic_test)
char const* sourceCode = R"(
contract test {
/// @notice Multiplies `a` by 7
- function mul(uint a) returns(uint d) { return a * 7; }
+ function mul(uint a) public returns(uint d) { return a * 7; }
}
)";
@@ -102,7 +102,7 @@ BOOST_AUTO_TEST_CASE(dev_and_user_basic_test)
contract test {
/// @notice Multiplies `a` by 7
/// @dev Multiplies a number by 7
- function mul(uint a) returns(uint d) { return a * 7; }
+ function mul(uint a) public returns (uint d) { return a * 7; }
}
)";
@@ -129,7 +129,7 @@ BOOST_AUTO_TEST_CASE(user_multiline_comment)
contract test {
/// @notice Multiplies `a` by 7
/// and then adds `b`
- function mul_and_add(uint a, uint256 b) returns(uint256 d) {
+ function mul_and_add(uint a, uint256 b) public returns (uint256 d) {
return (a * 7) + b;
}
}
@@ -148,17 +148,17 @@ BOOST_AUTO_TEST_CASE(user_multiple_functions)
char const* sourceCode = R"(
contract test {
/// @notice Multiplies `a` by 7 and then adds `b`
- function mul_and_add(uint a, uint256 b) returns(uint256 d) {
+ function mul_and_add(uint a, uint256 b) public returns (uint256 d) {
return (a * 7) + b;
}
/// @notice Divides `input` by `div`
- function divide(uint input, uint div) returns(uint d) {
+ function divide(uint input, uint div) public returns (uint d) {
return input / div;
}
/// @notice Subtracts 3 from `input`
- function sub(int input) returns(int d) {
+ function sub(int input) public returns (int d) {
return input - 3;
}
}
@@ -189,10 +189,10 @@ BOOST_AUTO_TEST_CASE(dev_and_user_no_doc)
{
char const* sourceCode = R"(
contract test {
- function mul(uint a) returns(uint d) {
+ function mul(uint a) public returns (uint d) {
return a * 7;
}
- function sub(int input) returns(int d) {
+ function sub(int input) public returns (int d) {
return input - 3;
}
}
@@ -213,7 +213,7 @@ BOOST_AUTO_TEST_CASE(dev_desc_after_nl)
/// Multiplies a number by 7 and adds second parameter
/// @param a Documentation for the first parameter
/// @param second Documentation for the second parameter
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
@@ -238,7 +238,7 @@ BOOST_AUTO_TEST_CASE(dev_multiple_params)
/// @dev Multiplies a number by 7 and adds second parameter
/// @param a Documentation for the first parameter
/// @param second Documentation for the second parameter
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
@@ -262,7 +262,7 @@ BOOST_AUTO_TEST_CASE(dev_multiple_params_mixed_whitespace)
" /// @dev Multiplies a number by 7 and adds second parameter\n"
" /// @param a Documentation for the first parameter\n"
" /// @param second Documentation for the second parameter\n"
- " function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
+ " function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }\n"
"}\n";
char const* natspec = "{"
@@ -287,7 +287,7 @@ BOOST_AUTO_TEST_CASE(dev_mutiline_param_description)
/// @param a Documentation for the first parameter starts here.
/// Since it's a really complicated parameter we need 2 lines
/// @param second Documentation for the second parameter
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
@@ -312,18 +312,18 @@ BOOST_AUTO_TEST_CASE(dev_multiple_functions)
/// @dev Multiplies a number by 7 and adds second parameter
/// @param a Documentation for the first parameter
/// @param second Documentation for the second parameter
- function mul(uint a, uint second) returns(uint d) {
+ function mul(uint a, uint second) public returns (uint d) {
return a * 7 + second;
}
/// @dev Divides 2 numbers
/// @param input Documentation for the input parameter
/// @param div Documentation for the div parameter
- function divide(uint input, uint div) returns(uint d) {
+ function divide(uint input, uint div) public returns (uint d) {
return input / div;
}
/// @dev Subtracts 3 from `input`
/// @param input Documentation for the input parameter
- function sub(int input) returns(int d) {
+ function sub(int input) public returns (int d) {
return input - 3;
}
}
@@ -365,7 +365,7 @@ BOOST_AUTO_TEST_CASE(dev_return)
/// Since it's a really complicated parameter we need 2 lines
/// @param second Documentation for the second parameter
/// @return The result of the multiplication
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
@@ -393,7 +393,7 @@ BOOST_AUTO_TEST_CASE(dev_return_desc_after_nl)
/// @param second Documentation for the second parameter
/// @return
/// The result of the multiplication
- function mul(uint a, uint second) returns(uint d) {
+ function mul(uint a, uint second) public returns (uint d) {
return a * 7 + second;
}
}
@@ -425,7 +425,7 @@ BOOST_AUTO_TEST_CASE(dev_multiline_return)
/// @param second Documentation for the second parameter
/// @return The result of the multiplication
/// and cookies with nutella
- function mul(uint a, uint second) returns(uint d) {
+ function mul(uint a, uint second) public returns (uint d) {
return a * 7 + second;
}
}
@@ -458,7 +458,7 @@ BOOST_AUTO_TEST_CASE(dev_multiline_comment)
* @return The result of the multiplication
* and cookies with nutella
*/
- function mul(uint a, uint second) returns(uint d) {
+ function mul(uint a, uint second) public returns (uint d) {
return a * 7 + second;
}
}
@@ -484,7 +484,7 @@ BOOST_AUTO_TEST_CASE(dev_contract_no_doc)
char const* sourceCode = R"(
contract test {
/// @dev Mul function
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
@@ -506,7 +506,7 @@ BOOST_AUTO_TEST_CASE(dev_contract_doc)
/// @title Just a test contract
contract test {
/// @dev Mul function
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
@@ -531,7 +531,7 @@ BOOST_AUTO_TEST_CASE(dev_author_at_function)
contract test {
/// @dev Mul function
/// @author John Doe
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
@@ -554,7 +554,7 @@ BOOST_AUTO_TEST_CASE(natspec_notice_without_tag)
char const* sourceCode = R"(
contract test {
/// I do something awesome
- function mul(uint a) returns(uint d) { return a * 7; }
+ function mul(uint a) public returns (uint d) { return a * 7; }
}
)";
@@ -578,7 +578,7 @@ BOOST_AUTO_TEST_CASE(natspec_multiline_notice_without_tag)
contract test {
/// I do something awesome
/// which requires two lines to explain
- function mul(uint a) returns(uint d) { return a * 7; }
+ function mul(uint a) public returns (uint d) { return a * 7; }
}
)";
@@ -619,7 +619,7 @@ BOOST_AUTO_TEST_CASE(dev_title_at_function_error)
contract test {
/// @dev Mul function
/// @title I really should not be here
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
@@ -633,7 +633,7 @@ BOOST_AUTO_TEST_CASE(dev_documenting_nonexistent_param)
/// @dev Multiplies a number by 7 and adds second parameter
/// @param a Documentation for the first parameter
/// @param not_existing Documentation for the second parameter
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
@@ -647,7 +647,7 @@ BOOST_AUTO_TEST_CASE(dev_documenting_no_paramname)
/// @dev Multiplies a number by 7 and adds second parameter
/// @param a Documentation for the first parameter
/// @param
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
@@ -661,7 +661,7 @@ BOOST_AUTO_TEST_CASE(dev_documenting_no_paramname_end)
/// @dev Multiplies a number by 7 and adds second parameter
/// @param a Documentation for the first parameter
/// @param se
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
@@ -675,7 +675,7 @@ BOOST_AUTO_TEST_CASE(dev_documenting_no_param_description)
/// @dev Multiplies a number by 7 and adds second parameter
/// @param a Documentation for the first parameter
/// @param second
- function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }
+ function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; }
}
)";
diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp
index 805c8602..d375beff 100644
--- a/test/libsolidity/SolidityOptimizer.cpp
+++ b/test/libsolidity/SolidityOptimizer.cpp
@@ -136,7 +136,7 @@ BOOST_AUTO_TEST_CASE(smoke_test)
{
char const* sourceCode = R"(
contract test {
- function f(uint a) returns (uint b) {
+ function f(uint a) public returns (uint b) {
return a;
}
}
@@ -149,7 +149,7 @@ BOOST_AUTO_TEST_CASE(identities)
{
char const* sourceCode = R"(
contract test {
- function f(int a) returns (int b) {
+ function f(int a) public returns (int b) {
return int(0) | (int(1) * (int(0) ^ (0 + a)));
}
}
@@ -163,7 +163,7 @@ BOOST_AUTO_TEST_CASE(unused_expressions)
char const* sourceCode = R"(
contract test {
uint data;
- function f() returns (uint a, uint b) {
+ function f() public returns (uint a, uint b) {
10 + 20;
data;
}
@@ -180,7 +180,7 @@ BOOST_AUTO_TEST_CASE(constant_folding_both_sides)
// literals as late as possible
char const* sourceCode = R"(
contract test {
- function f(uint x) returns (uint y) {
+ function f(uint x) public returns (uint y) {
return 98 ^ (7 * ((1 | (x | 1000)) * 40) ^ 102);
}
}
@@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(storage_access)
char const* sourceCode = R"(
contract test {
uint8[40] data;
- function f(uint x) returns (uint y) {
+ function f(uint x) public returns (uint y) {
data[2] = data[7] = uint8(x);
data[4] = data[2] * 10 + data[3];
}
@@ -210,7 +210,7 @@ BOOST_AUTO_TEST_CASE(array_copy)
contract test {
bytes2[] data1;
bytes5[] data2;
- function f(uint x) returns (uint l, uint y) {
+ function f(uint x) public returns (uint l, uint y) {
data1.length = msg.data.length;
for (uint i = 0; i < msg.data.length; ++i)
data1[i] = msg.data[i];
@@ -230,8 +230,8 @@ BOOST_AUTO_TEST_CASE(function_calls)
{
char const* sourceCode = R"(
contract test {
- function f1(uint x) returns (uint) { return x*x; }
- function f(uint x) returns (uint) { return f1(7+x) - this.f1(x**9); }
+ function f1(uint x) public returns (uint) { return x*x; }
+ function f(uint x) public returns (uint) { return f1(7+x) - this.f1(x**9); }
}
)";
compileBothVersions(sourceCode);
@@ -245,8 +245,8 @@ BOOST_AUTO_TEST_CASE(storage_write_in_loops)
char const* sourceCode = R"(
contract test {
uint d;
- function f(uint a) returns (uint r) {
- var x = d;
+ function f(uint a) public returns (uint r) {
+ uint x = d;
for (uint i = 1; i < a * a; i++) {
r = d;
d = i;
@@ -270,7 +270,7 @@ BOOST_AUTO_TEST_CASE(retain_information_in_branches)
contract c {
bytes32 d;
uint a;
- function f(uint x, bytes32 y) returns (uint r_a, bytes32 r_d) {
+ function f(uint x, bytes32 y) public returns (uint r_a, bytes32 r_d) {
bytes32 z = keccak256(abi.encodePacked(y));
if (x > 8) {
z = keccak256(abi.encodePacked(y));
@@ -351,7 +351,7 @@ BOOST_AUTO_TEST_CASE(incorrect_storage_access_bug)
contract C
{
mapping(uint => uint) data;
- function f() returns (uint)
+ function f() public returns (uint)
{
if(data[now] == 0)
data[uint(-7)] = 5;
@@ -370,7 +370,7 @@ BOOST_AUTO_TEST_CASE(sequence_number_for_calls)
// to storage), so the sequence number should be incremented.
char const* sourceCode = R"(
contract test {
- function f(string a, string b) returns (bool) { return sha256(bytes(a)) == sha256(bytes(b)); }
+ function f(string a, string b) public returns (bool) { return sha256(bytes(a)) == sha256(bytes(b)); }
}
)";
compileBothVersions(sourceCode);
@@ -385,10 +385,10 @@ BOOST_AUTO_TEST_CASE(computing_constants)
uint m_b;
uint m_c;
uint m_d;
- constructor() {
+ constructor() public {
set();
}
- function set() returns (uint) {
+ function set() public returns (uint) {
m_a = 0x77abc0000000000000000000000000000000000000000000000000000000001;
m_b = 0x817416927846239487123469187231298734162934871263941234127518276;
g();
@@ -402,7 +402,7 @@ BOOST_AUTO_TEST_CASE(computing_constants)
function h() {
m_d = 0xff05694900000000000000000000000000000000000000000000000000000000;
}
- function get() returns (uint ra, uint rb, uint rc, uint rd) {
+ function get() public returns (uint ra, uint rb, uint rc, uint rd) {
ra = m_a;
rb = m_b;
rc = m_c;
@@ -444,7 +444,7 @@ BOOST_AUTO_TEST_CASE(constant_optimization_early_exit)
pragma solidity ^0.4.0;
contract HexEncoding {
- function hexEncodeTest(address addr) returns (bytes32 ret) {
+ function hexEncodeTest(address addr) public returns (bytes32 ret) {
uint x = uint(addr) / 2**32;
// Nibble interleave
@@ -561,11 +561,11 @@ BOOST_AUTO_TEST_CASE(dead_code_elimination_across_assemblies)
char const* sourceCode = R"(
contract DCE {
function () internal returns (uint) stored;
- constructor() {
+ constructor() public {
stored = f;
}
function f() internal returns (uint) { return 7; }
- function test() returns (uint) { return stored(); }
+ function test() public returns (uint) { return stored(); }
}
)";
compileBothVersions(sourceCode);
@@ -577,12 +577,12 @@ BOOST_AUTO_TEST_CASE(invalid_state_at_control_flow_join)
char const* sourceCode = R"(
contract Test {
uint256 public totalSupply = 100;
- function f() returns (uint r) {
+ function f() public returns (uint r) {
if (false)
r = totalSupply;
totalSupply -= 10;
}
- function test() returns (uint) {
+ function test() public returns (uint) {
f();
return this.totalSupply();
}
diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp
index 1ffbd771..5432e9b5 100644
--- a/test/libsolidity/SolidityParser.cpp
+++ b/test/libsolidity/SolidityParser.cpp
@@ -118,7 +118,7 @@ BOOST_AUTO_TEST_CASE(function_natspec_documentation)
contract test {
uint256 stateVar;
/// This is a test function
- function functionName(bytes32 input) returns (bytes32 out) {}
+ function functionName(bytes32 input) public returns (bytes32 out) {}
}
)";
BOOST_CHECK(successParse(text));
@@ -138,7 +138,7 @@ BOOST_AUTO_TEST_CASE(function_normal_comments)
contract test {
uint256 stateVar;
// We won't see this comment
- function functionName(bytes32 input) returns (bytes32 out) {}
+ function functionName(bytes32 input) public returns (bytes32 out) {}
}
)";
BOOST_CHECK(successParse(text));
@@ -157,13 +157,13 @@ BOOST_AUTO_TEST_CASE(multiple_functions_natspec_documentation)
contract test {
uint256 stateVar;
/// This is test function 1
- function functionName1(bytes32 input) returns (bytes32 out) {}
+ function functionName1(bytes32 input) public returns (bytes32 out) {}
/// This is test function 2
- function functionName2(bytes32 input) returns (bytes32 out) {}
+ function functionName2(bytes32 input) public returns (bytes32 out) {}
// nothing to see here
- function functionName3(bytes32 input) returns (bytes32 out) {}
+ function functionName3(bytes32 input) public returns (bytes32 out) {}
/// This is test function 4
- function functionName4(bytes32 input) returns (bytes32 out) {}
+ function functionName4(bytes32 input) public returns (bytes32 out) {}
}
)";
BOOST_CHECK(successParse(text));
@@ -193,7 +193,7 @@ BOOST_AUTO_TEST_CASE(multiline_function_documentation)
uint256 stateVar;
/// This is a test function
/// and it has 2 lines
- function functionName1(bytes32 input) returns (bytes32 out) {}
+ function functionName1(bytes32 input) public returns (bytes32 out) {}
}
)";
BOOST_CHECK(successParse(text));
@@ -220,7 +220,7 @@ BOOST_AUTO_TEST_CASE(natspec_comment_in_function_body)
}
/// This is a test function
/// and it has 2 lines
- function fun(bytes32 input) returns (bytes32 out) {}
+ function fun(bytes32 input) public returns (bytes32 out) {}
}
)";
BOOST_CHECK(successParse(text));
diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp
index 63c03881..bfb0d739 100644
--- a/test/libsolidity/StandardCompiler.cpp
+++ b/test/libsolidity/StandardCompiler.cpp
@@ -556,10 +556,10 @@ BOOST_AUTO_TEST_CASE(library_filename_with_colon)
},
"sources": {
"fileA": {
- "content": "import \"git:library.sol\"; contract A { function f() returns (uint) { return L.g(); } }"
+ "content": "import \"git:library.sol\"; contract A { function f() public returns (uint) { return L.g(); } }"
},
"git:library.sol": {
- "content": "library L { function g() returns (uint) { return 1; } }"
+ "content": "library L { function g() public returns (uint) { return 1; } }"
}
}
}
@@ -706,10 +706,10 @@ BOOST_AUTO_TEST_CASE(library_linking)
},
"sources": {
"fileA": {
- "content": "import \"library.sol\"; import \"library2.sol\"; contract A { function f() returns (uint) { L2.g(); return L.g(); } }"
+ "content": "import \"library.sol\"; import \"library2.sol\"; contract A { function f() public returns (uint) { L2.g(); return L.g(); } }"
},
"library.sol": {
- "content": "library L { function g() returns (uint) { return 1; } }"
+ "content": "library L { function g() public returns (uint) { return 1; } }"
},
"library2.sol": {
"content": "library L2 { function g() { } }"
diff --git a/test/libsolidity/ViewPureChecker.cpp b/test/libsolidity/ViewPureChecker.cpp
index 53761ff2..bb5480b2 100644
--- a/test/libsolidity/ViewPureChecker.cpp
+++ b/test/libsolidity/ViewPureChecker.cpp
@@ -43,13 +43,11 @@ BOOST_AUTO_TEST_CASE(environment_access)
vector<string> view{
"block.coinbase",
"block.timestamp",
- "block.blockhash(7)",
"block.difficulty",
"block.number",
"block.gaslimit",
"blockhash(7)",
"gasleft()",
- "msg.gas",
"msg.value",
"msg.sender",
"tx.origin",
@@ -90,12 +88,11 @@ BOOST_AUTO_TEST_CASE(environment_access)
"Statement has no effect."
}));
- CHECK_WARNING_ALLOW_MULTI(
+ CHECK_ERROR(
"contract C { function f() view public { block.blockhash; } }",
- (std::vector<std::string>{
- "Function state mutability can be restricted to pure",
- "\"block.blockhash()\" has been deprecated in favor of \"blockhash()\""
- }));
+ TypeError,
+ "\"block.blockhash()\" has been deprecated in favor of \"blockhash()\""
+ );
}
BOOST_AUTO_TEST_CASE(assembly_staticcall)
diff --git a/test/libsolidity/syntaxTests/constants/assign_constant_function_value.sol b/test/libsolidity/syntaxTests/constants/assign_constant_function_value.sol
index 88e94e29..0e242b30 100644
--- a/test/libsolidity/syntaxTests/constants/assign_constant_function_value.sol
+++ b/test/libsolidity/syntaxTests/constants/assign_constant_function_value.sol
@@ -3,4 +3,4 @@ contract C {
uint constant y = x();
}
// ----
-// Warning: (74-77): Initial value for constant variable has to be compile-time constant. This will fail to compile with the next breaking version change.
+// TypeError: (74-77): Initial value for constant variable has to be compile-time constant.
diff --git a/test/libsolidity/syntaxTests/constructor/constructor_no_visibility.sol b/test/libsolidity/syntaxTests/constructor/constructor_no_visibility.sol
index f8820fdc..88553084 100644
--- a/test/libsolidity/syntaxTests/constructor/constructor_no_visibility.sol
+++ b/test/libsolidity/syntaxTests/constructor/constructor_no_visibility.sol
@@ -1,3 +1,3 @@
contract A { constructor() {} }
// ----
-// Warning: (13-29): No visibility specified. Defaulting to "public".
+// Warning: (13-29): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/constructor/constructor_state_mutability_new.sol b/test/libsolidity/syntaxTests/constructor/constructor_state_mutability_new.sol
index 15ed0e1e..78272c98 100644
--- a/test/libsolidity/syntaxTests/constructor/constructor_state_mutability_new.sol
+++ b/test/libsolidity/syntaxTests/constructor/constructor_state_mutability_new.sol
@@ -1,13 +1,9 @@
contract test1 {
- constructor() constant {}
-}
-contract test2 {
constructor() view {}
}
-contract test3 {
+contract test2 {
constructor() pure {}
}
// ----
-// TypeError: (19-44): Constructor must be payable or non-payable, but is "view".
-// TypeError: (66-87): Constructor must be payable or non-payable, but is "view".
-// TypeError: (109-130): Constructor must be payable or non-payable, but is "pure".
+// TypeError: (19-40): Constructor must be payable or non-payable, but is "view".
+// TypeError: (62-83): Constructor must be payable or non-payable, but is "pure".
diff --git a/test/libsolidity/syntaxTests/constructor/constructor_state_mutability_old.sol b/test/libsolidity/syntaxTests/constructor/constructor_state_mutability_old.sol
index 6dbcbc97..1ceaffee 100644
--- a/test/libsolidity/syntaxTests/constructor/constructor_state_mutability_old.sol
+++ b/test/libsolidity/syntaxTests/constructor/constructor_state_mutability_old.sol
@@ -1,16 +1,11 @@
contract test1 {
- function test1() constant {}
+ function test1() view {}
}
contract test2 {
- function test2() view {}
-}
-contract test3 {
- function test3() pure {}
+ function test2() pure {}
}
// ----
-// Warning: (21-49): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
-// Warning: (73-97): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
-// Warning: (121-145): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
-// TypeError: (21-49): Constructor must be payable or non-payable, but is "view".
-// TypeError: (73-97): Constructor must be payable or non-payable, but is "view".
-// TypeError: (121-145): Constructor must be payable or non-payable, but is "pure".
+// Warning: (21-45): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
+// Warning: (69-93): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
+// TypeError: (21-45): Constructor must be payable or non-payable, but is "view".
+// TypeError: (69-93): Constructor must be payable or non-payable, but is "pure".
diff --git a/test/libsolidity/syntaxTests/fallback/default_visibility.sol b/test/libsolidity/syntaxTests/fallback/default_visibility.sol
index 2cb0af90..f45bbd3c 100644
--- a/test/libsolidity/syntaxTests/fallback/default_visibility.sol
+++ b/test/libsolidity/syntaxTests/fallback/default_visibility.sol
@@ -3,4 +3,4 @@ contract C {
function() {}
}
// ----
-// Warning: (90-103): No visibility specified. Defaulting to "public".
+// Warning: (90-103): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol b/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol
index 015b33e5..96be62f2 100644
--- a/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol
+++ b/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol
@@ -6,4 +6,4 @@ contract Derived is Base, Base1 {
constructor(uint i) Base(i) public {}
}
// ----
-// Warning: (138-145): Base constructor arguments given twice.
+// DeclarationError: (138-145): Base constructor arguments given twice.
diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol
index 24cff54d..76cc937b 100644
--- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol
+++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol
@@ -2,4 +2,4 @@ contract A { constructor(uint) public { } }
contract B is A(2) { constructor() public { } }
contract C is B { constructor() A(3) public { } }
// ----
-// Warning: (125-129): Base constructor arguments given twice.
+// DeclarationError: (125-129): Base constructor arguments given twice.
diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol
index 9ceaea5e..4c7a684f 100644
--- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol
+++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol
@@ -1,4 +1,4 @@
contract A { constructor(uint) public { } }
contract B is A(2) { constructor() A(3) public { } }
// ----
-// Warning: (79-83): Base constructor arguments given twice.
+// DeclarationError: (79-83): Base constructor arguments given twice.
diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol
index e5c2aa36..2e77e077 100644
--- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol
+++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol
@@ -3,5 +3,5 @@ contract A is C(2) {}
contract B is C(2) {}
contract D is A, B { constructor() C(3) public {} }
// ----
-// Warning: (122-126): Base constructor arguments given twice.
-// Warning: (122-126): Base constructor arguments given twice.
+// DeclarationError: (122-126): Base constructor arguments given twice.
+// DeclarationError: (122-126): Base constructor arguments given twice.
diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol
index 1abf2992..0beb1552 100644
--- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol
+++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol
@@ -3,4 +3,4 @@ contract A is C(2) {}
contract B is C(2) {}
contract D is A, B {}
// ----
-// Warning: (87-108): Base constructor arguments given twice.
+// DeclarationError: (87-108): Base constructor arguments given twice.
diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol
index e15242db..7142840e 100644
--- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol
+++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol
@@ -3,4 +3,4 @@ contract A is C { constructor() C(2) public {} }
contract B is C { constructor() C(2) public {} }
contract D is A, B { }
// ----
-// Warning: (141-163): Base constructor arguments given twice.
+// DeclarationError: (141-163): Base constructor arguments given twice.
diff --git a/test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol b/test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol
index bdbab5d8..49d0d7bf 100644
--- a/test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol
+++ b/test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol
@@ -3,5 +3,5 @@ contract B is C {
constructor() C(2) C(2) public {}
}
// ----
-// Warning: (81-85): Base constructor arguments given twice.
+// DeclarationError: (81-85): Base constructor arguments given twice.
// DeclarationError: (86-90): Base constructor already provided.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/040_functions_with_different_structs_in_interface.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/040_functions_with_different_structs_in_interface.sol
index 2af584b7..1689e6f5 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/040_functions_with_different_structs_in_interface.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/040_functions_with_different_structs_in_interface.sol
@@ -3,10 +3,8 @@ pragma experimental ABIEncoderV2;
contract C {
struct S1 { function() external a; }
struct S2 { bytes24 a; }
- function f(S1) pure {}
- function f(S2) pure {}
+ function f(S1) public pure {}
+ function f(S2) public pure {}
}
// ----
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
-// Warning: (122-144): No visibility specified. Defaulting to "public".
-// Warning: (149-171): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/124_enum_member_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/124_enum_member_access.sol
index 3fd7a0cb..98bc8e66 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/124_enum_member_access.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/124_enum_member_access.sol
@@ -1,10 +1,8 @@
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
- constructor()
+ constructor() public
{
choices = ActionChoices.GoStraight;
}
ActionChoices choices;
}
-// ----
-// Warning: (80-149): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/165_assigning_state_to_const_variable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/165_assigning_state_to_const_variable.sol
index f3986580..0de15dfb 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/165_assigning_state_to_const_variable.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/165_assigning_state_to_const_variable.sol
@@ -2,4 +2,4 @@ contract C {
address constant x = msg.sender;
}
// ----
-// Warning: (38-48): Initial value for constant variable has to be compile-time constant. This will fail to compile with the next breaking version change.
+// TypeError: (38-48): Initial value for constant variable has to be compile-time constant.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/239_multi_variable_declaration_wildcards_fine.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/239_multi_variable_declaration_wildcards_fine.sol
index ae260ce4..0da5c7ee 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/239_multi_variable_declaration_wildcards_fine.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/239_multi_variable_declaration_wildcards_fine.sol
@@ -1,7 +1,7 @@
contract C {
function three() public returns (uint, uint, uint);
function two() public returns (uint, uint);
- function none();
+ function none() public;
function f() public {
(uint a,) = three();
(uint b, uint c,) = two();
@@ -13,8 +13,7 @@ contract C {
}
}
// ----
-// Warning: (172-191): Different number of components on the left hand side (2) than on the right hand side (3).
-// Warning: (201-226): Different number of components on the left hand side (3) than on the right hand side (2).
-// Warning: (236-255): Different number of components on the left hand side (2) than on the right hand side (3).
-// Warning: (265-290): Different number of components on the left hand side (3) than on the right hand side (2).
-// Warning: (121-137): No visibility specified. Defaulting to "public".
+// Warning: (179-198): Different number of components on the left hand side (2) than on the right hand side (3).
+// Warning: (208-233): Different number of components on the left hand side (3) than on the right hand side (2).
+// Warning: (243-262): Different number of components on the left hand side (2) than on the right hand side (3).
+// Warning: (272-297): Different number of components on the left hand side (3) than on the right hand side (2).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/268_function_overload_array_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/268_function_overload_array_type.sol
index 0ff1ed75..97e68aa3 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/268_function_overload_array_type.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/268_function_overload_array_type.sol
@@ -1,7 +1,4 @@
- contract M {
- function f(uint[]);
- function f(int[]);
- }
-// ----
-// Warning: (25-44): No visibility specified. Defaulting to "public".
-// Warning: (53-71): No visibility specified. Defaulting to "public".
+contract M {
+ function f(uint[]) public;
+ function f(int[]) public;
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/275_inline_struct_declaration_arrays.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/275_inline_struct_declaration_arrays.sol
index e69c2934..bdf033a3 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/275_inline_struct_declaration_arrays.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/275_inline_struct_declaration_arrays.sol
@@ -3,11 +3,10 @@ contract C {
uint a;
string b;
}
- function f() {
+ function f() public {
S[2] memory x = [S({a: 1, b: "fish"}), S({a: 2, b: "fish"})];
}
}
// ----
-// Warning: (72-162): No visibility specified. Defaulting to "public".
-// Warning: (95-108): Unused local variable.
-// Warning: (72-162): Function state mutability can be restricted to pure
+// Warning: (102-115): Unused local variable.
+// Warning: (72-169): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/403_return_structs.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/403_return_structs.sol
index 5583dbff..8af8098c 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/403_return_structs.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/403_return_structs.sol
@@ -2,10 +2,9 @@ pragma experimental ABIEncoderV2;
contract C {
struct S { uint a; T[] sub; }
struct T { uint[] x; }
- function f() returns (uint, S) {
+ function f() public returns (uint, S) {
}
}
// ----
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
-// Warning: (112-150): No visibility specified. Defaulting to "public".
-// Warning: (112-150): Function state mutability can be restricted to pure
+// Warning: (112-157): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/423_using_interface.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/423_using_interface.sol
index f06ffa62..d576bb60 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/423_using_interface.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/423_using_interface.sol
@@ -1,10 +1,8 @@
interface I {
- function f();
+ function f() external;
}
contract C is I {
function f() public {
}
}
// ----
-// Warning: (18-31): Functions in interfaces should be declared external.
-// Warning: (18-31): No visibility specified. Defaulting to "public". In interfaces it defaults to external.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/498_msg_gas_deprecated.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/498_msg_gas_deprecated.sol
index d917b840..5efecd22 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/498_msg_gas_deprecated.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/498_msg_gas_deprecated.sol
@@ -2,4 +2,4 @@ contract C {
function f() public view returns (uint256 val) { return msg.gas; }
}
// ----
-// Warning: (73-80): "msg.gas" has been deprecated in favor of "gasleft()"
+// TypeError: (73-80): "msg.gas" has been deprecated in favor of "gasleft()"
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/499_msg_gas_deprecated_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/499_msg_gas_deprecated_v050.sol
deleted file mode 100644
index 31fd40da..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/499_msg_gas_deprecated_v050.sol
+++ /dev/null
@@ -1,6 +0,0 @@
-pragma experimental "v0.5.0";
-contract C {
- function f() public returns (uint256 val) { return msg.gas; }
-}
-// ----
-// TypeError: (98-105): "msg.gas" has been deprecated in favor of "gasleft()"
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol
index 35f4639e..157ea36b 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol
@@ -1,21 +1,18 @@
contract C {
- function balance() returns (uint) {
+ function balance() public returns (uint) {
this.balance; // to avoid pureness warning
return 1;
}
- function transfer(uint amount) {
+ function transfer(uint amount) public {
address(this).transfer(amount); // to avoid pureness warning
}
}
contract D {
- function f() {
+ function f() public {
uint x = (new C()).balance();
x;
(new C()).transfer(5);
}
}
// ----
-// Warning: (17-127): No visibility specified. Defaulting to "public".
-// Warning: (132-239): No visibility specified. Defaulting to "public".
-// Warning: (259-359): No visibility specified. Defaulting to "public".
-// Warning: (17-127): Function state mutability can be restricted to view
+// Warning: (17-134): Function state mutability can be restricted to view
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/569_block_blockhash_deprecated.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/569_block_blockhash_deprecated.sol
index f2e5a2c4..b8f5d6a8 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/569_block_blockhash_deprecated.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/569_block_blockhash_deprecated.sol
@@ -4,4 +4,4 @@ contract C {
}
}
// ----
-// Warning: (77-92): "block.blockhash()" has been deprecated in favor of "blockhash()"
+// TypeError: (77-92): "block.blockhash()" has been deprecated in favor of "blockhash()"
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/570_block_blockhash_deprecated_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/570_block_blockhash_deprecated_v050.sol
deleted file mode 100644
index b954eab7..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/570_block_blockhash_deprecated_v050.sol
+++ /dev/null
@@ -1,6 +0,0 @@
-pragma experimental "v0.5.0";
-contract C {
- function f() public returns (bytes32) { return block.blockhash(3); }
-}
-// ----
-// TypeError: (94-109): "block.blockhash()" has been deprecated in favor of "blockhash()"
diff --git a/test/libsolidity/syntaxTests/parsing/calling_function.sol b/test/libsolidity/syntaxTests/parsing/calling_function.sol
index 4c4fc1fc..9e88c451 100644
--- a/test/libsolidity/syntaxTests/parsing/calling_function.sol
+++ b/test/libsolidity/syntaxTests/parsing/calling_function.sol
@@ -1,9 +1,7 @@
contract test {
- function f() {
+ function f() public {
function() returns(function() returns(function() returns(function() returns(uint)))) x;
uint y;
y = x()()()();
}
}
-// ----
-// Warning: (20-175): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/parsing/conditional_multiple.sol b/test/libsolidity/syntaxTests/parsing/conditional_multiple.sol
index c7d11ed6..0e348f5b 100644
--- a/test/libsolidity/syntaxTests/parsing/conditional_multiple.sol
+++ b/test/libsolidity/syntaxTests/parsing/conditional_multiple.sol
@@ -1,9 +1,8 @@
contract A {
- function f() {
+ function f() public {
uint x = 3 < 0 ? 2 > 1 ? 2 : 1 : 7 > 2 ? 7 : 6;
}
}
// ----
-// Warning: (17-93): No visibility specified. Defaulting to "public".
-// Warning: (40-46): Unused local variable.
-// Warning: (17-93): Function state mutability can be restricted to pure
+// Warning: (47-53): Unused local variable.
+// Warning: (17-100): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/conditional_true_false_literal.sol b/test/libsolidity/syntaxTests/parsing/conditional_true_false_literal.sol
index 90974e96..40aaa917 100644
--- a/test/libsolidity/syntaxTests/parsing/conditional_true_false_literal.sol
+++ b/test/libsolidity/syntaxTests/parsing/conditional_true_false_literal.sol
@@ -1,11 +1,10 @@
contract A {
- function f() {
+ function f() public {
uint x = true ? 1 : 0;
uint y = false ? 0 : 1;
}
}
// ----
-// Warning: (17-100): No visibility specified. Defaulting to "public".
-// Warning: (40-46): Unused local variable.
-// Warning: (71-77): Unused local variable.
-// Warning: (17-100): Function state mutability can be restricted to pure
+// Warning: (47-53): Unused local variable.
+// Warning: (78-84): Unused local variable.
+// Warning: (17-107): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol b/test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol
index 35da69c6..705fbadf 100644
--- a/test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol
+++ b/test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol
@@ -1,11 +1,10 @@
contract A {
- function f() {
+ function f() public {
uint x = 3 > 0 ? 3 : 0;
uint y = (3 > 0) ? 3 : 0;
}
}
// ----
-// Warning: (17-103): No visibility specified. Defaulting to "public".
-// Warning: (40-46): Unused local variable.
-// Warning: (72-78): Unused local variable.
-// Warning: (17-103): Function state mutability can be restricted to pure
+// Warning: (47-53): Unused local variable.
+// Warning: (79-85): Unused local variable.
+// Warning: (17-110): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/conditional_with_variables.sol b/test/libsolidity/syntaxTests/parsing/conditional_with_variables.sol
index eb4c7091..bbabf957 100644
--- a/test/libsolidity/syntaxTests/parsing/conditional_with_variables.sol
+++ b/test/libsolidity/syntaxTests/parsing/conditional_with_variables.sol
@@ -1,5 +1,5 @@
contract A {
- function f() {
+ function f() public {
uint x = 3;
uint y = 1;
uint z = (x > y) ? x : y;
@@ -7,7 +7,6 @@ contract A {
}
}
// ----
-// Warning: (17-143): No visibility specified. Defaulting to "public".
-// Warning: (80-86): Unused local variable.
-// Warning: (114-120): Unused local variable.
-// Warning: (17-143): Function state mutability can be restricted to pure
+// Warning: (87-93): Unused local variable.
+// Warning: (121-127): Unused local variable.
+// Warning: (17-150): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/constant_state_modifier.sol b/test/libsolidity/syntaxTests/parsing/constant_state_modifier.sol
index da068351..8fddc988 100644
--- a/test/libsolidity/syntaxTests/parsing/constant_state_modifier.sol
+++ b/test/libsolidity/syntaxTests/parsing/constant_state_modifier.sol
@@ -1,7 +1,8 @@
contract C {
uint s;
- // this test should fail starting from 0.5.0
function f() public constant returns (uint) {
return s;
}
}
+// ----
+// ParserError: (43-51): The state mutability modifier "constant" was removed in version 0.5.0. Use "view" or "pure" instead.
diff --git a/test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol b/test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol
index 8be9667a..6d88669a 100644
--- a/test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol
+++ b/test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol
@@ -1,14 +1,13 @@
contract A {
fixed40x40 storeMe;
- function f(ufixed x, fixed32x32 y) {
+ function f(ufixed x, fixed32x32 y) public {
ufixed8x8 a;
fixed b;
}
}
// ----
-// Warning: (41-121): No visibility specified. Defaulting to "public".
// Warning: (52-60): Unused function parameter. Remove or comment out the variable name to silence this warning.
// Warning: (62-74): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (86-97): Unused local variable.
-// Warning: (107-114): Unused local variable.
-// Warning: (41-121): Function state mutability can be restricted to pure
+// Warning: (93-104): Unused local variable.
+// Warning: (114-121): Unused local variable.
+// Warning: (41-128): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/else_if_statement.sol b/test/libsolidity/syntaxTests/parsing/else_if_statement.sol
index 37763697..c2a1aaeb 100644
--- a/test/libsolidity/syntaxTests/parsing/else_if_statement.sol
+++ b/test/libsolidity/syntaxTests/parsing/else_if_statement.sol
@@ -1,8 +1,7 @@
contract test {
- function fun(uint256 a) returns (uint8 b) {
+ function fun(uint256 a) public returns (uint8 b) {
if (a < 0) b = 0x67; else if (a == 0) b = 0x12; else b = 0x78;
}
}
// ----
-// Warning: (20-140): No visibility specified. Defaulting to "public".
-// Warning: (20-140): Function state mutability can be restricted to pure
+// Warning: (20-147): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/empty_function.sol b/test/libsolidity/syntaxTests/parsing/empty_function.sol
index 218fd9a7..320a0bcc 100644
--- a/test/libsolidity/syntaxTests/parsing/empty_function.sol
+++ b/test/libsolidity/syntaxTests/parsing/empty_function.sol
@@ -1,10 +1,9 @@
contract test {
uint256 stateVar;
- function functionName(bytes20 arg1, address addr) view returns (int id) { }
+ function functionName(bytes20 arg1, address addr) public view returns (int id) { }
}
// ----
-// Warning: (36-111): No visibility specified. Defaulting to "public".
// Warning: (58-70): Unused function parameter. Remove or comment out the variable name to silence this warning.
// Warning: (72-84): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (100-106): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (36-111): Function state mutability can be restricted to pure
+// Warning: (107-113): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (36-118): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol b/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol
index 602c26ed..606f59d7 100644
--- a/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol
+++ b/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol
@@ -1,9 +1,7 @@
contract c {
enum validEnum { Value1, Value2, Value3, Value4 }
- constructor() {
+ constructor() public {
a = validEnum.Value3;
}
validEnum a;
}
-// ----
-// Warning: (71-122): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/parsing/exp_expression.sol b/test/libsolidity/syntaxTests/parsing/exp_expression.sol
index cdabb996..6b307ea0 100644
--- a/test/libsolidity/syntaxTests/parsing/exp_expression.sol
+++ b/test/libsolidity/syntaxTests/parsing/exp_expression.sol
@@ -1,9 +1,8 @@
contract test {
- function fun(uint256 a) {
+ function fun(uint256 a) public {
uint256 x = 3 ** a;
}
}
// ----
-// Warning: (20-79): No visibility specified. Defaulting to "public".
-// Warning: (54-63): Unused local variable.
-// Warning: (20-79): Function state mutability can be restricted to pure
+// Warning: (61-70): Unused local variable.
+// Warning: (20-86): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol b/test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol
index bd86f2f5..fce669dd 100644
--- a/test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol
+++ b/test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol
@@ -1,5 +1,5 @@
contract test {
- function fun(uint256 a) {
+ function fun(uint256 a) public {
uint256 i =0;
for (i = 0; i < 10; i++) {
uint256 x = i; break; continue;
@@ -7,7 +7,6 @@ contract test {
}
}
// ----
-// Warning: (20-162): No visibility specified. Defaulting to "public".
// Warning: (33-42): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (115-124): Unused local variable.
-// Warning: (20-162): Function state mutability can be restricted to pure
+// Warning: (122-131): Unused local variable.
+// Warning: (20-169): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/for_loop_simple_noexpr.sol b/test/libsolidity/syntaxTests/parsing/for_loop_simple_noexpr.sol
index 4a27e0fb..4adf0948 100644
--- a/test/libsolidity/syntaxTests/parsing/for_loop_simple_noexpr.sol
+++ b/test/libsolidity/syntaxTests/parsing/for_loop_simple_noexpr.sol
@@ -1,5 +1,5 @@
contract test {
- function fun(uint256 a) {
+ function fun(uint256 a) public {
uint256 i =0;
for (;;) {
uint256 x = i; break; continue;
@@ -7,7 +7,6 @@ contract test {
}
}
// ----
-// Warning: (24-170): No visibility specified. Defaulting to "public".
// Warning: (37-46): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (115-124): Unused local variable.
-// Warning: (24-170): Function state mutability can be restricted to pure
+// Warning: (122-131): Unused local variable.
+// Warning: (24-177): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/for_loop_single_stmt_body.sol b/test/libsolidity/syntaxTests/parsing/for_loop_single_stmt_body.sol
index 3df88ef5..c6af519c 100644
--- a/test/libsolidity/syntaxTests/parsing/for_loop_single_stmt_body.sol
+++ b/test/libsolidity/syntaxTests/parsing/for_loop_single_stmt_body.sol
@@ -1,11 +1,10 @@
contract test {
- function fun(uint256 a) {
+ function fun(uint256 a) public {
uint256 i = 0;
for (i = 0; i < 10; i++)
continue;
}
}
// ----
-// Warning: (20-129): No visibility specified. Defaulting to "public".
// Warning: (33-42): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (20-129): Function state mutability can be restricted to pure
+// Warning: (20-136): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/for_loop_vardef_initexpr.sol b/test/libsolidity/syntaxTests/parsing/for_loop_vardef_initexpr.sol
index a7c5e8bb..c22ae42f 100644
--- a/test/libsolidity/syntaxTests/parsing/for_loop_vardef_initexpr.sol
+++ b/test/libsolidity/syntaxTests/parsing/for_loop_vardef_initexpr.sol
@@ -1,12 +1,11 @@
contract test {
- function fun(uint256 a) {
+ function fun(uint256 a) public {
for (uint256 i = 0; i < 10; i++) {
uint256 x = i; break; continue;
}
}
}
// ----
-// Warning: (20-148): No visibility specified. Defaulting to "public".
// Warning: (33-42): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (101-110): Unused local variable.
-// Warning: (20-148): Function state mutability can be restricted to pure
+// Warning: (108-117): Unused local variable.
+// Warning: (20-155): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/function_no_body.sol b/test/libsolidity/syntaxTests/parsing/function_no_body.sol
index 0424ebd8..c4a686dc 100644
--- a/test/libsolidity/syntaxTests/parsing/function_no_body.sol
+++ b/test/libsolidity/syntaxTests/parsing/function_no_body.sol
@@ -1,5 +1,3 @@
contract test {
- function functionName(bytes32 input) returns (bytes32 out);
+ function functionName(bytes32 input) public returns (bytes32 out);
}
-// ----
-// Warning: (17-76): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol b/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol
index c7a023ac..94e1e60a 100644
--- a/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol
+++ b/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol
@@ -1,10 +1,9 @@
contract test {
uint256 stateVar;
// We won't see this comment
- function functionName(bytes32 input) returns (bytes32 out) {}
+ function functionName(bytes32 input) public returns (bytes32 out) {}
}
// ----
-// Warning: (75-136): No visibility specified. Defaulting to "public".
// Warning: (97-110): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (121-132): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (75-136): Function state mutability can be restricted to pure
+// Warning: (128-139): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (75-143): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol b/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol
index 3b784733..11e77f25 100644
--- a/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol
+++ b/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol
@@ -1,10 +1,9 @@
contract test {
- function f(uint x, uint y) returns (uint a) {}
+ function f(uint x, uint y) public returns (uint a) {}
function (uint, uint) internal returns (uint) f1 = f;
}
// ----
-// Warning: (20-66): No visibility specified. Defaulting to "public".
// Warning: (31-37): Unused function parameter. Remove or comment out the variable name to silence this warning.
// Warning: (39-45): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (56-62): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (20-66): Function state mutability can be restricted to pure
+// Warning: (63-69): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (20-73): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol b/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol
index fd6447c7..3defb5ea 100644
--- a/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol
+++ b/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol
@@ -1,15 +1,13 @@
contract test {
- function f(uint x, uint y) returns (uint a) {}
- function g() {
+ function f(uint x, uint y) public returns (uint a) {}
+ function g() public {
function (uint, uint) internal returns (uint) f1 = f;
}
}
// ----
-// Warning: (20-66): No visibility specified. Defaulting to "public".
// Warning: (31-37): Unused function parameter. Remove or comment out the variable name to silence this warning.
// Warning: (39-45): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (56-62): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (71-153): No visibility specified. Defaulting to "public".
-// Warning: (94-142): Unused local variable.
-// Warning: (20-66): Function state mutability can be restricted to pure
-// Warning: (71-153): Function state mutability can be restricted to pure
+// Warning: (63-69): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (108-156): Unused local variable.
+// Warning: (20-73): Function state mutability can be restricted to pure
+// Warning: (78-167): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/if_statement.sol b/test/libsolidity/syntaxTests/parsing/if_statement.sol
index 451fba1f..b3269785 100644
--- a/test/libsolidity/syntaxTests/parsing/if_statement.sol
+++ b/test/libsolidity/syntaxTests/parsing/if_statement.sol
@@ -1,9 +1,8 @@
contract test {
- function fun(uint256 a) returns (uint) {
+ function fun(uint256 a) public returns (uint) {
if (a >= 8) { return 2; } else { uint b = 7; }
}
}
// ----
-// Warning: (20-121): No visibility specified. Defaulting to "public".
-// Warning: (102-108): Unused local variable.
-// Warning: (20-121): Function state mutability can be restricted to pure
+// Warning: (109-115): Unused local variable.
+// Warning: (20-128): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol b/test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol
index f42f8f16..4730f950 100644
--- a/test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol
+++ b/test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol
@@ -1,9 +1,8 @@
contract c {
uint[] a;
- function f() returns (uint, uint) {
+ function f() public returns (uint, uint) {
a = [1,2,3];
return (a[3], [2,3,4][0]);
}
}
// ----
-// Warning: (31-128): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/parsing/interface_basic.sol b/test/libsolidity/syntaxTests/parsing/interface_basic.sol
index c25b48ba..2363eaa8 100644
--- a/test/libsolidity/syntaxTests/parsing/interface_basic.sol
+++ b/test/libsolidity/syntaxTests/parsing/interface_basic.sol
@@ -1,6 +1,5 @@
interface Interface {
- function f();
+ function f() public;
}
// ----
-// Warning: (23-36): Functions in interfaces should be declared external.
-// Warning: (23-36): No visibility specified. Defaulting to "public". In interfaces it defaults to external.
+// Warning: (23-43): Functions in interfaces should be declared external.
diff --git a/test/libsolidity/syntaxTests/parsing/library_simple.sol b/test/libsolidity/syntaxTests/parsing/library_simple.sol
index fcf2638e..006ff307 100644
--- a/test/libsolidity/syntaxTests/parsing/library_simple.sol
+++ b/test/libsolidity/syntaxTests/parsing/library_simple.sol
@@ -1,6 +1,5 @@
library Lib {
- function f() { }
+ function f() public { }
}
// ----
-// Warning: (18-34): No visibility specified. Defaulting to "public".
-// Warning: (18-34): Function state mutability can be restricted to pure
+// Warning: (18-41): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol
index 452b52c7..64116b88 100644
--- a/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol
+++ b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol
@@ -1,5 +1,5 @@
contract c {
- function f()
+ function f() public
{
a = 1 wei;
b = 2 szabo;
@@ -12,5 +12,4 @@ contract c {
uint256 d;
}
// ----
-// Warning: (163-172): This declaration shadows an existing declaration.
-// Warning: (17-128): No visibility specified. Defaulting to "public".
+// Warning: (170-179): This declaration shadows an existing declaration.
diff --git a/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol
index e0f49fbf..2f2302ed 100644
--- a/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol
+++ b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol
@@ -1,9 +1,7 @@
contract c {
- constructor()
+ constructor() public
{
a = 1 wei * 100 wei + 7 szabo - 3;
}
uint256 a;
}
-// ----
-// Warning: (17-86): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol
index 5d6c8dc5..e311dd96 100644
--- a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol
+++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol
@@ -1,12 +1,11 @@
contract Foo {
- function f() {
+ function f() public {
uint[] storage x;
uint[] memory y;
}
}
// ----
-// Warning: (42-58): Uninitialized storage pointer.
-// Warning: (19-90): No visibility specified. Defaulting to "public".
-// Warning: (42-58): Unused local variable.
-// Warning: (68-83): Unused local variable.
-// Warning: (19-90): Function state mutability can be restricted to pure
+// Warning: (49-65): Uninitialized storage pointer.
+// Warning: (49-65): Unused local variable.
+// Warning: (75-90): Unused local variable.
+// Warning: (19-97): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol b/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol
index cb2f2985..cf986efe 100644
--- a/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol
+++ b/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol
@@ -1,8 +1,7 @@
contract c {
modifier mod1(uint a) { if (msg.sender == address(a)) _; }
modifier mod2 { if (msg.sender == address(2)) _; }
- function f() mod1(7) mod2 { }
+ function f() public mod1(7) mod2 { }
}
// ----
-// Warning: (135-164): No visibility specified. Defaulting to "public".
-// Warning: (135-164): Function state mutability can be restricted to view
+// Warning: (135-171): Function state mutability can be restricted to view
diff --git a/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol b/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol
index 95a4d1e7..85d9e6a8 100644
--- a/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol
+++ b/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol
@@ -1,28 +1,24 @@
contract test {
uint256 stateVar;
/// This is test function 1
- function functionName1(bytes32 input) returns (bytes32 out) {}
+ function functionName1(bytes32 input) public returns (bytes32 out) {}
/// This is test function 2
- function functionName2(bytes32 input) returns (bytes32 out) {}
+ function functionName2(bytes32 input) public returns (bytes32 out) {}
// nothing to see here
- function functionName3(bytes32 input) returns (bytes32 out) {}
+ function functionName3(bytes32 input) public returns (bytes32 out) {}
/// This is test function 4
- function functionName4(bytes32 input) returns (bytes32 out) {}
+ function functionName4(bytes32 input) public returns (bytes32 out) {}
}
// ----
-// Warning: (74-136): No visibility specified. Defaulting to "public".
// Warning: (97-110): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (121-132): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (173-235): No visibility specified. Defaulting to "public".
-// Warning: (196-209): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (220-231): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (267-329): No visibility specified. Defaulting to "public".
-// Warning: (290-303): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (314-325): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (366-428): No visibility specified. Defaulting to "public".
-// Warning: (389-402): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (413-424): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (74-136): Function state mutability can be restricted to pure
-// Warning: (173-235): Function state mutability can be restricted to pure
-// Warning: (267-329): Function state mutability can be restricted to pure
-// Warning: (366-428): Function state mutability can be restricted to pure
+// Warning: (128-139): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (203-216): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (234-245): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (304-317): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (335-346): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (410-423): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (441-452): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (74-143): Function state mutability can be restricted to pure
+// Warning: (180-249): Function state mutability can be restricted to pure
+// Warning: (281-350): Function state mutability can be restricted to pure
+// Warning: (387-456): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/no_function_params.sol b/test/libsolidity/syntaxTests/parsing/no_function_params.sol
index 020f1233..5a024bdb 100644
--- a/test/libsolidity/syntaxTests/parsing/no_function_params.sol
+++ b/test/libsolidity/syntaxTests/parsing/no_function_params.sol
@@ -1,7 +1,6 @@
contract test {
uint256 stateVar;
- function functionName() {}
+ function functionName() public {}
}
// ----
-// Warning: (36-62): No visibility specified. Defaulting to "public".
-// Warning: (36-62): Function state mutability can be restricted to pure
+// Warning: (36-69): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/overloaded_functions.sol b/test/libsolidity/syntaxTests/parsing/overloaded_functions.sol
index 1a78d155..fe050d1b 100644
--- a/test/libsolidity/syntaxTests/parsing/overloaded_functions.sol
+++ b/test/libsolidity/syntaxTests/parsing/overloaded_functions.sol
@@ -1,9 +1,7 @@
contract test {
- function fun(uint a) returns(uint r) { return a; }
- function fun(uint a, uint b) returns(uint r) { return a + b; }
+ function fun(uint a) public returns(uint r) { return a; }
+ function fun(uint a, uint b) public returns(uint r) { return a + b; }
}
// ----
-// Warning: (17-67): No visibility specified. Defaulting to "public".
-// Warning: (69-131): No visibility specified. Defaulting to "public".
-// Warning: (17-67): Function state mutability can be restricted to pure
-// Warning: (69-131): Function state mutability can be restricted to pure
+// Warning: (17-74): Function state mutability can be restricted to pure
+// Warning: (76-145): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol b/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol
index e331440d..a50855c0 100644
--- a/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol
+++ b/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol
@@ -1,9 +1,8 @@
contract c {
- function fun() returns (uint r) {
+ function fun() public returns (uint r) {
uint _ = 8;
return _ + 1;
}
}
// ----
-// Warning: (17-98): No visibility specified. Defaulting to "public".
-// Warning: (17-98): Function state mutability can be restricted to pure
+// Warning: (17-105): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/single_function_param.sol b/test/libsolidity/syntaxTests/parsing/single_function_param.sol
index 08e531f1..955f20f0 100644
--- a/test/libsolidity/syntaxTests/parsing/single_function_param.sol
+++ b/test/libsolidity/syntaxTests/parsing/single_function_param.sol
@@ -1,9 +1,8 @@
contract test {
uint256 stateVar;
- function functionName(bytes32 input) returns (bytes32 out) {}
+ function functionName(bytes32 input) public returns (bytes32 out) {}
}
// ----
-// Warning: (36-97): No visibility specified. Defaulting to "public".
// Warning: (58-71): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (82-93): Unused function parameter. Remove or comment out the variable name to silence this warning.
-// Warning: (36-97): Function state mutability can be restricted to pure
+// Warning: (89-100): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (36-104): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/tuples.sol b/test/libsolidity/syntaxTests/parsing/tuples.sol
index d691da44..8266c94f 100644
--- a/test/libsolidity/syntaxTests/parsing/tuples.sol
+++ b/test/libsolidity/syntaxTests/parsing/tuples.sol
@@ -1,5 +1,5 @@
contract C {
- function f() {
+ function f() public {
uint a = (1);
(uint b,) = (1,);
(uint c, uint d) = (1, 2 + a);
@@ -8,10 +8,9 @@ contract C {
}
}
// ----
-// Warning: (47-63): Different number of components on the left hand side (2) than on the right hand side (1).
-// Warning: (100-121): Different number of components on the left hand side (2) than on the right hand side (3).
-// Warning: (14-136): No visibility specified. Defaulting to "public".
-// Warning: (68-74): Unused local variable.
-// Warning: (76-82): Unused local variable.
-// Warning: (101-107): Unused local variable.
-// Warning: (14-136): Function state mutability can be restricted to pure
+// Warning: (54-70): Different number of components on the left hand side (2) than on the right hand side (1).
+// Warning: (107-128): Different number of components on the left hand side (2) than on the right hand side (3).
+// Warning: (75-81): Unused local variable.
+// Warning: (83-89): Unused local variable.
+// Warning: (108-114): Unused local variable.
+// Warning: (14-143): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol b/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol
index 4706a26d..db890b37 100644
--- a/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol
+++ b/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol
@@ -3,15 +3,12 @@ contract c {
uint internal b;
uint public c;
uint d;
- function f() {}
+ function f() public {}
function f_priv() private {}
- function f_public() public {}
function f_internal() internal {}
}
// ----
// Warning: (58-71): This declaration shadows an existing declaration.
-// Warning: (89-104): No visibility specified. Defaulting to "public".
-// Warning: (89-104): Function state mutability can be restricted to pure
-// Warning: (109-137): Function state mutability can be restricted to pure
-// Warning: (142-171): Function state mutability can be restricted to pure
-// Warning: (176-209): Function state mutability can be restricted to pure
+// Warning: (89-111): Function state mutability can be restricted to pure
+// Warning: (116-144): Function state mutability can be restricted to pure
+// Warning: (149-182): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol
index b94a4391..a30e428a 100644
--- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol
+++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol
@@ -1,6 +1,6 @@
contract C {
function f() public pure {
- bytes32 h = keccak256(abi.encodePacked(keccak256, f, this.f.gas, block.blockhash));
+ bytes32 h = keccak256(abi.encodePacked(keccak256, f, this.f.gas, blockhash));
h;
}
}
@@ -8,4 +8,4 @@ contract C {
// TypeError: (91-100): This type cannot be encoded.
// TypeError: (102-103): This type cannot be encoded.
// TypeError: (105-115): This type cannot be encoded.
-// TypeError: (117-132): This type cannot be encoded.
+// TypeError: (117-126): This type cannot be encoded.
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump.sol b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol
index 418be561..418be561 100644
--- a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump.sol
+++ b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol
new file mode 100644
index 00000000..c1729db7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol
@@ -0,0 +1,8 @@
+contract C {
+ function k() public view {
+ assembly { jump(2) }
+ }
+}
+// ----
+// Warning: (63-70): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
+// TypeError: (63-70): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_restrict_warning.sol b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_restrict_warning.sol
new file mode 100644
index 00000000..0b834022
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_restrict_warning.sol
@@ -0,0 +1,21 @@
+contract C {
+ function f() view public {
+ bytes32 x = keccak256("abc");
+ bytes32 y = sha256("abc");
+ address z = ecrecover(bytes32(1), uint8(2), bytes32(3), bytes32(4));
+ require(true);
+ assert(true);
+ x; y; z;
+ }
+ function g() public {
+ bytes32 x = keccak256("abc");
+ bytes32 y = sha256("abc");
+ address z = ecrecover(bytes32(1), uint8(2), bytes32(3), bytes32(4));
+ require(true);
+ assert(true);
+ x; y; z;
+ }
+}
+// ----
+// Warning: (17-261): Function state mutability can be restricted to pure
+// Warning: (266-505): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_view_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_view_fail.sol
new file mode 100644
index 00000000..9b00fd6d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_view_fail.sol
@@ -0,0 +1,23 @@
+contract C {
+ function f() view public {
+ address(this).transfer(1);
+ }
+ function g() view public {
+ require(address(this).send(2));
+ }
+ function h() view public {
+ selfdestruct(address(this));
+ }
+ function i() view public {
+ require(address(this).delegatecall(""));
+ }
+ function j() view public {
+ require(address(this).call(""));
+ }
+}
+// ----
+// TypeError: (52-77): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
+// TypeError: (132-153): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
+// TypeError: (201-228): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
+// TypeError: (283-313): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
+// TypeError: (369-391): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/call_internal_functions_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/call_internal_functions_fail.sol
index 22855c34..e21037bd 100644
--- a/test/libsolidity/syntaxTests/viewPureChecker/call_internal_functions_fail.sol
+++ b/test/libsolidity/syntaxTests/viewPureChecker/call_internal_functions_fail.sol
@@ -1,7 +1,10 @@
contract C {
+ uint x;
function f() pure public { g(); }
- function g() view public {}
+ function g() view public { x; }
+ function h() view public { i(); }
+ function i() public { x = 2; }
}
// ----
-// TypeError: (44-47): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
-// Warning: (55-82): Function state mutability can be restricted to pure
+// TypeError: (56-59): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
+// TypeError: (130-133): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/constant_restrict_warning.sol b/test/libsolidity/syntaxTests/viewPureChecker/constant_restrict_warning.sol
new file mode 100644
index 00000000..a4b4a353
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/constant_restrict_warning.sol
@@ -0,0 +1,12 @@
+contract C {
+ uint constant x = 2;
+ function f() view public returns (uint) {
+ return x;
+ }
+ function g() public returns (uint) {
+ return x;
+ }
+}
+// ----
+// Warning: (42-107): Function state mutability can be restricted to pure
+// Warning: (112-172): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/creation.sol b/test/libsolidity/syntaxTests/viewPureChecker/creation_no_restrict_warning.sol
index d80edd1b..d80edd1b 100644
--- a/test/libsolidity/syntaxTests/viewPureChecker/creation.sol
+++ b/test/libsolidity/syntaxTests/viewPureChecker/creation_no_restrict_warning.sol
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/creation_view_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/creation_view_fail.sol
new file mode 100644
index 00000000..08e45ea1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/creation_view_fail.sol
@@ -0,0 +1,6 @@
+contract D {}
+contract C {
+ function f() public view { new D(); }
+}
+// ----
+// TypeError: (58-65): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/function_types_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/function_types_fail.sol
new file mode 100644
index 00000000..d00f65c9
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/function_types_fail.sol
@@ -0,0 +1,18 @@
+contract C {
+ function f() pure public {
+ function () external nonpayFun;
+ nonpayFun();
+ }
+ function g() pure public {
+ function () external view viewFun;
+ viewFun();
+ }
+ function h() view public {
+ function () external nonpayFun;
+ nonpayFun();
+ }
+}
+// ----
+// TypeError: (92-103): Function declared as pure, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
+// TypeError: (193-202): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
+// TypeError: (289-300): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/local_storage_variables_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/local_storage_variables_fail.sol
new file mode 100644
index 00000000..0ff1ac24
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/local_storage_variables_fail.sol
@@ -0,0 +1,15 @@
+contract C {
+ struct S { uint a; }
+ S s;
+ function f() pure public {
+ S storage x = s;
+ x;
+ }
+ function g() view public {
+ S storage x = s;
+ x.a = 1;
+ }
+}
+// ----
+// TypeError: (100-101): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
+// TypeError: (184-187): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/modifiers_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/modifiers_fail.sol
new file mode 100644
index 00000000..513850f7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/modifiers_fail.sol
@@ -0,0 +1,12 @@
+contract D {
+ uint x;
+ modifier viewm(uint) { uint a = x; _; a; }
+ modifier nonpayablem(uint) { x = 2; _; }
+}
+contract C is D {
+ function f() viewm(0) pure public {}
+ function g() nonpayablem(0) view public {}
+}
+// ----
+// TypeError: (154-162): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
+// TypeError: (195-209): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/overriding_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/overriding_fail.sol
new file mode 100644
index 00000000..61702495
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/overriding_fail.sol
@@ -0,0 +1,16 @@
+contract D {
+ uint x;
+ function f() public view { x; }
+ function g() public pure {}
+}
+contract C1 is D {
+ function f() public {}
+ function g() public view {}
+}
+contract C2 is D {
+ function g() public {}
+}
+// ----
+// TypeError: (118-140): Overriding function changes state mutability from "view" to "nonpayable".
+// TypeError: (145-172): Overriding function changes state mutability from "pure" to "view".
+// TypeError: (198-220): Overriding function changes state mutability from "pure" to "nonpayable".
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/overriding.sol b/test/libsolidity/syntaxTests/viewPureChecker/overriding_no_restrict_warning.sol
index c82c7908..c82c7908 100644
--- a/test/libsolidity/syntaxTests/viewPureChecker/overriding.sol
+++ b/test/libsolidity/syntaxTests/viewPureChecker/overriding_no_restrict_warning.sol
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/read_storage_pure_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/read_storage_pure_fail.sol
new file mode 100644
index 00000000..785656b9
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/read_storage_pure_fail.sol
@@ -0,0 +1,8 @@
+contract C {
+ uint x;
+ function f() public pure returns (uint) {
+ return x;
+ }
+}
+// ----
+// TypeError: (86-87): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/returning_structs_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/returning_structs_fail.sol
new file mode 100644
index 00000000..e04d0825
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/returning_structs_fail.sol
@@ -0,0 +1,13 @@
+contract C {
+ struct S { uint x; }
+ S s;
+ function f() pure internal returns (S storage) {
+ return s;
+ }
+ function g() pure public {
+ f().x;
+ }
+}
+// ----
+// TypeError: (115-116): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
+// TypeError: (163-168): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/returning_structs.sol b/test/libsolidity/syntaxTests/viewPureChecker/returning_structs_no_restrict_warning.sol
index 9b4eb466..9b4eb466 100644
--- a/test/libsolidity/syntaxTests/viewPureChecker/returning_structs.sol
+++ b/test/libsolidity/syntaxTests/viewPureChecker/returning_structs_no_restrict_warning.sol
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/selector.sol b/test/libsolidity/syntaxTests/viewPureChecker/selector.sol
index 2ad4518d..c4e30075 100644
--- a/test/libsolidity/syntaxTests/viewPureChecker/selector.sol
+++ b/test/libsolidity/syntaxTests/viewPureChecker/selector.sol
@@ -5,4 +5,8 @@ contract C {
function g() pure public returns (bytes4) {
return this.f.selector ^ this.x.selector;
}
+ function h() view public returns (bytes4) {
+ x;
+ return this.f.selector ^ this.x.selector;
+ }
}
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/write_storage_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/write_storage_fail.sol
index 2a8bba31..3fed4d29 100644
--- a/test/libsolidity/syntaxTests/viewPureChecker/write_storage_fail.sol
+++ b/test/libsolidity/syntaxTests/viewPureChecker/write_storage_fail.sol
@@ -3,4 +3,4 @@ contract C {
function f() view public { x = 2; }
}
// ----
-// Warning: (56-57): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
+// TypeError: (56-57): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/write_storage_fail_v050.sol b/test/libsolidity/syntaxTests/viewPureChecker/write_storage_fail_v050.sol
deleted file mode 100644
index b85078ed..00000000
--- a/test/libsolidity/syntaxTests/viewPureChecker/write_storage_fail_v050.sol
+++ /dev/null
@@ -1,7 +0,0 @@
-pragma experimental "v0.5.0";
-contract C {
- uint x;
- function f() view public { x = 2; }
-}
-// ----
-// TypeError: (86-87): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/566_require_visibility_specifiers.sol b/test/libsolidity/syntaxTests/visibility/function_no_visibility.sol
index 7330ef8d..ecc36f04 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/566_require_visibility_specifiers.sol
+++ b/test/libsolidity/syntaxTests/visibility/function_no_visibility.sol
@@ -2,4 +2,4 @@ contract C {
function f() pure { }
}
// ----
-// Warning: (17-38): No visibility specified. Defaulting to "public".
+// Warning: (17-38): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/visibility/function_no_visibility_050.sol b/test/libsolidity/syntaxTests/visibility/function_no_visibility_050.sol
new file mode 100644
index 00000000..ec7c0937
--- /dev/null
+++ b/test/libsolidity/syntaxTests/visibility/function_no_visibility_050.sol
@@ -0,0 +1,6 @@
+pragma experimental "v0.5.0";
+contract C {
+ function f() pure { }
+}
+// ----
+// SyntaxError: (47-68): No visibility specified.