aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.editorconfig1
-rw-r--r--CODE_OF_CONDUCT.md (renamed from CONDUCT.md)0
-rw-r--r--Changelog.md8
-rw-r--r--PULL_REQUEST_TEMPLATE.md7
-rw-r--r--cmake/EthCompilerSettings.cmake16
-rw-r--r--cmake/EthPolicy.cmake28
-rw-r--r--cmake/templates/license.h.in31
-rw-r--r--docs/abi-spec.rst2
-rw-r--r--docs/assembly.rst57
-rw-r--r--docs/common-patterns.rst2
-rw-r--r--docs/contracts.rst7
-rw-r--r--docs/contributing.rst2
-rw-r--r--docs/frequently-asked-questions.rst2
-rw-r--r--docs/grammar.txt1
-rw-r--r--docs/index.rst3
-rw-r--r--docs/security-considerations.rst2
-rw-r--r--docs/solidity-by-example.rst8
-rw-r--r--docs/types.rst27
-rw-r--r--libdevcore/Algorithms.h8
-rw-r--r--libdevcore/Common.h2
-rw-r--r--libdevcore/StringUtils.cpp14
-rw-r--r--libdevcore/StringUtils.h39
-rw-r--r--libevmasm/Instruction.cpp14
-rw-r--r--libevmasm/KnownState.h14
-rw-r--r--liblll/CodeFragment.cpp10
-rw-r--r--libsolidity/analysis/ControlFlowAnalyzer.cpp10
-rw-r--r--libsolidity/analysis/DeclarationContainer.cpp10
-rw-r--r--libsolidity/analysis/PostTypeChecker.cpp5
-rw-r--r--libsolidity/analysis/ReferencesResolver.cpp4
-rw-r--r--libsolidity/analysis/TypeChecker.cpp90
-rw-r--r--libsolidity/ast/Types.cpp34
-rw-r--r--libsolidity/ast/Types.h9
-rw-r--r--libsolidity/codegen/ABIFunctions.cpp18
-rw-r--r--libsolidity/codegen/CompilerUtils.cpp17
-rw-r--r--libsolidity/codegen/ContractCompiler.cpp4
-rw-r--r--libsolidity/formal/CVC4Interface.cpp13
-rw-r--r--libsolidity/formal/SMTChecker.cpp20
-rw-r--r--libsolidity/formal/SMTLib2Interface.cpp37
-rw-r--r--libsolidity/formal/SMTLib2Interface.h3
-rw-r--r--libsolidity/formal/Z3Interface.cpp9
-rw-r--r--libsolidity/inlineasm/AsmAnalysis.cpp6
-rw-r--r--libsolidity/interface/CompilerStack.cpp14
-rw-r--r--libsolidity/interface/CompilerStack.h3
-rw-r--r--test/boostTest.cpp7
-rw-r--r--test/compilationTests/MultiSigWallet/MultiSigWalletFactory.sol2
-rw-r--r--test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimitFactory.sol2
-rw-r--r--test/compilationTests/corion/announcementTypes.sol68
-rw-r--r--test/compilationTests/corion/ico.sol80
-rw-r--r--test/compilationTests/corion/module.sol30
-rw-r--r--test/compilationTests/corion/moduleHandler.sol64
-rw-r--r--test/compilationTests/corion/multiOwner.sol4
-rw-r--r--test/compilationTests/corion/owned.sol56
-rw-r--r--test/compilationTests/corion/premium.sol88
-rw-r--r--test/compilationTests/corion/provider.sol120
-rw-r--r--test/compilationTests/corion/publisher.sol556
-rw-r--r--test/compilationTests/corion/safeMath.sol6
-rw-r--r--test/compilationTests/corion/schelling.sol98
-rw-r--r--test/compilationTests/corion/token.sol130
-rw-r--r--test/compilationTests/corion/tokenDB.sol154
-rw-r--r--test/compilationTests/gnosis/Events/Event.sol2
-rw-r--r--test/compilationTests/gnosis/Markets/Campaign.sol8
-rw-r--r--test/compilationTests/gnosis/Markets/StandardMarket.sol20
-rw-r--r--test/compilationTests/gnosis/Oracles/FutarchyOracle.sol8
-rw-r--r--test/compilationTests/gnosis/Oracles/UltimateOracle.sol4
-rw-r--r--test/compilationTests/gnosis/Tokens/OutcomeToken.sol2
-rw-r--r--test/compilationTests/milestonetracker/RLP.sol9
-rw-r--r--test/compilationTests/zeppelin/Bounty.sol16
-rw-r--r--test/compilationTests/zeppelin/LimitBalance.sol2
-rw-r--r--test/compilationTests/zeppelin/ReentrancyGuard.sol2
-rw-r--r--test/compilationTests/zeppelin/crowdsale/FinalizableCrowdsale.sol2
-rw-r--r--test/compilationTests/zeppelin/lifecycle/Destructible.sol2
-rw-r--r--test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol6
-rw-r--r--test/compilationTests/zeppelin/ownership/Claimable.sol8
-rw-r--r--test/compilationTests/zeppelin/ownership/Contactable.sol2
-rw-r--r--test/compilationTests/zeppelin/ownership/DelayedClaimable.sol10
-rw-r--r--test/compilationTests/zeppelin/ownership/HasNoContracts.sol2
-rw-r--r--test/compilationTests/zeppelin/ownership/HasNoEther.sol8
-rw-r--r--test/compilationTests/zeppelin/ownership/HasNoTokens.sol6
-rw-r--r--test/compilationTests/zeppelin/ownership/NoOwner.sol4
-rw-r--r--test/compilationTests/zeppelin/ownership/Ownable.sol10
-rw-r--r--test/compilationTests/zeppelin/ownership/Shareable.sol12
-rw-r--r--test/compilationTests/zeppelin/token/BasicToken.sol4
-rw-r--r--test/compilationTests/zeppelin/token/LimitedTransferToken.sol10
-rw-r--r--test/compilationTests/zeppelin/token/SimpleToken.sol4
-rw-r--r--test/compilationTests/zeppelin/token/TokenTimelock.sol6
-rw-r--r--test/compilationTests/zeppelin/token/VestedToken.sol2
-rw-r--r--test/libdevcore/StringUtils.cpp18
-rw-r--r--test/libsolidity/ASTJSON.cpp145
-rw-r--r--test/libsolidity/ASTJSON/array_type_name.json76
-rw-r--r--test/libsolidity/ASTJSON/array_type_name.sol1
-rw-r--r--test/libsolidity/ASTJSON/array_type_name_legacy.json89
-rw-r--r--test/libsolidity/ASTJSON/documentation.json182
-rw-r--r--test/libsolidity/ASTJSON/documentation.sol17
-rw-r--r--test/libsolidity/ASTJSON/documentation_legacy.json178
-rw-r--r--test/libsolidity/ASTJSON/enum_value.json57
-rw-r--r--test/libsolidity/ASTJSON/enum_value.sol1
-rw-r--r--test/libsolidity/ASTJSON/enum_value_legacy.json78
-rw-r--r--test/libsolidity/ASTJSON/event_definition.json50
-rw-r--r--test/libsolidity/ASTJSON/event_definition.sol1
-rw-r--r--test/libsolidity/ASTJSON/event_definition_legacy.json74
-rw-r--r--test/libsolidity/ASTJSON/function_type.json230
-rw-r--r--test/libsolidity/ASTJSON/function_type.sol1
-rw-r--r--test/libsolidity/ASTJSON/function_type_legacy.json271
-rw-r--r--test/libsolidity/ASTJSON/inheritance_specifier.json80
-rw-r--r--test/libsolidity/ASTJSON/inheritance_specifier.sol1
-rw-r--r--test/libsolidity/ASTJSON/inheritance_specifier_legacy.json105
-rw-r--r--test/libsolidity/ASTJSON/long_type_name_binary_operation.json177
-rw-r--r--test/libsolidity/ASTJSON/long_type_name_binary_operation.sol1
-rw-r--r--test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json209
-rw-r--r--test/libsolidity/ASTJSON/long_type_name_identifier.json183
-rw-r--r--test/libsolidity/ASTJSON/long_type_name_identifier.sol1
-rw-r--r--test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json221
-rw-r--r--test/libsolidity/ASTJSON/modifier_definition.json176
-rw-r--r--test/libsolidity/ASTJSON/modifier_definition.sol1
-rw-r--r--test/libsolidity/ASTJSON/modifier_definition_legacy.json213
-rw-r--r--test/libsolidity/ASTJSON/modifier_invocation.json176
-rw-r--r--test/libsolidity/ASTJSON/modifier_invocation.sol1
-rw-r--r--test/libsolidity/ASTJSON/modifier_invocation_legacy.json213
-rw-r--r--test/libsolidity/ASTJSON/non_utf8.json124
-rw-r--r--test/libsolidity/ASTJSON/non_utf8.sol1
-rw-r--r--test/libsolidity/ASTJSON/non_utf8_legacy.json157
-rw-r--r--test/libsolidity/ASTJSON/placeholder_statement.json64
-rw-r--r--test/libsolidity/ASTJSON/placeholder_statement.sol1
-rw-r--r--test/libsolidity/ASTJSON/placeholder_statement_legacy.json87
-rw-r--r--test/libsolidity/ASTJSON/short_type_name.json128
-rw-r--r--test/libsolidity/ASTJSON/short_type_name.sol1
-rw-r--r--test/libsolidity/ASTJSON/short_type_name_legacy.json164
-rw-r--r--test/libsolidity/ASTJSON/short_type_name_ref.json140
-rw-r--r--test/libsolidity/ASTJSON/short_type_name_ref.sol1
-rw-r--r--test/libsolidity/ASTJSON/short_type_name_ref_legacy.json177
-rw-r--r--test/libsolidity/ASTJSON/smoke.json33
-rw-r--r--test/libsolidity/ASTJSON/smoke.sol1
-rw-r--r--test/libsolidity/ASTJSON/smoke_legacy.json48
-rw-r--r--test/libsolidity/ASTJSON/source_location.json162
-rw-r--r--test/libsolidity/ASTJSON/source_location.sol1
-rw-r--r--test/libsolidity/ASTJSON/source_location_legacy.json200
-rw-r--r--test/libsolidity/ASTJSON/using_for_directive.json87
-rw-r--r--test/libsolidity/ASTJSON/using_for_directive.sol1
-rw-r--r--test/libsolidity/ASTJSON/using_for_directive_legacy.json110
-rw-r--r--test/libsolidity/ASTJSONTest.cpp201
-rw-r--r--test/libsolidity/ASTJSONTest.h58
-rw-r--r--test/libsolidity/ASTLegacyJSON.cpp324
-rw-r--r--test/libsolidity/SMTChecker.cpp2
-rw-r--r--test/libsolidity/SolidityABIJSON.cpp3
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp154
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp10
-rw-r--r--test/libsolidity/SolidityOptimizer.cpp6
-rw-r--r--test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol4
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_err.sol10
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_fine.sol4
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_warn.sol10
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_err.sol52
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol52
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_err.sol14
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_fine.sol1
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_warn.sol15
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/for_err.sol16
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/for_warn.sol16
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/if_err.sol18
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/if_warn.sol18
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_err.sol22
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_warn.sol22
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_err.sol18
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_warn.sol18
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_err.sol13
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_warn.sol13
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/while_err.sol11
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/while_warn.sol11
-rw-r--r--test/libsolidity/syntaxTests/emit/emit_empty.sol (renamed from test/libsolidity/syntaxTests/emit_empty.sol)0
-rw-r--r--test/libsolidity/syntaxTests/emit/emit_non_event.sol (renamed from test/libsolidity/syntaxTests/emit_non_event.sol)0
-rw-r--r--test/libsolidity/syntaxTests/events/event_nested_array.sol5
-rw-r--r--test/libsolidity/syntaxTests/events/event_nested_array_2.sol4
-rw-r--r--test/libsolidity/syntaxTests/events/event_nested_array_in_struct.sol6
-rw-r--r--test/libsolidity/syntaxTests/events/event_struct.sol6
-rw-r--r--test/libsolidity/syntaxTests/events/event_struct_indexed.sol6
-rw-r--r--test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol2
-rw-r--r--test/libsolidity/syntaxTests/inheritance/modifiers_in_constructor_context.sol9
-rw-r--r--test/libsolidity/syntaxTests/inheritance/override/function_state_variable.sol2
-rw-r--r--test/libsolidity/syntaxTests/inheritance/override/state_variable_function.sol8
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol4
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol4
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol4
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol6
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol2
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol6
-rw-r--r--test/libsolidity/syntaxTests/multiVariableDeclaration/multiSingleVariableDeclaration.sol2
-rw-r--r--test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalidType.sol2
-rw-r--r--test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol2
-rw-r--r--test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol2
-rw-r--r--test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationThatIsExpression.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_1.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_2.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_3.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol12
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol1
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/570_function_type_undeclared_type.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/571_function_type_undeclared_type_external.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/572_function_type_undeclared_type_multi_nested.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol4
-rw-r--r--test/libsolidity/syntaxTests/parsing/tuples_decl_without_rhs.sol7
-rw-r--r--test/libsolidity/syntaxTests/scoping/function_state_variable_conflict.sol6
-rw-r--r--test/libsolidity/syntaxTests/scoping/state_variable_function_conflict.sol6
-rw-r--r--test/libsolidity/syntaxTests/scoping/state_variable_function_conflict_former_crash.sol14
-rw-r--r--test/libsolidity/syntaxTests/types/address_to_contract.sol6
-rw-r--r--test/libsolidity/syntaxTests/types/address_to_contract_implicitly.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/contract_to_address.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/contract_to_address_implicitly.sol8
-rw-r--r--test/libsolidity/syntaxTests/types/contract_to_base.sol9
-rw-r--r--test/libsolidity/syntaxTests/types/contract_to_base_base.sol10
-rw-r--r--test/libsolidity/syntaxTests/types/contract_to_derived.sol9
-rw-r--r--test/libsolidity/syntaxTests/types/contract_to_unrelated_contract.sol9
-rw-r--r--test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_exhausted.sol262
-rw-r--r--test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_good.sol135
-rw-r--r--test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_exhausted.sol260
-rw-r--r--test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_good.sol134
-rw-r--r--test/libsolidity/syntaxTests/types/empty_tuple_event.sol3
-rw-r--r--test/libsolidity/syntaxTests/types/empty_tuple_function.sol5
-rw-r--r--test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol3
-rw-r--r--test/libsolidity/syntaxTests/types/unnamed_tuple_decl.sol8
-rw-r--r--test/libsolidity/syntaxTests/types/var_empty_decl_0.sol9
-rw-r--r--test/libsolidity/syntaxTests/types/var_empty_decl_1.sol8
-rw-r--r--test/libsolidity/syntaxTests/types/var_empty_decl_2.sol9
-rw-r--r--test/libsolidity/syntaxTests/types/var_empty_decl_3.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/var_type_suggest.sol12
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol7
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol8
-rw-r--r--test/tools/CMakeLists.txt2
-rw-r--r--test/tools/isoltest.cpp38
239 files changed, 7505 insertions, 1977 deletions
diff --git a/.editorconfig b/.editorconfig
index 86a837c1..7b8a7be9 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -8,6 +8,7 @@ trim_trailing_whitespace = true
[*.{cpp,h}]
indent_style = tab
+indent_size = 4
[*.{py,rst,sh,yml}]
indent_style = space
diff --git a/CONDUCT.md b/CODE_OF_CONDUCT.md
index 36813f36..36813f36 100644
--- a/CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
diff --git a/Changelog.md b/Changelog.md
index 2953c86b..856ea1ca 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -17,6 +17,7 @@ Breaking Changes:
* Commandline interface: Remove obsolete ``--formal`` option.
* Commandline interface: Rename the ``--julia`` option to ``--yul``.
* Commandline interface: Require ``-`` if standard input is used as source.
+ * Control Flow Analyzer: Turn warning about returning uninitialized storage pointers into an error.
* 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.
@@ -32,6 +33,7 @@ Breaking Changes:
* General: Remove assembly instruction aliases ``sha3`` and ``suicide``
* General: C99-style scoping rules are enforced now. This was already the case in the experimental 0.5.0 mode.
* General: Disallow combining hex numbers with unit denominations (e.g. ``0x1e wei``). This was already the case in the experimental 0.5.0 mode.
+ * Name Resolver: Do not exclude public state variables when looking for conflicting declarations.
* 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.
@@ -39,16 +41,20 @@ Breaking Changes:
* 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 tight packing of literals. This was already the case in the experimental 0.5.0 mode.
+ * Type Checker: Disallow calling base constructors without parentheses. This was already the case in the experimental 0.5.0 mode.
* Type Checker: Disallow conversions between ``bytesX`` and ``uintY`` of different size.
+ * Type Checker: Disallow conversions between unrelated contract types. Explicit conversion via ``address`` can still achieve it.
* Type Checker: Disallow empty tuple components. This was partly already the case in the experimental 0.5.0 mode.
* Type Checker: Disallow multi-variable declarations with mismatching number of values. This was already the case in the experimental 0.5.0 mode.
* 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: Disallow calling constructor with wrong argument count. This was already the case in the experimental 0.5.0 mode.
* Type Checker: Disallow uninitialized storage variables. This was already the case in the experimental 0.5.0 mode.
+ * Type Checker: Detecting cyclic dependencies in variables and structs is limited in recursion to 256.
* Type Checker: Only accept a single ``bytes`` type for ``.call()`` (and family), ``keccak256()``, ``sha256()`` and ``ripemd160()``.
* Type Checker: Fallback function must be external. This was already the case in the experimental 0.5.0 mode.
* Type Checker: Interface functions must be declared external. This was already the case in the experimental 0.5.0 mode.
* Type Checker: Address members are not included in contract types anymore. An explicit conversion is now required before invoking an ``address`` member from a contract.
+ * Type Checker: Disallow "loose assembly" syntax entirely. This means that jump labels, jumps and non-functional instructions cannot be used anymore.
* 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.
* References Resolver: Turn missing storage locations into an error. This was already the case in the experimental 0.5.0 mode.
* Syntax Checker: Disallow functions without implementation to use modifiers. This was already the case in the experimental 0.5.0 mode.
@@ -73,7 +79,9 @@ Bugfixes:
* Code Generator: Fix allocation of byte arrays (zeroed out too much memory).
* Fix NatSpec json output for `@notice` and `@dev` tags on contract definitions.
* References Resolver: Enforce ``storage`` as data location for mappings.
+ * References Resolver: Report error instead of assertion fail when FunctionType has an undeclared type as parameter.
* Type Checker: Consider fixed size arrays when checking for recursive structs.
+ * Type Checker: Report error when using structs in events without experimental ABIEncoderV2. This used to crash or log the wrong values.
* Type System: Allow arbitrary exponents for literals with a mantissa of zero.
### 0.4.24 (2018-05-16)
diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md
index 43f82f50..6f544bc1 100644
--- a/PULL_REQUEST_TEMPLATE.md
+++ b/PULL_REQUEST_TEMPLATE.md
@@ -6,9 +6,10 @@ Please also note that this project is released with a [Contributor Code of Condu
### Checklist
- [ ] Code compiles correctly
-- [ ] All tests passing
-- [ ] Created tests which fail without the change (if possible)
-- [ ] Extended the README / documentation, if necessary
+- [ ] All tests are passing
+- [ ] New tests have been created which fail without the change (if possible)
+- [ ] README / documentation was extended, if necessary
+- [ ] Changelog entry (if change is visible to the user)
- [ ] Used meaningful commit messages
### Description
diff --git a/cmake/EthCompilerSettings.cmake b/cmake/EthCompilerSettings.cmake
index ee8cb1b3..b0786ce2 100644
--- a/cmake/EthCompilerSettings.cmake
+++ b/cmake/EthCompilerSettings.cmake
@@ -36,13 +36,6 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
add_compile_options(-Wextra)
add_compile_options(-Werror)
- # Disable warnings about unknown pragmas (which is enabled by -Wall). I assume we have external
- # dependencies (probably Boost) which have some of these. Whatever the case, we shouldn't be
- # disabling these globally. Instead, we should pragma around just the problem #includes.
- #
- # TODO - Track down what breaks if we do NOT do this.
- add_compile_options(-Wno-unknown-pragmas)
-
# Configuration-specific compiler settings.
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DETH_DEBUG")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
@@ -73,13 +66,13 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
# TODO - Is this even necessary? Why?
# See http://stackoverflow.com/questions/19774778/when-is-it-necessary-to-use-use-the-flag-stdlib-libstdc.
add_compile_options(-stdlib=libstdc++)
-
+
# Tell Boost that we're using Clang's libc++. Not sure exactly why we need to do.
add_definitions(-DBOOST_ASIO_HAS_CLANG_LIBCXX)
-
+
# Use fancy colors in the compiler diagnostics
add_compile_options(-fcolor-diagnostics)
-
+
# See "How to silence unused command line argument error with clang without disabling it?"
# When using -Werror with clang, it transforms "warning: argument unused during compilation" messages
# into errors, which makes sense.
@@ -146,9 +139,6 @@ endif ()
if (SANITIZE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=${SANITIZE}")
- if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-blacklist=${CMAKE_SOURCE_DIR}/sanitizer-blacklist.txt")
- endif()
endif()
# Code coverage support.
diff --git a/cmake/EthPolicy.cmake b/cmake/EthPolicy.cmake
index 31b09f15..4e29898c 100644
--- a/cmake/EthPolicy.cmake
+++ b/cmake/EthPolicy.cmake
@@ -4,32 +4,16 @@ macro (eth_policy)
# link_directories() treats paths relative to the source dir.
cmake_policy(SET CMP0015 NEW)
- # let cmake autolink dependencies on windows
- cmake_policy(SET CMP0020 NEW)
+ # Avoid warnings in CMake 3.0.2:
+ cmake_policy(SET CMP0042 NEW)
+ cmake_policy(SET CMP0043 NEW)
- # CMake 2.8.12 and lower allowed the use of targets and files with double
- # colons in target_link_libraries,
- cmake_policy(SET CMP0028 OLD)
+ # allow VERSION argument in project()
+ cmake_policy(SET CMP0048 NEW)
- if (${CMAKE_VERSION} VERSION_GREATER 3.0)
-
- # fix MACOSX_RPATH
- cmake_policy(SET CMP0042 OLD)
-
- # ignore COMPILE_DEFINITIONS_<Config> properties
- cmake_policy(SET CMP0043 OLD)
-
- # allow VERSION argument in project()
- cmake_policy(SET CMP0048 NEW)
-
- endif()
-
- if (${CMAKE_VERSION} VERSION_GREATER 3.1)
-
+ if (POLICY CMP0054)
# do not interpret if() arguments as variables!
cmake_policy(SET CMP0054 NEW)
-
endif()
-
endmacro()
diff --git a/cmake/templates/license.h.in b/cmake/templates/license.h.in
index 84524a52..4f22d8f4 100644
--- a/cmake/templates/license.h.in
+++ b/cmake/templates/license.h.in
@@ -66,6 +66,37 @@ jsoncpp:
Public Domain "license" you can re-license your copy using whatever
license you like.
+scanner/token:
+ The libsolidity/parsing/{scanner,token}.{h,cpp} files are dervied from
+ code originating from the V8 project licensed under the following terms:
+
+ Copyright 2006-2012, the V8 project authors. All rights reserved.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of Google Inc. nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
All other code is licensed under GPL version 3:
)"};
diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst
index 82c9f67a..ec84d123 100644
--- a/docs/abi-spec.rst
+++ b/docs/abi-spec.rst
@@ -391,7 +391,7 @@ In effect, a log entry using this ABI is described as:
- ``topics[n]``: ``EVENT_INDEXED_ARGS[n - 1]`` (``EVENT_INDEXED_ARGS`` is the series of ``EVENT_ARGS`` that are indexed);
- ``data``: ``abi_serialise(EVENT_NON_INDEXED_ARGS)`` (``EVENT_NON_INDEXED_ARGS`` is the series of ``EVENT_ARGS`` that are not indexed, ``abi_serialise`` is the ABI serialisation function used for returning a series of typed values from a function, as described above).
-For all fixed-length Solidity types, the ``EVENT_INDEXED_ARGS`` array contains the 32-byte encoded value directly. However, for *types of dynamic length*, which include ``string``, ``bytes``, and arrays, ``EVENT_INDEXED_ARGS`` will contain the *Keccak hash* of the encoded value, rather than the encoded value directly. This allows applications to efficiently query for values of dynamic-length types (by setting the hash of the encoded value as the topic), but leaves applications unable to decode indexed values they have not queried for. For dynamic-length types, application developers face a trade-off between fast search for predetermined values (if the argument is indexed) and legibility of arbitrary values (which requires that the arguments not be indexed). Developers may overcome this tradeoff and achieve both efficient search and arbitrary legibility by defining events with two arguments — one indexed, one not — intended to hold the same value.
+For all fixed-length Solidity types, the ``EVENT_INDEXED_ARGS`` array contains the 32-byte encoded value directly. However, for *types of dynamic length*, which include ``string``, ``bytes``, and arrays, ``EVENT_INDEXED_ARGS`` will contain the *Keccak hash* of the packed encoded value (see :ref:`abi_packed_mode`), rather than the encoded value directly. This allows applications to efficiently query for values of dynamic-length types (by setting the hash of the encoded value as the topic), but leaves applications unable to decode indexed values they have not queried for. For dynamic-length types, application developers face a trade-off between fast search for predetermined values (if the argument is indexed) and legibility of arbitrary values (which requires that the arguments not be indexed). Developers may overcome this tradeoff and achieve both efficient search and arbitrary legibility by defining events with two arguments — one indexed, one not — intended to hold the same value.
.. _abi_json:
diff --git a/docs/assembly.rst b/docs/assembly.rst
index ec6ac876..5041e72c 100644
--- a/docs/assembly.rst
+++ b/docs/assembly.rst
@@ -21,10 +21,9 @@ often hard to address the correct stack slot and provide arguments to opcodes at
point on the stack. Solidity's inline assembly tries to facilitate that and other issues
arising when writing manual assembly by the following features:
-* functional-style opcodes: ``mul(1, add(2, 3))`` instead of ``push1 3 push1 2 add push1 1 mul``
+* functional-style opcodes: ``mul(1, add(2, 3))``
* assembly-local variables: ``let x := add(2, 3) let y := mload(0x40) x := add(x, y)``
* access to external variables: ``function f(uint x) public { assembly { x := sub(x, 1) } }``
-* labels: ``let x := 10 repeat: x := sub(x, 1) jumpi(repeat, eq(x, 0))``
* loops: ``for { let i := 0 } lt(i, x) { i := add(i, 1) } { y := mul(2, y) }``
* if statements: ``if slt(x, 0) { x := sub(0, x) }``
* switch statements: ``switch x case 0 { y := mul(x, 2) } default { y := 0 }``
@@ -134,7 +133,6 @@ usual ``//`` and ``/* */`` comments. Inline assembly is marked by ``assembly { .
these curly braces, the following can be used (see the later sections for more details)
- literals, i.e. ``0x123``, ``42`` or ``"abc"`` (strings up to 32 characters)
- - opcodes (in "instruction style"), e.g. ``mload sload dup1 sstore``, for a list see below
- opcodes in functional style, e.g. ``add(1, mlod(0))``
- labels, e.g. ``name:``
- variable declarations, e.g. ``let x := 7``, ``let x := add(y, 3)`` or ``let x`` (initial value of empty (0) is assigned)
@@ -416,57 +414,8 @@ changes during the call, and thus references to local variables will be wrong.
Labels
------
-.. note::
- Labels are deprecated. Please use functions, loops, if or switch statements instead.
-
-Another problem in EVM assembly is that ``jump`` and ``jumpi`` use absolute addresses
-which can change easily. Solidity inline assembly provides labels to make the use of
-jumps easier. Note that labels are a low-level feature and it is possible to write
-efficient assembly without labels, just using assembly functions, loops, if and switch instructions
-(see below). The following code computes an element in the Fibonacci series.
-
-.. code::
-
- {
- let n := calldataload(4)
- let a := 1
- let b := a
- loop:
- jumpi(loopend, eq(n, 0))
- a add swap1
- n := sub(n, 1)
- jump(loop)
- loopend:
- mstore(0, a)
- return(0, 0x20)
- }
-
-Please note that automatically accessing stack variables can only work if the
-assembler knows the current stack height. This fails to work if the jump source
-and target have different stack heights. It is still fine to use such jumps, but
-you should just not access any stack variables (even assembly variables) in that case.
-
-Furthermore, the stack height analyser goes through the code opcode by opcode
-(and not according to control flow), so in the following case, the assembler
-will have a wrong impression about the stack height at label ``two``:
-
-.. code::
-
- {
- let x := 8
- jump(two)
- one:
- // Here the stack height is 2 (because we pushed x and 7),
- // but the assembler thinks it is 1 because it reads
- // from top to bottom.
- // Accessing the stack variable x here will lead to errors.
- x := 9
- jump(three)
- two:
- 7 // push something onto the stack
- jump(one)
- three:
- }
+Support for labels has been removed in version 0.5.0 of Solidity.
+Please use functions, loops, if or switch statements instead.
Declaring Assembly-Local Variables
----------------------------------
diff --git a/docs/common-patterns.rst b/docs/common-patterns.rst
index 7c38b0e7..bc8286b2 100644
--- a/docs/common-patterns.rst
+++ b/docs/common-patterns.rst
@@ -93,7 +93,7 @@ Notice that, in this example, an attacker could trap the
contract into an unusable state by causing ``richest`` to be
the address of a contract that has a fallback function
which fails (e.g. by using ``revert()`` or by just
-consuming more than the 2300 gas stipend). That way,
+consuming more than the 2300 gas stipend transferred to them). That way,
whenever ``transfer`` is called to deliver funds to the
"poisoned" contract, it will fail and thus also ``becomeRichest``
will fail, with the contract being stuck forever.
diff --git a/docs/contracts.rst b/docs/contracts.rst
index e78c3ff7..2149167b 100644
--- a/docs/contracts.rst
+++ b/docs/contracts.rst
@@ -1,5 +1,7 @@
.. index:: ! contract
+.. _contracts:
+
##########
Contracts
##########
@@ -561,7 +563,10 @@ Ether (without data). Additionally, in order to receive Ether, the fallback func
must be marked ``payable``. If no such function exists, the contract cannot receive
Ether through regular transactions.
-In the worst case, the fallback function can only rely on 2300 gas being available (for example when send or transfer is used), leaving not much room to perform other operations except basic logging. The following operations will consume more gas than the 2300 gas stipend:
+In the worst case, the fallback function can only rely on 2300 gas being
+available (for example when `send` or `transfer` is used), leaving little
+room to perform other operations except basic logging. The following operations
+will consume more gas than the 2300 gas stipend:
- Writing to storage
- Creating a contract
diff --git a/docs/contributing.rst b/docs/contributing.rst
index 155b4e65..160e73b3 100644
--- a/docs/contributing.rst
+++ b/docs/contributing.rst
@@ -63,7 +63,7 @@ for this project. Also, even though we do CI testing, please test your code and
ensure that it builds locally before submitting a pull request.
Please note that this project is released with a `Contributor Code of Conduct
-<https://raw.githubusercontent.com/ethereum/solidity/develop/CONDUCT.md>`_.
+<https://raw.githubusercontent.com/ethereum/solidity/develop/CODE_OF_CONDUCT.md>`_.
By participating in this project you agree to abide by its terms.
Thank you for your help!
diff --git a/docs/frequently-asked-questions.rst b/docs/frequently-asked-questions.rst
index cb46dea6..c2df0d3a 100644
--- a/docs/frequently-asked-questions.rst
+++ b/docs/frequently-asked-questions.rst
@@ -379,7 +379,7 @@ In this example::
}
contract A {
- address child;
+ B child;
function test() public {
child = (new B).value(10)(); //construct a new B with 10 wei
diff --git a/docs/grammar.txt b/docs/grammar.txt
index 8e91a7d6..809fcffc 100644
--- a/docs/grammar.txt
+++ b/docs/grammar.txt
@@ -79,7 +79,6 @@ Return = 'return' Expression?
Throw = 'throw'
EmitStatement = 'emit' FunctionCall
VariableDefinition = (VariableDeclaration | '(' VariableDeclaration? (',' VariableDeclaration? )* ')' ) ( '=' Expression )?
-IdentifierList = '(' ( Identifier? ',' )* Identifier? ')'
// Precedence by order (see github.com/ethereum/solidity/pull/732)
Expression
diff --git a/docs/index.rst b/docs/index.rst
index 75af4827..af27d534 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -125,6 +125,9 @@ Solidity Tools
* `evmdis <https://github.com/Arachnid/evmdis>`_
EVM Disassembler that performs static analysis on the bytecode to provide a higher level of abstraction than raw EVM operations.
+* `ABI to solidity interface converter <https://gist.github.com/chriseth/8f533d133fa0c15b0d6eaf3ec502c82b>`_
+ A script for generating contract interfaces from the ABI of a smart contract.
+
.. note::
Information like variable names, comments, and source code formatting is lost in the compilation process and it is not possible to completely recover the original source code. Decompiling smart contracts to view the original source code might not be possible, or the end result that useful.
diff --git a/docs/security-considerations.rst b/docs/security-considerations.rst
index b997466b..5bb3d81d 100644
--- a/docs/security-considerations.rst
+++ b/docs/security-considerations.rst
@@ -135,7 +135,7 @@ Sending and Receiving Ether
- If a contract receives Ether (without a function being called), the fallback function is executed.
If it does not have a fallback function, the Ether will be rejected (by throwing an exception).
During the execution of the fallback function, the contract can only rely
- on the "gas stipend" (2300 gas) being available to it at that time. This stipend is not enough to access storage in any way.
+ on the "gas stipend" it is passed (2300 gas) being available to it at that time. This stipend is not enough to access storage in any way.
To be sure that your contract can receive Ether in that way, check the gas requirements of the fallback function
(for example in the "details" section in Remix).
diff --git a/docs/solidity-by-example.rst b/docs/solidity-by-example.rst
index 3934d29d..3f054297 100644
--- a/docs/solidity-by-example.rst
+++ b/docs/solidity-by-example.rst
@@ -232,7 +232,7 @@ activate themselves.
// absolute unix timestamps (seconds since 1970-01-01)
// or time periods in seconds.
address public beneficiary;
- uint public auctionEnd;
+ uint public auctionEndTime;
// Current state of the auction.
address public highestBidder;
@@ -261,7 +261,7 @@ activate themselves.
address _beneficiary
) public {
beneficiary = _beneficiary;
- auctionEnd = now + _biddingTime;
+ auctionEndTime = now + _biddingTime;
}
/// Bid on the auction with the value sent
@@ -278,7 +278,7 @@ activate themselves.
// Revert the call if the bidding
// period is over.
require(
- now <= auctionEnd,
+ now <= auctionEndTime,
"Auction already ended."
);
@@ -337,7 +337,7 @@ activate themselves.
// external contracts.
// 1. Conditions
- require(now >= auctionEnd, "Auction not yet ended.");
+ require(now >= auctionEndTime, "Auction not yet ended.");
require(!ended, "auctionEnd has already been called.");
// 2. Effects
diff --git a/docs/types.rst b/docs/types.rst
index d6767b54..fbc83972 100644
--- a/docs/types.rst
+++ b/docs/types.rst
@@ -104,6 +104,14 @@ Operators:
* ``<=``, ``<``, ``==``, ``!=``, ``>=`` and ``>``
+.. warning::
+ If you convert a type that uses a larger byte size to an ``address``, for example ``bytes32``, then the ``address`` is truncated.
+ To reduce conversion ambiguity version 0.4.24 and higher of the compiler force you make the truncation explicit in the conversion.
+ Take for example the address ``0x111122223333444455556666777788889999AAAABBBBCCCCDDDDEEEEFFFFCCCC``.
+
+ You can use ``address(uint160(bytes20(b)))``, which results in ``0x111122223333444455556666777788889999aAaa``,
+ or you can use ``address(uint160(uint256(b)))``, which results in ``0x777788889999AaAAbBbbCcccddDdeeeEfFFfCcCc``.
+
.. note::
Starting with version 0.5.0 contracts do not derive from the address type, but can still be explicitly converted to address.
@@ -192,6 +200,23 @@ The ``.gas()`` option is available on all three methods, while the ``.value()``
.. note::
The use of ``callcode`` is discouraged and will be removed in the future.
+Contract Types
+--------------
+
+Every :ref:`contract<contracts>` defines its own type. Contracts can be implicitly converted
+to contracts they inherit from. They can be explicitly converted from and to ``address`` types.
+
+The data representation of a contract is identical to that of the ``address`` type and
+this type is also used in the :ref:`ABI<ABI>`.
+
+Contracts do not support any operators.
+
+The members of contract types are the external functions of the contract including
+public state variables.
+
+.. note::
+ Starting with version 0.5.0 contracts do not derive from the address type, but can still be explicitly converted to address.
+
.. index:: byte array, bytes32
@@ -884,7 +909,7 @@ for each ``_KeyType``, recursively.
function f() public returns (uint) {
MappingExample m = new MappingExample();
m.update(100);
- return m.balances(this);
+ return m.balances(address(this));
}
}
diff --git a/libdevcore/Algorithms.h b/libdevcore/Algorithms.h
index b2540668..7fe2472d 100644
--- a/libdevcore/Algorithms.h
+++ b/libdevcore/Algorithms.h
@@ -32,11 +32,13 @@ template <typename V>
class CycleDetector
{
public:
+ using Visitor = std::function<void(V const&, CycleDetector&, size_t)>;
+
/// Initializes the cycle detector
/// @param _visit function that is given the current vertex
/// and is supposed to call @a run on all
/// adjacent vertices.
- explicit CycleDetector(std::function<void(V const&, CycleDetector&)> _visit):
+ explicit CycleDetector(Visitor _visit):
m_visit(std::move(_visit))
{ }
@@ -55,7 +57,7 @@ public:
m_processing.insert(&_vertex);
m_depth++;
- m_visit(_vertex, *this);
+ m_visit(_vertex, *this, m_depth);
m_depth--;
if (m_firstCycleVertex && m_depth == 1)
m_firstCycleVertex = &_vertex;
@@ -66,7 +68,7 @@ public:
}
private:
- std::function<void(V const&, CycleDetector&)> m_visit;
+ Visitor m_visit;
std::set<V const*> m_processing;
std::set<V const*> m_processed;
size_t m_depth = 0;
diff --git a/libdevcore/Common.h b/libdevcore/Common.h
index 2543855d..0363d9a2 100644
--- a/libdevcore/Common.h
+++ b/libdevcore/Common.h
@@ -40,7 +40,6 @@
#include <libdevcore/vector_ref.h>
#if defined(__GNUC__)
-#pragma warning(push)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif // defined(__GNUC__)
@@ -57,7 +56,6 @@
#include <boost/multiprecision/cpp_int.hpp>
#if defined(__GNUC__)
-#pragma warning(pop)
#pragma GCC diagnostic pop
#endif // defined(__GNUC__)
diff --git a/libdevcore/StringUtils.cpp b/libdevcore/StringUtils.cpp
index 2ff86bd5..01bdc675 100644
--- a/libdevcore/StringUtils.cpp
+++ b/libdevcore/StringUtils.cpp
@@ -85,17 +85,11 @@ size_t dev::stringDistance(string const& _str1, string const& _str2)
string dev::quotedAlternativesList(vector<string> const& suggestions)
{
- if (suggestions.empty())
- return "";
- if (suggestions.size() == 1)
- return "\"" + suggestions.front() + "\"";
+ vector<string> quotedSuggestions;
- string choices = "\"" + suggestions.front() + "\"";
- for (size_t i = 1; i + 1 < suggestions.size(); ++i)
- choices += ", \"" + suggestions[i] + "\"";
+ for (auto& suggestion: suggestions)
+ quotedSuggestions.push_back("\"" + suggestion + "\"");
- choices += " or \"" + suggestions.back() + "\"";
-
- return choices;
+ return joinHumanReadable(quotedSuggestions, ", ", " or ");
}
diff --git a/libdevcore/StringUtils.h b/libdevcore/StringUtils.h
index acd93e32..4fb5a748 100644
--- a/libdevcore/StringUtils.h
+++ b/libdevcore/StringUtils.h
@@ -36,4 +36,43 @@ size_t stringDistance(std::string const& _str1, std::string const& _str2);
// Return a string having elements of suggestions as quoted, alternative suggestions. e.g. "a", "b" or "c"
std::string quotedAlternativesList(std::vector<std::string> const& suggestions);
+/// Joins collection of strings into one string with separators between, last separator can be different.
+/// @param _list collection of strings to join
+/// @param _separator defaults to ", "
+/// @param _lastSeparator (optional) will be used to separate last two strings instead of _separator
+/// @example join(vector<string>{"a", "b", "c"}, "; ", " or ") == "a; b or c"
+template<class T>
+std::string joinHumanReadable
+(
+ T const& _list,
+ std::string const& _separator = ", ",
+ std::string const& _lastSeparator = ""
+)
+{
+ auto it = begin(_list);
+ auto itEnd = end(_list);
+
+ std::string result;
+
+ // append first string
+ if (it != itEnd)
+ {
+ result += *it;
+ ++it;
+ }
+
+ for (;it != itEnd; ++it)
+ {
+ if ((next(it) == itEnd) && !_lastSeparator.empty())
+ result += _lastSeparator; // last iteration
+ else
+ result += _separator;
+
+ // append string
+ result += *it;
+ }
+
+ return result;
+}
+
}
diff --git a/libevmasm/Instruction.cpp b/libevmasm/Instruction.cpp
index f9bbad2c..37c5fdd4 100644
--- a/libevmasm/Instruction.cpp
+++ b/libevmasm/Instruction.cpp
@@ -21,6 +21,7 @@
#include "./Instruction.h"
+#include <algorithm>
#include <functional>
#include <libdevcore/Common.h>
#include <libdevcore/CommonIO.h>
@@ -325,13 +326,20 @@ void dev::solidity::eachInstruction(
size_t additional = 0;
if (isValidInstruction(instr))
additional = instructionInfo(instr).additional;
+
u256 data;
- for (size_t i = 0; i < additional; ++i)
+
+ // fill the data with the additional data bytes from the instruction stream
+ while (additional > 0 && next(it) < _mem.end())
{
data <<= 8;
- if (++it < _mem.end())
- data |= *it;
+ data |= *++it;
+ --additional;
}
+
+ // pad the remaining number of additional octets with zeros
+ data <<= 8 * additional;
+
_onInstruction(instr, data);
}
}
diff --git a/libevmasm/KnownState.h b/libevmasm/KnownState.h
index 8568b163..cd50550e 100644
--- a/libevmasm/KnownState.h
+++ b/libevmasm/KnownState.h
@@ -29,12 +29,18 @@
#include <tuple>
#include <memory>
#include <ostream>
-#pragma warning(push)
-#pragma GCC diagnostic push
+
+#if defined(__clang__)
+#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wredeclared-class-member"
+#endif // defined(__clang__)
+
#include <boost/bimap.hpp>
-#pragma warning(pop)
-#pragma GCC diagnostic pop
+
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif // defined(__clang__)
+
#include <libdevcore/CommonIO.h>
#include <libdevcore/Exceptions.h>
#include <libevmasm/ExpressionClasses.h>
diff --git a/liblll/CodeFragment.cpp b/liblll/CodeFragment.cpp
index 3e82889a..0aef05a9 100644
--- a/liblll/CodeFragment.cpp
+++ b/liblll/CodeFragment.cpp
@@ -22,12 +22,18 @@
#include "CodeFragment.h"
#include <boost/algorithm/string.hpp>
-#pragma warning(push)
+
+#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif // defined(__GNUC__)
+
#include <boost/spirit/include/support_utree.hpp>
-#pragma warning(pop)
+
+#if defined(__GNUC__)
#pragma GCC diagnostic pop
+#endif // defined(__GNUC__)
+
#include <libdevcore/CommonIO.h>
#include <libevmasm/Instruction.h>
#include "CompilerState.h"
diff --git a/libsolidity/analysis/ControlFlowAnalyzer.cpp b/libsolidity/analysis/ControlFlowAnalyzer.cpp
index 6edf7986..483d08c8 100644
--- a/libsolidity/analysis/ControlFlowAnalyzer.cpp
+++ b/libsolidity/analysis/ControlFlowAnalyzer.cpp
@@ -144,12 +144,12 @@ void ControlFlowAnalyzer::checkUnassignedStorageReturnValues(
ssl.append("Problematic end of function:", _function.location());
}
- m_errorReporter.warning(
+ m_errorReporter.typeError(
returnVal->location(),
- "This variable is of storage pointer type and might be returned without assignment. "
- "This can cause storage corruption. Assign the variable (potentially from itself) "
- "to remove this warning.",
- ssl
+ ssl,
+ "This variable is of storage pointer type and might be returned without assignment and "
+ "could be used uninitialized. Assign the variable (potentially from itself) "
+ "to fix this error."
);
}
}
diff --git a/libsolidity/analysis/DeclarationContainer.cpp b/libsolidity/analysis/DeclarationContainer.cpp
index 9e2bf6d3..347daaf8 100644
--- a/libsolidity/analysis/DeclarationContainer.cpp
+++ b/libsolidity/analysis/DeclarationContainer.cpp
@@ -49,16 +49,10 @@ Declaration const* DeclarationContainer::conflictingDeclaration(
dynamic_cast<MagicVariableDeclaration const*>(&_declaration)
)
{
- // check that all other declarations with the same name are functions or a public state variable or events.
- // And then check that the signatures are different.
+ // check that all other declarations are of the same kind (in which
+ // case the type checker will ensure that the signatures are different)
for (Declaration const* declaration: declarations)
{
- if (auto variableDeclaration = dynamic_cast<VariableDeclaration const*>(declaration))
- {
- if (variableDeclaration->isStateVariable() && !variableDeclaration->isConstant() && variableDeclaration->isPublic())
- continue;
- return declaration;
- }
if (
dynamic_cast<FunctionDefinition const*>(&_declaration) &&
!dynamic_cast<FunctionDefinition const*>(declaration)
diff --git a/libsolidity/analysis/PostTypeChecker.cpp b/libsolidity/analysis/PostTypeChecker.cpp
index 19d0b708..240d7973 100644
--- a/libsolidity/analysis/PostTypeChecker.cpp
+++ b/libsolidity/analysis/PostTypeChecker.cpp
@@ -91,8 +91,11 @@ bool PostTypeChecker::visit(Identifier const& _identifier)
VariableDeclaration const* PostTypeChecker::findCycle(VariableDeclaration const& _startingFrom)
{
- auto visitor = [&](VariableDeclaration const& _variable, CycleDetector<VariableDeclaration>& _cycleDetector)
+ auto visitor = [&](VariableDeclaration const& _variable, CycleDetector<VariableDeclaration>& _cycleDetector, size_t _depth)
{
+ if (_depth >= 256)
+ m_errorReporter.fatalDeclarationError(_variable.location(), "Variable definition exhausting cyclic dependency validator.");
+
// Iterating through the dependencies needs to be deterministic and thus cannot
// depend on the memory layout.
// Because of that, we sort by AST node id.
diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp
index 5815e3d2..e058d917 100644
--- a/libsolidity/analysis/ReferencesResolver.cpp
+++ b/libsolidity/analysis/ReferencesResolver.cpp
@@ -144,7 +144,7 @@ void ReferencesResolver::endVisit(UserDefinedTypeName const& _typeName)
Declaration const* declaration = m_resolver.pathFromCurrentScope(_typeName.namePath());
if (!declaration)
{
- declarationError(_typeName.location(), "Identifier not found or not unique.");
+ fatalDeclarationError(_typeName.location(), "Identifier not found or not unique.");
return;
}
@@ -277,7 +277,7 @@ bool ReferencesResolver::visit(InlineAssembly const& _inlineAssembly)
// Will be re-generated later with correct information
// We use the latest EVM version because we will re-run it anyway.
assembly::AsmAnalysisInfo analysisInfo;
- boost::optional<Error::Type> errorTypeForLoose = m_experimental050Mode ? Error::Type::SyntaxError : Error::Type::Warning;
+ boost::optional<Error::Type> errorTypeForLoose = Error::Type::SyntaxError;
assembly::AsmAnalyzer(analysisInfo, errorsIgnored, EVMVersion(), errorTypeForLoose, assembly::AsmFlavour::Loose, resolver).analyze(_inlineAssembly.operations());
return false;
}
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 8536e934..af4d44a6 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -22,6 +22,7 @@
#include <libsolidity/analysis/TypeChecker.h>
#include <memory>
+#include <boost/algorithm/cxx11/all_of.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/range/adaptor/reversed.hpp>
@@ -278,8 +279,6 @@ void TypeChecker::checkContractAbstractFunctions(ContractDefinition const& _cont
void TypeChecker::checkContractBaseConstructorArguments(ContractDefinition const& _contract)
{
- bool const v050 = _contract.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050);
-
vector<ContractDefinition const*> const& bases = _contract.annotation().linearizedBaseContracts;
// Determine the arguments that are used for the base constructors.
@@ -287,27 +286,19 @@ void TypeChecker::checkContractBaseConstructorArguments(ContractDefinition const
{
if (FunctionDefinition const* constructor = contract->constructor())
for (auto const& modifier: constructor->modifiers())
- {
- auto baseContract = dynamic_cast<ContractDefinition const*>(&dereference(*modifier->name()));
- if (modifier->arguments())
- {
- if (baseContract && baseContract->constructor())
- annotateBaseConstructorArguments(_contract, baseContract->constructor(), modifier.get());
- }
- else
+ if (auto baseContract = dynamic_cast<ContractDefinition const*>(&dereference(*modifier->name())))
{
- if (v050)
- m_errorReporter.declarationError(
- modifier->location(),
- "Modifier-style base constructor call without arguments."
- );
+ if (modifier->arguments())
+ {
+ if (baseContract->constructor())
+ annotateBaseConstructorArguments(_contract, baseContract->constructor(), modifier.get());
+ }
else
- m_errorReporter.warning(
+ m_errorReporter.declarationError(
modifier->location(),
"Modifier-style base constructor call without arguments."
);
}
- }
for (ASTPointer<InheritanceSpecifier> const& base: contract->baseContracts())
{
@@ -594,8 +585,11 @@ bool TypeChecker::visit(StructDefinition const& _struct)
m_errorReporter.typeError(member->location(), "Type cannot be used in struct.");
// Check recursion, fatal error if detected.
- auto visitor = [&](StructDefinition const& _struct, CycleDetector<StructDefinition>& _cycleDetector)
+ auto visitor = [&](StructDefinition const& _struct, CycleDetector<StructDefinition>& _cycleDetector, size_t _depth)
{
+ if (_depth >= 256)
+ m_errorReporter.fatalDeclarationError(_struct.location(), "Struct definition exhausting cyclic dependency validator.");
+
for (ASTPointer<VariableDeclaration> const& member: _struct.members())
{
Type const* memberType = type(*member).get();
@@ -709,6 +703,7 @@ bool TypeChecker::visit(VariableDeclaration const& _variable)
// TypeChecker at the VariableDeclarationStatement level.
TypePointer varType = _variable.annotation().type;
solAssert(!!varType, "Failed to infer variable type.");
+
if (_variable.value())
expectType(*_variable.value(), *varType);
if (_variable.isConstant())
@@ -822,6 +817,7 @@ void TypeChecker::visitManually(
bool TypeChecker::visit(EventDefinition const& _eventDef)
{
+ solAssert(_eventDef.visibility() > Declaration::Visibility::Internal, "");
unsigned numIndexed = 0;
for (ASTPointer<VariableDeclaration> const& var: _eventDef.parameters())
{
@@ -831,6 +827,15 @@ bool TypeChecker::visit(EventDefinition const& _eventDef)
m_errorReporter.typeError(var->location(), "Type is required to live outside storage.");
if (!type(*var)->interfaceType(false))
m_errorReporter.typeError(var->location(), "Internal or recursive type is not allowed as event parameter type.");
+ if (
+ !_eventDef.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::ABIEncoderV2) &&
+ !typeSupportedByOldABIEncoder(*type(*var))
+ )
+ m_errorReporter.typeError(
+ var->location(),
+ "This type is only supported in the new experimental ABI encoder. "
+ "Use \"pragma experimental ABIEncoderV2;\" to enable the feature."
+ );
}
if (_eventDef.isAnonymous() && numIndexed > 4)
m_errorReporter.typeError(_eventDef.location(), "More than 4 indexed arguments for anonymous event.");
@@ -932,15 +937,11 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
};
solAssert(!_inlineAssembly.annotation().analysisInfo, "");
_inlineAssembly.annotation().analysisInfo = make_shared<assembly::AsmAnalysisInfo>();
- boost::optional<Error::Type> errorTypeForLoose =
- m_scope->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050) ?
- Error::Type::SyntaxError :
- Error::Type::Warning;
assembly::AsmAnalyzer analyzer(
*_inlineAssembly.annotation().analysisInfo,
m_errorReporter,
m_evmVersion,
- errorTypeForLoose,
+ Error::Type::SyntaxError,
assembly::AsmFlavour::Loose,
identifierAccess
);
@@ -1043,7 +1044,10 @@ string createTupleDecl(vector<ASTPointer<VariableDeclaration>> const& _decls)
vector<string> components;
for (ASTPointer<VariableDeclaration> const& decl: _decls)
if (decl)
+ {
+ solAssert(decl->annotation().type, "");
components.emplace_back(decl->annotation().type->toString(false) + " " + decl->name());
+ }
else
components.emplace_back();
@@ -1061,6 +1065,9 @@ bool typeCanBeExpressed(vector<ASTPointer<VariableDeclaration>> const& decls)
if (!decl)
continue;
+ if (!decl->annotation().type)
+ return false;
+
if (auto functionType = dynamic_cast<FunctionType const*>(decl->annotation().type.get()))
if (
functionType->kind() != FunctionType::Kind::Internal &&
@@ -1079,10 +1086,25 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement)
{
// No initial value is only permitted for single variables with specified type.
if (_statement.declarations().size() != 1 || !_statement.declarations().front())
- m_errorReporter.fatalTypeError(_statement.location(), "Assignment necessary for type detection.");
+ {
+ if (boost::algorithm::all_of_equal(_statement.declarations(), nullptr))
+ {
+ // The syntax checker has already generated an error for this case (empty LHS tuple).
+ solAssert(m_errorReporter.hasErrors(), "");
+
+ // It is okay to return here, as there are no named components on the
+ // left-hand-side that could cause any damage later.
+ return false;
+ }
+ else
+ // Bailing out *fatal* here, as those (untyped) vars may be used later, and diagnostics wouldn't be helpful then.
+ m_errorReporter.fatalTypeError(_statement.location(), "Use of the \"var\" keyword is disallowed.");
+ }
+
VariableDeclaration const& varDecl = *_statement.declarations().front();
if (!varDecl.annotation().type)
- m_errorReporter.fatalTypeError(_statement.location(), "Assignment necessary for type detection.");
+ m_errorReporter.fatalTypeError(_statement.location(), "Use of the \"var\" keyword is disallowed.");
+
if (auto ref = dynamic_cast<ReferenceType const*>(type(varDecl).get()))
{
if (ref->dataStoredIn(DataLocation::Storage))
@@ -1732,22 +1754,8 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
m_errorReporter.typeError(arguments[i]->location(), "Invalid rational number (too large or division by zero).");
errored = true;
}
- if (!errored)
- {
- TypePointer encodingType;
- if (
- argType->mobileType() &&
- argType->mobileType()->interfaceType(false) &&
- argType->mobileType()->interfaceType(false)->encodingType()
- )
- encodingType = argType->mobileType()->interfaceType(false)->encodingType();
- // Structs are fine as long as ABIV2 is activated and we do not do packed encoding.
- if (!encodingType || (
- dynamic_cast<StructType const*>(encodingType.get()) &&
- !(abiEncodeV2 && functionType->padArguments())
- ))
- m_errorReporter.typeError(arguments[i]->location(), "This type cannot be encoded.");
- }
+ if (!errored && !argType->fullEncodingType(false, abiEncodeV2, !functionType->padArguments()))
+ m_errorReporter.typeError(arguments[i]->location(), "This type cannot be encoded.");
}
else if (!type(*arguments[i])->isImplicitlyConvertibleTo(*parameterTypes[i]))
{
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index 2c2d3b68..0954fdf3 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -390,6 +390,27 @@ MemberList const& Type::members(ContractDefinition const* _currentScope) const
return *m_members[_currentScope];
}
+TypePointer Type::fullEncodingType(bool _inLibraryCall, bool _encoderV2, bool _packed) const
+{
+ TypePointer encodingType = mobileType();
+ if (encodingType)
+ encodingType = encodingType->interfaceType(_inLibraryCall);
+ if (encodingType)
+ encodingType = encodingType->encodingType();
+ if (auto structType = dynamic_cast<StructType const*>(encodingType.get()))
+ {
+ // Structs are fine in the following circumstances:
+ // - ABIv2 without packed encoding or,
+ // - storage struct for a library
+ if (!(
+ (_encoderV2 && !_packed) ||
+ (structType->location() == DataLocation::Storage && _inLibraryCall)
+ ))
+ return TypePointer();
+ }
+ return encodingType;
+}
+
MemberList::MemberMap Type::boundFunctions(Type const& _type, ContractDefinition const& _scope)
{
// Normalise data location of type.
@@ -1403,15 +1424,15 @@ bool ContractType::isImplicitlyConvertibleTo(Type const& _convertTo) const
{
if (*this == _convertTo)
return true;
- if (_convertTo.category() == Category::Integer)
- return dynamic_cast<IntegerType const&>(_convertTo).isAddress();
if (_convertTo.category() == Category::Contract)
{
auto const& bases = contractDefinition().annotation().linearizedBaseContracts;
if (m_super && bases.size() <= 1)
return false;
- return find(m_super ? ++bases.begin() : bases.begin(), bases.end(),
- &dynamic_cast<ContractType const&>(_convertTo).contractDefinition()) != bases.end();
+ return find(
+ m_super ? ++bases.begin() : bases.begin(), bases.end(),
+ &dynamic_cast<ContractType const&>(_convertTo).contractDefinition()
+ ) != bases.end();
}
return false;
}
@@ -1420,8 +1441,7 @@ bool ContractType::isExplicitlyConvertibleTo(Type const& _convertTo) const
{
return
isImplicitlyConvertibleTo(_convertTo) ||
- _convertTo.category() == Category::Integer ||
- _convertTo.category() == Category::Contract;
+ _convertTo == IntegerType(160, IntegerType::Modifier::Address);
}
bool ContractType::isPayable() const
@@ -2120,7 +2140,7 @@ bool StructType::recursive() const
{
if (!m_recursive.is_initialized())
{
- auto visitor = [&](StructDefinition const& _struct, CycleDetector<StructDefinition>& _cycleDetector)
+ auto visitor = [&](StructDefinition const& _struct, CycleDetector<StructDefinition>& _cycleDetector, size_t /*_depth*/)
{
for (ASTPointer<VariableDeclaration> const& variable: _struct.members())
{
diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h
index 1a676b42..12029a4e 100644
--- a/libsolidity/ast/Types.h
+++ b/libsolidity/ast/Types.h
@@ -280,6 +280,11 @@ public:
/// This for example returns address for contract types.
/// If there is no such type, returns an empty shared pointer.
virtual TypePointer encodingType() const { return TypePointer(); }
+ /// @returns the encoding type used under the given circumstances for the type of an expression
+ /// when used for e.g. abi.encode(...) or the empty pointer if the object
+ /// cannot be encoded.
+ /// This is different from encodingType since it takes implicit conversions into account.
+ TypePointer fullEncodingType(bool _inLibraryCall, bool _encoderV2, bool _packed) const;
/// @returns a (simpler) type that is used when decoding this type in calldata.
virtual TypePointer decodingType() const { return encodingType(); }
/// @returns a type that will be used outside of Solidity for e.g. function signatures.
@@ -692,9 +697,9 @@ public:
virtual Category category() const override { return Category::Contract; }
explicit ContractType(ContractDefinition const& _contract, bool _super = false):
m_contract(_contract), m_super(_super) {}
- /// Contracts can be implicitly converted to super classes and to addresses.
+ /// Contracts can be implicitly converted only to base contracts.
virtual bool isImplicitlyConvertibleTo(Type const& _convertTo) const override;
- /// Contracts can be converted to themselves and to integers.
+ /// Contracts can only be explicitly converted to address types and base contracts.
virtual bool isExplicitlyConvertibleTo(Type const& _convertTo) const override;
virtual TypePointer unaryOperatorResult(Token::Value _operator) const override;
virtual std::string richIdentifier() const override;
diff --git a/libsolidity/codegen/ABIFunctions.cpp b/libsolidity/codegen/ABIFunctions.cpp
index b3f1bc7e..1ce77d67 100644
--- a/libsolidity/codegen/ABIFunctions.cpp
+++ b/libsolidity/codegen/ABIFunctions.cpp
@@ -471,13 +471,8 @@ string ABIFunctions::abiEncodingFunction(
bool _fromStack
)
{
- solUnimplementedAssert(
- _to.mobileType() &&
- _to.mobileType()->interfaceType(_encodeAsLibraryTypes) &&
- _to.mobileType()->interfaceType(_encodeAsLibraryTypes)->encodingType(),
- "Encoding type \"" + _to.toString() + "\" not yet implemented."
- );
- TypePointer toInterface = _to.mobileType()->interfaceType(_encodeAsLibraryTypes)->encodingType();
+ TypePointer toInterface = _to.fullEncodingType(_encodeAsLibraryTypes, true, false);
+ solUnimplementedAssert(toInterface, "Encoding type \"" + _to.toString() + "\" not yet implemented.");
Type const& to = *toInterface;
if (_from.category() == Type::Category::StringLiteral)
@@ -886,13 +881,8 @@ string ABIFunctions::abiEncodingFunctionStruct(
solAssert(member.type, "");
if (!member.type->canLiveOutsideStorage())
continue;
- solUnimplementedAssert(
- member.type->mobileType() &&
- member.type->mobileType()->interfaceType(_encodeAsLibraryTypes) &&
- member.type->mobileType()->interfaceType(_encodeAsLibraryTypes)->encodingType(),
- "Encoding type \"" + member.type->toString() + "\" not yet implemented."
- );
- auto memberTypeTo = member.type->mobileType()->interfaceType(_encodeAsLibraryTypes)->encodingType();
+ TypePointer memberTypeTo = member.type->fullEncodingType(_encodeAsLibraryTypes, true, false);
+ solUnimplementedAssert(memberTypeTo, "Encoding type \"" + member.type->toString() + "\" not yet implemented.");
auto memberTypeFrom = _from.memberType(member.name);
solAssert(memberTypeFrom, "");
bool dynamicMember = memberTypeTo->isDynamicallyEncoded();
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp
index 2d81a106..bd3ec8f5 100644
--- a/libsolidity/codegen/CompilerUtils.cpp
+++ b/libsolidity/codegen/CompilerUtils.cpp
@@ -333,26 +333,19 @@ void CompilerUtils::encodeToMemory(
)
{
// stack: <v1> <v2> ... <vn> <mem>
+ bool const encoderV2 = m_context.experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2);
TypePointers targetTypes = _targetTypes.empty() ? _givenTypes : _targetTypes;
solAssert(targetTypes.size() == _givenTypes.size(), "");
for (TypePointer& t: targetTypes)
{
- solUnimplementedAssert(
- t->mobileType() &&
- t->mobileType()->interfaceType(_encodeAsLibraryTypes) &&
- t->mobileType()->interfaceType(_encodeAsLibraryTypes)->encodingType(),
- "Encoding type \"" + t->toString() + "\" not yet implemented."
- );
- t = t->mobileType()->interfaceType(_encodeAsLibraryTypes)->encodingType();
+ TypePointer tEncoding = t->fullEncodingType(_encodeAsLibraryTypes, encoderV2, !_padToWordBoundaries);
+ solUnimplementedAssert(tEncoding, "Encoding type \"" + t->toString() + "\" not yet implemented.");
+ t = std::move(tEncoding);
}
if (_givenTypes.empty())
return;
- else if (
- _padToWordBoundaries &&
- !_copyDynamicDataInPlace &&
- m_context.experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2)
- )
+ else if (_padToWordBoundaries && !_copyDynamicDataInPlace && encoderV2)
{
// Use the new Yul-based encoding function
auto stackHeightBefore = m_context.stackHeight();
diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp
index bbb3db3d..2f15a33d 100644
--- a/libsolidity/codegen/ContractCompiler.cpp
+++ b/libsolidity/codegen/ContractCompiler.cpp
@@ -71,7 +71,11 @@ void ContractCompiler::compileContract(
appendDelegatecallCheck();
initializeContext(_contract, _contracts);
+ // This generates the dispatch function for externally visible functions
+ // and adds the function to the compilation queue. Additionally internal functions,
+ // which are referenced directly or indirectly will be added.
appendFunctionSelector(_contract);
+ // This processes the above populated queue until it is empty.
appendMissingFunctions();
}
diff --git a/libsolidity/formal/CVC4Interface.cpp b/libsolidity/formal/CVC4Interface.cpp
index 84d36de0..6cb91483 100644
--- a/libsolidity/formal/CVC4Interface.cpp
+++ b/libsolidity/formal/CVC4Interface.cpp
@@ -52,18 +52,23 @@ void CVC4Interface::pop()
void CVC4Interface::declareFunction(string _name, Sort _domain, Sort _codomain)
{
- CVC4::Type fType = m_context.mkFunctionType(cvc4Sort(_domain), cvc4Sort(_codomain));
- m_functions.insert({_name, m_context.mkVar(_name.c_str(), fType)});
+ if (!m_functions.count(_name))
+ {
+ CVC4::Type fType = m_context.mkFunctionType(cvc4Sort(_domain), cvc4Sort(_codomain));
+ m_functions.insert({_name, m_context.mkVar(_name.c_str(), fType)});
+ }
}
void CVC4Interface::declareInteger(string _name)
{
- m_constants.insert({_name, m_context.mkVar(_name.c_str(), m_context.integerType())});
+ if (!m_constants.count(_name))
+ m_constants.insert({_name, m_context.mkVar(_name.c_str(), m_context.integerType())});
}
void CVC4Interface::declareBool(string _name)
{
- m_constants.insert({_name, m_context.mkVar(_name.c_str(), m_context.booleanType())});
+ if (!m_constants.count(_name))
+ m_constants.insert({_name, m_context.mkVar(_name.c_str(), m_context.booleanType())});
}
void CVC4Interface::addAssertion(Expression const& _expr)
diff --git a/libsolidity/formal/SMTChecker.cpp b/libsolidity/formal/SMTChecker.cpp
index 109c8dbe..17b50a38 100644
--- a/libsolidity/formal/SMTChecker.cpp
+++ b/libsolidity/formal/SMTChecker.cpp
@@ -252,14 +252,14 @@ void SMTChecker::checkUnderOverflow(smt::Expression _value, IntegerType const& _
_value < SymbolicIntVariable::minValue(_type),
_location,
"Underflow (resulting value less than " + formatNumber(_type.minValue()) + ")",
- "value",
+ "<result>",
&_value
);
checkCondition(
_value > SymbolicIntVariable::maxValue(_type),
_location,
"Overflow (resulting value larger than " + formatNumber(_type.maxValue()) + ")",
- "value",
+ "<result>",
&_value
);
}
@@ -437,7 +437,7 @@ void SMTChecker::arithmeticOperation(BinaryOperation const& _op)
if (_op.getOperator() == Token::Div)
{
- checkCondition(right == 0, _op.location(), "Division by zero", "value", &right);
+ checkCondition(right == 0, _op.location(), "Division by zero", "<result>", &right);
m_interface->addAssertion(right != 0);
}
@@ -601,15 +601,23 @@ void SMTChecker::checkCondition(
message << _description << " happens here";
if (m_currentFunction)
{
- message << " for:\n";
+ std::ostringstream modelMessage;
+ modelMessage << " for:\n";
solAssert(values.size() == expressionNames.size(), "");
+ map<string, string> sortedModel;
for (size_t i = 0; i < values.size(); ++i)
if (expressionsToEvaluate.at(i).name != values.at(i))
- message << " " << expressionNames.at(i) << " = " << values.at(i) << "\n";
+ sortedModel[expressionNames.at(i)] = values.at(i);
+
+ for (auto const& eval: sortedModel)
+ modelMessage << " " << eval.first << " = " << eval.second << "\n";
+ m_errorReporter.warning(_location, message.str() + loopComment, SecondarySourceLocation().append(modelMessage.str(), SourceLocation()));
}
else
+ {
message << ".";
- m_errorReporter.warning(_location, message.str() + loopComment);
+ m_errorReporter.warning(_location, message.str() + loopComment);
+ }
break;
}
case smt::CheckResult::UNSATISFIABLE:
diff --git a/libsolidity/formal/SMTLib2Interface.cpp b/libsolidity/formal/SMTLib2Interface.cpp
index 8cac3cc6..a6c1f87c 100644
--- a/libsolidity/formal/SMTLib2Interface.cpp
+++ b/libsolidity/formal/SMTLib2Interface.cpp
@@ -47,6 +47,8 @@ void SMTLib2Interface::reset()
{
m_accumulatedOutput.clear();
m_accumulatedOutput.emplace_back();
+ m_constants.clear();
+ m_functions.clear();
write("(set-option :produce-models true)");
write("(set-logic QF_UFLIA)");
}
@@ -64,25 +66,38 @@ void SMTLib2Interface::pop()
void SMTLib2Interface::declareFunction(string _name, Sort _domain, Sort _codomain)
{
- write(
- "(declare-fun |" +
- _name +
- "| (" +
- (_domain == Sort::Int ? "Int" : "Bool") +
- ") " +
- (_codomain == Sort::Int ? "Int" : "Bool") +
- ")"
- );
+ // TODO Use domain and codomain as key as well
+ if (!m_functions.count(_name))
+ {
+ m_functions.insert(_name);
+ write(
+ "(declare-fun |" +
+ _name +
+ "| (" +
+ (_domain == Sort::Int ? "Int" : "Bool") +
+ ") " +
+ (_codomain == Sort::Int ? "Int" : "Bool") +
+ ")"
+ );
+ }
}
void SMTLib2Interface::declareInteger(string _name)
{
- write("(declare-const |" + _name + "| Int)");
+ if (!m_constants.count(_name))
+ {
+ m_constants.insert(_name);
+ write("(declare-const |" + _name + "| Int)");
+ }
}
void SMTLib2Interface::declareBool(string _name)
{
- write("(declare-const |" + _name + "| Bool)");
+ if (!m_constants.count(_name))
+ {
+ m_constants.insert(_name);
+ write("(declare-const |" + _name + "| Bool)");
+ }
}
void SMTLib2Interface::addAssertion(Expression const& _expr)
diff --git a/libsolidity/formal/SMTLib2Interface.h b/libsolidity/formal/SMTLib2Interface.h
index 61071fe5..eb876a7f 100644
--- a/libsolidity/formal/SMTLib2Interface.h
+++ b/libsolidity/formal/SMTLib2Interface.h
@@ -30,6 +30,7 @@
#include <string>
#include <vector>
#include <cstdio>
+#include <set>
namespace dev
{
@@ -68,6 +69,8 @@ private:
ReadCallback::Callback m_queryCallback;
std::vector<std::string> m_accumulatedOutput;
+ std::set<std::string> m_constants;
+ std::set<std::string> m_functions;
};
}
diff --git a/libsolidity/formal/Z3Interface.cpp b/libsolidity/formal/Z3Interface.cpp
index 784fbd28..747c9172 100644
--- a/libsolidity/formal/Z3Interface.cpp
+++ b/libsolidity/formal/Z3Interface.cpp
@@ -53,17 +53,20 @@ void Z3Interface::pop()
void Z3Interface::declareFunction(string _name, Sort _domain, Sort _codomain)
{
- m_functions.insert({_name, m_context.function(_name.c_str(), z3Sort(_domain), z3Sort(_codomain))});
+ if (!m_functions.count(_name))
+ m_functions.insert({_name, m_context.function(_name.c_str(), z3Sort(_domain), z3Sort(_codomain))});
}
void Z3Interface::declareInteger(string _name)
{
- m_constants.insert({_name, m_context.int_const(_name.c_str())});
+ if (!m_constants.count(_name))
+ m_constants.insert({_name, m_context.int_const(_name.c_str())});
}
void Z3Interface::declareBool(string _name)
{
- m_constants.insert({_name, m_context.bool_const(_name.c_str())});
+ if (!m_constants.count(_name))
+ m_constants.insert({_name, m_context.bool_const(_name.c_str())});
}
void Z3Interface::addAssertion(Expression const& _expr)
diff --git a/libsolidity/inlineasm/AsmAnalysis.cpp b/libsolidity/inlineasm/AsmAnalysis.cpp
index d5580dd2..ea804cf5 100644
--- a/libsolidity/inlineasm/AsmAnalysis.cpp
+++ b/libsolidity/inlineasm/AsmAnalysis.cpp
@@ -57,7 +57,7 @@ bool AsmAnalyzer::operator()(Label const& _label)
solAssert(!_label.name.empty(), "");
checkLooseFeature(
_label.location,
- "The use of labels is deprecated. Please use \"if\", \"switch\", \"for\" or function calls instead."
+ "The use of labels is disallowed. Please use \"if\", \"switch\", \"for\" or function calls instead."
);
m_info.stackHeightInfo[&_label] = m_stackHeight;
warnOnInstructions(solidity::Instruction::JUMPDEST, _label.location);
@@ -68,7 +68,7 @@ bool AsmAnalyzer::operator()(assembly::Instruction const& _instruction)
{
checkLooseFeature(
_instruction.location,
- "The use of non-functional instructions is deprecated. Please use functional notation instead."
+ "The use of non-functional instructions is disallowed. Please use functional notation instead."
);
auto const& info = instructionInfo(_instruction.instruction);
m_stackHeight += info.ret - info.args;
@@ -201,7 +201,7 @@ bool AsmAnalyzer::operator()(assembly::StackAssignment const& _assignment)
{
checkLooseFeature(
_assignment.location,
- "The use of stack assignment is deprecated. Please use assignment in functional notation instead."
+ "The use of stack assignment is disallowed. Please use assignment in functional notation instead."
);
bool success = checkAssignment(_assignment.variableName, size_t(-1));
m_info.stackHeightInfo[&_assignment] = m_stackHeight;
diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp
index aa33bad8..32cb488f 100644
--- a/libsolidity/interface/CompilerStack.cpp
+++ b/libsolidity/interface/CompilerStack.cpp
@@ -191,6 +191,8 @@ bool CompilerStack::analyze()
if (!resolver.performImports(*source->ast, sourceUnitsByName))
return false;
+ // This is the main name and type resolution loop. Needs to be run for every contract, because
+ // the special variables "this" and "super" must be set appropriately.
for (Source const* source: m_sourceOrder)
for (ASTPointer<ASTNode> const& node: source->ast->nodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
@@ -204,11 +206,15 @@ bool CompilerStack::analyze()
// thus contracts can only conflict if declared in the same source file. This
// already causes a double-declaration error elsewhere, so we do not report
// an error here and instead silently drop any additional contracts we find.
-
if (m_contracts.find(contract->fullyQualifiedName()) == m_contracts.end())
m_contracts[contract->fullyQualifiedName()].contract = contract;
}
+ // This cannot be done in the above loop, because cross-contract types couldn't be resolved.
+ // A good example is `LibraryName.TypeName x;`.
+ //
+ // Note: this does not resolve overloaded functions. In order to do that, types of arguments are needed,
+ // which is only done one step later.
TypeChecker typeChecker(m_evmVersion, m_errorReporter);
for (Source const* source: m_sourceOrder)
for (ASTPointer<ASTNode> const& node: source->ast->nodes())
@@ -218,6 +224,7 @@ bool CompilerStack::analyze()
if (noErrors)
{
+ // Checks that can only be done when all types of all AST nodes are known.
PostTypeChecker postTypeChecker(m_errorReporter);
for (Source const* source: m_sourceOrder)
if (!postTypeChecker.check(*source->ast))
@@ -226,6 +233,8 @@ bool CompilerStack::analyze()
if (noErrors)
{
+ // Control flow graph generator and analyzer. It can check for issues such as
+ // variable is used before it is assigned to.
CFG cfg(m_errorReporter);
for (Source const* source: m_sourceOrder)
if (!cfg.constructFlow(*source->ast))
@@ -242,6 +251,7 @@ bool CompilerStack::analyze()
if (noErrors)
{
+ // Checks for common mistakes. Only generates warnings.
StaticAnalyzer staticAnalyzer(m_errorReporter);
for (Source const* source: m_sourceOrder)
if (!staticAnalyzer.analyze(*source->ast))
@@ -250,6 +260,7 @@ bool CompilerStack::analyze()
if (noErrors)
{
+ // Check for state mutability in every function.
vector<ASTPointer<ASTNode>> ast;
for (Source const* source: m_sourceOrder)
ast.push_back(source->ast);
@@ -300,6 +311,7 @@ bool CompilerStack::compile()
if (!parseAndAnalyze())
return false;
+ // Only compile contracts individually which have been requested.
map<ContractDefinition const*, eth::Assembly const*> compiledContracts;
for (Source const* source: m_sourceOrder)
for (ASTPointer<ASTNode> const& node: source->ast->nodes())
diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h
index 0578ac86..7b144660 100644
--- a/libsolidity/interface/CompilerStack.h
+++ b/libsolidity/interface/CompilerStack.h
@@ -352,8 +352,9 @@ private:
std::vector<Remapping> m_remappings;
std::map<std::string const, Source> m_sources;
std::shared_ptr<GlobalContext> m_globalContext;
- std::map<ASTNode const*, std::shared_ptr<DeclarationContainer>> m_scopes;
std::vector<Source const*> m_sourceOrder;
+ /// This is updated during compilation.
+ std::map<ASTNode const*, std::shared_ptr<DeclarationContainer>> m_scopes;
std::map<std::string const, Contract> m_contracts;
ErrorList m_errorList;
ErrorReporter m_errorReporter;
diff --git a/test/boostTest.cpp b/test/boostTest.cpp
index 6c68100c..cef3b06f 100644
--- a/test/boostTest.cpp
+++ b/test/boostTest.cpp
@@ -36,6 +36,7 @@
#pragma GCC diagnostic pop
#include <test/Options.h>
+#include <test/libsolidity/ASTJSONTest.h>
#include <test/libsolidity/SyntaxTest.h>
#include <boost/algorithm/string.hpp>
@@ -131,6 +132,12 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] )
"syntaxTests",
SyntaxTest::create
) > 0, "no syntax tests found");
+ solAssert(registerTests(
+ master,
+ dev::test::Options::get().testPath / "libsolidity",
+ "ASTJSON",
+ ASTJSONTest::create
+ ) > 0, "no JSON AST tests found");
if (dev::test::Options::get().disableIPC)
{
for (auto suite: {
diff --git a/test/compilationTests/MultiSigWallet/MultiSigWalletFactory.sol b/test/compilationTests/MultiSigWallet/MultiSigWalletFactory.sol
index 16219aa2..8d0c1a3f 100644
--- a/test/compilationTests/MultiSigWallet/MultiSigWalletFactory.sol
+++ b/test/compilationTests/MultiSigWallet/MultiSigWalletFactory.sol
@@ -15,7 +15,7 @@ contract MultiSigWalletFactory is Factory {
public
returns (address wallet)
{
- wallet = new MultiSigWallet(_owners, _required);
+ wallet = address(new MultiSigWallet(_owners, _required));
register(wallet);
}
}
diff --git a/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimitFactory.sol b/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimitFactory.sol
index e4cfc031..f897d938 100644
--- a/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimitFactory.sol
+++ b/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimitFactory.sol
@@ -16,7 +16,7 @@ contract MultiSigWalletWithDailyLimitFactory is Factory {
public
returns (address wallet)
{
- wallet = new MultiSigWalletWithDailyLimit(_owners, _required, _dailyLimit);
+ wallet = address(new MultiSigWalletWithDailyLimit(_owners, _required, _dailyLimit));
register(wallet);
}
}
diff --git a/test/compilationTests/corion/announcementTypes.sol b/test/compilationTests/corion/announcementTypes.sol
index f31d580e..94f4a9dc 100644
--- a/test/compilationTests/corion/announcementTypes.sol
+++ b/test/compilationTests/corion/announcementTypes.sol
@@ -1,35 +1,35 @@
-pragma solidity ^0.4.11;
-
-contract announcementTypes {
-
- enum announcementType {
- /*
- type of announcements
- */
- newModule,
- dropModule,
- replaceModule,
- replaceModuleHandler,
- question,
- transactionFeeRate,
- transactionFeeMin,
- transactionFeeMax,
- transactionFeeBurn,
- providerPublicFunds,
- providerPrivateFunds,
- providerPrivateClientLimit,
- providerPublicMinRate,
- providerPublicMaxRate,
- providerPrivateMinRate,
- providerPrivateMaxRate,
- providerGasProtect,
- providerInterestMinFunds,
- providerRentRate,
- schellingRoundBlockDelay,
- schellingCheckRounds,
- schellingCheckAboves,
- schellingRate,
- publisherMinAnnouncementDelay,
- publisherOppositeRate
- }
+pragma solidity ^0.4.11;
+
+contract announcementTypes {
+
+ enum announcementType {
+ /*
+ type of announcements
+ */
+ newModule,
+ dropModule,
+ replaceModule,
+ replaceModuleHandler,
+ question,
+ transactionFeeRate,
+ transactionFeeMin,
+ transactionFeeMax,
+ transactionFeeBurn,
+ providerPublicFunds,
+ providerPrivateFunds,
+ providerPrivateClientLimit,
+ providerPublicMinRate,
+ providerPublicMaxRate,
+ providerPrivateMinRate,
+ providerPrivateMaxRate,
+ providerGasProtect,
+ providerInterestMinFunds,
+ providerRentRate,
+ schellingRoundBlockDelay,
+ schellingCheckRounds,
+ schellingCheckAboves,
+ schellingRate,
+ publisherMinAnnouncementDelay,
+ publisherOppositeRate
+ }
} \ No newline at end of file
diff --git a/test/compilationTests/corion/ico.sol b/test/compilationTests/corion/ico.sol
index 2f60e0fe..b1e0bf75 100644
--- a/test/compilationTests/corion/ico.sol
+++ b/test/compilationTests/corion/ico.sol
@@ -6,7 +6,7 @@ import "./premium.sol";
import "./moduleHandler.sol";
contract ico is safeMath {
-
+
struct icoLevels_s {
uint256 block;
uint8 rate;
@@ -24,9 +24,9 @@ contract ico is safeMath {
uint256 cor;
uint256 corp;
}
-
+
uint256 constant oneSegment = 40320;
-
+
address public owner;
address public tokenAddr;
address public premiumAddr;
@@ -53,7 +53,7 @@ contract ico is safeMath {
constructor(address foundation, address priceSet, uint256 exchangeRate, uint256 startBlockNum, address[] memory genesisAddr, uint256[] memory genesisValue) public {
/*
Installation function.
-
+
@foundation The ETC address of the foundation
@priceSet The address which will be able to make changes on the rate later on.
@exchangeRate The current ETC/USD rate multiplied by 1e4. For example: 2.5 USD/ETC = 25000
@@ -80,11 +80,11 @@ contract ico is safeMath {
interestDB[genesisAddr[a]][0].amount = genesisValue[a];
}
}
-
+
function ICObonus() public view returns(uint256 bonus) {
/*
Query of current bonus
-
+
@bonus Bonus %
*/
for ( uint8 a=0 ; a<icoLevels.length ; a++ ) {
@@ -93,32 +93,32 @@ contract ico is safeMath {
}
}
}
-
+
function setInterestDB(address addr, uint256 balance) external returns(bool success) {
/*
Setting interest database. It can be requested by Token contract only.
- A database has to be built in order that after ICO closed everybody can get their compound interest on their capital accumulated
-
+ A database has to be built in order that after ICO closed everybody can get their compound interest on their capital accumulated
+
@addr Sender
@balance Quantity
-
+
@success Was the process successful or not
*/
require( msg.sender == tokenAddr );
uint256 _num = (block.number - startBlock) / interestBlockDelay;
interestDB[addr][_num].amount = balance;
- if ( balance == 0 ) {
+ if ( balance == 0 ) {
interestDB[addr][_num].empty = true;
}
return true;
}
-
+
function checkInterest(address addr) public view returns(uint256 amount) {
/*
Query of compound interest
-
+
@addr Address
-
+
@amount Amount of compound interest
*/
uint256 _lastBal;
@@ -126,9 +126,9 @@ contract ico is safeMath {
bool _empty;
interest_s memory _idb;
uint256 _to = (block.number - startBlock) / interestBlockDelay;
-
+
if ( _to == 0 || aborted ) { return 0; }
-
+
for ( uint256 r=0 ; r < _to ; r++ ) {
if ( r*interestBlockDelay+startBlock >= icoDelay ) { break; }
_idb = interestDB[addr][r];
@@ -148,11 +148,11 @@ contract ico is safeMath {
amount += _tamount;
}
}
-
+
function getInterest(address beneficiary) external {
/*
Request of compound interest. This is deleted from the database after the ICO closed and following the query of the compound interest.
-
+
@beneficiary Beneficiary who will receive the interest
*/
uint256 _lastBal;
@@ -163,10 +163,10 @@ contract ico is safeMath {
address _addr = beneficiary;
uint256 _to = (block.number - startBlock) / interestBlockDelay;
if ( _addr == address(0x00) ) { _addr = msg.sender; }
-
+
require( block.number > icoDelay );
require( ! aborted );
-
+
for ( uint256 r=0 ; r < _to ; r++ ) {
if ( r*interestBlockDelay+startBlock >= icoDelay ) { break; }
_idb = interestDB[msg.sender][r];
@@ -186,17 +186,17 @@ contract ico is safeMath {
_amount += _tamount;
delete interestDB[msg.sender][r];
}
-
+
require( _amount > 0 );
token(tokenAddr).mint(_addr, _amount);
}
-
+
function setICOEthPrice(uint256 value) external {
/*
- Setting of the ICO ETC USD rates which can only be calle by a pre-defined address.
+ Setting of the ICO ETC USD rates which can only be calle by a pre-defined address.
After this function is completed till the call of the next function (which is at least an exchangeRateDelay array) this rate counts.
With this process avoiding the sudden rate changes.
-
+
@value The ETC/USD rate multiplied by 1e4. For example: 2.5 USD/ETC = 25000
*/
require( isICO() );
@@ -205,18 +205,18 @@ contract ico is safeMath {
icoExchangeRateSetBlock = block.number + exchangeRateDelay;
icoExchangeRate = value;
}
-
+
function extendICO() external {
/*
Extend the period of the ICO with one segment.
-
+
It is only possible during the ICO and only callable by the owner.
*/
require( isICO() );
require( msg.sender == owner );
icoDelay += oneSegment;
}
-
+
function closeICO() external {
/*
Closing the ICO.
@@ -235,10 +235,10 @@ contract ico is safeMath {
require( token(tokenAddr).closeIco() );
require( premium(premiumAddr).closeIco() );
}
-
+
function abortICO() external {
/*
- Withdrawal of the ICO.
+ Withdrawal of the ICO.
It is only possible during the ICO period.
Only callable by the owner.
After this process only the receiveFunds function will be available for the customers.
@@ -247,12 +247,12 @@ contract ico is safeMath {
require( msg.sender == owner );
aborted = true;
}
-
+
function connectTokens(address tokenContractAddr, address premiumContractAddr) external {
/*
Installation function which joins the two token contracts with this contract.
Only callable by the owner
-
+
@tokenContractAddr Address of the corion token contract.
@premiumContractAddr Address of the corion premium token contract
*/
@@ -261,7 +261,7 @@ contract ico is safeMath {
tokenAddr = tokenContractAddr;
premiumAddr = premiumContractAddr;
}
-
+
function receiveFunds() external {
/*
Refund the amount which was purchased during the ICO period.
@@ -274,7 +274,7 @@ contract ico is safeMath {
delete brought[msg.sender];
require( msg.sender.send(_val) );
}
-
+
function () external payable {
/*
Callback function. Simply calls the buy function as a beneficiary and there is no affiliate address.
@@ -287,7 +287,7 @@ contract ico is safeMath {
function buy(address beneficiaryAddress, address affilateAddress) public payable returns (bool success) {
/*
Buying a token
-
+
If there is not at least 0.2 ether balance on the beneficiaryAddress then the amount of the ether which was intended for the purchase will be reduced by 0.2 and that will be sent to the address of the beneficiary.
From the remaining amount calculate the reward with the help of the getIcoReward function.
Only that affiliate address is valid which has some token on it’s account.
@@ -327,7 +327,7 @@ contract ico is safeMath {
rate = 4;
} else if (extra >= 1e10) {
rate = 3;
- } else if (extra >= 1e9) {
+ } else if (extra >= 1e9) {
rate = 2;
} else {
rate = 1;
@@ -344,7 +344,7 @@ contract ico is safeMath {
function checkPremium(address owner) internal {
/*
Crediting the premium token
-
+
@owner The corion token balance of this address will be set based on the calculation which shows that how many times can be the amount of the purchased tokens divided by 5000. So after each 5000 token we give 1 premium token.
*/
uint256 _reward = (brought[owner].cor / 5e9) - brought[owner].corp;
@@ -354,11 +354,11 @@ contract ico is safeMath {
totalPremiumMint = safeAdd(totalPremiumMint, _reward);
}
}
-
+
function getIcoReward(uint256 value) public view returns (uint256 reward) {
/*
Expected token volume at token purchase
-
+
@value The amount of ether for the purchase
@reward Amount of the token
x = (value * 1e6 * USD_ETC_exchange rate / 1e4 / 1e18) * bonus percentage
@@ -367,10 +367,10 @@ contract ico is safeMath {
reward = (value * 1e6 * icoExchangeRate / icoExchangeRateM / 1 ether) * (ICObonus() + 100) / 100;
if ( reward < 5e6) { return 0; }
}
-
+
function isICO() public view returns (bool success) {
return startBlock <= block.number && block.number <= icoDelay && ( ! aborted ) && ( ! closed );
}
-
+
event EICO(address indexed Address, uint256 indexed value, address Affiliate, uint256 AffilateValue);
}
diff --git a/test/compilationTests/corion/module.sol b/test/compilationTests/corion/module.sol
index e0084ea5..da4dd344 100644
--- a/test/compilationTests/corion/module.sol
+++ b/test/compilationTests/corion/module.sol
@@ -9,18 +9,18 @@ contract module {
/*
Module
*/
-
+
enum status {
New,
Connected,
Disconnected,
Disabled
}
-
+
status public moduleStatus;
uint256 public disabledUntil;
address public moduleHandlerAddress;
-
+
function disableModule(bool forever) external onlyForModuleHandler returns (bool success) {
_disableModule(forever);
return true;
@@ -29,13 +29,13 @@ contract module {
/*
Disable the module for one week, if the forever true then for forever.
This function calls the Publisher module.
-
+
@forever For forever or not
*/
if ( forever ) { moduleStatus = status.Disabled; }
else { disabledUntil = block.number + 5760; }
}
-
+
function replaceModuleHandler(address newModuleHandlerAddress) external onlyForModuleHandler returns (bool success) {
_replaceModuleHandler(newModuleHandlerAddress);
return true;
@@ -44,13 +44,13 @@ contract module {
/*
Replace the ModuleHandler address.
This function calls the Publisher module.
-
+
@newModuleHandlerAddress New module handler address
*/
require( moduleStatus == status.Connected );
moduleHandlerAddress = newModuleHandlerAddress;
}
-
+
function connectModule() external onlyForModuleHandler returns (bool success) {
_connectModule();
return true;
@@ -63,7 +63,7 @@ contract module {
require( moduleStatus == status.New );
moduleStatus = status.Connected;
}
-
+
function disconnectModule() external onlyForModuleHandler returns (bool success) {
_disconnectModule();
return true;
@@ -76,7 +76,7 @@ contract module {
require( moduleStatus != status.New && moduleStatus != status.Disconnected );
moduleStatus = status.Disconnected;
}
-
+
function replaceModule(address newModuleAddress) external onlyForModuleHandler returns (bool success) {
_replaceModule(newModuleAddress);
return true;
@@ -86,7 +86,7 @@ contract module {
Replace the module for an another new module.
This function calls the Publisher module.
We send every Token and ether to the new module.
-
+
@newModuleAddress New module handler address
*/
require( moduleStatus != status.New && moduleStatus != status.Disconnected);
@@ -100,14 +100,14 @@ contract module {
}
moduleStatus = status.Disconnected;
}
-
+
function transferEvent(address from, address to, uint256 value) external onlyForModuleHandler returns (bool success) {
return true;
}
function newSchellingRoundEvent(uint256 roundID, uint256 reward) external onlyForModuleHandler returns (bool success) {
return true;
}
-
+
function registerModuleHandler(address _moduleHandlerAddress) internal {
/*
Module constructor function for registering ModuleHandler address.
@@ -118,9 +118,9 @@ contract module {
/*
Test for ModuleHandler address.
If the module is not connected then returns always false.
-
+
@addr Address to check
-
+
@ret This is the module handler address or not
*/
if ( moduleHandlerAddress == address(0x00) ) { return true; }
@@ -130,7 +130,7 @@ contract module {
function isActive() public view returns (bool success, bool active) {
/*
Check self for ready for functions or not.
-
+
@success Function call was successful or not
@active Ready for functions or not
*/
diff --git a/test/compilationTests/corion/moduleHandler.sol b/test/compilationTests/corion/moduleHandler.sol
index ce53114b..5628f657 100644
--- a/test/compilationTests/corion/moduleHandler.sol
+++ b/test/compilationTests/corion/moduleHandler.sol
@@ -23,14 +23,14 @@ contract abstractModule {
}
contract moduleHandler is multiOwner, announcementTypes {
-
+
struct modules_s {
address addr;
bytes32 name;
bool schellingEvent;
bool transferEvent;
}
-
+
modules_s[] public modules;
address public foundationAddress;
uint256 debugModeUntil = block.number + 1000000;
@@ -40,10 +40,10 @@ contract moduleHandler is multiOwner, announcementTypes {
function load(address foundation, bool forReplace, address Token, address Premium, address Publisher, address Schelling, address Provider) public {
/*
Loading modulest to ModuleHandler.
-
+
This module can be called only once and only by the owner, if every single module and its database are already put on the blockchain.
If forReaplace is true, than the ModuleHandler will be replaced. Before the publishing of its replace, the new contract must be already on the blockchain.
-
+
@foundation Address of foundation.
@forReplace Is it for replace or not. If not, it will be connected to the module.
@Token address of token.
@@ -64,7 +64,7 @@ contract moduleHandler is multiOwner, announcementTypes {
/*
Inside function for registration of the modules in the database.
If the call is false, won't happen any direct call.
-
+
@input _Structure of module.
@call Is connect to the module or not.
*/
@@ -84,7 +84,7 @@ contract moduleHandler is multiOwner, announcementTypes {
function getModuleAddressByName(string memory name) public view returns( bool success, bool found, address addr ) {
/*
Search by name for module. The result is an Ethereum address.
-
+
@name Name of module.
@addr Address of module.
@found Is there any result.
@@ -97,7 +97,7 @@ contract moduleHandler is multiOwner, announcementTypes {
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.
-
+
@name Name of module.
@id Index of module.
@found Was there any result or not.
@@ -112,7 +112,7 @@ contract moduleHandler is multiOwner, announcementTypes {
function getModuleIDByName(string memory name) public view returns( bool success, bool found, uint256 id ) {
/*
Search by name for module. The result is an index array.
-
+
@name Name of module.
@id Index of module.
@found Was there any result or not.
@@ -128,7 +128,7 @@ contract moduleHandler is multiOwner, announcementTypes {
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.
-
+
@name Name of module.
@id Index of module.
@found Was there any result or not.
@@ -143,7 +143,7 @@ contract moduleHandler is multiOwner, announcementTypes {
function replaceModule(string name, address addr, bool callCallback) external returns (bool success) {
/*
Module replace, can be called only by the Publisher contract.
-
+
@name Name of module.
@addr Address of module.
@bool Was there any result or not.
@@ -166,7 +166,7 @@ contract moduleHandler is multiOwner, announcementTypes {
modules[_id].addr = addr;
return true;
}
-
+
function callReplaceCallback(string moduleName, address newModule) external returns (bool success) {
require( block.number < debugModeUntil );
if ( ! insertAndCheckDo(calcDoHash("callReplaceCallback", keccak256(abi.encodePacked(moduleName, newModule)))) ) {
@@ -181,7 +181,7 @@ contract moduleHandler is multiOwner, announcementTypes {
function newModule(string name, address addr, bool schellingEvent, bool transferEvent) external returns (bool success) {
/*
Adding new module to the database. Can be called only by the Publisher contract.
-
+
@name Name of module.
@addr Address of module.
@schellingEvent Gets it new Schelling round notification?
@@ -202,7 +202,7 @@ contract moduleHandler is multiOwner, announcementTypes {
function dropModule(string name, bool callCallback) external returns (bool success) {
/*
Deleting module from the database. Can be called only by the Publisher contract.
-
+
@name Name of module to delete.
@bool Was the function successful?
@callCallback Call the replaceable module to confirm replacement or not.
@@ -223,7 +223,7 @@ contract moduleHandler is multiOwner, announcementTypes {
delete modules[_id];
return true;
}
-
+
function callDisableCallback(string moduleName) external returns (bool success) {
require( block.number < debugModeUntil );
if ( ! insertAndCheckDo(calcDoHash("callDisableCallback", keccak256(bytes(moduleName)))) ) {
@@ -234,14 +234,14 @@ contract moduleHandler is multiOwner, announcementTypes {
require( abstractModule(modules[_id].addr).disableModule(true) );
return true;
}
-
+
function broadcastTransfer(address from, address to, uint256 value) external returns (bool success) {
/*
Announcing transactions for the modules.
-
+
Can be called only by the token module.
Only the configured modules get notifications.( transferEvent )
-
+
@from from who.
@to to who.
@value amount.
@@ -261,7 +261,7 @@ contract moduleHandler is multiOwner, announcementTypes {
Announcing new Schelling round for the modules.
Can be called only by the Schelling module.
Only the configured modules get notifications( schellingEvent ).
-
+
@roundID Number of Schelling round.
@reward Coin emission in this Schelling round.
@bool Was the function successful?
@@ -278,10 +278,10 @@ contract moduleHandler is multiOwner, announcementTypes {
function replaceModuleHandler(address newHandler) external returns (bool success) {
/*
Replacing ModuleHandler.
-
+
Can be called only by the publisher.
Every module will be informed about the ModuleHandler replacement.
-
+
@newHandler Address of the new ModuleHandler.
@bool Was the function successful?
*/
@@ -301,7 +301,7 @@ contract moduleHandler is multiOwner, announcementTypes {
function balanceOf(address owner) public view returns (bool success, uint256 value) {
/*
Query of token balance.
-
+
@owner address
@value balance.
@success was the function successful?
@@ -313,7 +313,7 @@ contract moduleHandler is multiOwner, announcementTypes {
function totalSupply() public view returns (bool success, uint256 value) {
/*
Query of the whole token amount.
-
+
@value amount.
@success was the function successful?
*/
@@ -324,7 +324,7 @@ contract moduleHandler is multiOwner, announcementTypes {
function isICO() public view returns (bool success, bool ico) {
/*
Query of ICO state
-
+
@ico Is ICO in progress?.
@success was the function successful?
*/
@@ -335,7 +335,7 @@ contract moduleHandler is multiOwner, announcementTypes {
function getCurrentSchellingRoundID() public view returns (bool success, uint256 round) {
/*
Query of number of the actual Schelling round.
-
+
@round Schelling round.
@success was the function successful?
*/
@@ -346,10 +346,10 @@ contract moduleHandler is multiOwner, announcementTypes {
function mint(address to, uint256 value) external returns (bool success) {
/*
Token emission request. Can be called only by the provider.
-
+
@to Place of new token
@value Token amount
-
+
@success Was the function successful?
*/
(bool _success, bool _found, uint256 _id) = getModuleIDByAddress(msg.sender);
@@ -362,7 +362,7 @@ contract moduleHandler is multiOwner, announcementTypes {
function transfer(address from, address to, uint256 value, bool fee) external returns (bool success) {
/*
Token transaction request. Can be called only by a module.
-
+
@from from who.
@to To who.
@value Token amount.
@@ -379,7 +379,7 @@ contract moduleHandler is multiOwner, announcementTypes {
function processTransactionFee(address from, uint256 value) external returns (bool success) {
/*
Token transaction fee. Can be called only by the provider.
-
+
@from From who.
@value Token amount.
@success Was the function successful?
@@ -394,7 +394,7 @@ contract moduleHandler is multiOwner, announcementTypes {
function burn(address from, uint256 value) external returns (bool success) {
/*
Token burn. Can be called only by Schelling.
-
+
@from From who.
@value Token amount.
@success Was the function successful?
@@ -409,7 +409,7 @@ contract moduleHandler is multiOwner, announcementTypes {
function configureModule(string moduleName, announcementType aType, uint256 value) external returns (bool success) {
/*
Changing configuration of a module. Can be called only by Publisher or while debug mode by owners.
-
+
@moduleName Module name which will be configured
@aType Type of variable (announcementType).
@value New value
@@ -432,14 +432,14 @@ contract moduleHandler is multiOwner, announcementTypes {
/*
Freezing CORION Platform. Can be called only by the owner.
Freeze can not be recalled!
-
+
@forever Is it forever or not?
*/
require( owners[msg.sender] );
if ( forever ) {
if ( ! insertAndCheckDo(calcDoHash("freezing", keccak256(abi.encodePacked(forever)))) ) {
return;
- }
+ }
}
for ( uint256 a=0 ; a<modules.length ; a++ ) {
require( abstractModule(modules[a].addr).disableModule(forever) );
diff --git a/test/compilationTests/corion/multiOwner.sol b/test/compilationTests/corion/multiOwner.sol
index ecc51ac3..efda554a 100644
--- a/test/compilationTests/corion/multiOwner.sol
+++ b/test/compilationTests/corion/multiOwner.sol
@@ -3,12 +3,12 @@ pragma solidity ^0.4.11;
import "./safeMath.sol";
contract multiOwner is safeMath {
-
+
mapping(address => bool) public owners;
uint256 public ownerCount;
mapping(bytes32 => address[]) public doDB;
-
+
/*
Constructor
*/
diff --git a/test/compilationTests/corion/owned.sol b/test/compilationTests/corion/owned.sol
index 4a5ba673..f5a11c44 100644
--- a/test/compilationTests/corion/owned.sol
+++ b/test/compilationTests/corion/owned.sol
@@ -1,28 +1,28 @@
-pragma solidity ^0.4.11;
-
-contract ownedDB {
- address private owner;
-
- function replaceOwner(address newOwner) external returns(bool) {
- /*
- Owner replace.
-
- @newOwner Address of new owner.
- */
- require( isOwner() );
- owner = newOwner;
- return true;
- }
-
- function isOwner() internal returns(bool) {
- /*
- Check of owner address.
-
- @bool Owner has called the contract or not
- */
- if ( owner == address(0x00) ) {
- return true;
- }
- return owner == msg.sender;
- }
-}
+pragma solidity ^0.4.11;
+
+contract ownedDB {
+ address private owner;
+
+ function replaceOwner(address newOwner) external returns(bool) {
+ /*
+ Owner replace.
+
+ @newOwner Address of new owner.
+ */
+ require( isOwner() );
+ owner = newOwner;
+ return true;
+ }
+
+ function isOwner() internal returns(bool) {
+ /*
+ Check of owner address.
+
+ @bool Owner has called the contract or not
+ */
+ if ( owner == address(0x00) ) {
+ return true;
+ }
+ return owner == msg.sender;
+ }
+}
diff --git a/test/compilationTests/corion/premium.sol b/test/compilationTests/corion/premium.sol
index 45fe7666..65895f33 100644
--- a/test/compilationTests/corion/premium.sol
+++ b/test/compilationTests/corion/premium.sol
@@ -20,7 +20,7 @@ contract premium is module, safeMath {
}
modifier isReady {
(bool _success, bool _active) = super.isActive();
- require( _success && _active );
+ require( _success && _active );
_;
}
/**
@@ -29,22 +29,22 @@ contract premium is module, safeMath {
* @author iFA @ Corion Platform
*
*/
-
+
string public name = "Corion Premium";
string public symbol = "CORP";
uint8 public decimals = 0;
-
+
address public icoAddr;
tokenDB public db;
bool public isICO;
-
+
mapping(address => bool) public genesis;
constructor(bool forReplace, address moduleHandler, address dbAddress, address icoContractAddr, address[] memory genesisAddr, uint256[] memory genesisValue) public {
/*
Setup function.
If an ICOaddress is defined then the balance of the genesis addresses will be set as well.
-
+
@forReplace This address will be replaced with the old one or not.
@moduleHandler Modulhandler’s address
@dbAddress Address of database
@@ -56,7 +56,7 @@ contract premium is module, safeMath {
require( dbAddress != address(0x00) );
db = ptokenDB(dbAddress);
if ( ! forReplace ) {
- require( db.replaceOwner(this) );
+ require( db.replaceOwner(address(this)) );
isICO = true;
icoAddr = icoContractAddr;
assert( genesisAddr.length == genesisValue.length );
@@ -67,18 +67,18 @@ contract premium is module, safeMath {
}
}
}
-
+
function closeIco() external returns (bool success) {
/*
Finishing the ICO. Can be invited only by an ICO contract.
-
+
@success If the function was successful.
*/
require( isICO );
isICO = false;
return true;
}
-
+
/**
* @notice `msg.sender` approves `spender` to spend `amount` tokens on its behalf.
* @param spender The address of the account able to transfer the tokens
@@ -88,18 +88,18 @@ contract premium is module, safeMath {
*/
function approve(address spender, uint256 amount, uint256 nonce) isReady external returns (bool success) {
/*
- Authorize another address to use an exact amount of the principal’s balance.
-
+ Authorize another address to use an exact amount of the principal’s balance.
+
@spender Address of authorised party
@amount Token quantity
@nonce Transaction count
-
+
@success Was the Function successful?
*/
_approve(spender, amount, nonce);
return true;
}
-
+
/**
* @notice `msg.sender` approves `spender` to spend `amount` tokens on its behalf and notify the spender from your approve with your `extraData` data.
* @param spender The address of the account able to transfer the tokens
@@ -112,24 +112,24 @@ contract premium is module, safeMath {
/*
Authorize another address to use an exact amount of the principal’s balance.
After the transaction the approvedCorionPremiumToken function of the address will be called with the given data.
-
+
@spender Authorized address
@amount Token quantity
@extraData Extra data to be received by the receiver
@nonce Transaction count
-
+
@success Was the Function successful?
*/
_approve(spender, amount, nonce);
require( thirdPartyPContractAbstract(spender).approvedCorionPremiumToken(msg.sender, amount, extraData) );
return true;
}
-
+
function _approve(address spender, uint256 amount, uint256 nonce) isReady internal {
/*
- Inner function to authorize another address to use an exact amount of the principal’s balance.
+ Inner function to authorize another address to use an exact amount of the principal’s balance.
If the transaction count not match the authorise fails.
-
+
@spender Address of authorised party
@amount Token quantity
@nonce Transaction count
@@ -143,10 +143,10 @@ contract premium is module, safeMath {
function allowance(address owner, address spender) public view returns (uint256 remaining, uint256 nonce) {
/*
Get the quantity of tokens given to be used
-
+
@owner Authorising address
@spender Authorised address
-
+
@remaining Tokens to be spent
@nonce Transaction count
*/
@@ -154,7 +154,7 @@ contract premium is module, safeMath {
require( _success );
return (_remaining, _nonce);
}
-
+
/**
* @notice Send `amount` Corion tokens to `to` from `msg.sender`
* @param to The address of the recipient
@@ -166,10 +166,10 @@ contract premium is module, safeMath {
Launch a transaction where the token is sent from the sender’s address to the receiver’s address.
Transaction fee is going to be added as well.
If the receiver is not a natural address but also a person then she/he will be invited as well.
-
+
@to For who
@amount Amount
-
+
@success Was the function successful?
*/
bytes memory _data;
@@ -181,7 +181,7 @@ contract premium is module, safeMath {
emit Transfer(msg.sender, to, amount, _data);
return true;
}
-
+
/**
* @notice Send `amount` tokens to `to` from `from` on the condition it is approved by `from`
* @param from The address holding the tokens being transferred
@@ -194,11 +194,11 @@ contract premium is module, safeMath {
Launch a transaction where we transfer from a given address to another one. It can only be called by an address which was allowed before.
Transaction fee will be charged too.
If the receiver is not a natural address but also a person then she/he will be invited as well
-
+
@from From who?
@to For who?
@amount Amount
-
+
@success If the function was successful.
*/
if ( from != msg.sender ) {
@@ -218,7 +218,7 @@ contract premium is module, safeMath {
emit Transfer(from, to, amount, _data);
return true;
}
-
+
/**
* @notice Send `amount` Corion tokens to `to` from `msg.sender` and notify the receiver from your transaction with your `extraData` data
* @param to The contract address of the recipient
@@ -230,11 +230,11 @@ contract premium is module, safeMath {
/*
Launch a transaction where we transfer from a given address to another one.
After thetransaction the approvedCorionPremiumToken function of the receiver’s address is going to be called with the given data.
-
+
@to For who?
@amount Amount
@extraData Extra data that will be given to the receiver
-
+
@success If the function was successful.
*/
if ( isContract(to) ) {
@@ -245,11 +245,11 @@ contract premium is module, safeMath {
emit Transfer(msg.sender, to, amount, extraData);
return true;
}
-
+
function transferToContract(address from, address to, uint256 amount, bytes memory extraData) internal {
/*
Inner function in order to transact a contract.
-
+
@to For who?
@amount Amount
@extraData Extra data that will be given to the receiver
@@ -262,13 +262,13 @@ contract premium is module, safeMath {
_transfer(to, from, _back);
}
}
-
+
function _transfer(address from, address to, uint256 amount) isReady internal {
/*
Inner function to launch a transaction.
During the ICO transactions are only possible from the genesis address.
0xa636a97578d26a3b76b060bbc18226d954cf3757 address is blacklisted.
-
+
@from From how?
@to For who?
@amount Amount
@@ -278,38 +278,38 @@ contract premium is module, safeMath {
require( db.decrease(from, amount) );
require( db.increase(to, amount) );
}
-
+
function mint(address owner, uint256 value) external returns (bool success) {
/*
Generating tokens. It can be called only by ICO contract.
-
+
@owner Address
@value Amount.
-
+
@success Was the Function successful?
*/
require( msg.sender == icoAddr || isICO );
_mint(owner, value);
return true;
}
-
+
function _mint(address owner, uint256 value) isReady internal {
/*
Inner function to create a token.
-
+
@owner Address of crediting the token.
@value Amount
*/
require( db.increase(owner, value) );
emit Mint(owner, value);
}
-
+
function isContract(address addr) internal returns (bool success) {
/*
Inner function in order to check if the given address is a natural address or a contract.
-
+
@addr The address which is needed to be checked.
-
+
@success Is the address crontact or not
*/
uint256 _codeLength;
@@ -322,7 +322,7 @@ contract premium is module, safeMath {
function balanceOf(address owner) public view returns (uint256 value) {
/*
Token balance query
-
+
@owner Address
@value Balance of address
*/
@@ -332,12 +332,12 @@ contract premium is module, safeMath {
function totalSupply() public view returns (uint256 value) {
/*
Total token quantity query
-
+
@value Total token quantity
*/
return db.totalSupply();
}
-
+
event AllowanceUsed(address indexed spender, address indexed owner, uint256 indexed value);
event Mint(address indexed addr, uint256 indexed value);
event Burn(address indexed addr, uint256 indexed value);
diff --git a/test/compilationTests/corion/provider.sol b/test/compilationTests/corion/provider.sol
index 7d1e04e3..a4ee4a48 100644
--- a/test/compilationTests/corion/provider.sol
+++ b/test/compilationTests/corion/provider.sol
@@ -20,7 +20,7 @@ contract provider is module, safeMath, announcementTypes {
/*
Transaction completed. This function is only available for the modulehandler.
It should be checked if the sender or the acceptor does not connect to the provider or it is not a provider itself if so than the change should be recorded.
-
+
@from From whom?
@to For who?
@value amount
@@ -36,9 +36,9 @@ contract provider is module, safeMath, announcementTypes {
New schelling round. This function is only available for the moduleHandler.
We are recording the new schelling round and we are storing the whole current quantity of the tokens.
We generate a reward quantity of tokens directed to the providers address. The collected interest will be transferred from this contract.
-
+
@roundID Number of the schelling round.
- @reward token emission
+ @reward token emission
@bool Was the function successful?
*/
require( super.isModuleHandler(msg.sender) );
@@ -50,7 +50,7 @@ contract provider is module, safeMath, announcementTypes {
}
modifier isReady {
(bool _success, bool _active) = super.isActive();
- require( _success && _active );
+ require( _success && _active );
_;
}
/*
@@ -98,13 +98,13 @@ contract provider is module, safeMath, announcementTypes {
uint256 currentHeight;
}
mapping(address => _providers) private providers;
-
+
struct _globalFunds {
uint256 reward;
uint256 supply;
}
mapping(uint256 => _globalFunds) private globalFunds;
-
+
struct _client{
address providerAddress;
uint256 providerHeight;
@@ -115,13 +115,13 @@ contract provider is module, safeMath, announcementTypes {
uint256 paidUpTo;
}
mapping(address => _client) private clients;
-
+
uint256 private currentSchellingRound = 1;
constructor(address _moduleHandler) public {
/*
Install function.
-
+
@_moduleHandler Address of the moduleHandler.
*/
super.registerModuleHandler(_moduleHandler);
@@ -129,7 +129,7 @@ contract provider is module, safeMath, announcementTypes {
function configure(announcementType a, uint256 b) external returns(bool) {
/*
Configuration of the provider. Can be invited just by the moduleHandler.
-
+
@a Type of the setting
@b value
*/
@@ -150,7 +150,7 @@ contract provider is module, safeMath, announcementTypes {
function getUserDetails(address addr, uint256 schellingRound) public view returns (address ProviderAddress, uint256 ProviderHeight, uint256 ConnectedOn, uint256 value) {
/*
Collecting the datas of the client.
-
+
@addr Address of the client.
@schellingRound Number of the schelling round. If it is not defined then the current one.
@ProviderAddress Address of the provider the one where connected to
@@ -173,9 +173,9 @@ contract provider is module, safeMath, announcementTypes {
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.
The provider’s account counts as a capital for the emission as well.
-
+
@value amount of the connected capital
- @priv Is the provider private or not?
+ @priv Is the provider private or not?
@bool Gets the share from the token emission.
*/
if ( priv ) {
@@ -187,8 +187,8 @@ contract provider is module, safeMath, announcementTypes {
/*
It checks if the provider has enough connected captital to be able to get from the token emission.
In case the provider is not able to get the share from the token emission then the connected capital will not count to the value of the globalFunds, to the current schelling round.
-
- @oldValue old
+
+ @oldValue old
@newValue new
@priv Is the provider private?
*/
@@ -205,12 +205,12 @@ contract provider is module, safeMath, announcementTypes {
function checkCorrectRate(bool priv, uint8 rate) internal returns(bool) {
/*
Inner function which checks if the amount of interest what is given by the provider is fits to the criteria.
-
+
@priv Is the provider private or not?
@rate Percentage/rate of the interest
@bool Correct or not?
*/
- return ( ! priv && ( rate >= publicMinRate && rate <= publicMaxRate ) ) ||
+ return ( ! priv && ( rate >= publicMinRate && rate <= publicMaxRate ) ) ||
( priv && ( rate >= privateMinRate && rate <= privateMaxRate ) );
}
function createProvider(bool priv, string name, string website, string country, string info, uint8 rate, bool isForRent, address admin) isReady external {
@@ -222,7 +222,7 @@ contract provider is module, safeMath, announcementTypes {
For opening, has to have enough capital.
All the functions of the provider except of the closing are going to be handled by the admin.
The provider can be start as a rent as well, in this case the isForRent has to be true/correct. In case it runs as a rent the 20% of the profit will belong to the leser and the rest goes to the admin.
-
+
@priv Privat szolgaltato e. Is private provider?
@name Provider’s name.
@website Provider’s website
@@ -241,7 +241,7 @@ contract provider is module, safeMath, announcementTypes {
require( getTokenBalance(msg.sender) >= minFundsForPublic );
}
require( checkCorrectRate(priv, rate) );
-
+
providers[msg.sender].currentHeight++;
uint256 currHeight = providers[msg.sender].currentHeight;
providers[msg.sender].data[currHeight].valid = true;
@@ -276,10 +276,10 @@ contract provider is module, safeMath, announcementTypes {
This can only be invited by the provider’s admin.
The emission rate is only valid for the next schelling round for this one it is not.
The admin can only be changed by the address of the provider.
-
+
@addr Address of the provider.
@website Website.
- @admin The new address of the admin. If we do not want to set it then we should enter 0X00.
+ @admin The new address of the admin. If we do not want to set it then we should enter 0X00.
@country Country
@info Short intro.
@rate Rate of the emission what will be given to the client.
@@ -303,7 +303,7 @@ contract provider is module, safeMath, announcementTypes {
/*
for the infos of the provider.
In case the height is unknown then the system will use the last known height.
-
+
@addr Addr of the provider
@height Height
@name Name of the provider.
@@ -348,7 +348,7 @@ contract provider is module, safeMath, announcementTypes {
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.
-
+
@addr Provider’s address.
@uint256 Amount of the connected capital
*/
@@ -363,7 +363,7 @@ contract provider is module, safeMath, announcementTypes {
uint256 currHeight = providers[msg.sender].currentHeight;
require( providers[msg.sender].data[currHeight].valid );
require( providers[msg.sender].data[currHeight].paidUpTo == currentSchellingRound );
-
+
providers[msg.sender].data[currHeight].valid = false;
providers[msg.sender].data[currHeight].close = currentSchellingRound;
setRightForInterest(getProviderCurrentSupply(msg.sender), 0, providers[msg.sender].data[currHeight].priv);
@@ -373,8 +373,8 @@ contract provider is module, safeMath, announcementTypes {
/*
Permition of the user to be able to connect to the provider.
This can only be invited by the provider’s admin.
- With this kind of call only 100 address can be permitted.
-
+ With this kind of call only 100 address can be permitted.
+
@addr Array of the addresses for whom the connection is allowed.
*/
uint256 currHeight = providers[provider].currentHeight;
@@ -382,7 +382,7 @@ contract provider is module, safeMath, announcementTypes {
require( providers[provider].data[currHeight].priv );
require( providers[provider].data[currHeight].admin == msg.sender );
require( addr.length <= 100 );
-
+
for ( uint256 a=0 ; a<addr.length ; a++ ) {
providers[provider].data[currHeight].allowedUsers[addr[a]] = true;
}
@@ -391,8 +391,8 @@ contract provider is module, safeMath, announcementTypes {
/*
Disable of the user not to be able to connect to the provider.
It is can called only for the admin of the provider.
- With this kind of call only 100 address can be permitted.
-
+ With this kind of call only 100 address can be permitted.
+
@addr Array of the addresses for whom the connection is allowed.
*/
uint256 currHeight = providers[provider].currentHeight;
@@ -400,7 +400,7 @@ contract provider is module, safeMath, announcementTypes {
require( providers[provider].data[currHeight].priv );
require( providers[provider].data[currHeight].admin == msg.sender );
require( addr.length <= 100 );
-
+
for ( uint256 a=0 ; a<addr.length ; a++ ) {
delete providers[provider].data[currHeight].allowedUsers[addr[a]];
}
@@ -414,7 +414,7 @@ contract provider is module, safeMath, announcementTypes {
If is an active provider then the client can only connect, if address is permitted at the provider (Whitelist).
At private providers, the number of the client is restricted. If it reaches the limit no further clients are allowed to connect.
This process has a transaction fee based on the senders whole token quantity.
-
+
@provider Address of the provider.
*/
uint256 currHeight = providers[provider].currentHeight;
@@ -427,7 +427,7 @@ contract provider is module, safeMath, announcementTypes {
}
uint256 bal = getTokenBalance(msg.sender);
require( moduleHandler(moduleHandlerAddress).processTransactionFee(msg.sender, bal) );
-
+
checkFloatingSupply(provider, currHeight, false, bal);
providers[provider].data[currHeight].clientsCount++;
clients[msg.sender].providerAddress = provider;
@@ -455,7 +455,7 @@ contract provider is module, safeMath, announcementTypes {
} else {
require( clients[msg.sender].paidUpTo == currentSchellingRound );
}
-
+
uint256 bal = getTokenBalance(msg.sender);
if ( ! providerHasClosed ) {
providers[provider].data[currHeight].clientsCount--;
@@ -472,7 +472,7 @@ contract provider is module, safeMath, announcementTypes {
function checkReward(address addr) public returns (uint256 reward) {
/*
Polling the share from the token emission for clients and for providers.
-
+
@addr The address want to check.
@reward Accumulated amount.
*/
@@ -494,7 +494,7 @@ contract provider is module, safeMath, announcementTypes {
In case the client/provider was far behind then it is possible that this function should be called several times to check the total generated schelling rounds and to collect the share.
If is neither a client nor a provider then the function is not available.
The tokens will be sent to the beneficiary from the address of the provider without any transaction fees.
-
+
@beneficiary Address of the beneficiary
@limit Quota of the check-rounds.
@provider Address of the provider
@@ -527,7 +527,7 @@ contract provider is module, safeMath, announcementTypes {
function getClientReward(uint256 limit) internal returns (uint256 reward) {
/*
Inner function for the client in order to collect the share from the token emission
-
+
@limit Quota of checking the schelling-rounds.
@reward Collected token amount from the checked rounds.
*/
@@ -574,7 +574,7 @@ contract provider is module, safeMath, announcementTypes {
}
function getProviderReward(address addr, uint256 limit) internal returns (uint256 providerReward, uint256 adminReward) {
/*
- Inner function for the provider in order to collect the share from the token emission
+ Inner function for the provider in order to collect the share from the token emission
@addr Address of the provider.
@limit Quota of the check-rounds.
@providerReward The reward of the provider’s address from the checked rounds.
@@ -594,7 +594,7 @@ contract provider is module, safeMath, announcementTypes {
rate = providers[addr].data[currHeight].rateHistory[a].value;
}
if ( rate > 0 ) {
- if ( ( a > LTSID && rightForInterest(providers[addr].data[currHeight].supply[LTSID], providers[addr].data[currHeight].priv) ||
+ if ( ( a > LTSID && rightForInterest(providers[addr].data[currHeight].supply[LTSID], providers[addr].data[currHeight].priv) ||
rightForInterest(providers[addr].data[currHeight].supply[a], providers[addr].data[currHeight].priv) ) ) {
if ( limit > 0 && steps > limit ) {
a--;
@@ -636,7 +636,7 @@ contract provider is module, safeMath, announcementTypes {
/*
Inner function for updating the database when some token change has happened.
In this case we are checking if despite the changes the provider is still entitled to the token emission. In case the legitimacy changes then the global supply should be set as well.
-
+
@providerAddress Provider address.
@providerHeight Provider height.
@neg the change was negative or not
@@ -646,15 +646,15 @@ contract provider is module, safeMath, announcementTypes {
if ( currentSchellingRound != LSID ) {
if ( neg ) {
setRightForInterest(
- providers[providerAddress].data[providerHeight].supply[LSID],
- providers[providerAddress].data[providerHeight].supply[LSID] - value,
+ providers[providerAddress].data[providerHeight].supply[LSID],
+ providers[providerAddress].data[providerHeight].supply[LSID] - value,
providers[providerAddress].data[providerHeight].priv
);
providers[providerAddress].data[providerHeight].supply[currentSchellingRound] = providers[providerAddress].data[providerHeight].supply[LSID] - value;
} else {
setRightForInterest(
- providers[providerAddress].data[providerHeight].supply[LSID],
- providers[providerAddress].data[providerHeight].supply[LSID] + value,
+ providers[providerAddress].data[providerHeight].supply[LSID],
+ providers[providerAddress].data[providerHeight].supply[LSID] + value,
providers[providerAddress].data[providerHeight].priv
);
providers[providerAddress].data[providerHeight].supply[currentSchellingRound] = providers[providerAddress].data[providerHeight].supply[LSID] + value;
@@ -663,15 +663,15 @@ contract provider is module, safeMath, announcementTypes {
} else {
if ( neg ) {
setRightForInterest(
- getProviderCurrentSupply(providerAddress),
- getProviderCurrentSupply(providerAddress) - value,
+ getProviderCurrentSupply(providerAddress),
+ getProviderCurrentSupply(providerAddress) - value,
providers[providerAddress].data[providerHeight].priv
);
providers[providerAddress].data[providerHeight].supply[currentSchellingRound] -= value;
} else {
setRightForInterest(
- getProviderCurrentSupply(providerAddress),
- getProviderCurrentSupply(providerAddress) + value,
+ getProviderCurrentSupply(providerAddress),
+ getProviderCurrentSupply(providerAddress) + value,
providers[providerAddress].data[providerHeight].priv
);
providers[providerAddress].data[providerHeight].supply[currentSchellingRound] += value;
@@ -683,7 +683,7 @@ contract provider is module, safeMath, announcementTypes {
Inner function for updating the database in case token change has happened.
In this case we check if the provider despite the changes is still entitled to the token emission.
We just call this only if the private provider and it’s own capital bears emission.
-
+
@providerAddress Provider address.
@providerHeight Provider height.
@neg Was the change negative?
@@ -693,15 +693,15 @@ contract provider is module, safeMath, announcementTypes {
if ( currentSchellingRound != LSID ) {
if ( neg ) {
setRightForInterest(
- providers[providerAddress].data[providerHeight].ownSupply[LSID],
- providers[providerAddress].data[providerHeight].ownSupply[LSID] - value,
+ providers[providerAddress].data[providerHeight].ownSupply[LSID],
+ providers[providerAddress].data[providerHeight].ownSupply[LSID] - value,
true
);
providers[providerAddress].data[providerHeight].ownSupply[currentSchellingRound] = providers[providerAddress].data[providerHeight].ownSupply[LSID] - value;
} else {
setRightForInterest(
- providers[providerAddress].data[providerHeight].ownSupply[LSID],
- providers[providerAddress].data[providerHeight].ownSupply[LSID] + value,
+ providers[providerAddress].data[providerHeight].ownSupply[LSID],
+ providers[providerAddress].data[providerHeight].ownSupply[LSID] + value,
true
);
providers[providerAddress].data[providerHeight].ownSupply[currentSchellingRound] = providers[providerAddress].data[providerHeight].ownSupply[LSID] + value;
@@ -710,15 +710,15 @@ contract provider is module, safeMath, announcementTypes {
} else {
if ( neg ) {
setRightForInterest(
- getProviderCurrentSupply(providerAddress),
- getProviderCurrentSupply(providerAddress) - value,
+ getProviderCurrentSupply(providerAddress),
+ getProviderCurrentSupply(providerAddress) - value,
true
);
providers[providerAddress].data[providerHeight].ownSupply[currentSchellingRound] -= value;
} else {
setRightForInterest(
- getProviderCurrentSupply(providerAddress),
- getProviderCurrentSupply(providerAddress) + value,
+ getProviderCurrentSupply(providerAddress),
+ getProviderCurrentSupply(providerAddress) + value,
true
);
providers[providerAddress].data[providerHeight].ownSupply[currentSchellingRound] += value;
@@ -728,7 +728,7 @@ contract provider is module, safeMath, announcementTypes {
function TEMath(uint256 a, uint256 b, bool neg) internal returns (uint256) {
/*
Inner function for the changes of the numbers
-
+
@a First number
@b 2nd number
@neg Operation with numbers. If it is TRUE then subtraction, if it is FALSE then addition.
@@ -740,7 +740,7 @@ contract provider is module, safeMath, announcementTypes {
/*
Inner function for perceiving the changes of the balance and updating the database.
If the address is a provider and the balance is decreasing than can not let it go under the minimum level.
-
+
@addr The address where the change happened.
@value Rate of the change.
@neg ype of the change. If it is TRUE then the balance has been decreased if it is FALSE then it has been increased.
@@ -771,9 +771,9 @@ contract provider is module, safeMath, announcementTypes {
function getTokenBalance(address addr) internal returns (uint256 balance) {
/*
Inner function in order to poll the token balance of the address.
-
+
@addr Address
-
+
@balance Balance of the address.
*/
(bool _success, uint256 _balance) = moduleHandler(moduleHandlerAddress).balanceOf(addr);
@@ -783,7 +783,7 @@ contract provider is module, safeMath, announcementTypes {
function checkICO() internal returns (bool isICO) {
/*
Inner function to check the ICO status.
-
+
@isICO Is the ICO in process or not?
*/
(bool _success, bool _isICO) = moduleHandler(moduleHandlerAddress).isICO();
diff --git a/test/compilationTests/corion/publisher.sol b/test/compilationTests/corion/publisher.sol
index 575b99a8..fcba13ad 100644
--- a/test/compilationTests/corion/publisher.sol
+++ b/test/compilationTests/corion/publisher.sol
@@ -1,278 +1,278 @@
-pragma solidity ^0.4.11;
-
-import "./announcementTypes.sol";
-import "./module.sol";
-import "./moduleHandler.sol";
-import "./safeMath.sol";
-
-contract publisher is announcementTypes, module, safeMath {
- /*
- module callbacks
- */
- function transferEvent(address from, address to, uint256 value) external returns (bool success) {
- /*
- Transaction completed. This function is available only for moduleHandler
- If a transaction is carried out from or to an address which participated in the objection of an announcement, its objection purport is automatically set
- */
- require( super.isModuleHandler(msg.sender) );
- uint256 announcementID;
- uint256 a;
- // need reverse lookup
- for ( a=0 ; a<opponents[from].length ; a++ ) {
- announcementID = opponents[msg.sender][a];
- if ( announcements[announcementID].end < block.number && announcements[announcementID].open ) {
- announcements[announcementID].oppositionWeight = safeSub(announcements[a].oppositionWeight, value);
- }
- }
- for ( a=0 ; a<opponents[to].length ; a++ ) {
- announcementID = opponents[msg.sender][a];
- if ( announcements[announcementID].end < block.number && announcements[announcementID].open ) {
- announcements[announcementID].oppositionWeight = safeAdd(announcements[a].oppositionWeight, value);
- }
- }
- return true;
- }
-
- /*
- Pool
- */
-
- uint256 public minAnnouncementDelay = 40320;
- uint256 public minAnnouncementDelayOnICO = 17280;
- uint8 public oppositeRate = 33;
-
- struct announcements_s {
- announcementType Type;
- uint256 start;
- uint256 end;
- bool open;
- string announcement;
- string link;
- bool oppositable;
- uint256 oppositionWeight;
- bool result;
-
- string _str;
- uint256 _uint;
- address _addr;
- }
- mapping(uint256 => announcements_s) public announcements;
- uint256 announcementsLength = 1;
-
- mapping (address => uint256[]) public opponents;
-
- constructor(address moduleHandler) public {
- /*
- Installation function. The installer will be registered in the admin list automatically
-
- @moduleHandler Address of moduleHandler
- */
- super.registerModuleHandler(moduleHandler);
- }
-
- function Announcements(uint256 id) public view returns (uint256 Type, uint256 Start, uint256 End, bool Closed, string memory Announcement, string memory Link, bool Opposited, string memory _str, uint256 _uint, address _addr) {
- /*
- Announcement data query
-
- @id Its identification
-
- @Type Subject of announcement
- @Start Height of announcement block
- @End Planned completion of announcement
- @Closed Closed or not
- @Announcement Announcement text
- @Link Link perhaps to a Forum
- @Opposited Objected or not
- @_str Text value
- @_uint Number value
- @_addr Address value
- */
- Type = uint256(announcements[id].Type);
- Start = announcements[id].start;
- End = announcements[id].end;
- Closed = ! announcements[id].open;
- Announcement = announcements[id].announcement;
- Link = announcements[id].link;
- if ( checkOpposited(announcements[id].oppositionWeight, announcements[id].oppositable) ) {
- Opposited = true;
- }
- _str = announcements[id]._str;
- _uint = announcements[id]._uint;
- _addr = announcements[id]._addr;
- }
-
- function checkOpposited(uint256 weight, bool oppositable) public view returns (bool success) {
- /*
- Veto check
-
- @weight Purport of objections so far
- @oppositable Opposable at all
-
- @success Opposed or not
- */
- if ( ! oppositable ) { return false; }
- (bool _success, uint256 _amount) = moduleHandler(moduleHandlerAddress).totalSupply();
- require( _success );
- return _amount * oppositeRate / 100 > weight;
- }
-
- function newAnnouncement(announcementType Type, string Announcement, string Link, bool Oppositable, string _str, uint256 _uint, address _addr) onlyOwner external {
- /*
- New announcement. Can be called only by those in the admin list
-
- @Type Topic of announcement
- @Start height of announcement block
- @End planned completion of announcement
- @Closed Completed or not
- @Announcement Announcement text
- @Link link to a Forum
- @Opposition opposed or not
- @_str text box
- @_uint number box
- @_addr address box
- */
- announcementsLength++;
- announcements[announcementsLength].Type = Type;
- announcements[announcementsLength].start = block.number;
- if ( checkICO() ) {
- announcements[announcementsLength].end = block.number + minAnnouncementDelayOnICO;
- } else {
- announcements[announcementsLength].end = block.number + minAnnouncementDelay;
- }
- announcements[announcementsLength].open = true;
- announcements[announcementsLength].announcement = Announcement;
- announcements[announcementsLength].link = Link;
- announcements[announcementsLength].oppositable = Oppositable;
- announcements[announcementsLength].oppositionWeight = 0;
- announcements[announcementsLength].result = false;
- announcements[announcementsLength]._str = _str;
- announcements[announcementsLength]._uint = _uint;
- announcements[announcementsLength]._addr = _addr;
- emit ENewAnnouncement(announcementsLength, Type);
- }
-
- function closeAnnouncement(uint256 id) onlyOwner external {
- /*
- Close announcement. It can be closed only by those in the admin list. Windup is allowed only after the announcement is completed.
-
- @id Announcement identification
- */
- require( announcements[id].open && announcements[id].end < block.number );
- if ( ! checkOpposited(announcements[id].oppositionWeight, announcements[id].oppositable) ) {
- announcements[id].result = true;
- if ( announcements[id].Type == announcementType.newModule ) {
- require( moduleHandler(moduleHandlerAddress).newModule(announcements[id]._str, announcements[id]._addr, true, true) );
- } else if ( announcements[id].Type == announcementType.dropModule ) {
- require( moduleHandler(moduleHandlerAddress).dropModule(announcements[id]._str, true) );
- } else if ( announcements[id].Type == announcementType.replaceModule ) {
- require( moduleHandler(moduleHandlerAddress).replaceModule(announcements[id]._str, announcements[id]._addr, true) );
- } else if ( announcements[id].Type == announcementType.replaceModuleHandler) {
- require( moduleHandler(moduleHandlerAddress).replaceModuleHandler(announcements[id]._addr) );
- } else if ( announcements[id].Type == announcementType.transactionFeeRate ||
- announcements[id].Type == announcementType.transactionFeeMin ||
- announcements[id].Type == announcementType.transactionFeeMax ||
- announcements[id].Type == announcementType.transactionFeeBurn ) {
- require( moduleHandler(moduleHandlerAddress).configureModule("token", announcements[id].Type, announcements[id]._uint) );
- } else if ( announcements[id].Type == announcementType.providerPublicFunds ||
- announcements[id].Type == announcementType.providerPrivateFunds ||
- announcements[id].Type == announcementType.providerPrivateClientLimit ||
- announcements[id].Type == announcementType.providerPublicMinRate ||
- announcements[id].Type == announcementType.providerPublicMaxRate ||
- announcements[id].Type == announcementType.providerPrivateMinRate ||
- announcements[id].Type == announcementType.providerPrivateMaxRate ||
- announcements[id].Type == announcementType.providerGasProtect ||
- announcements[id].Type == announcementType.providerInterestMinFunds ||
- announcements[id].Type == announcementType.providerRentRate ) {
- require( moduleHandler(moduleHandlerAddress).configureModule("provider", announcements[id].Type, announcements[id]._uint) );
- } else if ( announcements[id].Type == announcementType.schellingRoundBlockDelay ||
- announcements[id].Type == announcementType.schellingCheckRounds ||
- announcements[id].Type == announcementType.schellingCheckAboves ||
- announcements[id].Type == announcementType.schellingRate ) {
- require( moduleHandler(moduleHandlerAddress).configureModule("schelling", announcements[id].Type, announcements[id]._uint) );
- } else if ( announcements[id].Type == announcementType.publisherMinAnnouncementDelay) {
- minAnnouncementDelay = announcements[id]._uint;
- } else if ( announcements[id].Type == announcementType.publisherOppositeRate) {
- oppositeRate = uint8(announcements[id]._uint);
- }
- }
- announcements[id].end = block.number;
- announcements[id].open = false;
- }
-
- function oppositeAnnouncement(uint256 id) external {
- /*
- Opposition of announcement
- If announcement is opposable, anyone owning a token can oppose it
- Opposition is automatically with the total amount of tokens
- If the quantity of his tokens changes, the purport of his opposition changes automatically
- The prime time is the windup of the announcement, because this is the moment when the number of tokens in opposition are counted.
- One address is entitled to be in oppositon only once. An opposition cannot be withdrawn.
- Running announcements can be opposed only.
-
- @id Announcement identification
- */
- uint256 newArrayID = 0;
- bool foundEmptyArrayID = false;
- require( announcements[id].open );
- require( announcements[id].oppositable );
- for ( uint256 a=0 ; a<opponents[msg.sender].length ; a++ ) {
- require( opponents[msg.sender][a] != id );
- if ( ! announcements[opponents[msg.sender][a]].open) {
- delete opponents[msg.sender][a];
- if ( ! foundEmptyArrayID ) {
- foundEmptyArrayID = true;
- newArrayID = a;
- }
- }
- if ( ! foundEmptyArrayID ) {
- foundEmptyArrayID = true;
- newArrayID = a;
- }
- }
- (bool _success, uint256 _balance) = moduleHandler(moduleHandlerAddress).balanceOf(msg.sender);
- require( _success );
- require( _balance > 0);
- if ( foundEmptyArrayID ) {
- opponents[msg.sender][newArrayID] = id;
- } else {
- opponents[msg.sender].push(id);
- }
- announcements[id].oppositionWeight += _balance;
- emit EOppositeAnnouncement(id, msg.sender, _balance);
- }
-
- function invalidateAnnouncement(uint256 id) onlyOwner external {
- /*
- Withdraw announcement. Only those in the admin list can withdraw it.
-
- @id Announcement identification
- */
- require( announcements[id].open );
- announcements[id].end = block.number;
- announcements[id].open = false;
- emit EInvalidateAnnouncement(id);
- }
-
- modifier onlyOwner() {
- /*
- Only the owner is allowed to call it.
- */
- require( moduleHandler(moduleHandlerAddress).owners(msg.sender) );
- _;
- }
-
- function checkICO() internal returns (bool isICO) {
- /*
- Inner function to check the ICO status.
- @bool Is the ICO in process or not?
- */
- (bool _success, bool _isICO) = moduleHandler(moduleHandlerAddress).isICO();
- require( _success );
- return _isICO;
- }
-
- event ENewAnnouncement(uint256 id, announcementType typ);
- event EOppositeAnnouncement(uint256 id, address addr, uint256 value);
- event EInvalidateAnnouncement(uint256 id);
- event ECloseAnnouncement(uint256 id);
-}
+pragma solidity ^0.4.11;
+
+import "./announcementTypes.sol";
+import "./module.sol";
+import "./moduleHandler.sol";
+import "./safeMath.sol";
+
+contract publisher is announcementTypes, module, safeMath {
+ /*
+ module callbacks
+ */
+ function transferEvent(address from, address to, uint256 value) external returns (bool success) {
+ /*
+ Transaction completed. This function is available only for moduleHandler
+ If a transaction is carried out from or to an address which participated in the objection of an announcement, its objection purport is automatically set
+ */
+ require( super.isModuleHandler(msg.sender) );
+ uint256 announcementID;
+ uint256 a;
+ // need reverse lookup
+ for ( a=0 ; a<opponents[from].length ; a++ ) {
+ announcementID = opponents[msg.sender][a];
+ if ( announcements[announcementID].end < block.number && announcements[announcementID].open ) {
+ announcements[announcementID].oppositionWeight = safeSub(announcements[a].oppositionWeight, value);
+ }
+ }
+ for ( a=0 ; a<opponents[to].length ; a++ ) {
+ announcementID = opponents[msg.sender][a];
+ if ( announcements[announcementID].end < block.number && announcements[announcementID].open ) {
+ announcements[announcementID].oppositionWeight = safeAdd(announcements[a].oppositionWeight, value);
+ }
+ }
+ return true;
+ }
+
+ /*
+ Pool
+ */
+
+ uint256 public minAnnouncementDelay = 40320;
+ uint256 public minAnnouncementDelayOnICO = 17280;
+ uint8 public oppositeRate = 33;
+
+ struct announcements_s {
+ announcementType Type;
+ uint256 start;
+ uint256 end;
+ bool open;
+ string announcement;
+ string link;
+ bool oppositable;
+ uint256 oppositionWeight;
+ bool result;
+
+ string _str;
+ uint256 _uint;
+ address _addr;
+ }
+ mapping(uint256 => announcements_s) public announcements;
+ uint256 announcementsLength = 1;
+
+ mapping (address => uint256[]) public opponents;
+
+ constructor(address moduleHandler) public {
+ /*
+ Installation function. The installer will be registered in the admin list automatically
+
+ @moduleHandler Address of moduleHandler
+ */
+ super.registerModuleHandler(moduleHandler);
+ }
+
+ function Announcements(uint256 id) public view returns (uint256 Type, uint256 Start, uint256 End, bool Closed, string memory Announcement, string memory Link, bool Opposited, string memory _str, uint256 _uint, address _addr) {
+ /*
+ Announcement data query
+
+ @id Its identification
+
+ @Type Subject of announcement
+ @Start Height of announcement block
+ @End Planned completion of announcement
+ @Closed Closed or not
+ @Announcement Announcement text
+ @Link Link perhaps to a Forum
+ @Opposited Objected or not
+ @_str Text value
+ @_uint Number value
+ @_addr Address value
+ */
+ Type = uint256(announcements[id].Type);
+ Start = announcements[id].start;
+ End = announcements[id].end;
+ Closed = ! announcements[id].open;
+ Announcement = announcements[id].announcement;
+ Link = announcements[id].link;
+ if ( checkOpposited(announcements[id].oppositionWeight, announcements[id].oppositable) ) {
+ Opposited = true;
+ }
+ _str = announcements[id]._str;
+ _uint = announcements[id]._uint;
+ _addr = announcements[id]._addr;
+ }
+
+ function checkOpposited(uint256 weight, bool oppositable) public view returns (bool success) {
+ /*
+ Veto check
+
+ @weight Purport of objections so far
+ @oppositable Opposable at all
+
+ @success Opposed or not
+ */
+ if ( ! oppositable ) { return false; }
+ (bool _success, uint256 _amount) = moduleHandler(moduleHandlerAddress).totalSupply();
+ require( _success );
+ return _amount * oppositeRate / 100 > weight;
+ }
+
+ function newAnnouncement(announcementType Type, string Announcement, string Link, bool Oppositable, string _str, uint256 _uint, address _addr) onlyOwner external {
+ /*
+ New announcement. Can be called only by those in the admin list
+
+ @Type Topic of announcement
+ @Start height of announcement block
+ @End planned completion of announcement
+ @Closed Completed or not
+ @Announcement Announcement text
+ @Link link to a Forum
+ @Opposition opposed or not
+ @_str text box
+ @_uint number box
+ @_addr address box
+ */
+ announcementsLength++;
+ announcements[announcementsLength].Type = Type;
+ announcements[announcementsLength].start = block.number;
+ if ( checkICO() ) {
+ announcements[announcementsLength].end = block.number + minAnnouncementDelayOnICO;
+ } else {
+ announcements[announcementsLength].end = block.number + minAnnouncementDelay;
+ }
+ announcements[announcementsLength].open = true;
+ announcements[announcementsLength].announcement = Announcement;
+ announcements[announcementsLength].link = Link;
+ announcements[announcementsLength].oppositable = Oppositable;
+ announcements[announcementsLength].oppositionWeight = 0;
+ announcements[announcementsLength].result = false;
+ announcements[announcementsLength]._str = _str;
+ announcements[announcementsLength]._uint = _uint;
+ announcements[announcementsLength]._addr = _addr;
+ emit ENewAnnouncement(announcementsLength, Type);
+ }
+
+ function closeAnnouncement(uint256 id) onlyOwner external {
+ /*
+ Close announcement. It can be closed only by those in the admin list. Windup is allowed only after the announcement is completed.
+
+ @id Announcement identification
+ */
+ require( announcements[id].open && announcements[id].end < block.number );
+ if ( ! checkOpposited(announcements[id].oppositionWeight, announcements[id].oppositable) ) {
+ announcements[id].result = true;
+ if ( announcements[id].Type == announcementType.newModule ) {
+ require( moduleHandler(moduleHandlerAddress).newModule(announcements[id]._str, announcements[id]._addr, true, true) );
+ } else if ( announcements[id].Type == announcementType.dropModule ) {
+ require( moduleHandler(moduleHandlerAddress).dropModule(announcements[id]._str, true) );
+ } else if ( announcements[id].Type == announcementType.replaceModule ) {
+ require( moduleHandler(moduleHandlerAddress).replaceModule(announcements[id]._str, announcements[id]._addr, true) );
+ } else if ( announcements[id].Type == announcementType.replaceModuleHandler) {
+ require( moduleHandler(moduleHandlerAddress).replaceModuleHandler(announcements[id]._addr) );
+ } else if ( announcements[id].Type == announcementType.transactionFeeRate ||
+ announcements[id].Type == announcementType.transactionFeeMin ||
+ announcements[id].Type == announcementType.transactionFeeMax ||
+ announcements[id].Type == announcementType.transactionFeeBurn ) {
+ require( moduleHandler(moduleHandlerAddress).configureModule("token", announcements[id].Type, announcements[id]._uint) );
+ } else if ( announcements[id].Type == announcementType.providerPublicFunds ||
+ announcements[id].Type == announcementType.providerPrivateFunds ||
+ announcements[id].Type == announcementType.providerPrivateClientLimit ||
+ announcements[id].Type == announcementType.providerPublicMinRate ||
+ announcements[id].Type == announcementType.providerPublicMaxRate ||
+ announcements[id].Type == announcementType.providerPrivateMinRate ||
+ announcements[id].Type == announcementType.providerPrivateMaxRate ||
+ announcements[id].Type == announcementType.providerGasProtect ||
+ announcements[id].Type == announcementType.providerInterestMinFunds ||
+ announcements[id].Type == announcementType.providerRentRate ) {
+ require( moduleHandler(moduleHandlerAddress).configureModule("provider", announcements[id].Type, announcements[id]._uint) );
+ } else if ( announcements[id].Type == announcementType.schellingRoundBlockDelay ||
+ announcements[id].Type == announcementType.schellingCheckRounds ||
+ announcements[id].Type == announcementType.schellingCheckAboves ||
+ announcements[id].Type == announcementType.schellingRate ) {
+ require( moduleHandler(moduleHandlerAddress).configureModule("schelling", announcements[id].Type, announcements[id]._uint) );
+ } else if ( announcements[id].Type == announcementType.publisherMinAnnouncementDelay) {
+ minAnnouncementDelay = announcements[id]._uint;
+ } else if ( announcements[id].Type == announcementType.publisherOppositeRate) {
+ oppositeRate = uint8(announcements[id]._uint);
+ }
+ }
+ announcements[id].end = block.number;
+ announcements[id].open = false;
+ }
+
+ function oppositeAnnouncement(uint256 id) external {
+ /*
+ Opposition of announcement
+ If announcement is opposable, anyone owning a token can oppose it
+ Opposition is automatically with the total amount of tokens
+ If the quantity of his tokens changes, the purport of his opposition changes automatically
+ The prime time is the windup of the announcement, because this is the moment when the number of tokens in opposition are counted.
+ One address is entitled to be in oppositon only once. An opposition cannot be withdrawn.
+ Running announcements can be opposed only.
+
+ @id Announcement identification
+ */
+ uint256 newArrayID = 0;
+ bool foundEmptyArrayID = false;
+ require( announcements[id].open );
+ require( announcements[id].oppositable );
+ for ( uint256 a=0 ; a<opponents[msg.sender].length ; a++ ) {
+ require( opponents[msg.sender][a] != id );
+ if ( ! announcements[opponents[msg.sender][a]].open) {
+ delete opponents[msg.sender][a];
+ if ( ! foundEmptyArrayID ) {
+ foundEmptyArrayID = true;
+ newArrayID = a;
+ }
+ }
+ if ( ! foundEmptyArrayID ) {
+ foundEmptyArrayID = true;
+ newArrayID = a;
+ }
+ }
+ (bool _success, uint256 _balance) = moduleHandler(moduleHandlerAddress).balanceOf(msg.sender);
+ require( _success );
+ require( _balance > 0);
+ if ( foundEmptyArrayID ) {
+ opponents[msg.sender][newArrayID] = id;
+ } else {
+ opponents[msg.sender].push(id);
+ }
+ announcements[id].oppositionWeight += _balance;
+ emit EOppositeAnnouncement(id, msg.sender, _balance);
+ }
+
+ function invalidateAnnouncement(uint256 id) onlyOwner external {
+ /*
+ Withdraw announcement. Only those in the admin list can withdraw it.
+
+ @id Announcement identification
+ */
+ require( announcements[id].open );
+ announcements[id].end = block.number;
+ announcements[id].open = false;
+ emit EInvalidateAnnouncement(id);
+ }
+
+ modifier onlyOwner() {
+ /*
+ Only the owner is allowed to call it.
+ */
+ require( moduleHandler(moduleHandlerAddress).owners(msg.sender) );
+ _;
+ }
+
+ function checkICO() internal returns (bool isICO) {
+ /*
+ Inner function to check the ICO status.
+ @bool Is the ICO in process or not?
+ */
+ (bool _success, bool _isICO) = moduleHandler(moduleHandlerAddress).isICO();
+ require( _success );
+ return _isICO;
+ }
+
+ event ENewAnnouncement(uint256 id, announcementType typ);
+ event EOppositeAnnouncement(uint256 id, address addr, uint256 value);
+ event EInvalidateAnnouncement(uint256 id);
+ event ECloseAnnouncement(uint256 id);
+}
diff --git a/test/compilationTests/corion/safeMath.sol b/test/compilationTests/corion/safeMath.sol
index 9e27d379..a6680f27 100644
--- a/test/compilationTests/corion/safeMath.sol
+++ b/test/compilationTests/corion/safeMath.sol
@@ -5,7 +5,7 @@ contract safeMath {
/*
Biztonsagos hozzadas. Tulcsordulas elleni vedelem.
A vegeredmeny nem lehet kevesebb mint az @a, ha igen megall a kod.
-
+
@a Amihez hozzaadni kell
@b Amennyit hozzaadni kell.
@uint256 Vegeredmeny.
@@ -15,12 +15,12 @@ contract safeMath {
}
return a + b;
}
-
+
function safeSub(uint256 a, uint256 b) internal returns(uint256) {
/*
Biztonsagos kivonas. Tulcsordulas elleni vedelem.
A vegeredmeny nem lehet tobb mint az @a, ha igen megall a kod.
-
+
@a Amibol kivonni kell.
@b Amennyit kivonni kell.
@uint256 Vegeredmeny.
diff --git a/test/compilationTests/corion/schelling.sol b/test/compilationTests/corion/schelling.sol
index 3905e300..c4f3c02c 100644
--- a/test/compilationTests/corion/schelling.sol
+++ b/test/compilationTests/corion/schelling.sol
@@ -141,9 +141,9 @@ contract schelling is module, announcementTypes, schellingVars {
}
function transferEvent(address from, address to, uint256 value) external returns (bool) {
/*
- Transaction completed. This function can be called only by the ModuleHandler.
+ Transaction completed. This function can be called only by the ModuleHandler.
If this contract is the receiver, the amount will be added to the prize pool of the current round.
-
+
@from From who
@to To who
@value Amount
@@ -160,7 +160,7 @@ contract schelling is module, announcementTypes, schellingVars {
}
modifier isReady {
(bool _success, bool _active) = super.isActive();
- require( _success && _active );
+ require( _success && _active );
_;
}
/*
@@ -175,7 +175,7 @@ contract schelling is module, announcementTypes, schellingVars {
require( db.setFunds(addr, amount) );
}
function setVoter(address owner, _voter memory voter) internal {
- require( db.setVoter(owner,
+ require( db.setVoter(owner,
voter.roundID,
voter.hash,
voter.status,
@@ -189,7 +189,7 @@ contract schelling is module, announcementTypes, schellingVars {
return _voter(b, c, d, e, f);
}
function setRound(uint256 id, _rounds memory round) internal {
- require( db.setRound(id,
+ require( db.setRound(id,
round.totalAboveWeight,
round.totalBelowWeight,
round.reward,
@@ -250,7 +250,7 @@ contract schelling is module, announcementTypes, schellingVars {
constructor(address _moduleHandler, address _db, bool _forReplace) public {
/*
Installation function.
-
+
@_moduleHandler Address of ModuleHandler.
@_db Address of the database.
@_forReplace This address will be replaced with the old one or not.
@@ -259,13 +259,13 @@ contract schelling is module, announcementTypes, schellingVars {
db = schellingDB(_db);
super.registerModuleHandler(_moduleHandler);
if ( ! _forReplace ) {
- require( db.replaceOwner(this) );
+ require( db.replaceOwner(address(this)) );
}
}
function configure(announcementType a, uint256 b) external returns(bool) {
/*
Can be called only by the ModuleHandler.
-
+
@a Sort of configuration
@b Value
*/
@@ -280,22 +280,22 @@ contract schelling is module, announcementTypes, schellingVars {
function prepareVote(bytes32 votehash, uint256 roundID) isReady noContract external {
/*
Initializing manual vote.
- Only the hash of vote will be sent. (Envelope sending).
- The address must be in default state, that is there are no vote in progress.
+ Only the hash of vote will be sent. (Envelope sending).
+ The address must be in default state, that is there are no vote in progress.
Votes can be sent only on the actually Schelling round.
-
+
@votehash Hash of the vote
@roundID Number of Schelling round
*/
nextRound();
-
+
uint256 currentRound = getCurrentRound();
schellingVars._rounds memory round = getRound(currentRound);
_voter memory voter;
uint256 funds;
-
+
require( roundID == currentRound );
-
+
voter = getVoter(msg.sender);
funds = getFunds(msg.sender);
@@ -304,10 +304,10 @@ contract schelling is module, announcementTypes, schellingVars {
voter.roundID = currentRound;
voter.hash = votehash;
voter.status = voterStatus.afterPrepareVote;
-
+
setVoter(msg.sender, voter);
round.voted = true;
-
+
setRound(currentRound, round);
}
function sendVote(string vote) isReady noContract external {
@@ -318,21 +318,21 @@ contract schelling is module, announcementTypes, schellingVars {
If the vote invalid, the deposit will be lost.
If the “envelope” was opened later than 1,5 Schelling round, the vote is automatically invalid, and deposit can be lost.
Lost deposits will be 100% burned.
-
+
@vote Hash of the content of the vote.
*/
nextRound();
-
+
uint256 currentRound = getCurrentRound();
_rounds memory round;
_voter memory voter;
uint256 funds;
-
+
bool lostEverything;
voter = getVoter(msg.sender);
round = getRound(voter.roundID);
funds = getFunds(msg.sender);
-
+
require( voter.status == voterStatus.afterPrepareVote );
require( voter.roundID < currentRound );
if ( keccak256(bytes(vote)) == voter.hash ) {
@@ -355,7 +355,7 @@ contract schelling is module, announcementTypes, schellingVars {
delete funds;
delete voter.status;
}
-
+
setVoter(msg.sender, voter);
setRound(voter.roundID, round);
setFunds(msg.sender, funds);
@@ -368,17 +368,17 @@ contract schelling is module, announcementTypes, schellingVars {
The right votes take share of deposits.
*/
nextRound();
-
+
uint256 currentRound = getCurrentRound();
_rounds memory round;
_voter memory voter;
uint256 funds;
-
+
voter = getVoter(msg.sender);
round = getRound(voter.roundID);
funds = getFunds(msg.sender);
-
- require( voter.status == voterStatus.afterSendVoteOk ||
+
+ require( voter.status == voterStatus.afterSendVoteOk ||
voter.status == voterStatus.afterSendVoteBad );
if ( round.blockHeight+roundBlockDelay/2 <= block.number ) {
if ( isWinner(round, voter.voteResult) && voter.status == voterStatus.afterSendVoteOk ) {
@@ -390,7 +390,7 @@ contract schelling is module, announcementTypes, schellingVars {
delete voter.status;
delete voter.roundID;
} else { revert(); }
-
+
setVoter(msg.sender, voter);
setFunds(msg.sender, funds);
}
@@ -400,12 +400,12 @@ contract schelling is module, announcementTypes, schellingVars {
The prizes will be collected here, and with this function can be transferred to the account of the user.
Optionally there can be an address of a beneficiary added, which address the prize will be sent to. Without beneficiary, the owner is the default address.
Prize will be sent from the Schelling address without any transaction fee.
-
+
@beneficiary Address of the beneficiary
*/
schellingVars._voter memory voter = getVoter(msg.sender);
uint256 funds = getFunds(msg.sender);
-
+
address _beneficiary = msg.sender;
if (beneficiary != address(0x00)) { _beneficiary = beneficiary; }
uint256 reward;
@@ -414,13 +414,13 @@ contract schelling is module, announcementTypes, schellingVars {
reward = voter.rewards;
delete voter.rewards;
require( moduleHandler(moduleHandlerAddress).transfer(address(this), _beneficiary, reward, false) );
-
+
setVoter(msg.sender, voter);
}
function checkReward() public view returns (uint256 reward) {
/*
Withdraw of the amount of the prize (it’s only information).
-
+
@reward Prize
*/
schellingVars._voter memory voter = getVoter(msg.sender);
@@ -435,9 +435,9 @@ contract schelling is module, announcementTypes, schellingVars {
_rounds memory newRound;
_rounds memory prevRound;
uint256 currentSchellingRound = getCurrentSchellingRound();
-
+
if ( round.blockHeight+roundBlockDelay > block.number) { return false; }
-
+
newRound.blockHeight = block.number;
if ( ! round.voted ) {
newRound.reward = round.reward;
@@ -452,9 +452,9 @@ contract schelling is module, announcementTypes, schellingVars {
if ( above >= interestCheckAboves ) {
expansion = getTotalSupply() * interestRate / interestRateM / 100;
}
-
+
currentSchellingRound++;
-
+
pushRound(newRound);
setSchellingExpansion(currentSchellingRound, expansion);
require( moduleHandler(moduleHandlerAddress).broadcastSchellingRound(currentSchellingRound, expansion) );
@@ -466,19 +466,19 @@ contract schelling is module, announcementTypes, schellingVars {
Every participant entry with his own deposit.
In case of wrong vote only this amount of deposit will be burn.
The deposit will be sent to the address of Schelling, charged with transaction fee.
-
+
@amount Amount of deposit.
*/
_voter memory voter = getVoter(msg.sender);
uint256 funds = getFunds(msg.sender);
-
+
(bool a, bool b) = moduleHandler(moduleHandlerAddress).isICO();
require( b && b );
require( voter.status == voterStatus.base );
require( amount > 0 );
require( moduleHandler(moduleHandlerAddress).transfer(msg.sender, address(this), amount, true) );
funds += amount;
-
+
setFunds(msg.sender, funds);
}
function getFunds() isReady noContract external {
@@ -489,17 +489,17 @@ contract schelling is module, announcementTypes, schellingVars {
*/
_voter memory voter = getVoter(msg.sender);
uint256 funds = getFunds(msg.sender);
-
+
require( funds > 0 );
require( voter.status == voterStatus.base );
setFunds(msg.sender, 0);
-
+
require( moduleHandler(moduleHandlerAddress).transfer(address(this), msg.sender, funds, true) );
}
function getCurrentSchellingRoundID() public view returns (uint256) {
/*
Number of actual Schelling round.
-
+
@uint256 Schelling round.
*/
return getCurrentSchellingRound();
@@ -507,7 +507,7 @@ contract schelling is module, announcementTypes, schellingVars {
function getSchellingRound(uint256 id) public view returns (uint256 expansion) {
/*
Amount of token emission of the Schelling round.
-
+
@id Number of Schelling round
@expansion Amount of token emission
*/
@@ -516,7 +516,7 @@ contract schelling is module, announcementTypes, schellingVars {
function getRoundWeight(uint256 aboveW, uint256 belowW) internal returns (uint256) {
/*
Inside function for calculating the weights of the votes.
-
+
@aboveW Weight of votes: ABOVE
@belowW Weight of votes: BELOW
@uint256 Calculatet weight
@@ -532,7 +532,7 @@ contract schelling is module, announcementTypes, schellingVars {
function isWinner(_rounds memory round, bool aboveVote) internal returns (bool) {
/*
Inside function for calculating the result of the game.
-
+
@round Structure of Schelling round.
@aboveVote Is the vote = ABOVE or not
@bool Result
@@ -543,31 +543,31 @@ contract schelling is module, announcementTypes, schellingVars {
}
return false;
}
-
+
function getTotalSupply() internal returns (uint256 amount) {
/*
Inside function for querying the whole amount of the tokens.
-
+
@uint256 Whole token amount
*/
(bool _success, uint256 _amount) = moduleHandler(moduleHandlerAddress).totalSupply();
require( _success );
return _amount;
}
-
+
function getTokenBalance(address addr) internal returns (uint256 balance) {
/*
Inner function in order to poll the token balance of the address.
-
+
@addr Address
-
+
@balance Balance of the address.
*/
(bool _success, uint256 _balance) = moduleHandler(moduleHandlerAddress).balanceOf(addr);
require( _success );
return _balance;
}
-
+
modifier noContract {
/*
Contract can’t call this function, only a natural address.
diff --git a/test/compilationTests/corion/token.sol b/test/compilationTests/corion/token.sol
index 6c8f6f24..87ec64d6 100644
--- a/test/compilationTests/corion/token.sol
+++ b/test/compilationTests/corion/token.sol
@@ -23,7 +23,7 @@ contract token is safeMath, module, announcementTypes {
}
modifier isReady {
(bool _success, bool _active) = super.isActive();
- require( _success && _active );
+ require( _success && _active );
_;
}
/**
@@ -35,7 +35,7 @@ contract token is safeMath, module, announcementTypes {
string public name = "Corion";
string public symbol = "COR";
uint8 public decimals = 6;
-
+
tokenDB public db;
address public icoAddr;
uint256 public transactionFeeRate = 20;
@@ -45,15 +45,15 @@ contract token is safeMath, module, announcementTypes {
uint256 public transactionFeeBurn = 80;
address public exchangeAddress;
bool public isICO = true;
-
+
mapping(address => bool) public genesis;
constructor(bool forReplace, address moduleHandler, address dbAddr, address icoContractAddr, address exchangeContractAddress, address[] memory genesisAddr, uint256[] memory genesisValue) public payable {
/*
Installation function
-
+
When _icoAddr is defined, 0.2 ether has to be attached as many times as many genesis addresses are given
-
+
@forReplace This address will be replaced with the old one or not.
@moduleHandler Modulhandler's address
@dbAddr Address of database
@@ -71,7 +71,7 @@ contract token is safeMath, module, announcementTypes {
exchangeAddress = exchangeContractAddress;
isICO = ! forReplace;
if ( ! forReplace ) {
- require( db.replaceOwner(this) );
+ require( db.replaceOwner(address(this)) );
assert( genesisAddr.length == genesisValue.length );
require( address(this).balance >= genesisAddr.length * 0.2 ether );
for ( uint256 a=0 ; a<genesisAddr.length ; a++ ) {
@@ -82,18 +82,18 @@ contract token is safeMath, module, announcementTypes {
}
}
}
-
+
function closeIco() external returns (bool success) {
/*
ICO finished. It can be called only by ICO contract
-
+
@success Was the Function successful?
*/
require( msg.sender == icoAddr );
isICO = false;
return true;
}
-
+
/**
* @notice `msg.sender` approves `spender` to spend `amount` tokens on its behalf.
* @param spender The address of the account able to transfer the tokens
@@ -104,17 +104,17 @@ contract token is safeMath, module, announcementTypes {
function approve(address spender, uint256 amount, uint256 nonce) isReady external returns (bool success) {
/*
Authorise another address to use a certain quantity of the authorising owner’s balance
-
+
@spender Address of authorised party
@amount Token quantity
@nonce Transaction count
-
+
@success Was the Function successful?
*/
_approve(spender, amount, nonce);
return true;
}
-
+
/**
* @notice `msg.sender` approves `spender` to spend `amount` tokens on its behalf and notify the spender from your approve with your `extraData` data.
* @param spender The address of the account able to transfer the tokens
@@ -127,24 +127,24 @@ contract token is safeMath, module, announcementTypes {
/*
Authorise another address to use a certain quantity of the authorising owner’s balance
Following the transaction the receiver address `approvedCorionToken` function is called by the given data
-
+
@spender Authorized address
@amount Token quantity
@extraData Extra data to be received by the receiver
@nonce Transaction count
-
+
@success Was the Function successful?
*/
_approve(spender, amount, nonce);
require( thirdPartyContractAbstract(spender).approvedCorionToken(msg.sender, amount, extraData) );
return true;
}
-
+
function _approve(address spender, uint256 amount, uint256 nonce) internal {
/*
Internal Function to authorise another address to use a certain quantity of the authorising owner’s balance.
If the transaction count not match the authorise fails.
-
+
@spender Address of authorised party
@amount Token quantity
@nonce Transaction count
@@ -158,10 +158,10 @@ contract token is safeMath, module, announcementTypes {
function allowance(address owner, address spender) public view returns (uint256 remaining, uint256 nonce) {
/*
Get the quantity of tokens given to be used
-
+
@owner Authorising address
@spender Authorised address
-
+
@remaining Tokens to be spent
@nonce Transaction count
*/
@@ -169,7 +169,7 @@ contract token is safeMath, module, announcementTypes {
require( _success );
return (_remaining, _nonce);
}
-
+
/**
* @notice Send `amount` Corion tokens to `to` from `msg.sender`
* @param to The address of the recipient
@@ -181,10 +181,10 @@ contract token is safeMath, module, announcementTypes {
Start transaction, token is sent from caller’s address to receiver’s address
Transaction fee is to be deducted.
If receiver is not a natural address but a person, he will be called
-
+
@to To who
@amount Quantity
-
+
@success Was the Function successful?
*/
bytes memory _data;
@@ -196,7 +196,7 @@ contract token is safeMath, module, announcementTypes {
emit Transfer(msg.sender, to, amount, _data);
return true;
}
-
+
/**
* @notice Send `amount` tokens to `to` from `from` on the condition it is approved by `from`
* @param from The address holding the tokens being transferred
@@ -209,11 +209,11 @@ contract token is safeMath, module, announcementTypes {
Start transaction to send a quantity from a given address to another address. (approve / allowance). This can be called only by the address approved in advance
Transaction fee is to be deducted
If receiver is not a natural address but a person, he will be called
-
+
@from From who.
@to To who
@amount Quantity
-
+
@success Was the Function successful?
*/
if ( from != msg.sender ) {
@@ -233,7 +233,7 @@ contract token is safeMath, module, announcementTypes {
emit Transfer(from, to, amount, _data);
return true;
}
-
+
/**
* @notice Send `amount` tokens to `to` from `from` on the condition it is approved by `from`
* @param from The address holding the tokens being transferred
@@ -245,12 +245,12 @@ contract token is safeMath, module, announcementTypes {
/*
Start transaction to send a quantity from a given address to another address
Only ModuleHandler can call it
-
+
@from From who
@to To who.
@amount Quantity
@fee Deduct transaction fee - yes or no?
-
+
@success Was the Function successful?
*/
bytes memory _data;
@@ -259,7 +259,7 @@ contract token is safeMath, module, announcementTypes {
emit Transfer(from, to, amount, _data);
return true;
}
-
+
/**
* @notice Send `amount` Corion tokens to `to` from `msg.sender` and notify the receiver from your transaction with your `extraData` data
* @param to The contract address of the recipient
@@ -272,11 +272,11 @@ contract token is safeMath, module, announcementTypes {
Start transaction to send a quantity from a given address to another address
After transaction the function `receiveCorionToken`of the receiver is called by the given data
When sending an amount, it is possible the total amount cannot be processed, the remaining amount is sent back with no fee charged
-
+
@to To who.
@amount Quantity
@extraData Extra data the receiver will get
-
+
@success Was the Function successful?
*/
if ( isContract(to) ) {
@@ -287,11 +287,11 @@ contract token is safeMath, module, announcementTypes {
emit Transfer(msg.sender, to, amount, extraData);
return true;
}
-
+
function _transferToContract(address from, address to, uint256 amount, bytes memory extraData) internal {
/*
Internal function to start transactions to a contract
-
+
@from From who
@to To who.
@amount Quantity
@@ -306,15 +306,15 @@ contract token is safeMath, module, announcementTypes {
}
_processTransactionFee(from, amount - _back);
}
-
+
function _transfer(address from, address to, uint256 amount, bool fee) internal {
/*
Internal function to start transactions. When Tokens are sent, transaction fee is charged
During ICO transactions are allowed only from genesis addresses.
- After sending the tokens, the ModuleHandler is notified and it will broadcast the fact among members
-
+ After sending the tokens, the ModuleHandler is notified and it will broadcast the fact among members
+
The 0xa636a97578d26a3b76b060bbc18226d954cf3757 address are blacklisted.
-
+
@from From who
@to To who
@amount Quantity
@@ -336,7 +336,7 @@ contract token is safeMath, module, announcementTypes {
}
require( moduleHandler(moduleHandlerAddress).broadcastTransfer(from, to, amount) );
}
-
+
/**
* @notice Transaction fee will be deduced from `owner` for transacting `value`
* @param owner The address where will the transaction fee deduced
@@ -345,23 +345,23 @@ contract token is safeMath, module, announcementTypes {
*/
function processTransactionFee(address owner, uint256 value) isReady external returns (bool success) {
/*
- Charge transaction fee. It can be called only by moduleHandler
-
+ Charge transaction fee. It can be called only by moduleHandler
+
@owner From who.
@value Quantity to calculate the fee
-
+
@success Was the Function successful?
*/
require( super.isModuleHandler(msg.sender) );
_processTransactionFee(owner, value);
return true;
}
-
+
function _processTransactionFee(address owner, uint256 value) internal {
/*
Internal function to charge the transaction fee. A certain quantity is burnt, the rest is sent to the Schelling game prize pool.
No transaction fee during ICO.
-
+
@owner From who
@value Quantity to calculate the fee
*/
@@ -385,13 +385,13 @@ contract token is safeMath, module, announcementTypes {
_burn(owner, _fee);
}
}
-
+
function getTransactionFee(uint256 value) public view returns (bool success, uint256 fee) {
/*
Transaction fee query.
-
+
@value Quantity to calculate the fee
-
+
@success Was the Function successful?
@fee Amount of Transaction fee
*/
@@ -401,25 +401,25 @@ contract token is safeMath, module, announcementTypes {
else if ( fee < transactionFeeMin ) { fee = transactionFeeMin; }
return (true, fee);
}
-
+
function mint(address owner, uint256 value) isReady external returns (bool success) {
/*
Generating tokens. It can be called only by ICO contract or the moduleHandler.
-
+
@owner Address
@value Amount.
-
+
@success Was the Function successful?
*/
require( super.isModuleHandler(msg.sender) || msg.sender == icoAddr );
_mint(owner, value);
return true;
}
-
+
function _mint(address owner, uint256 value) internal {
/*
Internal function to generate tokens
-
+
@owner Token is credited to this address
@value Quantity
*/
@@ -430,25 +430,25 @@ contract token is safeMath, module, announcementTypes {
}
emit Mint(owner, value);
}
-
+
function burn(address owner, uint256 value) isReady external returns (bool success) {
/*
Burning the token. Can call only modulehandler
-
+
@owner Burn the token from this address
@value Quantity
-
+
@success Was the Function successful?
*/
require( super.isModuleHandler(msg.sender) );
_burn(owner, value);
return true;
}
-
+
function _burn(address owner, uint256 value) internal {
/*
Internal function to burn the token
-
+
@owner Burn the token from this address
@value Quantity
*/
@@ -456,13 +456,13 @@ contract token is safeMath, module, announcementTypes {
require( moduleHandler(moduleHandlerAddress).broadcastTransfer(owner, address(0x00), value) );
emit Burn(owner, value);
}
-
+
function isContract(address addr) internal returns (bool success) {
/*
Internal function to check if the given address is natural, or a contract
-
+
@addr Address to be checked
-
+
@success Is the address crontact or not
*/
uint256 _codeLength;
@@ -475,9 +475,9 @@ contract token is safeMath, module, announcementTypes {
function balanceOf(address owner) public view returns (uint256 value) {
/*
Token balance query
-
+
@owner Address
-
+
@value Balance of address
*/
return db.balanceOf(owner);
@@ -486,19 +486,19 @@ contract token is safeMath, module, announcementTypes {
function totalSupply() public view returns (uint256 value) {
/*
Total token quantity query
-
+
@value Total token quantity
*/
return db.totalSupply();
}
-
+
function configure(announcementType aType, uint256 value) isReady external returns(bool success) {
/*
Token settings configuration.It can be call only by moduleHandler
-
+
@aType Type of setting
@value Value
-
+
@success Was the Function successful?
*/
require( super.isModuleHandler(msg.sender) );
@@ -509,7 +509,7 @@ contract token is safeMath, module, announcementTypes {
else { return false; }
return true;
}
-
+
event AllowanceUsed(address indexed spender, address indexed owner, uint256 indexed value);
event Mint(address indexed addr, uint256 indexed value);
event Burn(address indexed addr, uint256 indexed value);
diff --git a/test/compilationTests/corion/tokenDB.sol b/test/compilationTests/corion/tokenDB.sol
index 484135ca..1632a89b 100644
--- a/test/compilationTests/corion/tokenDB.sol
+++ b/test/compilationTests/corion/tokenDB.sol
@@ -1,77 +1,77 @@
-pragma solidity ^0.4.11;
-
-import "./safeMath.sol";
-import "./owned.sol";
-
-contract tokenDB is safeMath, ownedDB {
-
- struct allowance_s {
- uint256 amount;
- uint256 nonce;
- }
-
- mapping(address => mapping(address => allowance_s)) public allowance;
- mapping (address => uint256) public balanceOf;
- uint256 public totalSupply;
-
- function increase(address owner, uint256 value) external returns(bool success) {
- /*
- Increase of balance of the address in database. Only owner can call it.
-
- @owner Address
- @value Quantity
-
- @success Was the Function successful?
- */
- require( isOwner() );
- balanceOf[owner] = safeAdd(balanceOf[owner], value);
- totalSupply = safeAdd(totalSupply, value);
- return true;
- }
-
- function decrease(address owner, uint256 value) external returns(bool success) {
- /*
- Decrease of balance of the address in database. Only owner can call it.
-
- @owner Address
- @value Quantity
-
- @success Was the Function successful?
- */
- require( isOwner() );
- balanceOf[owner] = safeSub(balanceOf[owner], value);
- totalSupply = safeSub(totalSupply, value);
- return true;
- }
-
- function setAllowance(address owner, address spender, uint256 amount, uint256 nonce) external returns(bool success) {
- /*
- Set allowance in the database. Only owner can call it.
-
- @owner Owner address
- @spender Spender address
- @amount Amount to set
- @nonce Transaction count
-
- @success Was the Function successful?
- */
- require( isOwner() );
- allowance[owner][spender].amount = amount;
- allowance[owner][spender].nonce = nonce;
- return true;
- }
-
- function getAllowance(address owner, address spender) public view returns(bool success, uint256 remaining, uint256 nonce) {
- /*
- Get allowance from the database.
-
- @owner Owner address
- @spender Spender address
-
- @success Was the Function successful?
- @remaining Remaining amount of the allowance
- @nonce Transaction count
- */
- return ( true, allowance[owner][spender].amount, allowance[owner][spender].nonce );
- }
-}
+pragma solidity ^0.4.11;
+
+import "./safeMath.sol";
+import "./owned.sol";
+
+contract tokenDB is safeMath, ownedDB {
+
+ struct allowance_s {
+ uint256 amount;
+ uint256 nonce;
+ }
+
+ mapping(address => mapping(address => allowance_s)) public allowance;
+ mapping (address => uint256) public balanceOf;
+ uint256 public totalSupply;
+
+ function increase(address owner, uint256 value) external returns(bool success) {
+ /*
+ Increase of balance of the address in database. Only owner can call it.
+
+ @owner Address
+ @value Quantity
+
+ @success Was the Function successful?
+ */
+ require( isOwner() );
+ balanceOf[owner] = safeAdd(balanceOf[owner], value);
+ totalSupply = safeAdd(totalSupply, value);
+ return true;
+ }
+
+ function decrease(address owner, uint256 value) external returns(bool success) {
+ /*
+ Decrease of balance of the address in database. Only owner can call it.
+
+ @owner Address
+ @value Quantity
+
+ @success Was the Function successful?
+ */
+ require( isOwner() );
+ balanceOf[owner] = safeSub(balanceOf[owner], value);
+ totalSupply = safeSub(totalSupply, value);
+ return true;
+ }
+
+ function setAllowance(address owner, address spender, uint256 amount, uint256 nonce) external returns(bool success) {
+ /*
+ Set allowance in the database. Only owner can call it.
+
+ @owner Owner address
+ @spender Spender address
+ @amount Amount to set
+ @nonce Transaction count
+
+ @success Was the Function successful?
+ */
+ require( isOwner() );
+ allowance[owner][spender].amount = amount;
+ allowance[owner][spender].nonce = nonce;
+ return true;
+ }
+
+ function getAllowance(address owner, address spender) public view returns(bool success, uint256 remaining, uint256 nonce) {
+ /*
+ Get allowance from the database.
+
+ @owner Owner address
+ @spender Spender address
+
+ @success Was the Function successful?
+ @remaining Remaining amount of the allowance
+ @nonce Transaction count
+ */
+ return ( true, allowance[owner][spender].amount, allowance[owner][spender].nonce );
+ }
+}
diff --git a/test/compilationTests/gnosis/Events/Event.sol b/test/compilationTests/gnosis/Events/Event.sol
index 5b1a550c..0a40cf7e 100644
--- a/test/compilationTests/gnosis/Events/Event.sol
+++ b/test/compilationTests/gnosis/Events/Event.sol
@@ -54,7 +54,7 @@ contract Event {
public
{
// Transfer collateral tokens to events contract
- require(collateralToken.transferFrom(msg.sender, this, collateralTokenCount));
+ require(collateralToken.transferFrom(msg.sender, address(this), collateralTokenCount));
// Issue new outcome tokens to sender
for (uint8 i = 0; i < outcomeTokens.length; i++)
outcomeTokens[i].issue(msg.sender, collateralTokenCount);
diff --git a/test/compilationTests/gnosis/Markets/Campaign.sol b/test/compilationTests/gnosis/Markets/Campaign.sol
index f99ede53..119f8df2 100644
--- a/test/compilationTests/gnosis/Markets/Campaign.sol
+++ b/test/compilationTests/gnosis/Markets/Campaign.sol
@@ -102,12 +102,12 @@ contract Campaign {
timedTransitions
atStage(Stages.AuctionStarted)
{
- uint raisedAmount = eventContract.collateralToken().balanceOf(this);
+ uint raisedAmount = eventContract.collateralToken().balanceOf(address(this));
uint maxAmount = funding.sub(raisedAmount);
if (maxAmount < amount)
amount = maxAmount;
// Collect collateral tokens
- require(eventContract.collateralToken().transferFrom(msg.sender, this, amount));
+ require(eventContract.collateralToken().transferFrom(msg.sender, address(this), amount));
contributions[msg.sender] = contributions[msg.sender].add(amount);
if (amount == maxAmount)
stage = Stages.AuctionSuccessful;
@@ -138,7 +138,7 @@ contract Campaign {
returns (Market)
{
market = marketFactory.createMarket(eventContract, marketMaker, fee);
- require(eventContract.collateralToken().approve(market, funding));
+ require(eventContract.collateralToken().approve(address(market), funding));
market.fund(funding);
stage = Stages.MarketCreated;
emit MarketCreation(market);
@@ -156,7 +156,7 @@ contract Campaign {
market.close();
market.withdrawFees();
eventContract.redeemWinnings();
- finalBalance = eventContract.collateralToken().balanceOf(this);
+ finalBalance = eventContract.collateralToken().balanceOf(address(this));
stage = Stages.MarketClosed;
emit MarketClosing();
}
diff --git a/test/compilationTests/gnosis/Markets/StandardMarket.sol b/test/compilationTests/gnosis/Markets/StandardMarket.sol
index 0a9f77db..2f52a896 100644
--- a/test/compilationTests/gnosis/Markets/StandardMarket.sol
+++ b/test/compilationTests/gnosis/Markets/StandardMarket.sol
@@ -60,8 +60,8 @@ contract StandardMarket is Market {
atStage(Stages.MarketCreated)
{
// Request collateral tokens and allow event contract to transfer them to buy all outcomes
- require( eventContract.collateralToken().transferFrom(msg.sender, this, _funding)
- && eventContract.collateralToken().approve(eventContract, _funding));
+ require( eventContract.collateralToken().transferFrom(msg.sender, address(this), _funding)
+ && eventContract.collateralToken().approve(address(eventContract), _funding));
eventContract.buyAllOutcomes(_funding);
funding = _funding;
stage = Stages.MarketFunded;
@@ -76,7 +76,7 @@ contract StandardMarket is Market {
{
uint8 outcomeCount = eventContract.getOutcomeCount();
for (uint8 i = 0; i < outcomeCount; i++)
- require(eventContract.outcomeTokens(i).transfer(creator, eventContract.outcomeTokens(i).balanceOf(this)));
+ require(eventContract.outcomeTokens(i).transfer(creator, eventContract.outcomeTokens(i).balanceOf(address(this))));
stage = Stages.MarketClosed;
emit MarketClosing();
}
@@ -88,7 +88,7 @@ contract StandardMarket is Market {
isCreator
returns (uint fees)
{
- fees = eventContract.collateralToken().balanceOf(this);
+ fees = eventContract.collateralToken().balanceOf(address(this));
// Transfer fees
require(eventContract.collateralToken().transfer(creator, fees));
emit FeeWithdrawal(fees);
@@ -112,8 +112,8 @@ contract StandardMarket is Market {
// Check cost doesn't exceed max cost
require(cost > 0 && cost <= maxCost);
// Transfer tokens to markets contract and buy all outcomes
- require( eventContract.collateralToken().transferFrom(msg.sender, this, cost)
- && eventContract.collateralToken().approve(eventContract, outcomeTokenCost));
+ require( eventContract.collateralToken().transferFrom(msg.sender, address(this), cost)
+ && eventContract.collateralToken().approve(address(eventContract), outcomeTokenCost));
// Buy all outcomes
eventContract.buyAllOutcomes(outcomeTokenCost);
// Transfer outcome tokens to buyer
@@ -142,7 +142,7 @@ contract StandardMarket is Market {
// Check profit is not too low
require(profit > 0 && profit >= minProfit);
// Transfer outcome tokens to markets contract to sell all outcomes
- require(eventContract.outcomeTokens(outcomeTokenIndex).transferFrom(msg.sender, this, outcomeTokenCount));
+ require(eventContract.outcomeTokens(outcomeTokenIndex).transferFrom(msg.sender, address(this), outcomeTokenCount));
// Sell all outcomes
eventContract.sellAllOutcomes(outcomeTokenProfit);
// Transfer profit to seller
@@ -164,11 +164,11 @@ contract StandardMarket is Market {
returns (uint cost)
{
// Buy all outcomes
- require( eventContract.collateralToken().transferFrom(msg.sender, this, outcomeTokenCount)
- && eventContract.collateralToken().approve(eventContract, outcomeTokenCount));
+ require( eventContract.collateralToken().transferFrom(msg.sender, address(this), outcomeTokenCount)
+ && eventContract.collateralToken().approve(address(eventContract), outcomeTokenCount));
eventContract.buyAllOutcomes(outcomeTokenCount);
// Short sell selected outcome
- eventContract.outcomeTokens(outcomeTokenIndex).approve(this, outcomeTokenCount);
+ eventContract.outcomeTokens(outcomeTokenIndex).approve(address(this), outcomeTokenCount);
uint profit = this.sell(outcomeTokenIndex, outcomeTokenCount, minProfit);
cost = outcomeTokenCount - profit;
// Transfer outcome tokens to buyer
diff --git a/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol b/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol
index cf851f5b..83d10b2e 100644
--- a/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol
+++ b/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol
@@ -95,14 +95,14 @@ contract FutarchyOracle is Oracle {
isCreator
{
// Buy all outcomes
- require( categoricalEvent.collateralToken().transferFrom(creator, this, funding)
- && categoricalEvent.collateralToken().approve(categoricalEvent, funding));
+ require( categoricalEvent.collateralToken().transferFrom(creator, address(this), funding)
+ && categoricalEvent.collateralToken().approve(address(categoricalEvent), funding));
categoricalEvent.buyAllOutcomes(funding);
// Fund each market with outcome tokens from categorical event
for (uint8 i = 0; i < markets.length; i++) {
Market market = markets[i];
// Approve funding for market
- require(market.eventContract().collateralToken().approve(market, funding));
+ require(market.eventContract().collateralToken().approve(address(market), funding));
market.fund(funding);
}
emit FutarchyFunding(funding);
@@ -122,7 +122,7 @@ contract FutarchyOracle is Oracle {
market.withdrawFees();
// Redeem collateral token for winning outcome tokens and transfer collateral tokens to creator
categoricalEvent.redeemWinnings();
- require(categoricalEvent.collateralToken().transfer(creator, categoricalEvent.collateralToken().balanceOf(this)));
+ require(categoricalEvent.collateralToken().transfer(creator, categoricalEvent.collateralToken().balanceOf(address(this))));
emit FutarchyClosing();
}
diff --git a/test/compilationTests/gnosis/Oracles/UltimateOracle.sol b/test/compilationTests/gnosis/Oracles/UltimateOracle.sol
index b7cc231c..452a34ec 100644
--- a/test/compilationTests/gnosis/Oracles/UltimateOracle.sol
+++ b/test/compilationTests/gnosis/Oracles/UltimateOracle.sol
@@ -92,7 +92,7 @@ contract UltimateOracle is Oracle {
// There was no challenge yet or the challenge period expired
require( !isChallenged()
&& !isChallengePeriodOver()
- && collateralToken.transferFrom(msg.sender, this, challengeAmount));
+ && collateralToken.transferFrom(msg.sender, address(this), challengeAmount));
outcomeAmounts[msg.sender][_outcome] = challengeAmount;
totalOutcomeAmounts[_outcome] = challengeAmount;
totalAmount = challengeAmount;
@@ -113,7 +113,7 @@ contract UltimateOracle is Oracle {
// Outcome is challenged and front runner period is not over yet and tokens can be transferred
require( isChallenged()
&& !isFrontRunnerPeriodOver()
- && collateralToken.transferFrom(msg.sender, this, amount));
+ && collateralToken.transferFrom(msg.sender, address(this), amount));
outcomeAmounts[msg.sender][_outcome] = outcomeAmounts[msg.sender][_outcome].add(amount);
totalOutcomeAmounts[_outcome] = totalOutcomeAmounts[_outcome].add(amount);
totalAmount = totalAmount.add(amount);
diff --git a/test/compilationTests/gnosis/Tokens/OutcomeToken.sol b/test/compilationTests/gnosis/Tokens/OutcomeToken.sol
index 0bc7307d..fccf05e5 100644
--- a/test/compilationTests/gnosis/Tokens/OutcomeToken.sol
+++ b/test/compilationTests/gnosis/Tokens/OutcomeToken.sol
@@ -36,7 +36,7 @@ contract OutcomeToken is StandardToken {
{
eventContract = msg.sender;
}
-
+
/// @dev Events contract issues new tokens for address. Returns success
/// @param _for Address of receiver
/// @param outcomeTokenCount Number of tokens to issue
diff --git a/test/compilationTests/milestonetracker/RLP.sol b/test/compilationTests/milestonetracker/RLP.sol
index e261bf23..e1f44457 100644
--- a/test/compilationTests/milestonetracker/RLP.sol
+++ b/test/compilationTests/milestonetracker/RLP.sol
@@ -381,19 +381,16 @@ library RLP {
// we can write entire words, and just overwrite any excess.
assembly {
{
- let i := 0 // Start at arr + 0x20
let words := div(add(btsLen, 31), 32)
let rOffset := btsPtr
let wOffset := add(tgt, 0x20)
- tag_loop:
- jumpi(end, eq(i, words))
+
+ // Start at arr + 0x20
+ for { let i := 0 } not(eq(i, words)) { i := add(i, 1) }
{
let offset := mul(i, 0x20)
mstore(add(wOffset, offset), mload(add(rOffset, offset)))
- i := add(i, 1)
}
- jump(tag_loop)
- end:
mstore(add(tgt, add(0x20, mload(tgt))), 0)
}
}
diff --git a/test/compilationTests/zeppelin/Bounty.sol b/test/compilationTests/zeppelin/Bounty.sol
index 55e64071..d45e130c 100644
--- a/test/compilationTests/zeppelin/Bounty.sol
+++ b/test/compilationTests/zeppelin/Bounty.sol
@@ -25,14 +25,14 @@ contract Bounty is PullPayment, Destructible {
}
/**
- * @dev Create and deploy the target contract (extension of Target contract), and sets the
+ * @dev Create and deploy the target contract (extension of Target contract), and sets the
* msg.sender as a researcher
* @return A target contract
*/
function createTarget() public returns(Target) {
Target target = Target(deployContract());
- researchers[target] = msg.sender;
- emit TargetCreated(target);
+ researchers[address(target)] = msg.sender;
+ emit TargetCreated(address(target));
return target;
}
@@ -47,7 +47,7 @@ contract Bounty is PullPayment, Destructible {
* @param target contract
*/
function claim(Target target) public {
- address researcher = researchers[target];
+ address researcher = researchers[address(target)];
if (researcher == address(0)) {
revert();
}
@@ -69,10 +69,10 @@ contract Bounty is PullPayment, Destructible {
contract Target {
/**
- * @dev Checks all values a contract assumes to be true all the time. If this function returns
- * false, the contract is broken in some way and is in an inconsistent state.
- * In order to win the bounty, security researchers will try to cause this broken state.
- * @return True if all invariant values are correct, false otherwise.
+ * @dev Checks all values a contract assumes to be true all the time. If this function returns
+ * false, the contract is broken in some way and is in an inconsistent state.
+ * In order to win the bounty, security researchers will try to cause this broken state.
+ * @return True if all invariant values are correct, false otherwise.
*/
function checkInvariant() public returns(bool);
}
diff --git a/test/compilationTests/zeppelin/LimitBalance.sol b/test/compilationTests/zeppelin/LimitBalance.sol
index 8bf4b253..d07b3c2c 100644
--- a/test/compilationTests/zeppelin/LimitBalance.sol
+++ b/test/compilationTests/zeppelin/LimitBalance.sol
@@ -12,7 +12,7 @@ contract LimitBalance {
uint256 public limit;
/**
- * @dev Constructor that sets the passed value as a limit.
+ * @dev Constructor that sets the passed value as a limit.
* @param _limit uint256 to represent the limit.
*/
constructor(uint256 _limit) public {
diff --git a/test/compilationTests/zeppelin/ReentrancyGuard.sol b/test/compilationTests/zeppelin/ReentrancyGuard.sol
index 7805ec07..f7abb698 100644
--- a/test/compilationTests/zeppelin/ReentrancyGuard.sol
+++ b/test/compilationTests/zeppelin/ReentrancyGuard.sol
@@ -9,7 +9,7 @@ pragma solidity ^0.4.11;
contract ReentrancyGuard {
/**
- * @dev We use a single lock for the whole contract.
+ * @dev We use a single lock for the whole contract.
*/
bool private rentrancy_lock = false;
diff --git a/test/compilationTests/zeppelin/crowdsale/FinalizableCrowdsale.sol b/test/compilationTests/zeppelin/crowdsale/FinalizableCrowdsale.sol
index da4e3b7f..e94fc9fb 100644
--- a/test/compilationTests/zeppelin/crowdsale/FinalizableCrowdsale.sol
+++ b/test/compilationTests/zeppelin/crowdsale/FinalizableCrowdsale.sol
@@ -24,7 +24,7 @@ contract FinalizableCrowdsale is Crowdsale, Ownable {
finalization();
emit Finalized();
-
+
isFinalized = true;
}
diff --git a/test/compilationTests/zeppelin/lifecycle/Destructible.sol b/test/compilationTests/zeppelin/lifecycle/Destructible.sol
index 5b0e9f58..8b57924d 100644
--- a/test/compilationTests/zeppelin/lifecycle/Destructible.sol
+++ b/test/compilationTests/zeppelin/lifecycle/Destructible.sol
@@ -13,7 +13,7 @@ contract Destructible is Ownable {
constructor() public payable { }
/**
- * @dev Transfers the current balance to the owner and terminates the contract.
+ * @dev Transfers the current balance to the owner and terminates the contract.
*/
function destroy() public onlyOwner {
selfdestruct(owner);
diff --git a/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol b/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol
index 51f6b68e..eb141587 100644
--- a/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol
+++ b/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol
@@ -4,7 +4,7 @@ pragma solidity ^0.4.11;
import "../ownership/Ownable.sol";
import "../token/ERC20Basic.sol";
-/**
+/**
* @title TokenDestructible:
* @author Remco Bloemen <remco@2π.com>
* @dev Base contract that can be destroyed by owner. All funds in contract including
@@ -14,7 +14,7 @@ contract TokenDestructible is Ownable {
constructor() public payable { }
- /**
+ /**
* @notice Terminate contract and refund to owner
* @param tokens List of addresses of ERC20 or ERC20Basic token contracts to
refund.
@@ -26,7 +26,7 @@ contract TokenDestructible is Ownable {
// Transfer tokens to owner
for(uint256 i = 0; i < tokens.length; i++) {
ERC20Basic token = ERC20Basic(tokens[i]);
- uint256 balance = token.balanceOf(this);
+ uint256 balance = token.balanceOf(address(this));
token.transfer(owner, balance);
}
diff --git a/test/compilationTests/zeppelin/ownership/Claimable.sol b/test/compilationTests/zeppelin/ownership/Claimable.sol
index d7b48a29..7778e2de 100644
--- a/test/compilationTests/zeppelin/ownership/Claimable.sol
+++ b/test/compilationTests/zeppelin/ownership/Claimable.sol
@@ -6,14 +6,14 @@ import './Ownable.sol';
/**
* @title Claimable
- * @dev Extension for the Ownable contract, where the ownership needs to be claimed.
+ * @dev Extension for the Ownable contract, where the ownership needs to be claimed.
* This allows the new owner to accept the transfer.
*/
contract Claimable is Ownable {
address public pendingOwner;
/**
- * @dev Modifier throws if called by any account other than the pendingOwner.
+ * @dev Modifier throws if called by any account other than the pendingOwner.
*/
modifier onlyPendingOwner() {
if (msg.sender != pendingOwner) {
@@ -23,8 +23,8 @@ contract Claimable is Ownable {
}
/**
- * @dev Allows the current owner to set the pendingOwner address.
- * @param newOwner The address to transfer ownership to.
+ * @dev Allows the current owner to set the pendingOwner address.
+ * @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
pendingOwner = newOwner;
diff --git a/test/compilationTests/zeppelin/ownership/Contactable.sol b/test/compilationTests/zeppelin/ownership/Contactable.sol
index 5f781e13..5053494d 100644
--- a/test/compilationTests/zeppelin/ownership/Contactable.sol
+++ b/test/compilationTests/zeppelin/ownership/Contactable.sol
@@ -4,7 +4,7 @@ import './Ownable.sol';
/**
* @title Contactable token
- * @dev Basic version of a contactable contract, allowing the owner to provide a string with their
+ * @dev Basic version of a contactable contract, allowing the owner to provide a string with their
* contact information.
*/
contract Contactable is Ownable{
diff --git a/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol b/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol
index 540a2ce0..f4c8a681 100644
--- a/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol
+++ b/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol
@@ -15,10 +15,10 @@ contract DelayedClaimable is Claimable {
uint256 public start;
/**
- * @dev Used to specify the time period during which a pending
- * owner can claim ownership.
+ * @dev Used to specify the time period during which a pending
+ * owner can claim ownership.
* @param _start The earliest time ownership can be claimed.
- * @param _end The latest time ownership can be claimed.
+ * @param _end The latest time ownership can be claimed.
*/
function setLimits(uint256 _start, uint256 _end) public onlyOwner {
if (_start > _end)
@@ -29,8 +29,8 @@ contract DelayedClaimable is Claimable {
/**
- * @dev Allows the pendingOwner address to finalize the transfer, as long as it is called within
- * the specified start and end time.
+ * @dev Allows the pendingOwner address to finalize the transfer, as long as it is called within
+ * the specified start and end time.
*/
function claimOwnership() public onlyPendingOwner {
if ((block.number > end) || (block.number < start))
diff --git a/test/compilationTests/zeppelin/ownership/HasNoContracts.sol b/test/compilationTests/zeppelin/ownership/HasNoContracts.sol
index b5bd649d..19b363d4 100644
--- a/test/compilationTests/zeppelin/ownership/HasNoContracts.sol
+++ b/test/compilationTests/zeppelin/ownership/HasNoContracts.sol
@@ -2,7 +2,7 @@ pragma solidity ^0.4.11;
import "./Ownable.sol";
-/**
+/**
* @title Contracts that should not own Contracts
* @author Remco Bloemen <remco@2π.com>
* @dev Should contracts (anything Ownable) end up being owned by this contract, it allows the owner
diff --git a/test/compilationTests/zeppelin/ownership/HasNoEther.sol b/test/compilationTests/zeppelin/ownership/HasNoEther.sol
index 75d90841..5e3d27d2 100644
--- a/test/compilationTests/zeppelin/ownership/HasNoEther.sol
+++ b/test/compilationTests/zeppelin/ownership/HasNoEther.sol
@@ -2,7 +2,7 @@ pragma solidity ^0.4.11;
import "./Ownable.sol";
-/**
+/**
* @title Contracts that should not own Ether
* @author Remco Bloemen <remco@2π.com>
* @dev This tries to block incoming ether to prevent accidental loss of Ether. Should Ether end up
@@ -16,9 +16,9 @@ contract HasNoEther is Ownable {
/**
* @dev Constructor that rejects incoming Ether
- * @dev The `payable` flag is added so we can access `msg.value` without compiler warning. If we
- * leave out payable, then Solidity will allow inheriting contracts to implement a payable
- * constructor. By doing it this way we prevent a payable constructor from working. Alternatively
+ * @dev The `payable` flag is added so we can access `msg.value` without compiler warning. If we
+ * leave out payable, then Solidity will allow inheriting contracts to implement a payable
+ * constructor. By doing it this way we prevent a payable constructor from working. Alternatively
* we could use assembly to access msg.value.
*/
constructor() public payable {
diff --git a/test/compilationTests/zeppelin/ownership/HasNoTokens.sol b/test/compilationTests/zeppelin/ownership/HasNoTokens.sol
index df4284f1..e14d8da7 100644
--- a/test/compilationTests/zeppelin/ownership/HasNoTokens.sol
+++ b/test/compilationTests/zeppelin/ownership/HasNoTokens.sol
@@ -3,7 +3,7 @@ pragma solidity ^0.4.11;
import "./Ownable.sol";
import "../token/ERC20Basic.sol";
-/**
+/**
* @title Contracts that should not own Tokens
* @author Remco Bloemen <remco@2π.com>
* @dev This blocks incoming ERC23 tokens to prevent accidental loss of tokens.
@@ -12,7 +12,7 @@ import "../token/ERC20Basic.sol";
*/
contract HasNoTokens is Ownable {
- /**
+ /**
* @dev Reject all ERC23 compatible tokens
* @param from_ address The address that is transferring the tokens
* @param value_ uint256 the amount of the specified token
@@ -28,7 +28,7 @@ contract HasNoTokens is Ownable {
*/
function reclaimToken(address tokenAddr) external onlyOwner {
ERC20Basic tokenInst = ERC20Basic(tokenAddr);
- uint256 balance = tokenInst.balanceOf(this);
+ uint256 balance = tokenInst.balanceOf(address(this));
tokenInst.transfer(owner, balance);
}
}
diff --git a/test/compilationTests/zeppelin/ownership/NoOwner.sol b/test/compilationTests/zeppelin/ownership/NoOwner.sol
index 7215abf3..c0ef7f4d 100644
--- a/test/compilationTests/zeppelin/ownership/NoOwner.sol
+++ b/test/compilationTests/zeppelin/ownership/NoOwner.sol
@@ -4,10 +4,10 @@ import "./HasNoEther.sol";
import "./HasNoTokens.sol";
import "./HasNoContracts.sol";
-/**
+/**
* @title Base contract for contracts that should not own things.
* @author Remco Bloemen <remco@2π.com>
- * @dev Solves a class of errors where a contract accidentally becomes owner of Ether, Tokens or
+ * @dev Solves a class of errors where a contract accidentally becomes owner of Ether, Tokens or
* Owned contracts. See respective base contracts for details.
*/
contract NoOwner is HasNoEther, HasNoTokens, HasNoContracts {
diff --git a/test/compilationTests/zeppelin/ownership/Ownable.sol b/test/compilationTests/zeppelin/ownership/Ownable.sol
index a862cb74..bd175077 100644
--- a/test/compilationTests/zeppelin/ownership/Ownable.sol
+++ b/test/compilationTests/zeppelin/ownership/Ownable.sol
@@ -3,14 +3,14 @@ pragma solidity ^0.4.11;
/**
* @title Ownable
- * @dev The Ownable contract has an owner address, and provides basic authorization control
- * functions, this simplifies the implementation of "user permissions".
+ * @dev The Ownable contract has an owner address, and provides basic authorization control
+ * functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
- /**
+ /**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
@@ -20,7 +20,7 @@ contract Ownable {
/**
- * @dev Throws if called by any account other than the owner.
+ * @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
if (msg.sender != owner) {
@@ -32,7 +32,7 @@ contract Ownable {
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
- * @param newOwner The address to transfer ownership to.
+ * @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
if (newOwner != address(0)) {
diff --git a/test/compilationTests/zeppelin/ownership/Shareable.sol b/test/compilationTests/zeppelin/ownership/Shareable.sol
index 0c8d16a5..b2cb165d 100644
--- a/test/compilationTests/zeppelin/ownership/Shareable.sol
+++ b/test/compilationTests/zeppelin/ownership/Shareable.sol
@@ -3,7 +3,7 @@ pragma solidity ^0.4.11;
/**
* @title Shareable
- * @dev inheritable "property" contract that enables methods to be protected by requiring the
+ * @dev inheritable "property" contract that enables methods to be protected by requiring the
* acquiescence of either a single, or, crucially, each of a number of, designated owners.
* @dev Usage: use modifiers onlyowner (just own owned) or onlymanyowners(hash), whereby the same hash must be provided by some number (specified in constructor) of the set of owners (specified in the constructor) before the interior is executed.
*/
@@ -41,9 +41,9 @@ contract Shareable {
}
_;
}
-
- /**
- * @dev Modifier for multisig functions.
+
+ /**
+ * @dev Modifier for multisig functions.
* @param _operation The operation must have an intrinsic hash in order that later attempts can be
* realised as the same underlying operation and thus count as confirmations.
*/
@@ -53,8 +53,8 @@ contract Shareable {
}
}
- /**
- * @dev Constructor is given the number of sigs required to do protected "onlymanyowners"
+ /**
+ * @dev Constructor is given the number of sigs required to do protected "onlymanyowners"
* transactions as well as the selection of addresses capable of confirming them.
* @param _owners A list of owners.
* @param _required The amount required for a transaction to be approved.
diff --git a/test/compilationTests/zeppelin/token/BasicToken.sol b/test/compilationTests/zeppelin/token/BasicToken.sol
index bc085f85..3d5646a4 100644
--- a/test/compilationTests/zeppelin/token/BasicToken.sol
+++ b/test/compilationTests/zeppelin/token/BasicToken.sol
@@ -7,7 +7,7 @@ import '../math/SafeMath.sol';
/**
* @title Basic token
- * @dev Basic version of StandardToken, with no allowances.
+ * @dev Basic version of StandardToken, with no allowances.
*/
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
@@ -27,7 +27,7 @@ contract BasicToken is ERC20Basic {
/**
* @dev Gets the balance of the specified address.
- * @param _owner The address to query the the balance of.
+ * @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) public view returns (uint256 balance) {
diff --git a/test/compilationTests/zeppelin/token/LimitedTransferToken.sol b/test/compilationTests/zeppelin/token/LimitedTransferToken.sol
index 3ce928f6..d668b86f 100644
--- a/test/compilationTests/zeppelin/token/LimitedTransferToken.sol
+++ b/test/compilationTests/zeppelin/token/LimitedTransferToken.sol
@@ -4,11 +4,11 @@ import "./ERC20.sol";
/**
* @title LimitedTransferToken
- * @dev LimitedTransferToken defines the generic interface and the implementation to limit token
- * transferability for different events. It is intended to be used as a base class for other token
- * contracts.
+ * @dev LimitedTransferToken defines the generic interface and the implementation to limit token
+ * transferability for different events. It is intended to be used as a base class for other token
+ * contracts.
* LimitedTransferToken has been designed to allow for different limiting factors,
- * this can be achieved by recursively calling super.transferableTokens() until the base class is
+ * this can be achieved by recursively calling super.transferableTokens() until the base class is
* hit. For example:
* function transferableTokens(address holder, uint64 time) view public returns (uint256) {
* return min256(unlockedTokens, super.transferableTokens(holder, time));
@@ -48,7 +48,7 @@ contract LimitedTransferToken is ERC20 {
/**
* @dev Default transferable tokens function returns all tokens for a holder (no limit).
- * @dev Overwriting transferableTokens(address holder, uint64 time) is the way to provide the
+ * @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) view public returns (uint256) {
diff --git a/test/compilationTests/zeppelin/token/SimpleToken.sol b/test/compilationTests/zeppelin/token/SimpleToken.sol
index 6c3f5740..d8717562 100644
--- a/test/compilationTests/zeppelin/token/SimpleToken.sol
+++ b/test/compilationTests/zeppelin/token/SimpleToken.sol
@@ -6,7 +6,7 @@ import "./StandardToken.sol";
/**
* @title SimpleToken
- * @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator.
+ * @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator.
* Note they can later distribute these tokens as they wish using `transfer` and other
* `StandardToken` functions.
*/
@@ -18,7 +18,7 @@ contract SimpleToken is StandardToken {
uint256 public INITIAL_SUPPLY = 10000;
/**
- * @dev Constructor that gives msg.sender all of existing tokens.
+ * @dev Constructor that gives msg.sender all of existing tokens.
*/
constructor() public {
totalSupply = INITIAL_SUPPLY;
diff --git a/test/compilationTests/zeppelin/token/TokenTimelock.sol b/test/compilationTests/zeppelin/token/TokenTimelock.sol
index fa1af025..4847b648 100644
--- a/test/compilationTests/zeppelin/token/TokenTimelock.sol
+++ b/test/compilationTests/zeppelin/token/TokenTimelock.sol
@@ -5,11 +5,11 @@ import './ERC20Basic.sol';
/**
* @title TokenTimelock
- * @dev TokenTimelock is a token holder contract that will allow a
+ * @dev TokenTimelock is a token holder contract that will allow a
* beneficiary to extract the tokens after a given release time
*/
contract TokenTimelock {
-
+
// ERC20 basic token contract being held
ERC20Basic token;
@@ -33,7 +33,7 @@ contract TokenTimelock {
require(msg.sender == beneficiary);
require(now >= releaseTime);
- uint amount = token.balanceOf(this);
+ uint amount = token.balanceOf(address(this));
require(amount > 0);
token.transfer(beneficiary, amount);
diff --git a/test/compilationTests/zeppelin/token/VestedToken.sol b/test/compilationTests/zeppelin/token/VestedToken.sol
index ca13b638..7edc7d16 100644
--- a/test/compilationTests/zeppelin/token/VestedToken.sol
+++ b/test/compilationTests/zeppelin/token/VestedToken.sol
@@ -226,7 +226,7 @@ contract VestedToken is StandardToken, LimitedTransferToken {
* @dev Calculate the amount of non vested tokens at a specific time.
* @param grant TokenGrant The grant to be checked.
* @param time uint64 The time to be checked
- * @return An uint256 representing the amount of non vested tokens of a specific grant on the
+ * @return An uint256 representing the amount of non vested tokens of a specific grant on the
* passed time frame.
*/
function nonVestedTokens(TokenGrant memory grant, uint64 time) private view returns (uint256) {
diff --git a/test/libdevcore/StringUtils.cpp b/test/libdevcore/StringUtils.cpp
index 9ee93d02..94f1b753 100644
--- a/test/libdevcore/StringUtils.cpp
+++ b/test/libdevcore/StringUtils.cpp
@@ -81,6 +81,24 @@ BOOST_AUTO_TEST_CASE(test_alternatives_list)
BOOST_CHECK_EQUAL(quotedAlternativesList(strings), "\"a\", \"b\", \"c\" or \"d\"");
}
+BOOST_AUTO_TEST_CASE(test_human_readable_join)
+{
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({})), "");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a"})), "a");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b"})), "a, b");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b", "c"})), "a, b, c");
+
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({}), "; "), "");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a"}), "; "), "a");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b"}), "; "), "a; b");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b", "c"}), "; "), "a; b; c");
+
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({}), "; ", " or "), "");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a"}), "; ", " or "), "a");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b"}), "; ", " or "), "a or b");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b", "c"}), "; ", " or "), "a; b or c");
+}
+
BOOST_AUTO_TEST_SUITE_END()
diff --git a/test/libsolidity/ASTJSON.cpp b/test/libsolidity/ASTJSON.cpp
deleted file mode 100644
index 482b05e6..00000000
--- a/test/libsolidity/ASTJSON.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- This file is part of solidity.
-
- solidity is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- solidity is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with solidity. If not, see <http://www.gnu.org/licenses/>.
-*/
-/**
- * @author Christian <c@ethdev.com>
- * @date 2016
- * Tests for the json ast output.
- */
-
-#include <test/Options.h>
-
-#include <libsolidity/interface/Exceptions.h>
-#include <libsolidity/interface/CompilerStack.h>
-#include <libsolidity/ast/ASTJsonConverter.h>
-
-#include <boost/test/unit_test.hpp>
-
-#include <string>
-
-using namespace std;
-
-namespace dev
-{
-namespace solidity
-{
-namespace test
-{
-
-BOOST_AUTO_TEST_SUITE(SolidityASTJSON)
-
-BOOST_AUTO_TEST_CASE(short_type_name)
-{
- CompilerStack c;
- c.addSource("a", "contract c { function f() public { uint[] memory x; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(false, sourceIndices).toJson(c.ast("a"));
- Json::Value varDecl = astJson["nodes"][0]["nodes"][0]["body"]["statements"][0]["declarations"][0];
- BOOST_CHECK_EQUAL(varDecl["storageLocation"], "memory");
- BOOST_CHECK_EQUAL(varDecl["typeDescriptions"]["typeIdentifier"], "t_array$_t_uint256_$dyn_memory_ptr");
- BOOST_CHECK_EQUAL(varDecl["typeDescriptions"]["typeString"], "uint256[]");
-}
-
-BOOST_AUTO_TEST_CASE(short_type_name_ref)
-{
- CompilerStack c;
- c.addSource("a", "contract c { function f() public { uint[][] memory rows; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(false, sourceIndices).toJson(c.ast("a"));
- Json::Value varDecl = astJson["nodes"][0]["nodes"][0]["body"]["statements"][0]["declarations"][0];
- BOOST_CHECK_EQUAL(varDecl["storageLocation"], "memory");
- BOOST_CHECK_EQUAL(varDecl["typeName"]["typeDescriptions"]["typeIdentifier"], "t_array$_t_array$_t_uint256_$dyn_storage_$dyn_storage_ptr");
- BOOST_CHECK_EQUAL(varDecl["typeName"]["typeDescriptions"]["typeString"], "uint256[][]");
-}
-
-BOOST_AUTO_TEST_CASE(long_type_name_binary_operation)
-{
- CompilerStack c;
- c.addSource("a", "contract c { function f() public { uint a = 2 + 3; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(false, sourceIndices).toJson(c.ast("a"));
- Json::Value varDecl = astJson["nodes"][0]["nodes"][0]["body"]["statements"][0]["initialValue"]["commonType"];
- BOOST_CHECK_EQUAL(varDecl["typeIdentifier"], "t_rational_5_by_1");
- BOOST_CHECK_EQUAL(varDecl["typeString"], "int_const 5");
-}
-
-BOOST_AUTO_TEST_CASE(long_type_name_identifier)
-{
- CompilerStack c;
- c.addSource("a", "contract c { uint[] a; function f() public { uint[] storage b = a; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(false, sourceIndices).toJson(c.ast("a"));
- Json::Value varDecl = astJson["nodes"][0]["nodes"][1]["body"]["statements"][0]["initialValue"];
- BOOST_CHECK_EQUAL(varDecl["typeDescriptions"]["typeIdentifier"], "t_array$_t_uint256_$dyn_storage");
- BOOST_CHECK_EQUAL(varDecl["typeDescriptions"]["typeString"], "uint256[] storage ref");
-}
-
-BOOST_AUTO_TEST_CASE(documentation)
-{
- CompilerStack c;
- c.addSource("a", "/**This contract is empty*/ contract C {}");
- c.addSource("b",
- "/**This contract is empty"
- " and has a line-breaking comment.*/"
- "contract C {}"
- );
- c.addSource("c",
- "contract C {"
- " /** Some comment on Evt.*/ event Evt();"
- " /** Some comment on mod.*/ modifier mod() { _; }"
- " /** Some comment on fn.*/ function fn() public {}"
- "}"
- );
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 0;
- sourceIndices["b"] = 1;
- sourceIndices["c"] = 2;
- //same tests for non-legacy mode
- Json::Value astJsonA = ASTJsonConverter(false, sourceIndices).toJson(c.ast("a"));
- Json::Value documentationA = astJsonA["nodes"][0]["documentation"];
- BOOST_CHECK_EQUAL(documentationA, "This contract is empty");
- Json::Value astJsonB = ASTJsonConverter(false, sourceIndices).toJson(c.ast("b"));
- Json::Value documentationB = astJsonB["nodes"][0]["documentation"];
- BOOST_CHECK_EQUAL(documentationB, "This contract is empty and has a line-breaking comment.");
- Json::Value astJsonC = ASTJsonConverter(false, sourceIndices).toJson(c.ast("c"));
- Json::Value documentationC0 = astJsonC["nodes"][0]["nodes"][0]["documentation"];
- Json::Value documentationC1 = astJsonC["nodes"][0]["nodes"][1]["documentation"];
- Json::Value documentationC2 = astJsonC["nodes"][0]["nodes"][2]["documentation"];
- BOOST_CHECK_EQUAL(documentationC0, "Some comment on Evt.");
- BOOST_CHECK_EQUAL(documentationC1, "Some comment on mod.");
- BOOST_CHECK_EQUAL(documentationC2, "Some comment on fn.");
-}
-
-
-BOOST_AUTO_TEST_SUITE_END()
-
-}
-}
-} // end namespaces
diff --git a/test/libsolidity/ASTJSON/array_type_name.json b/test/libsolidity/ASTJSON/array_type_name.json
new file mode 100644
index 00000000..e3a3bea9
--- /dev/null
+++ b/test/libsolidity/ASTJSON/array_type_name.json
@@ -0,0 +1,76 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 4
+ ]
+ },
+ "id" : 5,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 4,
+ "linearizedBaseContracts" :
+ [
+ 4
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "constant" : false,
+ "id" : 3,
+ "name" : "i",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 4,
+ "src" : "13:8:1",
+ "stateVariable" : true,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage",
+ "typeString" : "uint256[]"
+ },
+ "typeName" :
+ {
+ "baseType" :
+ {
+ "id" : 1,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "13:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "id" : 2,
+ "length" : null,
+ "nodeType" : "ArrayTypeName",
+ "src" : "13:6:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage_ptr",
+ "typeString" : "uint256[]"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "scope" : 5,
+ "src" : "0:24:1"
+ }
+ ],
+ "src" : "0:25:1"
+}
diff --git a/test/libsolidity/ASTJSON/array_type_name.sol b/test/libsolidity/ASTJSON/array_type_name.sol
new file mode 100644
index 00000000..202ecf02
--- /dev/null
+++ b/test/libsolidity/ASTJSON/array_type_name.sol
@@ -0,0 +1 @@
+contract C { uint[] i; }
diff --git a/test/libsolidity/ASTJSON/array_type_name_legacy.json b/test/libsolidity/ASTJSON/array_type_name_legacy.json
new file mode 100644
index 00000000..80feb344
--- /dev/null
+++ b/test/libsolidity/ASTJSON/array_type_name_legacy.json
@@ -0,0 +1,89 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 4
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 4
+ ],
+ "name" : "C",
+ "scope" : 5
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "i",
+ "scope" : 4,
+ "stateVariable" : true,
+ "storageLocation" : "default",
+ "type" : "uint256[]",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "length" : null,
+ "type" : "uint256[]"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 1,
+ "name" : "ElementaryTypeName",
+ "src" : "13:4:1"
+ }
+ ],
+ "id" : 2,
+ "name" : "ArrayTypeName",
+ "src" : "13:6:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "VariableDeclaration",
+ "src" : "13:8:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "ContractDefinition",
+ "src" : "0:24:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "SourceUnit",
+ "src" : "0:25:1"
+}
diff --git a/test/libsolidity/ASTJSON/documentation.json b/test/libsolidity/ASTJSON/documentation.json
new file mode 100644
index 00000000..56b748c1
--- /dev/null
+++ b/test/libsolidity/ASTJSON/documentation.json
@@ -0,0 +1,182 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 1
+ ]
+ },
+ "id" : 2,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : "This contract is empty",
+ "fullyImplemented" : true,
+ "id" : 1,
+ "linearizedBaseContracts" :
+ [
+ 1
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" : [],
+ "scope" : 2,
+ "src" : "28:13:1"
+ }
+ ],
+ "src" : "28:14:1"
+},
+{
+ "absolutePath" : "b",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 3
+ ]
+ },
+ "id" : 4,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : "This contract is empty\nand has a line-breaking comment.",
+ "fullyImplemented" : true,
+ "id" : 3,
+ "linearizedBaseContracts" :
+ [
+ 3
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" : [],
+ "scope" : 4,
+ "src" : "62:13:2"
+ }
+ ],
+ "src" : "62:14:2"
+},
+{
+ "absolutePath" : "c",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 15
+ ]
+ },
+ "id" : 16,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 15,
+ "linearizedBaseContracts" :
+ [
+ 15
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "anonymous" : false,
+ "documentation" : "Some comment on Evt.",
+ "id" : 6,
+ "name" : "Evt",
+ "nodeType" : "EventDefinition",
+ "parameters" :
+ {
+ "id" : 5,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "51:2:3"
+ },
+ "src" : "42:12:3"
+ },
+ {
+ "body" :
+ {
+ "id" : 9,
+ "nodeType" : "Block",
+ "src" : "99:6:3",
+ "statements" :
+ [
+ {
+ "id" : 8,
+ "nodeType" : "PlaceholderStatement",
+ "src" : "101:1:3"
+ }
+ ]
+ },
+ "documentation" : "Some comment on mod.",
+ "id" : 10,
+ "name" : "mod",
+ "nodeType" : "ModifierDefinition",
+ "parameters" :
+ {
+ "id" : 7,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "96:2:3"
+ },
+ "src" : "84:21:3",
+ "visibility" : "internal"
+ },
+ {
+ "body" :
+ {
+ "id" : 13,
+ "nodeType" : "Block",
+ "src" : "155:2:3",
+ "statements" : []
+ },
+ "documentation" : "Some comment on fn.",
+ "id" : 14,
+ "implemented" : true,
+ "isConstructor" : false,
+ "isDeclaredConst" : false,
+ "modifiers" : [],
+ "name" : "fn",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 11,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "145:2:3"
+ },
+ "payable" : false,
+ "returnParameters" :
+ {
+ "id" : 12,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "155:0:3"
+ },
+ "scope" : 15,
+ "src" : "134:23:3",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 16,
+ "src" : "0:159:3"
+ }
+ ],
+ "src" : "0:160:3"
+}
diff --git a/test/libsolidity/ASTJSON/documentation.sol b/test/libsolidity/ASTJSON/documentation.sol
new file mode 100644
index 00000000..e65af9b4
--- /dev/null
+++ b/test/libsolidity/ASTJSON/documentation.sol
@@ -0,0 +1,17 @@
+// ---- SOURCE: a
+
+/**This contract is empty*/ contract C {}
+
+// ---- SOURCE: b
+
+/**This contract is empty
+ and has a line-breaking comment.*/
+contract C {}
+
+// ---- SOURCE: c
+
+contract C {
+ /** Some comment on Evt.*/ event Evt();
+ /** Some comment on mod.*/ modifier mod() { _; }
+ /** Some comment on fn.*/ function fn() public {}
+}
diff --git a/test/libsolidity/ASTJSON/documentation_legacy.json b/test/libsolidity/ASTJSON/documentation_legacy.json
new file mode 100644
index 00000000..44ae537b
--- /dev/null
+++ b/test/libsolidity/ASTJSON/documentation_legacy.json
@@ -0,0 +1,178 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "c",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 15
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 15
+ ],
+ "name" : "C",
+ "scope" : 16
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "anonymous" : false,
+ "documentation" : "Some comment on Evt.",
+ "name" : "Evt"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 5,
+ "name" : "ParameterList",
+ "src" : "51:2:3"
+ }
+ ],
+ "id" : 6,
+ "name" : "EventDefinition",
+ "src" : "42:12:3"
+ },
+ {
+ "attributes" :
+ {
+ "documentation" : "Some comment on mod.",
+ "name" : "mod",
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 7,
+ "name" : "ParameterList",
+ "src" : "96:2:3"
+ },
+ {
+ "children" :
+ [
+ {
+ "id" : 8,
+ "name" : "PlaceholderStatement",
+ "src" : "101:1:3"
+ }
+ ],
+ "id" : 9,
+ "name" : "Block",
+ "src" : "99:6:3"
+ }
+ ],
+ "id" : 10,
+ "name" : "ModifierDefinition",
+ "src" : "84:21:3"
+ },
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "documentation" : "Some comment on fn.",
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "fn",
+ "payable" : false,
+ "scope" : 15,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 11,
+ "name" : "ParameterList",
+ "src" : "145:2:3"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 12,
+ "name" : "ParameterList",
+ "src" : "155:0:3"
+ },
+ {
+ "attributes" :
+ {
+ "statements" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 13,
+ "name" : "Block",
+ "src" : "155:2:3"
+ }
+ ],
+ "id" : 14,
+ "name" : "FunctionDefinition",
+ "src" : "134:23:3"
+ }
+ ],
+ "id" : 15,
+ "name" : "ContractDefinition",
+ "src" : "0:159:3"
+ }
+ ],
+ "id" : 16,
+ "name" : "SourceUnit",
+ "src" : "0:160:3"
+}
diff --git a/test/libsolidity/ASTJSON/enum_value.json b/test/libsolidity/ASTJSON/enum_value.json
new file mode 100644
index 00000000..21afd9a7
--- /dev/null
+++ b/test/libsolidity/ASTJSON/enum_value.json
@@ -0,0 +1,57 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 4
+ ]
+ },
+ "id" : 5,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 4,
+ "linearizedBaseContracts" :
+ [
+ 4
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "canonicalName" : "C.E",
+ "id" : 3,
+ "members" :
+ [
+ {
+ "id" : 1,
+ "name" : "A",
+ "nodeType" : "EnumValue",
+ "src" : "22:1:1"
+ },
+ {
+ "id" : 2,
+ "name" : "B",
+ "nodeType" : "EnumValue",
+ "src" : "25:1:1"
+ }
+ ],
+ "name" : "E",
+ "nodeType" : "EnumDefinition",
+ "src" : "13:15:1"
+ }
+ ],
+ "scope" : 5,
+ "src" : "0:30:1"
+ }
+ ],
+ "src" : "0:31:1"
+}
diff --git a/test/libsolidity/ASTJSON/enum_value.sol b/test/libsolidity/ASTJSON/enum_value.sol
new file mode 100644
index 00000000..ef0875fb
--- /dev/null
+++ b/test/libsolidity/ASTJSON/enum_value.sol
@@ -0,0 +1 @@
+contract C { enum E { A, B } }
diff --git a/test/libsolidity/ASTJSON/enum_value_legacy.json b/test/libsolidity/ASTJSON/enum_value_legacy.json
new file mode 100644
index 00000000..d7782969
--- /dev/null
+++ b/test/libsolidity/ASTJSON/enum_value_legacy.json
@@ -0,0 +1,78 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 4
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 4
+ ],
+ "name" : "C",
+ "scope" : 5
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "canonicalName" : "C.E",
+ "name" : "E"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "A"
+ },
+ "id" : 1,
+ "name" : "EnumValue",
+ "src" : "22:1:1"
+ },
+ {
+ "attributes" :
+ {
+ "name" : "B"
+ },
+ "id" : 2,
+ "name" : "EnumValue",
+ "src" : "25:1:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "EnumDefinition",
+ "src" : "13:15:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "ContractDefinition",
+ "src" : "0:30:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "SourceUnit",
+ "src" : "0:31:1"
+}
diff --git a/test/libsolidity/ASTJSON/event_definition.json b/test/libsolidity/ASTJSON/event_definition.json
new file mode 100644
index 00000000..029062c3
--- /dev/null
+++ b/test/libsolidity/ASTJSON/event_definition.json
@@ -0,0 +1,50 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 3
+ ]
+ },
+ "id" : 4,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 3,
+ "linearizedBaseContracts" :
+ [
+ 3
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "anonymous" : false,
+ "documentation" : null,
+ "id" : 2,
+ "name" : "E",
+ "nodeType" : "EventDefinition",
+ "parameters" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "20:2:1"
+ },
+ "src" : "13:10:1"
+ }
+ ],
+ "scope" : 4,
+ "src" : "0:25:1"
+ }
+ ],
+ "src" : "0:26:1"
+}
diff --git a/test/libsolidity/ASTJSON/event_definition.sol b/test/libsolidity/ASTJSON/event_definition.sol
new file mode 100644
index 00000000..81b43c67
--- /dev/null
+++ b/test/libsolidity/ASTJSON/event_definition.sol
@@ -0,0 +1 @@
+contract C { event E(); }
diff --git a/test/libsolidity/ASTJSON/event_definition_legacy.json b/test/libsolidity/ASTJSON/event_definition_legacy.json
new file mode 100644
index 00000000..f5967bf4
--- /dev/null
+++ b/test/libsolidity/ASTJSON/event_definition_legacy.json
@@ -0,0 +1,74 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 3
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 3
+ ],
+ "name" : "C",
+ "scope" : 4
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "anonymous" : false,
+ "documentation" : null,
+ "name" : "E"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "20:2:1"
+ }
+ ],
+ "id" : 2,
+ "name" : "EventDefinition",
+ "src" : "13:10:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "ContractDefinition",
+ "src" : "0:25:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "SourceUnit",
+ "src" : "0:26:1"
+}
diff --git a/test/libsolidity/ASTJSON/function_type.json b/test/libsolidity/ASTJSON/function_type.json
new file mode 100644
index 00000000..f0389d17
--- /dev/null
+++ b/test/libsolidity/ASTJSON/function_type.json
@@ -0,0 +1,230 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 17
+ ]
+ },
+ "id" : 18,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 17,
+ "linearizedBaseContracts" :
+ [
+ 17
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 15,
+ "nodeType" : "Block",
+ "src" : "120:2:1",
+ "statements" : []
+ },
+ "documentation" : null,
+ "id" : 16,
+ "implemented" : true,
+ "isConstructor" : false,
+ "isDeclaredConst" : false,
+ "modifiers" : [],
+ "name" : "f",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 7,
+ "nodeType" : "ParameterList",
+ "parameters" :
+ [
+ {
+ "constant" : false,
+ "id" : 6,
+ "name" : "x",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 16,
+ "src" : "24:44:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_function_external_payable$__$returns$_t_uint256_$",
+ "typeString" : "function () payable external returns (uint256)"
+ },
+ "typeName" :
+ {
+ "id" : 5,
+ "isDeclaredConst" : false,
+ "nodeType" : "FunctionTypeName",
+ "parameterTypes" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "32:2:1"
+ },
+ "payable" : true,
+ "returnParameterTypes" :
+ {
+ "id" : 4,
+ "nodeType" : "ParameterList",
+ "parameters" :
+ [
+ {
+ "constant" : false,
+ "id" : 3,
+ "name" : "",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 16,
+ "src" : "61:4:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ },
+ "typeName" :
+ {
+ "id" : 2,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "61:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "src" : "60:6:1"
+ },
+ "src" : "24:44:1",
+ "stateMutability" : "payable",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_function_external_payable$__$returns$_t_uint256_$",
+ "typeString" : "function () payable external returns (uint256)"
+ },
+ "visibility" : "external"
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "src" : "23:46:1"
+ },
+ "payable" : false,
+ "returnParameters" :
+ {
+ "id" : 14,
+ "nodeType" : "ParameterList",
+ "parameters" :
+ [
+ {
+ "constant" : false,
+ "id" : 13,
+ "name" : "",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 16,
+ "src" : "79:40:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_function_external_view$__$returns$_t_uint256_$",
+ "typeString" : "function () view external returns (uint256)"
+ },
+ "typeName" :
+ {
+ "id" : 12,
+ "isDeclaredConst" : true,
+ "nodeType" : "FunctionTypeName",
+ "parameterTypes" :
+ {
+ "id" : 8,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "87:2:1"
+ },
+ "payable" : false,
+ "returnParameterTypes" :
+ {
+ "id" : 11,
+ "nodeType" : "ParameterList",
+ "parameters" :
+ [
+ {
+ "constant" : false,
+ "id" : 10,
+ "name" : "",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 16,
+ "src" : "113:4:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ },
+ "typeName" :
+ {
+ "id" : 9,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "113:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "src" : "112:6:1"
+ },
+ "src" : "79:40:1",
+ "stateMutability" : "view",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_function_external_view$__$returns$_t_uint256_$",
+ "typeString" : "function () view external returns (uint256)"
+ },
+ "visibility" : "external"
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "src" : "78:41:1"
+ },
+ "scope" : 17,
+ "src" : "13:109:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 18,
+ "src" : "0:124:1"
+ }
+ ],
+ "src" : "0:125:1"
+}
diff --git a/test/libsolidity/ASTJSON/function_type.sol b/test/libsolidity/ASTJSON/function_type.sol
new file mode 100644
index 00000000..b63bcbf0
--- /dev/null
+++ b/test/libsolidity/ASTJSON/function_type.sol
@@ -0,0 +1 @@
+contract C { function f(function() external payable returns (uint) x) returns (function() external view returns (uint)) {} }
diff --git a/test/libsolidity/ASTJSON/function_type_legacy.json b/test/libsolidity/ASTJSON/function_type_legacy.json
new file mode 100644
index 00000000..4db5fb1c
--- /dev/null
+++ b/test/libsolidity/ASTJSON/function_type_legacy.json
@@ -0,0 +1,271 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 17
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 17
+ ],
+ "name" : "C",
+ "scope" : 18
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "f",
+ "payable" : false,
+ "scope" : 17,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "x",
+ "scope" : 16,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "function () payable external returns (uint256)",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "payable" : true,
+ "stateMutability" : "payable",
+ "type" : "function () payable external returns (uint256)",
+ "visibility" : "external"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "32:2:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "",
+ "scope" : 16,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "uint256",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 2,
+ "name" : "ElementaryTypeName",
+ "src" : "61:4:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "VariableDeclaration",
+ "src" : "61:4:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "ParameterList",
+ "src" : "60:6:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "FunctionTypeName",
+ "src" : "24:44:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "VariableDeclaration",
+ "src" : "24:44:1"
+ }
+ ],
+ "id" : 7,
+ "name" : "ParameterList",
+ "src" : "23:46:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "",
+ "scope" : 16,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "function () view external returns (uint256)",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : true,
+ "payable" : false,
+ "stateMutability" : "view",
+ "type" : "function () view external returns (uint256)",
+ "visibility" : "external"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 8,
+ "name" : "ParameterList",
+ "src" : "87:2:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "",
+ "scope" : 16,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "uint256",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 9,
+ "name" : "ElementaryTypeName",
+ "src" : "113:4:1"
+ }
+ ],
+ "id" : 10,
+ "name" : "VariableDeclaration",
+ "src" : "113:4:1"
+ }
+ ],
+ "id" : 11,
+ "name" : "ParameterList",
+ "src" : "112:6:1"
+ }
+ ],
+ "id" : 12,
+ "name" : "FunctionTypeName",
+ "src" : "79:40:1"
+ }
+ ],
+ "id" : 13,
+ "name" : "VariableDeclaration",
+ "src" : "79:40:1"
+ }
+ ],
+ "id" : 14,
+ "name" : "ParameterList",
+ "src" : "78:41:1"
+ },
+ {
+ "attributes" :
+ {
+ "statements" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 15,
+ "name" : "Block",
+ "src" : "120:2:1"
+ }
+ ],
+ "id" : 16,
+ "name" : "FunctionDefinition",
+ "src" : "13:109:1"
+ }
+ ],
+ "id" : 17,
+ "name" : "ContractDefinition",
+ "src" : "0:124:1"
+ }
+ ],
+ "id" : 18,
+ "name" : "SourceUnit",
+ "src" : "0:125:1"
+}
diff --git a/test/libsolidity/ASTJSON/inheritance_specifier.json b/test/libsolidity/ASTJSON/inheritance_specifier.json
new file mode 100644
index 00000000..edef8677
--- /dev/null
+++ b/test/libsolidity/ASTJSON/inheritance_specifier.json
@@ -0,0 +1,80 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C1" :
+ [
+ 1
+ ],
+ "C2" :
+ [
+ 4
+ ]
+ },
+ "id" : 5,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 1,
+ "linearizedBaseContracts" :
+ [
+ 1
+ ],
+ "name" : "C1",
+ "nodeType" : "ContractDefinition",
+ "nodes" : [],
+ "scope" : 5,
+ "src" : "0:14:1"
+ },
+ {
+ "baseContracts" :
+ [
+ {
+ "arguments" : null,
+ "baseName" :
+ {
+ "contractScope" : null,
+ "id" : 2,
+ "name" : "C1",
+ "nodeType" : "UserDefinedTypeName",
+ "referencedDeclaration" : 1,
+ "src" : "30:2:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_contract$_C1_$1",
+ "typeString" : "contract C1"
+ }
+ },
+ "id" : 3,
+ "nodeType" : "InheritanceSpecifier",
+ "src" : "30:2:1"
+ }
+ ],
+ "contractDependencies" :
+ [
+ 1
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 4,
+ "linearizedBaseContracts" :
+ [
+ 4,
+ 1
+ ],
+ "name" : "C2",
+ "nodeType" : "ContractDefinition",
+ "nodes" : [],
+ "scope" : 5,
+ "src" : "15:20:1"
+ }
+ ],
+ "src" : "0:36:1"
+}
diff --git a/test/libsolidity/ASTJSON/inheritance_specifier.sol b/test/libsolidity/ASTJSON/inheritance_specifier.sol
new file mode 100644
index 00000000..02dbf0c5
--- /dev/null
+++ b/test/libsolidity/ASTJSON/inheritance_specifier.sol
@@ -0,0 +1 @@
+contract C1 {} contract C2 is C1 {}
diff --git a/test/libsolidity/ASTJSON/inheritance_specifier_legacy.json b/test/libsolidity/ASTJSON/inheritance_specifier_legacy.json
new file mode 100644
index 00000000..0fcf2939
--- /dev/null
+++ b/test/libsolidity/ASTJSON/inheritance_specifier_legacy.json
@@ -0,0 +1,105 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C1" :
+ [
+ 1
+ ],
+ "C2" :
+ [
+ 4
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 1
+ ],
+ "name" : "C1",
+ "nodes" :
+ [
+ null
+ ],
+ "scope" : 5
+ },
+ "id" : 1,
+ "name" : "ContractDefinition",
+ "src" : "0:14:1"
+ },
+ {
+ "attributes" :
+ {
+ "contractDependencies" :
+ [
+ 1
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 4,
+ 1
+ ],
+ "name" : "C2",
+ "nodes" :
+ [
+ null
+ ],
+ "scope" : 5
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "arguments" : null
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "contractScope" : null,
+ "name" : "C1",
+ "referencedDeclaration" : 1,
+ "type" : "contract C1"
+ },
+ "id" : 2,
+ "name" : "UserDefinedTypeName",
+ "src" : "30:2:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "InheritanceSpecifier",
+ "src" : "30:2:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "ContractDefinition",
+ "src" : "15:20:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "SourceUnit",
+ "src" : "0:36:1"
+}
diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation.json b/test/libsolidity/ASTJSON/long_type_name_binary_operation.json
new file mode 100644
index 00000000..6a956ca4
--- /dev/null
+++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation.json
@@ -0,0 +1,177 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 11
+ ]
+ },
+ "id" : 12,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 11,
+ "linearizedBaseContracts" :
+ [
+ 11
+ ],
+ "name" : "c",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 9,
+ "nodeType" : "Block",
+ "src" : "33:19:1",
+ "statements" :
+ [
+ {
+ "assignments" :
+ [
+ 4
+ ],
+ "declarations" :
+ [
+ {
+ "constant" : false,
+ "id" : 4,
+ "name" : "a",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 9,
+ "src" : "35:6:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ },
+ "typeName" :
+ {
+ "id" : 3,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "35:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "id" : 8,
+ "initialValue" :
+ {
+ "argumentTypes" : null,
+ "commonType" :
+ {
+ "typeIdentifier" : "t_rational_5_by_1",
+ "typeString" : "int_const 5"
+ },
+ "id" : 7,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "leftExpression" :
+ {
+ "argumentTypes" : null,
+ "hexValue" : "32",
+ "id" : 5,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "kind" : "number",
+ "lValueRequested" : false,
+ "nodeType" : "Literal",
+ "src" : "44:1:1",
+ "subdenomination" : null,
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_rational_2_by_1",
+ "typeString" : "int_const 2"
+ },
+ "value" : "2"
+ },
+ "nodeType" : "BinaryOperation",
+ "operator" : "+",
+ "rightExpression" :
+ {
+ "argumentTypes" : null,
+ "hexValue" : "33",
+ "id" : 6,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "kind" : "number",
+ "lValueRequested" : false,
+ "nodeType" : "Literal",
+ "src" : "48:1:1",
+ "subdenomination" : null,
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_rational_3_by_1",
+ "typeString" : "int_const 3"
+ },
+ "value" : "3"
+ },
+ "src" : "44:5:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_rational_5_by_1",
+ "typeString" : "int_const 5"
+ }
+ },
+ "nodeType" : "VariableDeclarationStatement",
+ "src" : "35:14:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 10,
+ "implemented" : true,
+ "isConstructor" : false,
+ "isDeclaredConst" : false,
+ "modifiers" : [],
+ "name" : "f",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "23:2:1"
+ },
+ "payable" : false,
+ "returnParameters" :
+ {
+ "id" : 2,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "33:0:1"
+ },
+ "scope" : 11,
+ "src" : "13:39:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 12,
+ "src" : "0:54:1"
+ }
+ ],
+ "src" : "0:55:1"
+}
diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation.sol b/test/libsolidity/ASTJSON/long_type_name_binary_operation.sol
new file mode 100644
index 00000000..f07029d7
--- /dev/null
+++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation.sol
@@ -0,0 +1 @@
+contract c { function f() public { uint a = 2 + 3; } }
diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json b/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json
new file mode 100644
index 00000000..cd4eefb1
--- /dev/null
+++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json
@@ -0,0 +1,209 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 11
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 11
+ ],
+ "name" : "c",
+ "scope" : 12
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "f",
+ "payable" : false,
+ "scope" : 11,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "23:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 2,
+ "name" : "ParameterList",
+ "src" : "33:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "assignments" :
+ [
+ 4
+ ]
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "a",
+ "scope" : 9,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "uint256",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 3,
+ "name" : "ElementaryTypeName",
+ "src" : "35:4:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "VariableDeclaration",
+ "src" : "35:6:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "commonType" :
+ {
+ "typeIdentifier" : "t_rational_5_by_1",
+ "typeString" : "int_const 5"
+ },
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "operator" : "+",
+ "type" : "int_const 5"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "hexvalue" : "32",
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "subdenomination" : null,
+ "token" : "number",
+ "type" : "int_const 2",
+ "value" : "2"
+ },
+ "id" : 5,
+ "name" : "Literal",
+ "src" : "44:1:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "hexvalue" : "33",
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "subdenomination" : null,
+ "token" : "number",
+ "type" : "int_const 3",
+ "value" : "3"
+ },
+ "id" : 6,
+ "name" : "Literal",
+ "src" : "48:1:1"
+ }
+ ],
+ "id" : 7,
+ "name" : "BinaryOperation",
+ "src" : "44:5:1"
+ }
+ ],
+ "id" : 8,
+ "name" : "VariableDeclarationStatement",
+ "src" : "35:14:1"
+ }
+ ],
+ "id" : 9,
+ "name" : "Block",
+ "src" : "33:19:1"
+ }
+ ],
+ "id" : 10,
+ "name" : "FunctionDefinition",
+ "src" : "13:39:1"
+ }
+ ],
+ "id" : 11,
+ "name" : "ContractDefinition",
+ "src" : "0:54:1"
+ }
+ ],
+ "id" : 12,
+ "name" : "SourceUnit",
+ "src" : "0:55:1"
+}
diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier.json b/test/libsolidity/ASTJSON/long_type_name_identifier.json
new file mode 100644
index 00000000..b1f8faa2
--- /dev/null
+++ b/test/libsolidity/ASTJSON/long_type_name_identifier.json
@@ -0,0 +1,183 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 14
+ ]
+ },
+ "id" : 15,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 14,
+ "linearizedBaseContracts" :
+ [
+ 14
+ ],
+ "name" : "c",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "constant" : false,
+ "id" : 3,
+ "name" : "a",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 14,
+ "src" : "13:8:1",
+ "stateVariable" : true,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage",
+ "typeString" : "uint256[]"
+ },
+ "typeName" :
+ {
+ "baseType" :
+ {
+ "id" : 1,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "13:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "id" : 2,
+ "length" : null,
+ "nodeType" : "ArrayTypeName",
+ "src" : "13:6:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage_ptr",
+ "typeString" : "uint256[]"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ },
+ {
+ "body" :
+ {
+ "id" : 12,
+ "nodeType" : "Block",
+ "src" : "43:25:1",
+ "statements" :
+ [
+ {
+ "assignments" :
+ [
+ 9
+ ],
+ "declarations" :
+ [
+ {
+ "constant" : false,
+ "id" : 9,
+ "name" : "b",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 12,
+ "src" : "45:16:1",
+ "stateVariable" : false,
+ "storageLocation" : "storage",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage_ptr",
+ "typeString" : "uint256[]"
+ },
+ "typeName" :
+ {
+ "baseType" :
+ {
+ "id" : 7,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "45:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "id" : 8,
+ "length" : null,
+ "nodeType" : "ArrayTypeName",
+ "src" : "45:6:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage_ptr",
+ "typeString" : "uint256[]"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "id" : 11,
+ "initialValue" :
+ {
+ "argumentTypes" : null,
+ "id" : 10,
+ "name" : "a",
+ "nodeType" : "Identifier",
+ "overloadedDeclarations" : [],
+ "referencedDeclaration" : 3,
+ "src" : "64:1:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage",
+ "typeString" : "uint256[] storage ref"
+ }
+ },
+ "nodeType" : "VariableDeclarationStatement",
+ "src" : "45:20:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 13,
+ "implemented" : true,
+ "isConstructor" : false,
+ "isDeclaredConst" : false,
+ "modifiers" : [],
+ "name" : "f",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 4,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "33:2:1"
+ },
+ "payable" : false,
+ "returnParameters" :
+ {
+ "id" : 5,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "43:0:1"
+ },
+ "scope" : 14,
+ "src" : "23:45:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 15,
+ "src" : "0:70:1"
+ }
+ ],
+ "src" : "0:71:1"
+}
diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier.sol b/test/libsolidity/ASTJSON/long_type_name_identifier.sol
new file mode 100644
index 00000000..f03f7a84
--- /dev/null
+++ b/test/libsolidity/ASTJSON/long_type_name_identifier.sol
@@ -0,0 +1 @@
+contract c { uint[] a; function f() public { uint[] storage b = a; } }
diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json b/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json
new file mode 100644
index 00000000..d7739f10
--- /dev/null
+++ b/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json
@@ -0,0 +1,221 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 14
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 14
+ ],
+ "name" : "c",
+ "scope" : 15
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "a",
+ "scope" : 14,
+ "stateVariable" : true,
+ "storageLocation" : "default",
+ "type" : "uint256[]",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "length" : null,
+ "type" : "uint256[]"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 1,
+ "name" : "ElementaryTypeName",
+ "src" : "13:4:1"
+ }
+ ],
+ "id" : 2,
+ "name" : "ArrayTypeName",
+ "src" : "13:6:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "VariableDeclaration",
+ "src" : "13:8:1"
+ },
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "f",
+ "payable" : false,
+ "scope" : 14,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 4,
+ "name" : "ParameterList",
+ "src" : "33:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 5,
+ "name" : "ParameterList",
+ "src" : "43:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "assignments" :
+ [
+ 9
+ ]
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "b",
+ "scope" : 12,
+ "stateVariable" : false,
+ "storageLocation" : "storage",
+ "type" : "uint256[]",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "length" : null,
+ "type" : "uint256[]"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 7,
+ "name" : "ElementaryTypeName",
+ "src" : "45:4:1"
+ }
+ ],
+ "id" : 8,
+ "name" : "ArrayTypeName",
+ "src" : "45:6:1"
+ }
+ ],
+ "id" : 9,
+ "name" : "VariableDeclaration",
+ "src" : "45:16:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "overloadedDeclarations" :
+ [
+ null
+ ],
+ "referencedDeclaration" : 3,
+ "type" : "uint256[] storage ref",
+ "value" : "a"
+ },
+ "id" : 10,
+ "name" : "Identifier",
+ "src" : "64:1:1"
+ }
+ ],
+ "id" : 11,
+ "name" : "VariableDeclarationStatement",
+ "src" : "45:20:1"
+ }
+ ],
+ "id" : 12,
+ "name" : "Block",
+ "src" : "43:25:1"
+ }
+ ],
+ "id" : 13,
+ "name" : "FunctionDefinition",
+ "src" : "23:45:1"
+ }
+ ],
+ "id" : 14,
+ "name" : "ContractDefinition",
+ "src" : "0:70:1"
+ }
+ ],
+ "id" : 15,
+ "name" : "SourceUnit",
+ "src" : "0:71:1"
+}
diff --git a/test/libsolidity/ASTJSON/modifier_definition.json b/test/libsolidity/ASTJSON/modifier_definition.json
new file mode 100644
index 00000000..da64b78d
--- /dev/null
+++ b/test/libsolidity/ASTJSON/modifier_definition.json
@@ -0,0 +1,176 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 14
+ ]
+ },
+ "id" : 15,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 14,
+ "linearizedBaseContracts" :
+ [
+ 14
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 5,
+ "nodeType" : "Block",
+ "src" : "32:6:1",
+ "statements" :
+ [
+ {
+ "id" : 4,
+ "nodeType" : "PlaceholderStatement",
+ "src" : "34:1:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 6,
+ "name" : "M",
+ "nodeType" : "ModifierDefinition",
+ "parameters" :
+ {
+ "id" : 3,
+ "nodeType" : "ParameterList",
+ "parameters" :
+ [
+ {
+ "constant" : false,
+ "id" : 2,
+ "name" : "i",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 6,
+ "src" : "24:6:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ },
+ "typeName" :
+ {
+ "id" : 1,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "24:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "src" : "23:8:1"
+ },
+ "src" : "13:25:1",
+ "visibility" : "internal"
+ },
+ {
+ "body" :
+ {
+ "id" : 12,
+ "nodeType" : "Block",
+ "src" : "64:2:1",
+ "statements" : []
+ },
+ "documentation" : null,
+ "id" : 13,
+ "implemented" : true,
+ "isConstructor" : false,
+ "isDeclaredConst" : false,
+ "modifiers" :
+ [
+ {
+ "arguments" :
+ [
+ {
+ "argumentTypes" : null,
+ "hexValue" : "31",
+ "id" : 9,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "kind" : "number",
+ "lValueRequested" : false,
+ "nodeType" : "Literal",
+ "src" : "54:1:1",
+ "subdenomination" : null,
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_rational_1_by_1",
+ "typeString" : "int_const 1"
+ },
+ "value" : "1"
+ }
+ ],
+ "id" : 10,
+ "modifierName" :
+ {
+ "argumentTypes" : null,
+ "id" : 8,
+ "name" : "M",
+ "nodeType" : "Identifier",
+ "overloadedDeclarations" : [],
+ "referencedDeclaration" : 6,
+ "src" : "52:1:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_modifier$_t_uint256_$",
+ "typeString" : "modifier (uint256)"
+ }
+ },
+ "nodeType" : "ModifierInvocation",
+ "src" : "52:4:1"
+ }
+ ],
+ "name" : "F",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 7,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "49:2:1"
+ },
+ "payable" : false,
+ "returnParameters" :
+ {
+ "id" : 11,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "64:0:1"
+ },
+ "scope" : 14,
+ "src" : "39:27:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 15,
+ "src" : "0:68:1"
+ }
+ ],
+ "src" : "0:69:1"
+}
diff --git a/test/libsolidity/ASTJSON/modifier_definition.sol b/test/libsolidity/ASTJSON/modifier_definition.sol
new file mode 100644
index 00000000..96474e0f
--- /dev/null
+++ b/test/libsolidity/ASTJSON/modifier_definition.sol
@@ -0,0 +1 @@
+contract C { modifier M(uint i) { _; } function F() M(1) public {} }
diff --git a/test/libsolidity/ASTJSON/modifier_definition_legacy.json b/test/libsolidity/ASTJSON/modifier_definition_legacy.json
new file mode 100644
index 00000000..f38d07be
--- /dev/null
+++ b/test/libsolidity/ASTJSON/modifier_definition_legacy.json
@@ -0,0 +1,213 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 14
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 14
+ ],
+ "name" : "C",
+ "scope" : 15
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "documentation" : null,
+ "name" : "M",
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "i",
+ "scope" : 6,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "uint256",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 1,
+ "name" : "ElementaryTypeName",
+ "src" : "24:4:1"
+ }
+ ],
+ "id" : 2,
+ "name" : "VariableDeclaration",
+ "src" : "24:6:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "ParameterList",
+ "src" : "23:8:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "id" : 4,
+ "name" : "PlaceholderStatement",
+ "src" : "34:1:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "Block",
+ "src" : "32:6:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "ModifierDefinition",
+ "src" : "13:25:1"
+ },
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "name" : "F",
+ "payable" : false,
+ "scope" : 14,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 7,
+ "name" : "ParameterList",
+ "src" : "49:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 11,
+ "name" : "ParameterList",
+ "src" : "64:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "overloadedDeclarations" :
+ [
+ null
+ ],
+ "referencedDeclaration" : 6,
+ "type" : "modifier (uint256)",
+ "value" : "M"
+ },
+ "id" : 8,
+ "name" : "Identifier",
+ "src" : "52:1:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "hexvalue" : "31",
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "subdenomination" : null,
+ "token" : "number",
+ "type" : "int_const 1",
+ "value" : "1"
+ },
+ "id" : 9,
+ "name" : "Literal",
+ "src" : "54:1:1"
+ }
+ ],
+ "id" : 10,
+ "name" : "ModifierInvocation",
+ "src" : "52:4:1"
+ },
+ {
+ "attributes" :
+ {
+ "statements" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 12,
+ "name" : "Block",
+ "src" : "64:2:1"
+ }
+ ],
+ "id" : 13,
+ "name" : "FunctionDefinition",
+ "src" : "39:27:1"
+ }
+ ],
+ "id" : 14,
+ "name" : "ContractDefinition",
+ "src" : "0:68:1"
+ }
+ ],
+ "id" : 15,
+ "name" : "SourceUnit",
+ "src" : "0:69:1"
+}
diff --git a/test/libsolidity/ASTJSON/modifier_invocation.json b/test/libsolidity/ASTJSON/modifier_invocation.json
new file mode 100644
index 00000000..da64b78d
--- /dev/null
+++ b/test/libsolidity/ASTJSON/modifier_invocation.json
@@ -0,0 +1,176 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 14
+ ]
+ },
+ "id" : 15,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 14,
+ "linearizedBaseContracts" :
+ [
+ 14
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 5,
+ "nodeType" : "Block",
+ "src" : "32:6:1",
+ "statements" :
+ [
+ {
+ "id" : 4,
+ "nodeType" : "PlaceholderStatement",
+ "src" : "34:1:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 6,
+ "name" : "M",
+ "nodeType" : "ModifierDefinition",
+ "parameters" :
+ {
+ "id" : 3,
+ "nodeType" : "ParameterList",
+ "parameters" :
+ [
+ {
+ "constant" : false,
+ "id" : 2,
+ "name" : "i",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 6,
+ "src" : "24:6:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ },
+ "typeName" :
+ {
+ "id" : 1,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "24:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "src" : "23:8:1"
+ },
+ "src" : "13:25:1",
+ "visibility" : "internal"
+ },
+ {
+ "body" :
+ {
+ "id" : 12,
+ "nodeType" : "Block",
+ "src" : "64:2:1",
+ "statements" : []
+ },
+ "documentation" : null,
+ "id" : 13,
+ "implemented" : true,
+ "isConstructor" : false,
+ "isDeclaredConst" : false,
+ "modifiers" :
+ [
+ {
+ "arguments" :
+ [
+ {
+ "argumentTypes" : null,
+ "hexValue" : "31",
+ "id" : 9,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "kind" : "number",
+ "lValueRequested" : false,
+ "nodeType" : "Literal",
+ "src" : "54:1:1",
+ "subdenomination" : null,
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_rational_1_by_1",
+ "typeString" : "int_const 1"
+ },
+ "value" : "1"
+ }
+ ],
+ "id" : 10,
+ "modifierName" :
+ {
+ "argumentTypes" : null,
+ "id" : 8,
+ "name" : "M",
+ "nodeType" : "Identifier",
+ "overloadedDeclarations" : [],
+ "referencedDeclaration" : 6,
+ "src" : "52:1:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_modifier$_t_uint256_$",
+ "typeString" : "modifier (uint256)"
+ }
+ },
+ "nodeType" : "ModifierInvocation",
+ "src" : "52:4:1"
+ }
+ ],
+ "name" : "F",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 7,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "49:2:1"
+ },
+ "payable" : false,
+ "returnParameters" :
+ {
+ "id" : 11,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "64:0:1"
+ },
+ "scope" : 14,
+ "src" : "39:27:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 15,
+ "src" : "0:68:1"
+ }
+ ],
+ "src" : "0:69:1"
+}
diff --git a/test/libsolidity/ASTJSON/modifier_invocation.sol b/test/libsolidity/ASTJSON/modifier_invocation.sol
new file mode 100644
index 00000000..96474e0f
--- /dev/null
+++ b/test/libsolidity/ASTJSON/modifier_invocation.sol
@@ -0,0 +1 @@
+contract C { modifier M(uint i) { _; } function F() M(1) public {} }
diff --git a/test/libsolidity/ASTJSON/modifier_invocation_legacy.json b/test/libsolidity/ASTJSON/modifier_invocation_legacy.json
new file mode 100644
index 00000000..f38d07be
--- /dev/null
+++ b/test/libsolidity/ASTJSON/modifier_invocation_legacy.json
@@ -0,0 +1,213 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 14
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 14
+ ],
+ "name" : "C",
+ "scope" : 15
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "documentation" : null,
+ "name" : "M",
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "i",
+ "scope" : 6,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "uint256",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 1,
+ "name" : "ElementaryTypeName",
+ "src" : "24:4:1"
+ }
+ ],
+ "id" : 2,
+ "name" : "VariableDeclaration",
+ "src" : "24:6:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "ParameterList",
+ "src" : "23:8:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "id" : 4,
+ "name" : "PlaceholderStatement",
+ "src" : "34:1:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "Block",
+ "src" : "32:6:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "ModifierDefinition",
+ "src" : "13:25:1"
+ },
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "name" : "F",
+ "payable" : false,
+ "scope" : 14,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 7,
+ "name" : "ParameterList",
+ "src" : "49:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 11,
+ "name" : "ParameterList",
+ "src" : "64:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "overloadedDeclarations" :
+ [
+ null
+ ],
+ "referencedDeclaration" : 6,
+ "type" : "modifier (uint256)",
+ "value" : "M"
+ },
+ "id" : 8,
+ "name" : "Identifier",
+ "src" : "52:1:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "hexvalue" : "31",
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "subdenomination" : null,
+ "token" : "number",
+ "type" : "int_const 1",
+ "value" : "1"
+ },
+ "id" : 9,
+ "name" : "Literal",
+ "src" : "54:1:1"
+ }
+ ],
+ "id" : 10,
+ "name" : "ModifierInvocation",
+ "src" : "52:4:1"
+ },
+ {
+ "attributes" :
+ {
+ "statements" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 12,
+ "name" : "Block",
+ "src" : "64:2:1"
+ }
+ ],
+ "id" : 13,
+ "name" : "FunctionDefinition",
+ "src" : "39:27:1"
+ }
+ ],
+ "id" : 14,
+ "name" : "ContractDefinition",
+ "src" : "0:68:1"
+ }
+ ],
+ "id" : 15,
+ "name" : "SourceUnit",
+ "src" : "0:69:1"
+}
diff --git a/test/libsolidity/ASTJSON/non_utf8.json b/test/libsolidity/ASTJSON/non_utf8.json
new file mode 100644
index 00000000..ec4804f1
--- /dev/null
+++ b/test/libsolidity/ASTJSON/non_utf8.json
@@ -0,0 +1,124 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 8
+ ]
+ },
+ "id" : 9,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 8,
+ "linearizedBaseContracts" :
+ [
+ 8
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 6,
+ "nodeType" : "Block",
+ "src" : "33:20:1",
+ "statements" :
+ [
+ {
+ "assignments" :
+ [
+ 3
+ ],
+ "declarations" :
+ [
+ {
+ "constant" : false,
+ "id" : 3,
+ "name" : "x",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 6,
+ "src" : "35:5:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_string_memory_ptr",
+ "typeString" : "string"
+ },
+ "typeName" : null,
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "id" : 5,
+ "initialValue" :
+ {
+ "argumentTypes" : null,
+ "hexValue" : "ff",
+ "id" : 4,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "kind" : "string",
+ "lValueRequested" : false,
+ "nodeType" : "Literal",
+ "src" : "43:7:1",
+ "subdenomination" : null,
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_stringliteral_8b1a944cf13a9a1c08facb2c9e98623ef3254d2ddb48113885c3e8e97fec8db9",
+ "typeString" : "literal_string (contains invalid UTF-8 sequence at position 0)"
+ },
+ "value" : null
+ },
+ "nodeType" : "VariableDeclarationStatement",
+ "src" : "35:15:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 7,
+ "implemented" : true,
+ "isConstructor" : false,
+ "isDeclaredConst" : false,
+ "modifiers" : [],
+ "name" : "f",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "23:2:1"
+ },
+ "payable" : false,
+ "returnParameters" :
+ {
+ "id" : 2,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "33:0:1"
+ },
+ "scope" : 8,
+ "src" : "13:40:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 9,
+ "src" : "0:55:1"
+ }
+ ],
+ "src" : "0:56:1"
+}
diff --git a/test/libsolidity/ASTJSON/non_utf8.sol b/test/libsolidity/ASTJSON/non_utf8.sol
new file mode 100644
index 00000000..b83f3d70
--- /dev/null
+++ b/test/libsolidity/ASTJSON/non_utf8.sol
@@ -0,0 +1 @@
+contract C { function f() public { var x = hex"ff"; } }
diff --git a/test/libsolidity/ASTJSON/non_utf8_legacy.json b/test/libsolidity/ASTJSON/non_utf8_legacy.json
new file mode 100644
index 00000000..d83d2d97
--- /dev/null
+++ b/test/libsolidity/ASTJSON/non_utf8_legacy.json
@@ -0,0 +1,157 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 8
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 8
+ ],
+ "name" : "C",
+ "scope" : 9
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "f",
+ "payable" : false,
+ "scope" : 8,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "23:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 2,
+ "name" : "ParameterList",
+ "src" : "33:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "assignments" :
+ [
+ 3
+ ]
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "x",
+ "scope" : 6,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "string",
+ "typeName" : null,
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" : [],
+ "id" : 3,
+ "name" : "VariableDeclaration",
+ "src" : "35:5:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "hexvalue" : "ff",
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "subdenomination" : null,
+ "token" : "string",
+ "type" : "literal_string (contains invalid UTF-8 sequence at position 0)",
+ "value" : null
+ },
+ "id" : 4,
+ "name" : "Literal",
+ "src" : "43:7:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "VariableDeclarationStatement",
+ "src" : "35:15:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "Block",
+ "src" : "33:20:1"
+ }
+ ],
+ "id" : 7,
+ "name" : "FunctionDefinition",
+ "src" : "13:40:1"
+ }
+ ],
+ "id" : 8,
+ "name" : "ContractDefinition",
+ "src" : "0:55:1"
+ }
+ ],
+ "id" : 9,
+ "name" : "SourceUnit",
+ "src" : "0:56:1"
+}
diff --git a/test/libsolidity/ASTJSON/placeholder_statement.json b/test/libsolidity/ASTJSON/placeholder_statement.json
new file mode 100644
index 00000000..496e1500
--- /dev/null
+++ b/test/libsolidity/ASTJSON/placeholder_statement.json
@@ -0,0 +1,64 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 5
+ ]
+ },
+ "id" : 6,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 5,
+ "linearizedBaseContracts" :
+ [
+ 5
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 3,
+ "nodeType" : "Block",
+ "src" : "24:6:1",
+ "statements" :
+ [
+ {
+ "id" : 2,
+ "nodeType" : "PlaceholderStatement",
+ "src" : "26:1:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 4,
+ "name" : "M",
+ "nodeType" : "ModifierDefinition",
+ "parameters" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "24:0:1"
+ },
+ "src" : "13:17:1",
+ "visibility" : "internal"
+ }
+ ],
+ "scope" : 6,
+ "src" : "0:32:1"
+ }
+ ],
+ "src" : "0:33:1"
+}
diff --git a/test/libsolidity/ASTJSON/placeholder_statement.sol b/test/libsolidity/ASTJSON/placeholder_statement.sol
new file mode 100644
index 00000000..cb2c0990
--- /dev/null
+++ b/test/libsolidity/ASTJSON/placeholder_statement.sol
@@ -0,0 +1 @@
+contract C { modifier M { _; } }
diff --git a/test/libsolidity/ASTJSON/placeholder_statement_legacy.json b/test/libsolidity/ASTJSON/placeholder_statement_legacy.json
new file mode 100644
index 00000000..a5582976
--- /dev/null
+++ b/test/libsolidity/ASTJSON/placeholder_statement_legacy.json
@@ -0,0 +1,87 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 5
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 5
+ ],
+ "name" : "C",
+ "scope" : 6
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "documentation" : null,
+ "name" : "M",
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "24:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "id" : 2,
+ "name" : "PlaceholderStatement",
+ "src" : "26:1:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "Block",
+ "src" : "24:6:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "ModifierDefinition",
+ "src" : "13:17:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "ContractDefinition",
+ "src" : "0:32:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "SourceUnit",
+ "src" : "0:33:1"
+}
diff --git a/test/libsolidity/ASTJSON/short_type_name.json b/test/libsolidity/ASTJSON/short_type_name.json
new file mode 100644
index 00000000..32df8cde
--- /dev/null
+++ b/test/libsolidity/ASTJSON/short_type_name.json
@@ -0,0 +1,128 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 10
+ ]
+ },
+ "id" : 11,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 10,
+ "linearizedBaseContracts" :
+ [
+ 10
+ ],
+ "name" : "c",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 8,
+ "nodeType" : "Block",
+ "src" : "33:20:1",
+ "statements" :
+ [
+ {
+ "assignments" :
+ [
+ 6
+ ],
+ "declarations" :
+ [
+ {
+ "constant" : false,
+ "id" : 6,
+ "name" : "x",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 8,
+ "src" : "35:15:1",
+ "stateVariable" : false,
+ "storageLocation" : "memory",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_memory_ptr",
+ "typeString" : "uint256[]"
+ },
+ "typeName" :
+ {
+ "baseType" :
+ {
+ "id" : 4,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "35:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "id" : 5,
+ "length" : null,
+ "nodeType" : "ArrayTypeName",
+ "src" : "35:6:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage_ptr",
+ "typeString" : "uint256[]"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "id" : 7,
+ "initialValue" : null,
+ "nodeType" : "VariableDeclarationStatement",
+ "src" : "35:15:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 9,
+ "implemented" : true,
+ "isConstructor" : false,
+ "isDeclaredConst" : false,
+ "modifiers" : [],
+ "name" : "f",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "23:2:1"
+ },
+ "payable" : false,
+ "returnParameters" :
+ {
+ "id" : 2,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "33:0:1"
+ },
+ "scope" : 10,
+ "src" : "13:40:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 11,
+ "src" : "0:55:1"
+ }
+ ],
+ "src" : "0:56:1"
+}
diff --git a/test/libsolidity/ASTJSON/short_type_name.sol b/test/libsolidity/ASTJSON/short_type_name.sol
new file mode 100644
index 00000000..533874ae
--- /dev/null
+++ b/test/libsolidity/ASTJSON/short_type_name.sol
@@ -0,0 +1 @@
+contract c { function f() public { uint[] memory x; } }
diff --git a/test/libsolidity/ASTJSON/short_type_name_legacy.json b/test/libsolidity/ASTJSON/short_type_name_legacy.json
new file mode 100644
index 00000000..d14954c8
--- /dev/null
+++ b/test/libsolidity/ASTJSON/short_type_name_legacy.json
@@ -0,0 +1,164 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 10
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 10
+ ],
+ "name" : "c",
+ "scope" : 11
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "f",
+ "payable" : false,
+ "scope" : 10,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "23:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 2,
+ "name" : "ParameterList",
+ "src" : "33:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "assignments" :
+ [
+ 6
+ ],
+ "initialValue" : null
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "x",
+ "scope" : 8,
+ "stateVariable" : false,
+ "storageLocation" : "memory",
+ "type" : "uint256[]",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "length" : null,
+ "type" : "uint256[]"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 4,
+ "name" : "ElementaryTypeName",
+ "src" : "35:4:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "ArrayTypeName",
+ "src" : "35:6:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "VariableDeclaration",
+ "src" : "35:15:1"
+ }
+ ],
+ "id" : 7,
+ "name" : "VariableDeclarationStatement",
+ "src" : "35:15:1"
+ }
+ ],
+ "id" : 8,
+ "name" : "Block",
+ "src" : "33:20:1"
+ }
+ ],
+ "id" : 9,
+ "name" : "FunctionDefinition",
+ "src" : "13:40:1"
+ }
+ ],
+ "id" : 10,
+ "name" : "ContractDefinition",
+ "src" : "0:55:1"
+ }
+ ],
+ "id" : 11,
+ "name" : "SourceUnit",
+ "src" : "0:56:1"
+}
diff --git a/test/libsolidity/ASTJSON/short_type_name_ref.json b/test/libsolidity/ASTJSON/short_type_name_ref.json
new file mode 100644
index 00000000..ebe940cf
--- /dev/null
+++ b/test/libsolidity/ASTJSON/short_type_name_ref.json
@@ -0,0 +1,140 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 11
+ ]
+ },
+ "id" : 12,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 11,
+ "linearizedBaseContracts" :
+ [
+ 11
+ ],
+ "name" : "c",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 9,
+ "nodeType" : "Block",
+ "src" : "33:25:1",
+ "statements" :
+ [
+ {
+ "assignments" :
+ [
+ 7
+ ],
+ "declarations" :
+ [
+ {
+ "constant" : false,
+ "id" : 7,
+ "name" : "rows",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 9,
+ "src" : "35:20:1",
+ "stateVariable" : false,
+ "storageLocation" : "memory",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_array$_t_uint256_$dyn_memory_$dyn_memory_ptr",
+ "typeString" : "uint256[][]"
+ },
+ "typeName" :
+ {
+ "baseType" :
+ {
+ "baseType" :
+ {
+ "id" : 4,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "35:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ },
+ "id" : 5,
+ "length" : null,
+ "nodeType" : "ArrayTypeName",
+ "src" : "35:6:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_uint256_$dyn_storage_ptr",
+ "typeString" : "uint256[]"
+ }
+ },
+ "id" : 6,
+ "length" : null,
+ "nodeType" : "ArrayTypeName",
+ "src" : "35:8:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_array$_t_array$_t_uint256_$dyn_storage_$dyn_storage_ptr",
+ "typeString" : "uint256[][]"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "id" : 8,
+ "initialValue" : null,
+ "nodeType" : "VariableDeclarationStatement",
+ "src" : "35:20:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 10,
+ "implemented" : true,
+ "isConstructor" : false,
+ "isDeclaredConst" : false,
+ "modifiers" : [],
+ "name" : "f",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "23:2:1"
+ },
+ "payable" : false,
+ "returnParameters" :
+ {
+ "id" : 2,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "33:0:1"
+ },
+ "scope" : 11,
+ "src" : "13:45:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 12,
+ "src" : "0:60:1"
+ }
+ ],
+ "src" : "0:61:1"
+}
diff --git a/test/libsolidity/ASTJSON/short_type_name_ref.sol b/test/libsolidity/ASTJSON/short_type_name_ref.sol
new file mode 100644
index 00000000..a808b982
--- /dev/null
+++ b/test/libsolidity/ASTJSON/short_type_name_ref.sol
@@ -0,0 +1 @@
+contract c { function f() public { uint[][] memory rows; } }
diff --git a/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json b/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json
new file mode 100644
index 00000000..aaf9b8be
--- /dev/null
+++ b/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json
@@ -0,0 +1,177 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "c" :
+ [
+ 11
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 11
+ ],
+ "name" : "c",
+ "scope" : 12
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "f",
+ "payable" : false,
+ "scope" : 11,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "23:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 2,
+ "name" : "ParameterList",
+ "src" : "33:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "assignments" :
+ [
+ 7
+ ],
+ "initialValue" : null
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "rows",
+ "scope" : 9,
+ "stateVariable" : false,
+ "storageLocation" : "memory",
+ "type" : "uint256[][]",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "length" : null,
+ "type" : "uint256[][]"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "length" : null,
+ "type" : "uint256[]"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 4,
+ "name" : "ElementaryTypeName",
+ "src" : "35:4:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "ArrayTypeName",
+ "src" : "35:6:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "ArrayTypeName",
+ "src" : "35:8:1"
+ }
+ ],
+ "id" : 7,
+ "name" : "VariableDeclaration",
+ "src" : "35:20:1"
+ }
+ ],
+ "id" : 8,
+ "name" : "VariableDeclarationStatement",
+ "src" : "35:20:1"
+ }
+ ],
+ "id" : 9,
+ "name" : "Block",
+ "src" : "33:25:1"
+ }
+ ],
+ "id" : 10,
+ "name" : "FunctionDefinition",
+ "src" : "13:45:1"
+ }
+ ],
+ "id" : 11,
+ "name" : "ContractDefinition",
+ "src" : "0:60:1"
+ }
+ ],
+ "id" : 12,
+ "name" : "SourceUnit",
+ "src" : "0:61:1"
+}
diff --git a/test/libsolidity/ASTJSON/smoke.json b/test/libsolidity/ASTJSON/smoke.json
new file mode 100644
index 00000000..f5369bfc
--- /dev/null
+++ b/test/libsolidity/ASTJSON/smoke.json
@@ -0,0 +1,33 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 1
+ ]
+ },
+ "id" : 2,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 1,
+ "linearizedBaseContracts" :
+ [
+ 1
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" : [],
+ "scope" : 2,
+ "src" : "0:13:1"
+ }
+ ],
+ "src" : "0:14:1"
+}
diff --git a/test/libsolidity/ASTJSON/smoke.sol b/test/libsolidity/ASTJSON/smoke.sol
new file mode 100644
index 00000000..2dde0d20
--- /dev/null
+++ b/test/libsolidity/ASTJSON/smoke.sol
@@ -0,0 +1 @@
+contract C {}
diff --git a/test/libsolidity/ASTJSON/smoke_legacy.json b/test/libsolidity/ASTJSON/smoke_legacy.json
new file mode 100644
index 00000000..e01a3c9b
--- /dev/null
+++ b/test/libsolidity/ASTJSON/smoke_legacy.json
@@ -0,0 +1,48 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 1
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 1
+ ],
+ "name" : "C",
+ "nodes" :
+ [
+ null
+ ],
+ "scope" : 2
+ },
+ "id" : 1,
+ "name" : "ContractDefinition",
+ "src" : "0:13:1"
+ }
+ ],
+ "id" : 2,
+ "name" : "SourceUnit",
+ "src" : "0:14:1"
+}
diff --git a/test/libsolidity/ASTJSON/source_location.json b/test/libsolidity/ASTJSON/source_location.json
new file mode 100644
index 00000000..bd9290fd
--- /dev/null
+++ b/test/libsolidity/ASTJSON/source_location.json
@@ -0,0 +1,162 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 11
+ ]
+ },
+ "id" : 12,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 11,
+ "linearizedBaseContracts" :
+ [
+ 11
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "body" :
+ {
+ "id" : 9,
+ "nodeType" : "Block",
+ "src" : "26:19:1",
+ "statements" :
+ [
+ {
+ "assignments" :
+ [
+ 3
+ ],
+ "declarations" :
+ [
+ {
+ "constant" : false,
+ "id" : 3,
+ "name" : "x",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 9,
+ "src" : "28:5:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint8",
+ "typeString" : "uint8"
+ },
+ "typeName" : null,
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "id" : 5,
+ "initialValue" :
+ {
+ "argumentTypes" : null,
+ "hexValue" : "32",
+ "id" : 4,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "kind" : "number",
+ "lValueRequested" : false,
+ "nodeType" : "Literal",
+ "src" : "36:1:1",
+ "subdenomination" : null,
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_rational_2_by_1",
+ "typeString" : "int_const 2"
+ },
+ "value" : "2"
+ },
+ "nodeType" : "VariableDeclarationStatement",
+ "src" : "28:9:1"
+ },
+ {
+ "expression" :
+ {
+ "argumentTypes" : null,
+ "id" : 7,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : false,
+ "lValueRequested" : false,
+ "nodeType" : "UnaryOperation",
+ "operator" : "++",
+ "prefix" : false,
+ "src" : "39:3:1",
+ "subExpression" :
+ {
+ "argumentTypes" : null,
+ "id" : 6,
+ "name" : "x",
+ "nodeType" : "Identifier",
+ "overloadedDeclarations" : [],
+ "referencedDeclaration" : 3,
+ "src" : "39:1:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint8",
+ "typeString" : "uint8"
+ }
+ },
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint8",
+ "typeString" : "uint8"
+ }
+ },
+ "id" : 8,
+ "nodeType" : "ExpressionStatement",
+ "src" : "39:3:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 10,
+ "implemented" : true,
+ "isConstructor" : false,
+ "isDeclaredConst" : false,
+ "modifiers" : [],
+ "name" : "f",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 1,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "23:2:1"
+ },
+ "payable" : false,
+ "returnParameters" :
+ {
+ "id" : 2,
+ "nodeType" : "ParameterList",
+ "parameters" : [],
+ "src" : "26:0:1"
+ },
+ "scope" : 11,
+ "src" : "13:32:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 12,
+ "src" : "0:47:1"
+ }
+ ],
+ "src" : "0:48:1"
+}
diff --git a/test/libsolidity/ASTJSON/source_location.sol b/test/libsolidity/ASTJSON/source_location.sol
new file mode 100644
index 00000000..1fcec2e6
--- /dev/null
+++ b/test/libsolidity/ASTJSON/source_location.sol
@@ -0,0 +1 @@
+contract C { function f() { var x = 2; x++; } }
diff --git a/test/libsolidity/ASTJSON/source_location_legacy.json b/test/libsolidity/ASTJSON/source_location_legacy.json
new file mode 100644
index 00000000..d046e6ae
--- /dev/null
+++ b/test/libsolidity/ASTJSON/source_location_legacy.json
@@ -0,0 +1,200 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 11
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 11
+ ],
+ "name" : "C",
+ "scope" : 12
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "f",
+ "payable" : false,
+ "scope" : 11,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 1,
+ "name" : "ParameterList",
+ "src" : "23:2:1"
+ },
+ {
+ "attributes" :
+ {
+ "parameters" :
+ [
+ null
+ ]
+ },
+ "children" : [],
+ "id" : 2,
+ "name" : "ParameterList",
+ "src" : "26:0:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "assignments" :
+ [
+ 3
+ ]
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "x",
+ "scope" : 9,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "uint8",
+ "typeName" : null,
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" : [],
+ "id" : 3,
+ "name" : "VariableDeclaration",
+ "src" : "28:5:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "hexvalue" : "32",
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "subdenomination" : null,
+ "token" : "number",
+ "type" : "int_const 2",
+ "value" : "2"
+ },
+ "id" : 4,
+ "name" : "Literal",
+ "src" : "36:1:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "VariableDeclarationStatement",
+ "src" : "28:9:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : false,
+ "lValueRequested" : false,
+ "operator" : "++",
+ "prefix" : false,
+ "type" : "uint8"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "overloadedDeclarations" :
+ [
+ null
+ ],
+ "referencedDeclaration" : 3,
+ "type" : "uint8",
+ "value" : "x"
+ },
+ "id" : 6,
+ "name" : "Identifier",
+ "src" : "39:1:1"
+ }
+ ],
+ "id" : 7,
+ "name" : "UnaryOperation",
+ "src" : "39:3:1"
+ }
+ ],
+ "id" : 8,
+ "name" : "ExpressionStatement",
+ "src" : "39:3:1"
+ }
+ ],
+ "id" : 9,
+ "name" : "Block",
+ "src" : "26:19:1"
+ }
+ ],
+ "id" : 10,
+ "name" : "FunctionDefinition",
+ "src" : "13:32:1"
+ }
+ ],
+ "id" : 11,
+ "name" : "ContractDefinition",
+ "src" : "0:47:1"
+ }
+ ],
+ "id" : 12,
+ "name" : "SourceUnit",
+ "src" : "0:48:1"
+}
diff --git a/test/libsolidity/ASTJSON/using_for_directive.json b/test/libsolidity/ASTJSON/using_for_directive.json
new file mode 100644
index 00000000..33caabb4
--- /dev/null
+++ b/test/libsolidity/ASTJSON/using_for_directive.json
@@ -0,0 +1,87 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 5
+ ],
+ "L" :
+ [
+ 1
+ ]
+ },
+ "id" : 6,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "library",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 1,
+ "linearizedBaseContracts" :
+ [
+ 1
+ ],
+ "name" : "L",
+ "nodeType" : "ContractDefinition",
+ "nodes" : [],
+ "scope" : 6,
+ "src" : "0:12:1"
+ },
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 5,
+ "linearizedBaseContracts" :
+ [
+ 5
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "id" : 4,
+ "libraryName" :
+ {
+ "contractScope" : null,
+ "id" : 2,
+ "name" : "L",
+ "nodeType" : "UserDefinedTypeName",
+ "referencedDeclaration" : 1,
+ "src" : "32:1:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_contract$_L_$1",
+ "typeString" : "library L"
+ }
+ },
+ "nodeType" : "UsingForDirective",
+ "src" : "26:17:1",
+ "typeName" :
+ {
+ "id" : 3,
+ "name" : "uint",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "38:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_uint256",
+ "typeString" : "uint256"
+ }
+ }
+ }
+ ],
+ "scope" : 6,
+ "src" : "13:32:1"
+ }
+ ],
+ "src" : "0:46:1"
+}
diff --git a/test/libsolidity/ASTJSON/using_for_directive.sol b/test/libsolidity/ASTJSON/using_for_directive.sol
new file mode 100644
index 00000000..a882ad88
--- /dev/null
+++ b/test/libsolidity/ASTJSON/using_for_directive.sol
@@ -0,0 +1 @@
+library L {} contract C { using L for uint; }
diff --git a/test/libsolidity/ASTJSON/using_for_directive_legacy.json b/test/libsolidity/ASTJSON/using_for_directive_legacy.json
new file mode 100644
index 00000000..0827ef90
--- /dev/null
+++ b/test/libsolidity/ASTJSON/using_for_directive_legacy.json
@@ -0,0 +1,110 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 5
+ ],
+ "L" :
+ [
+ 1
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "library",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 1
+ ],
+ "name" : "L",
+ "nodes" :
+ [
+ null
+ ],
+ "scope" : 6
+ },
+ "id" : 1,
+ "name" : "ContractDefinition",
+ "src" : "0:12:1"
+ },
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 5
+ ],
+ "name" : "C",
+ "scope" : 6
+ },
+ "children" :
+ [
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "contractScope" : null,
+ "name" : "L",
+ "referencedDeclaration" : 1,
+ "type" : "library L"
+ },
+ "id" : 2,
+ "name" : "UserDefinedTypeName",
+ "src" : "32:1:1"
+ },
+ {
+ "attributes" :
+ {
+ "name" : "uint",
+ "type" : "uint256"
+ },
+ "id" : 3,
+ "name" : "ElementaryTypeName",
+ "src" : "38:4:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "UsingForDirective",
+ "src" : "26:17:1"
+ }
+ ],
+ "id" : 5,
+ "name" : "ContractDefinition",
+ "src" : "13:32:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "SourceUnit",
+ "src" : "0:46:1"
+}
diff --git a/test/libsolidity/ASTJSONTest.cpp b/test/libsolidity/ASTJSONTest.cpp
new file mode 100644
index 00000000..05839c1f
--- /dev/null
+++ b/test/libsolidity/ASTJSONTest.cpp
@@ -0,0 +1,201 @@
+/*
+ This file is part of solidity.
+
+ solidity is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ solidity is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with solidity. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <test/libsolidity/ASTJSONTest.h>
+#include <test/Options.h>
+#include <libsolidity/ast/ASTJsonConverter.h>
+#include <libsolidity/interface/CompilerStack.h>
+#include <boost/algorithm/string.hpp>
+#include <boost/algorithm/string/predicate.hpp>
+#include <boost/throw_exception.hpp>
+#include <cctype>
+#include <fstream>
+#include <memory>
+#include <stdexcept>
+
+using namespace dev;
+using namespace solidity;
+using namespace dev::solidity::test;
+using namespace dev::solidity::test::formatting;
+using namespace std;
+namespace fs = boost::filesystem;
+using namespace boost::unit_test;
+
+ASTJSONTest::ASTJSONTest(string const& _filename)
+{
+ if (!boost::algorithm::ends_with(_filename, ".sol"))
+ BOOST_THROW_EXCEPTION(runtime_error("Invalid test contract file name: \"" + _filename + "\"."));
+
+ m_astFilename = _filename.substr(0, _filename.size() - 4) + ".json";
+ m_legacyAstFilename = _filename.substr(0, _filename.size() - 4) + "_legacy.json";
+
+ ifstream file(_filename);
+ if (!file)
+ BOOST_THROW_EXCEPTION(runtime_error("Cannot open test contract: \"" + _filename + "\"."));
+ file.exceptions(ios::badbit);
+
+ string sourceName;
+ string source;
+ string line;
+ string const sourceDelimiter("// ---- SOURCE: ");
+ string const delimiter("// ----");
+ while (getline(file, line))
+ {
+ if (boost::algorithm::starts_with(line, sourceDelimiter))
+ {
+ if (!sourceName.empty())
+ m_sources.emplace_back(sourceName, source);
+
+ sourceName = line.substr(sourceDelimiter.size(), string::npos);
+ source = string();
+ }
+ else if (!line.empty() && !boost::algorithm::starts_with(line, delimiter))
+ source += line + "\n";
+ }
+
+ m_sources.emplace_back(sourceName.empty() ? "a" : sourceName, source);
+
+ file.close();
+ file.open(m_astFilename);
+ if (file)
+ {
+ string line;
+ while (getline(file, line))
+ m_expectation += line + "\n";
+ }
+
+ file.close();
+ file.open(m_legacyAstFilename);
+ if (file)
+ {
+ string line;
+ while (getline(file, line))
+ m_expectationLegacy += line + "\n";
+ }
+}
+
+bool ASTJSONTest::run(ostream& _stream, string const& _linePrefix, bool const _formatted)
+{
+ CompilerStack c;
+
+ map<string, unsigned> sourceIndices;
+ for (size_t i = 0; i < m_sources.size(); i++)
+ {
+ c.addSource(m_sources[i].first, m_sources[i].second);
+ sourceIndices[m_sources[i].first] = i + 1;
+ }
+
+ c.setEVMVersion(dev::test::Options::get().evmVersion());
+ c.parseAndAnalyze();
+
+ for (size_t i = 0; i < m_sources.size(); i++)
+ {
+ ostringstream result;
+ ASTJsonConverter(false, sourceIndices).print(result, c.ast(m_sources[i].first));
+ m_result += result.str();
+ if (i != m_sources.size() - 1)
+ m_result += ",";
+ m_result += "\n";
+ }
+
+ bool resultsMatch = true;
+
+ if (m_expectation != m_result)
+ {
+ string nextIndentLevel = _linePrefix + " ";
+ FormattedScope(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Expected result:" << endl;
+ {
+ istringstream stream(m_expectation);
+ string line;
+ while (getline(stream, line))
+ _stream << nextIndentLevel << line << endl;
+ }
+ _stream << endl;
+ FormattedScope(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Obtained result:" << endl;
+ {
+ istringstream stream(m_result);
+ string line;
+ while (getline(stream, line))
+ _stream << nextIndentLevel << line << endl;
+ }
+ _stream << endl;
+ resultsMatch = false;
+ }
+
+ for (size_t i = 0; i < m_sources.size(); i++)
+ {
+ ostringstream result;
+ ASTJsonConverter(true, sourceIndices).print(result, c.ast(m_sources[i].first));
+ m_resultLegacy = result.str();
+ if (i != m_sources.size() - 1)
+ m_resultLegacy += ",";
+ m_resultLegacy += "\n";
+ }
+
+ if (m_expectationLegacy != m_resultLegacy)
+ {
+ string nextIndentLevel = _linePrefix + " ";
+ FormattedScope(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Expected result (legacy):" << endl;
+ {
+ istringstream stream(m_expectationLegacy);
+ string line;
+ while (getline(stream, line))
+ _stream << nextIndentLevel << line << endl;
+ }
+ _stream << endl;
+ FormattedScope(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Obtained result (legacy):" << endl;
+ {
+ istringstream stream(m_resultLegacy);
+ string line;
+ while (getline(stream, line))
+ _stream << nextIndentLevel << line << endl;
+ }
+ _stream << endl;
+ resultsMatch = false;
+ }
+
+ return resultsMatch;
+}
+
+void ASTJSONTest::printSource(ostream& _stream, string const& _linePrefix, bool const) const
+{
+ for (auto const& source: m_sources)
+ {
+ if (m_sources.size() > 1 || source.first != "a")
+ _stream << _linePrefix << "// ---- SOURCE: " << source.first << endl << endl;
+ stringstream stream(source.second);
+ string line;
+ while (getline(stream, line))
+ _stream << _linePrefix << line << endl;
+ _stream << endl;
+ }
+}
+
+void ASTJSONTest::printUpdatedExpectations(std::ostream&, std::string const&) const
+{
+ ofstream file(m_astFilename.c_str());
+ if (!file) BOOST_THROW_EXCEPTION(runtime_error("Cannot write AST expectation to \"" + m_astFilename + "\"."));
+ file.exceptions(ios::badbit);
+ file << m_result;
+ file.flush();
+ file.close();
+ file.open(m_legacyAstFilename.c_str());
+ if (!file) BOOST_THROW_EXCEPTION(runtime_error("Cannot write legacy AST expectation to \"" + m_legacyAstFilename + "\"."));
+ file << m_resultLegacy;
+ file.flush();
+ file.close();
+}
diff --git a/test/libsolidity/ASTJSONTest.h b/test/libsolidity/ASTJSONTest.h
new file mode 100644
index 00000000..6f24bb60
--- /dev/null
+++ b/test/libsolidity/ASTJSONTest.h
@@ -0,0 +1,58 @@
+/*
+ This file is part of solidity.
+
+ solidity is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ solidity is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with solidity. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#pragma once
+
+#include <test/libsolidity/FormattedScope.h>
+#include <test/libsolidity/TestCase.h>
+
+#include <iosfwd>
+#include <string>
+#include <vector>
+#include <utility>
+
+namespace dev
+{
+namespace solidity
+{
+namespace test
+{
+
+class ASTJSONTest: public TestCase
+{
+public:
+ static std::unique_ptr<TestCase> create(std::string const& _filename)
+ { return std::unique_ptr<TestCase>(new ASTJSONTest(_filename)); }
+ ASTJSONTest(std::string const& _filename);
+
+ virtual bool run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) override;
+
+ virtual void printSource(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) const override;
+ virtual void printUpdatedExpectations(std::ostream& _stream, std::string const& _linePrefix) const override;
+private:
+ std::vector<std::pair<std::string, std::string>> m_sources;
+ std::string m_expectation;
+ std::string m_expectationLegacy;
+ std::string m_astFilename;
+ std::string m_legacyAstFilename;
+ std::string m_result;
+ std::string m_resultLegacy;
+};
+
+}
+}
+}
diff --git a/test/libsolidity/ASTLegacyJSON.cpp b/test/libsolidity/ASTLegacyJSON.cpp
deleted file mode 100644
index 69cb1bb9..00000000
--- a/test/libsolidity/ASTLegacyJSON.cpp
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- This file is part of solidity.
-
- solidity is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- solidity is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with solidity. If not, see <http://www.gnu.org/licenses/>.
-*/
-/**
- * @author Christian <c@ethdev.com>
- * @date 2016
- * Tests for the json ast output.
- */
-
-#include <test/Options.h>
-
-#include <libsolidity/interface/Exceptions.h>
-#include <libsolidity/interface/CompilerStack.h>
-#include <libsolidity/ast/ASTJsonConverter.h>
-
-#include <boost/test/unit_test.hpp>
-
-#include <string>
-
-using namespace std;
-
-namespace dev
-{
-namespace solidity
-{
-namespace test
-{
-
-BOOST_AUTO_TEST_SUITE(SolidityASTLegacyJSON)
-
-BOOST_AUTO_TEST_CASE(smoke_test)
-{
- CompilerStack c;
- c.addSource("a", "contract C {}");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- BOOST_CHECK_EQUAL(astJson["name"], "SourceUnit");
-}
-
-BOOST_AUTO_TEST_CASE(source_location)
-{
- CompilerStack c;
- c.addSource("a", "contract C { function f() { var x = 2; x++; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- BOOST_CHECK_EQUAL(astJson["name"], "SourceUnit");
- BOOST_CHECK_EQUAL(astJson["children"][0]["name"], "ContractDefinition");
- BOOST_CHECK_EQUAL(astJson["children"][0]["children"][0]["name"], "FunctionDefinition");
- BOOST_CHECK_EQUAL(astJson["children"][0]["children"][0]["src"], "13:32:1");
-
-}
-
-BOOST_AUTO_TEST_CASE(inheritance_specifier)
-{
- CompilerStack c;
- c.addSource("a", "contract C1 {} contract C2 is C1 {}");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- BOOST_CHECK_EQUAL(astJson["children"][1]["attributes"]["name"], "C2");
- BOOST_CHECK_EQUAL(astJson["children"][1]["children"][0]["name"], "InheritanceSpecifier");
- BOOST_CHECK_EQUAL(astJson["children"][1]["children"][0]["src"], "30:2:1");
- BOOST_CHECK_EQUAL(astJson["children"][1]["children"][0]["children"][0]["name"], "UserDefinedTypeName");
- BOOST_CHECK_EQUAL(astJson["children"][1]["children"][0]["children"][0]["attributes"]["name"], "C1");
-}
-
-BOOST_AUTO_TEST_CASE(using_for_directive)
-{
- CompilerStack c;
- c.addSource("a", "library L {} contract C { using L for uint; }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value usingFor = astJson["children"][1]["children"][0];
- BOOST_CHECK_EQUAL(usingFor["name"], "UsingForDirective");
- BOOST_CHECK_EQUAL(usingFor["src"], "26:17:1");
- BOOST_CHECK_EQUAL(usingFor["children"][0]["name"], "UserDefinedTypeName");
- BOOST_CHECK_EQUAL(usingFor["children"][0]["attributes"]["name"], "L");
- BOOST_CHECK_EQUAL(usingFor["children"][1]["name"], "ElementaryTypeName");
- BOOST_CHECK_EQUAL(usingFor["children"][1]["attributes"]["name"], "uint");
-}
-
-BOOST_AUTO_TEST_CASE(enum_value)
-{
- CompilerStack c;
- c.addSource("a", "contract C { enum E { A, B } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value enumDefinition = astJson["children"][0]["children"][0];
- BOOST_CHECK_EQUAL(enumDefinition["children"][0]["name"], "EnumValue");
- BOOST_CHECK_EQUAL(enumDefinition["children"][0]["attributes"]["name"], "A");
- BOOST_CHECK_EQUAL(enumDefinition["children"][0]["src"], "22:1:1");
- BOOST_CHECK_EQUAL(enumDefinition["children"][1]["name"], "EnumValue");
- BOOST_CHECK_EQUAL(enumDefinition["children"][1]["attributes"]["name"], "B");
- BOOST_CHECK_EQUAL(enumDefinition["children"][1]["src"], "25:1:1");
-}
-
-BOOST_AUTO_TEST_CASE(modifier_definition)
-{
- CompilerStack c;
- 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;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value modifier = astJson["children"][0]["children"][0];
- BOOST_CHECK_EQUAL(modifier["name"], "ModifierDefinition");
- BOOST_CHECK_EQUAL(modifier["attributes"]["name"], "M");
- BOOST_CHECK_EQUAL(modifier["src"], "13:25:1");
-}
-
-BOOST_AUTO_TEST_CASE(modifier_invocation)
-{
- CompilerStack c;
- 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;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value modifier = astJson["children"][0]["children"][1]["children"][2];
- BOOST_CHECK_EQUAL(modifier["name"], "ModifierInvocation");
- BOOST_CHECK_EQUAL(modifier["src"], "52:4:1");
- BOOST_CHECK_EQUAL(modifier["children"][0]["attributes"]["type"], "modifier (uint256)");
- BOOST_CHECK_EQUAL(modifier["children"][0]["attributes"]["value"], "M");
- BOOST_CHECK_EQUAL(modifier["children"][1]["attributes"]["value"], "1");
-}
-
-BOOST_AUTO_TEST_CASE(event_definition)
-{
- CompilerStack c;
- c.addSource("a", "contract C { event E(); }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value event = astJson["children"][0]["children"][0];
- BOOST_CHECK_EQUAL(event["name"], "EventDefinition");
- BOOST_CHECK_EQUAL(event["attributes"]["name"], "E");
- BOOST_CHECK_EQUAL(event["src"], "13:10:1");
-}
-
-BOOST_AUTO_TEST_CASE(array_type_name)
-{
- CompilerStack c;
- c.addSource("a", "contract C { uint[] i; }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value arrayDecl = astJson["children"][0]["children"][0]["attributes"];
- BOOST_CHECK_EQUAL(arrayDecl["storageLocation"], "default");
- BOOST_CHECK_EQUAL(arrayDecl["type"], "uint256[]");
- Json::Value array = astJson["children"][0]["children"][0]["children"][0];
- BOOST_CHECK_EQUAL(array["name"], "ArrayTypeName");
- BOOST_CHECK_EQUAL(array["src"], "13:6:1");
-}
-
-BOOST_AUTO_TEST_CASE(short_type_name)
-{
- CompilerStack c;
- c.addSource("a", "contract c { function f() public { uint[] memory x; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value arrayDecl = astJson["children"][0]["children"][0]["children"][2]["children"][0]["children"][0];
- BOOST_CHECK_EQUAL(arrayDecl["attributes"]["storageLocation"], "memory");
- BOOST_CHECK_EQUAL(arrayDecl["attributes"]["type"], "uint256[]");
-}
-
-BOOST_AUTO_TEST_CASE(short_type_name_ref)
-{
- CompilerStack c;
- c.addSource("a", "contract c { function f() public { uint[][] memory rows; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value arrayDecl = astJson["children"][0]["children"][0]["children"][2]["children"][0]["children"][0];
- BOOST_CHECK_EQUAL(arrayDecl["attributes"]["storageLocation"], "memory");
- BOOST_CHECK_EQUAL(arrayDecl["attributes"]["type"], "uint256[][]");
-}
-
-BOOST_AUTO_TEST_CASE(placeholder_statement)
-{
- CompilerStack c;
- c.addSource("a", "contract C { modifier M { _; } }");
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value placeholder = astJson["children"][0]["children"][0]["children"][1]["children"][0];
- BOOST_CHECK_EQUAL(placeholder["name"], "PlaceholderStatement");
- BOOST_CHECK_EQUAL(placeholder["src"], "26:1:1");
-}
-
-BOOST_AUTO_TEST_CASE(non_utf8)
-{
- CompilerStack c;
- 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;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value varDecl = astJson["children"][0]["children"][0]["children"][2]["children"][0]["children"][0];
- BOOST_CHECK_EQUAL(varDecl["attributes"]["type"], "string");
- BOOST_CHECK_EQUAL(varDecl["attributes"]["typeName"], Json::nullValue);
- Json::Value literal = astJson["children"][0]["children"][0]["children"][2]["children"][0]["children"][1];
- BOOST_CHECK_EQUAL(literal["name"], "Literal");
- BOOST_CHECK_EQUAL(literal["attributes"]["hexvalue"], "ff");
- BOOST_CHECK_EQUAL(literal["attributes"]["token"], "string");
- BOOST_CHECK_EQUAL(literal["attributes"]["value"], Json::nullValue);
- BOOST_CHECK(literal["attributes"]["type"].asString().find("invalid") != string::npos);
-}
-
-BOOST_AUTO_TEST_CASE(function_type)
-{
- CompilerStack c;
- c.addSource("a",
- "contract C { function f(function() external payable returns (uint) x) "
- "returns (function() external view returns (uint)) {} }"
- );
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 1;
- Json::Value astJson = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value fun = astJson["children"][0]["children"][0];
- BOOST_CHECK_EQUAL(fun["name"], "FunctionDefinition");
- Json::Value argument = fun["children"][0]["children"][0];
- BOOST_CHECK_EQUAL(argument["name"], "VariableDeclaration");
- BOOST_CHECK_EQUAL(argument["attributes"]["name"], "x");
- BOOST_CHECK_EQUAL(argument["attributes"]["type"], "function () payable external returns (uint256)");
- Json::Value funType = argument["children"][0];
- BOOST_CHECK_EQUAL(funType["attributes"]["constant"], false);
- BOOST_CHECK_EQUAL(funType["attributes"]["payable"], true);
- BOOST_CHECK_EQUAL(funType["attributes"]["visibility"], "external");
- Json::Value retval = fun["children"][1]["children"][0];
- BOOST_CHECK_EQUAL(retval["name"], "VariableDeclaration");
- BOOST_CHECK_EQUAL(retval["attributes"]["name"], "");
- BOOST_CHECK_EQUAL(retval["attributes"]["type"], "function () view external returns (uint256)");
- funType = retval["children"][0];
- BOOST_CHECK_EQUAL(funType["attributes"]["constant"], true);
- BOOST_CHECK_EQUAL(funType["attributes"]["payable"], false);
- BOOST_CHECK_EQUAL(funType["attributes"]["visibility"], "external");
-}
-
-BOOST_AUTO_TEST_CASE(documentation)
-{
- CompilerStack c;
- c.addSource("a", "/**This contract is empty*/ contract C {}");
- c.addSource("b",
- "/**This contract is empty"
- " and has a line-breaking comment.*/"
- "contract C {}"
- );
- c.addSource("c",
- "contract C {"
- " /** Some comment on Evt.*/ event Evt();"
- " /** Some comment on mod.*/ modifier mod() { _; }"
- " /** Some comment on fn.*/ function fn() public {}"
- "}"
- );
- c.setEVMVersion(dev::test::Options::get().evmVersion());
- c.parseAndAnalyze();
- map<string, unsigned> sourceIndices;
- sourceIndices["a"] = 0;
- sourceIndices["b"] = 1;
- sourceIndices["c"] = 2;
- Json::Value astJsonA = ASTJsonConverter(true, sourceIndices).toJson(c.ast("a"));
- Json::Value documentationA = astJsonA["children"][0]["attributes"]["documentation"];
- BOOST_CHECK_EQUAL(documentationA, "This contract is empty");
- Json::Value astJsonB = ASTJsonConverter(true, sourceIndices).toJson(c.ast("b"));
- Json::Value documentationB = astJsonB["children"][0]["attributes"]["documentation"];
- BOOST_CHECK_EQUAL(documentationB, "This contract is empty and has a line-breaking comment.");
- Json::Value astJsonC = ASTJsonConverter(true, sourceIndices).toJson(c.ast("c"));
- Json::Value documentationC0 = astJsonC["children"][0]["children"][0]["attributes"]["documentation"];
- Json::Value documentationC1 = astJsonC["children"][0]["children"][1]["attributes"]["documentation"];
- Json::Value documentationC2 = astJsonC["children"][0]["children"][2]["attributes"]["documentation"];
- BOOST_CHECK_EQUAL(documentationC0, "Some comment on Evt.");
- BOOST_CHECK_EQUAL(documentationC1, "Some comment on mod.");
- BOOST_CHECK_EQUAL(documentationC2, "Some comment on fn.");
-}
-
-
-BOOST_AUTO_TEST_SUITE_END()
-
-}
-}
-} // end namespaces
diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp
index 497ee867..736aa46c 100644
--- a/test/libsolidity/SMTChecker.cpp
+++ b/test/libsolidity/SMTChecker.cpp
@@ -110,7 +110,7 @@ BOOST_AUTO_TEST_CASE(simple_assert)
function f(uint a) public pure { assert(a == 2); }
}
)";
- CHECK_WARNING(text, "Assertion violation happens here for");
+ CHECK_WARNING(text, "Assertion violation happens here");
}
BOOST_AUTO_TEST_CASE(simple_assert_with_require)
diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp
index 14413ca0..0b2e23e6 100644
--- a/test/libsolidity/SolidityABIJSON.cpp
+++ b/test/libsolidity/SolidityABIJSON.cpp
@@ -756,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) public returns (uint[] memory e, StructType storage f) {}
+ function f(StructType storage b, uint[] storage c, test d) public returns (uint[] memory e, StructType storage f) { f = f; }
}
)";
@@ -980,6 +980,7 @@ BOOST_AUTO_TEST_CASE(return_structs_with_contracts)
BOOST_AUTO_TEST_CASE(event_structs)
{
char const* text = R"(
+ pragma experimental ABIEncoderV2;
contract C {
struct S { uint a; T[] sub; bytes b; }
struct T { uint[2] x; }
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 223250fa..45a56b22 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -8910,52 +8910,6 @@ BOOST_AUTO_TEST_CASE(inline_assembly_storage_access_via_pointer)
ABI_CHECK(callContractFunction("separator2()"), encodeArgs(u256(0)));
}
-BOOST_AUTO_TEST_CASE(inline_assembly_jumps)
-{
- char const* sourceCode = R"(
- contract C {
- function f() public {
- assembly {
- let n := calldataload(4)
- let a := 1
- let b := a
- loop:
- jumpi(loopend, eq(n, 0))
- a add swap1
- n := sub(n, 1)
- jump(loop)
- loopend:
- mstore(0, a)
- return(0, 0x20)
- }
- }
- }
- )";
- compileAndRun(sourceCode, 0, "C");
- ABI_CHECK(callContractFunction("f()", u256(5)), encodeArgs(u256(13)));
- ABI_CHECK(callContractFunction("f()", u256(7)), encodeArgs(u256(34)));
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_function_access)
-{
- char const* sourceCode = R"(
- contract C {
- uint public x;
- function g(uint y) public { x = 2 * y; assembly { stop } }
- function f(uint _x) public {
- assembly {
- _x
- jump(g)
- pop
- }
- }
- }
- )";
- compileAndRun(sourceCode, 0, "C");
- ABI_CHECK(callContractFunction("f(uint256)", u256(5)), encodeArgs());
- ABI_CHECK(callContractFunction("x()"), encodeArgs(u256(10)));
-}
-
BOOST_AUTO_TEST_CASE(inline_assembly_function_call)
{
char const* sourceCode = R"(
@@ -9420,7 +9374,7 @@ BOOST_AUTO_TEST_CASE(failed_create)
contract C {
uint public x;
constructor() public payable {}
- function f(uint amount) public returns (address) {
+ function f(uint amount) public returns (D) {
x++;
return (new D).value(amount)();
}
@@ -9428,7 +9382,7 @@ BOOST_AUTO_TEST_CASE(failed_create)
if (depth < 1024)
return this.stack(depth - 1);
else
- return f(0);
+ return address(f(0));
}
}
)";
@@ -11261,7 +11215,7 @@ BOOST_AUTO_TEST_CASE(invalid_instruction)
contract C {
function f() public {
assembly {
- invalid
+ invalid()
}
}
}
@@ -11688,19 +11642,10 @@ BOOST_AUTO_TEST_CASE(keccak256_assembly)
ret := keccak256(0, 0)
}
}
- function g() public pure returns (bytes32 ret) {
- assembly {
- 0
- 0
- keccak256
- =: ret
- }
- }
}
)";
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f()"), fromHex("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"));
- ABI_CHECK(callContractFunction("g()"), fromHex("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"));
}
BOOST_AUTO_TEST_CASE(multi_modifiers)
@@ -12524,10 +12469,10 @@ BOOST_AUTO_TEST_CASE(staticcall_for_view_and_pure)
return (new C()).f();
}
function fview() public returns (uint) {
- return (CView(new C())).f();
+ return (CView(address(new C()))).f();
}
function fpure() public returns (uint) {
- return (CPure(new C())).f();
+ return (CPure(address(new C()))).f();
}
}
)";
@@ -12547,50 +12492,6 @@ BOOST_AUTO_TEST_CASE(staticcall_for_view_and_pure)
}
}
-BOOST_AUTO_TEST_CASE(swap_peephole_optimisation)
-{
- char const* sourceCode = R"(
- contract C {
- function lt(uint a, uint b) public returns (bool c) {
- assembly {
- a
- b
- swap1
- lt
- =: c
- }
- }
- function add(uint a, uint b) public returns (uint c) {
- assembly {
- a
- b
- swap1
- add
- =: c
- }
- }
- function div(uint a, uint b) public returns (uint c) {
- assembly {
- a
- b
- swap1
- div
- =: c
- }
- }
- }
- )";
- compileAndRun(sourceCode);
- BOOST_CHECK(callContractFunction("lt(uint256,uint256)", u256(1), u256(2)) == encodeArgs(u256(1)));
- BOOST_CHECK(callContractFunction("lt(uint256,uint256)", u256(2), u256(1)) == encodeArgs(u256(0)));
- BOOST_CHECK(callContractFunction("add(uint256,uint256)", u256(1), u256(2)) == encodeArgs(u256(3)));
- BOOST_CHECK(callContractFunction("add(uint256,uint256)", u256(100), u256(200)) == encodeArgs(u256(300)));
- BOOST_CHECK(callContractFunction("div(uint256,uint256)", u256(2), u256(1)) == encodeArgs(u256(2)));
- BOOST_CHECK(callContractFunction("div(uint256,uint256)", u256(200), u256(10)) == encodeArgs(u256(20)));
- BOOST_CHECK(callContractFunction("div(uint256,uint256)", u256(1), u256(0)) == encodeArgs(u256(0)));
- BOOST_CHECK(callContractFunction("div(uint256,uint256)", u256(0), u256(1)) == encodeArgs(u256(0)));
-}
-
BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople)
{
if (!dev::test::Options::get().evmVersion().hasBitwiseShifting())
@@ -12599,26 +12500,17 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople)
contract C {
function shl(uint a, uint b) public returns (uint c) {
assembly {
- a
- b
- shl
- =: c
+ c := shl(b, a)
}
}
function shr(uint a, uint b) public returns (uint c) {
assembly {
- a
- b
- shr
- =: c
+ c := shr(b, a)
}
}
function sar(uint a, uint b) public returns (uint c) {
assembly {
- a
- b
- sar
- =: c
+ c := sar(b, a)
}
}
}
@@ -12646,10 +12538,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
function shl_1() public returns (bool) {
uint c;
assembly {
- 1
- 2
- shl
- =: c
+ c := shl(2, 1)
}
assert(c == 4);
return true;
@@ -12657,10 +12546,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
function shl_2() public returns (bool) {
uint c;
assembly {
- 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
- 1
- shl
- =: c
+ c := shl(1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
}
assert(c == 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe);
return true;
@@ -12668,10 +12554,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
function shl_3() public returns (bool) {
uint c;
assembly {
- 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
- 256
- shl
- =: c
+ c := shl(256, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
}
assert(c == 0);
return true;
@@ -12679,10 +12562,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
function shr_1() public returns (bool) {
uint c;
assembly {
- 3
- 1
- shr
- =: c
+ c := shr(1, 3)
}
assert(c == 1);
return true;
@@ -12690,10 +12570,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
function shr_2() public returns (bool) {
uint c;
assembly {
- 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
- 1
- shr
- =: c
+ c := shr(1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
}
assert(c == 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
return true;
@@ -12701,10 +12578,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
function shr_3() public returns (bool) {
uint c;
assembly {
- 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
- 256
- shr
- =: c
+ c := shr(256, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
}
assert(c == 0);
return true;
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index d025e65a..41814888 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -390,12 +390,10 @@ BOOST_AUTO_TEST_CASE(unsatisfied_version)
BOOST_AUTO_TEST_CASE(returndatasize_as_variable)
{
char const* text = R"(
- contract c { function f() public { uint returndatasize; assembly { returndatasize }}}
+ contract C { function f() public pure { uint returndatasize; returndatasize; assembly { pop(returndatasize()) }}}
)";
vector<pair<Error::Type, std::string>> expectations(vector<pair<Error::Type, std::string>>{
- {Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"},
- {Error::Type::Warning, "The use of non-functional instructions is deprecated."},
- {Error::Type::DeclarationError, "Unbalanced stack"}
+ {Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"}
});
if (!dev::test::Options::get().evmVersion().supportsReturndata())
expectations.emplace_back(make_pair(Error::Type::Warning, std::string("\"returndatasize\" instruction is only available for Byzantium-compatible")));
@@ -405,15 +403,13 @@ BOOST_AUTO_TEST_CASE(returndatasize_as_variable)
BOOST_AUTO_TEST_CASE(create2_as_variable)
{
char const* text = R"(
- contract c { function f() public { uint create2; assembly { create2(0, 0, 0, 0) } }}
+ contract c { function f() public { uint create2; create2; assembly { pop(create2(0, 0, 0, 0)) } }}
)";
// This needs special treatment, because the message mentions the EVM version,
// so cannot be run via isoltest.
CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{
{Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"},
{Error::Type::Warning, "The \"create2\" instruction is not supported by the VM version"},
- {Error::Type::DeclarationError, "Unbalanced stack"},
- {Error::Type::Warning, "not supposed to return values"}
}));
}
diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp
index 3e2dce26..119f80d1 100644
--- a/test/libsolidity/SolidityOptimizer.cpp
+++ b/test/libsolidity/SolidityOptimizer.cpp
@@ -74,9 +74,9 @@ public:
unsigned const _optimizeRuns = 200
)
{
- m_nonOptimizedBytecode = compileAndRunWithOptimizer(_sourceCode, _value, _contractName, false, _optimizeRuns);
+ m_nonOptimizedBytecode = compileAndRunWithOptimizer("pragma solidity >=0.0;\n" + _sourceCode, _value, _contractName, false, _optimizeRuns);
m_nonOptimizedContract = m_contractAddress;
- m_optimizedBytecode = compileAndRunWithOptimizer(_sourceCode, _value, _contractName, true, _optimizeRuns);
+ m_optimizedBytecode = compileAndRunWithOptimizer("pragma solidity >=0.0;\n" + _sourceCode, _value, _contractName, true, _optimizeRuns);
size_t nonOptimizedSize = numInstructions(m_nonOptimizedBytecode);
size_t optimizedSize = numInstructions(m_optimizedBytecode);
BOOST_CHECK_MESSAGE(
@@ -441,8 +441,6 @@ BOOST_AUTO_TEST_CASE(constant_optimization_early_exit)
// This tests that the constant optimizer does not try to find the best representation
// indefinitely but instead stops after some number of iterations.
char const* sourceCode = R"(
- pragma solidity ^0.4.0;
-
contract HexEncoding {
function hexEncodeTest(address addr) public returns (bytes32 ret) {
uint x = uint(addr) / 2**32;
diff --git a/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol b/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol
index 2a199b3a..17cb701d 100644
--- a/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol
+++ b/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol
@@ -3,11 +3,11 @@
contract B {
A a;
constructor() public {
- a = new A(this);
+ a = new A(address(this));
}
}
contract A {
- constructor(address a) internal {}
+ constructor(address) internal {}
}
// ----
// TypeError: (141-146): Contract with internal constructor cannot be created directly.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_err.sol
new file mode 100644
index 00000000..5fde497c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_err.sol
@@ -0,0 +1,10 @@
+contract C {
+ struct S { bool f; }
+ S s;
+ function f() internal pure returns (S storage) {
+ assembly {
+ }
+ }
+}
+// ----
+// TypeError: (87-88): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_fine.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_fine.sol
index 65902cc8..0d3db856 100644
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_fine.sol
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_fine.sol
@@ -8,7 +8,7 @@ contract C {
}
function g(bool flag) internal returns (S storage c) {
// control flow in assembly will not be analyzed for now,
- // so this will not issue a warning
+ // so this will not issue an error
assembly {
if flag {
sstore(c_slot, sload(s_slot))
@@ -17,7 +17,7 @@ contract C {
}
function h() internal returns (S storage c) {
// any reference from assembly will be sufficient for now,
- // so this will not issue a warning
+ // so this will not issue an error
assembly {
sstore(s_slot, sload(c_slot))
}
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_warn.sol
deleted file mode 100644
index 09c13847..00000000
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/assembly_warn.sol
+++ /dev/null
@@ -1,10 +0,0 @@
-contract C {
- struct S { bool f; }
- S s;
- function f() internal pure returns (S storage) {
- assembly {
- }
- }
-}
-// ----
-// Warning: (87-88): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_err.sol
new file mode 100644
index 00000000..eb574c96
--- /dev/null
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_err.sol
@@ -0,0 +1,52 @@
+contract C {
+ struct S { bool f; }
+ S s;
+ function f() internal view returns (S storage c) {
+ do {
+ break;
+ c = s;
+ } while(false);
+ }
+ function g() internal view returns (S storage c) {
+ do {
+ if (s.f) {
+ continue;
+ c = s;
+ }
+ else {
+ }
+ } while(false);
+ }
+ function h() internal view returns (S storage c) {
+ do {
+ if (s.f) {
+ break;
+ }
+ else {
+ c = s;
+ }
+ } while(false);
+ }
+ function i() internal view returns (S storage c) {
+ do {
+ if (s.f) {
+ continue;
+ }
+ else {
+ c = s;
+ }
+ } while(false);
+ }
+ function j() internal view returns (S storage c) {
+ do {
+ continue;
+ c = s;
+ } while(false);
+ }
+}
+// ----
+// TypeError: (87-98): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (223-234): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (440-451): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (654-665): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (871-882): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol
deleted file mode 100644
index 7d001c19..00000000
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol
+++ /dev/null
@@ -1,52 +0,0 @@
-contract C {
- struct S { bool f; }
- S s;
- function f() internal view returns (S storage c) {
- do {
- break;
- c = s;
- } while(false);
- }
- function g() internal view returns (S storage c) {
- do {
- if (s.f) {
- continue;
- c = s;
- }
- else {
- }
- } while(false);
- }
- function h() internal view returns (S storage c) {
- do {
- if (s.f) {
- break;
- }
- else {
- c = s;
- }
- } while(false);
- }
- function i() internal view returns (S storage c) {
- do {
- if (s.f) {
- continue;
- }
- else {
- c = s;
- }
- } while(false);
- }
- function j() internal view returns (S storage c) {
- do {
- continue;
- c = s;
- } while(false);
- }
-}
-// ----
-// Warning: (87-98): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (223-234): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (440-451): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (654-665): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (871-882): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_err.sol
new file mode 100644
index 00000000..0d266ccf
--- /dev/null
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_err.sol
@@ -0,0 +1,14 @@
+contract C {
+ struct S { bool f; }
+ S s;
+ function f() internal pure returns (S storage) { return; }
+ function g() internal view returns (S storage c, S storage) { c = s; return; }
+ function h() internal view returns (S storage, S storage d) { d = s; return; }
+ function i() internal pure returns (S storage, S storage) { return; }
+}
+// ----
+// TypeError: (87-88): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (163-164): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (233-234): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (316-317): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (327-328): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_fine.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_fine.sol
index 3a0a30ea..6d72e4ef 100644
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_fine.sol
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_fine.sol
@@ -2,5 +2,6 @@ contract C {
struct S { bool f; }
S s;
function f() internal view returns (S storage c, S storage d) { c = s; d = s; return; }
+ function g() internal view returns (S storage, S storage) { return (s,s); }
}
// ----
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_warn.sol
deleted file mode 100644
index 0a5b2fbf..00000000
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_warn.sol
+++ /dev/null
@@ -1,15 +0,0 @@
-contract C {
- struct S { bool f; }
- S s;
- function f() internal pure returns (S storage) { return; }
- function g() internal view returns (S storage c, S storage) { c = s; return; }
- function h() internal view returns (S storage, S storage d) { d = s; return; }
- function i() internal pure returns (S storage, S storage) { return; }
- function j() internal view returns (S storage, S storage) { return (s,s); }
-}
-// ----
-// Warning: (87-88): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (163-164): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (233-234): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (316-317): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (327-328): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_err.sol
new file mode 100644
index 00000000..9aa580a4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_err.sol
@@ -0,0 +1,16 @@
+contract C {
+ struct S { bool f; }
+ S s;
+ function f() internal view returns (S storage c) {
+ for(;; c = s) {
+ }
+ }
+ function g() internal view returns (S storage c) {
+ for(;;) {
+ c = s;
+ }
+ }
+}
+// ----
+// TypeError: (87-98): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (182-193): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_warn.sol
deleted file mode 100644
index ba9a2440..00000000
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/for_warn.sol
+++ /dev/null
@@ -1,16 +0,0 @@
-contract C {
- struct S { bool f; }
- S s;
- function f() internal view returns (S storage c) {
- for(;; c = s) {
- }
- }
- function g() internal view returns (S storage c) {
- for(;;) {
- c = s;
- }
- }
-}
-// ----
-// Warning: (87-98): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (182-193): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_err.sol
new file mode 100644
index 00000000..f3e55318
--- /dev/null
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_err.sol
@@ -0,0 +1,18 @@
+contract C {
+ struct S { bool f; }
+ S s;
+ function f(bool flag) internal view returns (S storage c) {
+ if (flag) c = s;
+ }
+ function g(bool flag) internal returns (S storage c) {
+ if (flag) c = s;
+ else
+ {
+ if (!flag) c = s;
+ else s.f = true;
+ }
+ }
+}
+// ----
+// TypeError: (96-107): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (186-197): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_warn.sol
deleted file mode 100644
index c257c252..00000000
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/if_warn.sol
+++ /dev/null
@@ -1,18 +0,0 @@
-contract C {
- struct S { bool f; }
- S s;
- function f(bool flag) internal view returns (S storage c) {
- if (flag) c = s;
- }
- function g(bool flag) internal returns (S storage c) {
- if (flag) c = s;
- else
- {
- if (!flag) c = s;
- else s.f = true;
- }
- }
-}
-// ----
-// Warning: (96-107): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (186-197): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_err.sol
new file mode 100644
index 00000000..a0047782
--- /dev/null
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_err.sol
@@ -0,0 +1,22 @@
+contract C {
+ modifier revertIfNoReturn() {
+ _;
+ revert();
+ }
+ modifier ifFlag(bool flag) {
+ if (flag)
+ _;
+ }
+ struct S { uint a; }
+ S s;
+ function f(bool flag) ifFlag(flag) internal view returns(S storage) {
+ return s;
+ }
+
+ function g(bool flag) ifFlag(flag) revertIfNoReturn() internal view returns(S storage) {
+ return s;
+ }
+}
+// ----
+// TypeError: (249-250): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (367-368): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_warn.sol
deleted file mode 100644
index 50c6dd99..00000000
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/modifier_warn.sol
+++ /dev/null
@@ -1,22 +0,0 @@
-contract C {
- modifier revertIfNoReturn() {
- _;
- revert();
- }
- modifier ifFlag(bool flag) {
- if (flag)
- _;
- }
- struct S { uint a; }
- S s;
- function f(bool flag) ifFlag(flag) internal view returns(S storage) {
- return s;
- }
-
- function g(bool flag) ifFlag(flag) revertIfNoReturn() internal view returns(S storage) {
- return s;
- }
-}
-// ----
-// Warning: (249-250): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (367-368): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_err.sol
new file mode 100644
index 00000000..d0ad8245
--- /dev/null
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_err.sol
@@ -0,0 +1,18 @@
+contract C {
+ struct S { bool f; }
+ S s;
+ function f() internal view returns (S storage c) {
+ false && (c = s).f;
+ }
+ function g() internal view returns (S storage c) {
+ true || (c = s).f;
+ }
+ function h() internal view returns (S storage c) {
+ // expect error, although this is always fine
+ true && (false || (c = s).f);
+ }
+}
+// ----
+// TypeError: (87-98): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (176-187): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (264-275): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_warn.sol
deleted file mode 100644
index 9f660f11..00000000
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/short_circuit_warn.sol
+++ /dev/null
@@ -1,18 +0,0 @@
-contract C {
- struct S { bool f; }
- S s;
- function f() internal view returns (S storage c) {
- false && (c = s).f;
- }
- function g() internal view returns (S storage c) {
- true || (c = s).f;
- }
- function h() internal view returns (S storage c) {
- // expect warning, although this is always fine
- true && (false || (c = s).f);
- }
-}
-// ----
-// Warning: (87-98): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (176-187): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (264-275): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_err.sol
new file mode 100644
index 00000000..6d10287b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_err.sol
@@ -0,0 +1,13 @@
+contract C {
+ struct S { bool f; }
+ S s;
+ function f(bool flag) internal view returns (S storage c) {
+ flag ? (c = s).f : false;
+ }
+ function g(bool flag) internal view returns (S storage c) {
+ flag ? false : (c = s).f;
+ }
+}
+// ----
+// TypeError: (96-107): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
+// TypeError: (200-211): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_warn.sol
deleted file mode 100644
index 57561fbb..00000000
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/ternary_warn.sol
+++ /dev/null
@@ -1,13 +0,0 @@
-contract C {
- struct S { bool f; }
- S s;
- function f(bool flag) internal view returns (S storage c) {
- flag ? (c = s).f : false;
- }
- function g(bool flag) internal view returns (S storage c) {
- flag ? false : (c = s).f;
- }
-}
-// ----
-// Warning: (96-107): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
-// Warning: (200-211): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_err.sol
new file mode 100644
index 00000000..e7b4fae7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_err.sol
@@ -0,0 +1,11 @@
+contract C {
+ struct S { bool f; }
+ S s;
+ function f() internal view returns (S storage c) {
+ while(false) {
+ c = s;
+ }
+ }
+}
+// ----
+// TypeError: (87-98): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_warn.sol
deleted file mode 100644
index 26db892f..00000000
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/while_warn.sol
+++ /dev/null
@@ -1,11 +0,0 @@
-contract C {
- struct S { bool f; }
- S s;
- function f() internal view returns (S storage c) {
- while(false) {
- c = s;
- }
- }
-}
-// ----
-// Warning: (87-98): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
diff --git a/test/libsolidity/syntaxTests/emit_empty.sol b/test/libsolidity/syntaxTests/emit/emit_empty.sol
index 819d88fe..819d88fe 100644
--- a/test/libsolidity/syntaxTests/emit_empty.sol
+++ b/test/libsolidity/syntaxTests/emit/emit_empty.sol
diff --git a/test/libsolidity/syntaxTests/emit_non_event.sol b/test/libsolidity/syntaxTests/emit/emit_non_event.sol
index d5045ddf..d5045ddf 100644
--- a/test/libsolidity/syntaxTests/emit_non_event.sol
+++ b/test/libsolidity/syntaxTests/emit/emit_non_event.sol
diff --git a/test/libsolidity/syntaxTests/events/event_nested_array.sol b/test/libsolidity/syntaxTests/events/event_nested_array.sol
new file mode 100644
index 00000000..70af63b6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/events/event_nested_array.sol
@@ -0,0 +1,5 @@
+contract c {
+ event E(uint[][]);
+}
+// ----
+// TypeError: (25-33): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.
diff --git a/test/libsolidity/syntaxTests/events/event_nested_array_2.sol b/test/libsolidity/syntaxTests/events/event_nested_array_2.sol
new file mode 100644
index 00000000..5825650e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/events/event_nested_array_2.sol
@@ -0,0 +1,4 @@
+contract c {
+ event E(uint[2][]);
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/events/event_nested_array_in_struct.sol b/test/libsolidity/syntaxTests/events/event_nested_array_in_struct.sol
new file mode 100644
index 00000000..fd59e962
--- /dev/null
+++ b/test/libsolidity/syntaxTests/events/event_nested_array_in_struct.sol
@@ -0,0 +1,6 @@
+contract c {
+ struct S { uint x; uint[][] arr; }
+ event E(S);
+}
+// ----
+// TypeError: (61-62): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.
diff --git a/test/libsolidity/syntaxTests/events/event_struct.sol b/test/libsolidity/syntaxTests/events/event_struct.sol
new file mode 100644
index 00000000..c955dc5e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/events/event_struct.sol
@@ -0,0 +1,6 @@
+contract c {
+ struct S { uint a ; }
+ event E(S);
+}
+// ----
+// TypeError: (51-52): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.
diff --git a/test/libsolidity/syntaxTests/events/event_struct_indexed.sol b/test/libsolidity/syntaxTests/events/event_struct_indexed.sol
new file mode 100644
index 00000000..69ee5017
--- /dev/null
+++ b/test/libsolidity/syntaxTests/events/event_struct_indexed.sol
@@ -0,0 +1,6 @@
+contract c {
+ struct S { uint a ; }
+ event E(S indexed);
+}
+// ----
+// TypeError: (51-52): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.
diff --git a/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol b/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol
index 6cf68d2a..8f5ceef8 100644
--- a/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol
+++ b/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol
@@ -1,4 +1,4 @@
contract A { constructor() public { } }
contract B is A { constructor() A public { } }
// ----
-// Warning: (72-73): Modifier-style base constructor call without arguments.
+// DeclarationError: (72-73): Modifier-style base constructor call without arguments.
diff --git a/test/libsolidity/syntaxTests/inheritance/modifiers_in_constructor_context.sol b/test/libsolidity/syntaxTests/inheritance/modifiers_in_constructor_context.sol
new file mode 100644
index 00000000..d8ce0e48
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inheritance/modifiers_in_constructor_context.sol
@@ -0,0 +1,9 @@
+// This generated an invalid warning on m1 in some compiler versions.
+contract A {
+ constructor() m1 public { }
+ modifier m1 { _; }
+}
+contract B is A {
+ modifier m2 { _; }
+ constructor() A() m1 m2 public { }
+}
diff --git a/test/libsolidity/syntaxTests/inheritance/override/function_state_variable.sol b/test/libsolidity/syntaxTests/inheritance/override/function_state_variable.sol
new file mode 100644
index 00000000..023a161a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inheritance/override/function_state_variable.sol
@@ -0,0 +1,2 @@
+interface ERC20 { function x() external returns (uint); }
+contract C is ERC20 { uint public x; }
diff --git a/test/libsolidity/syntaxTests/inheritance/override/state_variable_function.sol b/test/libsolidity/syntaxTests/inheritance/override/state_variable_function.sol
new file mode 100644
index 00000000..0f05cc8e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inheritance/override/state_variable_function.sol
@@ -0,0 +1,8 @@
+contract A {
+ uint public x;
+}
+contract C is A {
+ function x() public returns (uint);
+}
+// ----
+// DeclarationError: (50-85): Identifier already declared.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol b/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol
index cbea8991..ac1f541e 100644
--- a/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol
+++ b/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol
@@ -11,6 +11,6 @@ contract C {
}
// ----
// TypeError: (87-88): Expected 1 arguments but got 0.
-// Warning: (87-90): Top-level expressions are not supposed to return values (this expression returns -1 values). Use ``pop()`` or assign them.
+// SyntaxError: (87-90): Top-level expressions are not supposed to return values (this expression returns -1 values). Use ``pop()`` or assign them.
// TypeError: (108-109): Expected 1 arguments but got 2.
-// Warning: (108-115): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
+// SyntaxError: (108-115): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol b/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol
index 5de492e1..150fb938 100644
--- a/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol
+++ b/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol
@@ -8,6 +8,6 @@ contract C {
}
}
// ----
-// Warning: (63-64): The use of labels is deprecated. Please use "if", "switch", "for" or function calls instead.
-// Warning: (63-64): 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.
+// SyntaxError: (63-64): The use of labels is disallowed. Please use "if", "switch", "for" or function calls instead.
+// SyntaxError: (63-64): 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: (73-74): Attempt to call label instead of function.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol
index b6dd12b8..07113093 100644
--- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol
+++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol
@@ -1,6 +1,6 @@
contract C {
uint[] x;
- function() external {
+ function() external {
uint[] storage y = x;
assembly {
pop(y)
@@ -8,4 +8,4 @@ contract C {
}
}
// ----
-// TypeError: (119-120): You have to use the _slot or _offset suffix to access storage reference variables.
+// TypeError: (118-119): You have to use the _slot or _offset suffix to access storage reference variables.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol
index d5c8eaf5..dc742142 100644
--- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol
+++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol
@@ -1,6 +1,6 @@
contract C {
uint[] x;
- function() external {
+ function() external {
uint[] storage y = x;
assembly {
y_slot := 1
@@ -9,5 +9,5 @@ contract C {
}
}
// ----
-// TypeError: (115-121): Storage variables cannot be assigned to.
-// TypeError: (139-147): Storage variables cannot be assigned to.
+// TypeError: (114-120): Storage variables cannot be assigned to.
+// TypeError: (138-146): Storage variables cannot be assigned to.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol
index 84f98ed9..b01a7705 100644
--- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol
+++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol
@@ -1,6 +1,6 @@
contract C {
uint[] x;
- function() external {
+ function() external {
uint[] storage y = x;
assembly {
pop(y_slot)
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol
index 4025e11c..704b712d 100644
--- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol
+++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol
@@ -1,6 +1,6 @@
contract C {
uint[] x;
- function() external {
+ function() external {
uint[] memory y = x;
assembly {
pop(y_slot)
@@ -9,5 +9,5 @@ contract C {
}
}
// ----
-// TypeError: (118-124): The suffixes _offset and _slot can only be used on storage variables.
-// TypeError: (142-150): The suffixes _offset and _slot can only be used on storage variables.
+// TypeError: (117-123): The suffixes _offset and _slot can only be used on storage variables.
+// TypeError: (141-149): The suffixes _offset and _slot can only be used on storage variables.
diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiSingleVariableDeclaration.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiSingleVariableDeclaration.sol
index 182ba072..7db98577 100644
--- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiSingleVariableDeclaration.sol
+++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiSingleVariableDeclaration.sol
@@ -3,4 +3,4 @@ contract C {
(uint a) = f();
a;
}
-}
+}
diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalidType.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalidType.sol
index 2b765837..85094d00 100644
--- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalidType.sol
+++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalidType.sol
@@ -3,7 +3,7 @@ contract C {
(uint a, string memory b,,) = f();
a; b;
}
-}
+}
// ----
// TypeError: (85-118): Type string memory is not implicitly convertible to expected type uint256.
// TypeError: (85-118): Type uint256 is not implicitly convertible to expected type string memory.
diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol
index 224d9614..1f9e52d1 100644
--- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol
+++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol
@@ -5,6 +5,6 @@ contract C {
}
a;
}
-}
+}
// ----
// DeclarationError: (99-100): Undeclared identifier.
diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol
index 242a1f39..45b8858b 100644
--- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol
+++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol
@@ -4,7 +4,7 @@ contract C {
(uint a, uint b, uint c) = (a, b, c);
}
}
-}
+}
// ----
// DeclarationError: (79-80): Undeclared identifier. "a" is not (or not yet) visible at this point.
// DeclarationError: (82-83): Undeclared identifier. "b" is not (or not yet) visible at this point.
diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationThatIsExpression.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationThatIsExpression.sol
index 8ae0eaac..00458908 100644
--- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationThatIsExpression.sol
+++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationThatIsExpression.sol
@@ -4,6 +4,6 @@ contract C {
function f() internal pure returns (uint, uint, uint, S storage, uint, uint) {
(,,,s.x[2](),,) = f();
}
-}
+}
// ----
// TypeError: (160-168): Expression has to be an lvalue.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword.sol
deleted file mode 100644
index 1b6bbae7..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword.sol
+++ /dev/null
@@ -1,11 +0,0 @@
-contract test {
- function f() public {
- uintM something = 3;
- intM should = 4;
- bytesM fail = "now";
- }
-}
-// ----
-// DeclarationError: (50-55): Identifier not found or not unique.
-// DeclarationError: (79-83): Identifier not found or not unique.
-// DeclarationError: (104-110): Identifier not found or not unique.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_1.sol
new file mode 100644
index 00000000..0d0a0797
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_1.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ uintM something = 3;
+ }
+}
+// ----
+// DeclarationError: (50-55): Identifier not found or not unique.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_2.sol
new file mode 100644
index 00000000..b9590a8c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_2.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ intM should = 4;
+ }
+}
+// ----
+// DeclarationError: (50-54): Identifier not found or not unique.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_3.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_3.sol
new file mode 100644
index 00000000..85d4c25b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_3.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ bytesM fail = "now";
+ }
+}
+// ----
+// DeclarationError: (50-56): Identifier not found or not unique.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol
index 273e1844..e9599f4b 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol
@@ -6,5 +6,5 @@ contract test {
}
}
// ----
-// Warning: (73-74): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
+// SyntaxError: (73-74): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
// DeclarationError: (59-84): Unbalanced stack at the end of a block: 1 surplus item(s).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol
index bda090b4..342afc46 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol
@@ -6,5 +6,5 @@ contract test {
}
}
// ----
-// Warning: (73-76): The use of non-functional instructions is deprecated. Please use functional notation instead.
+// SyntaxError: (73-76): The use of non-functional instructions is disallowed. Please use functional notation instead.
// DeclarationError: (59-86): Unbalanced stack at the end of a block: 1 missing item(s).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol
deleted file mode 100644
index a5f0f96c..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol
+++ /dev/null
@@ -1,11 +0,0 @@
-pragma experimental "v0.5.0";
-contract C {
- function f() pure public {
- assembly {
- 1
- }
- }
-}
-// ----
-// SyntaxError: (105-106): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
-// DeclarationError: (91-116): Unbalanced stack at the end of a block: 1 surplus item(s).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol
index 7b68c60b..62fe7171 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol
@@ -6,5 +6,5 @@ contract C {
}
}
// ----
-// Warning: (75-76): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
+// SyntaxError: (75-76): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
// DeclarationError: (61-86): Unbalanced stack at the end of a block: 1 surplus item(s).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol
deleted file mode 100644
index 4a7aca8a..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol
+++ /dev/null
@@ -1,12 +0,0 @@
-pragma experimental "v0.5.0";
-contract C {
- function f() view public {
- assembly {
- address
- pop
- }
- }
-}
-// ----
-// SyntaxError: (105-112): The use of non-functional instructions is deprecated. Please use functional notation instead.
-// SyntaxError: (125-128): The use of non-functional instructions is deprecated. Please use functional notation instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol
index c44412cf..7315d5d1 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol
@@ -7,5 +7,5 @@ contract C {
}
}
// ----
-// Warning: (75-82): The use of non-functional instructions is deprecated. Please use functional notation instead.
-// Warning: (95-98): The use of non-functional instructions is deprecated. Please use functional notation instead.
+// SyntaxError: (75-82): The use of non-functional instructions is disallowed. Please use functional notation instead.
+// SyntaxError: (95-98): The use of non-functional instructions is disallowed. Please use functional notation instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol
deleted file mode 100644
index 77a73ebc..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol
+++ /dev/null
@@ -1,11 +0,0 @@
-pragma experimental "v0.5.0";
-contract C {
- function f() pure public {
- assembly {
- label:
- }
- }
-}
-// ----
-// SyntaxError: (105-110): The use of labels is deprecated. Please use "if", "switch", "for" or function calls instead.
-// SyntaxError: (105-110): 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.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol
index 15bd6660..0d7bacb4 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol
@@ -6,5 +6,5 @@ contract C {
}
}
// ----
-// Warning: (75-80): The use of labels is deprecated. Please use "if", "switch", "for" or function calls instead.
-// Warning: (75-80): 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.
+// SyntaxError: (75-80): The use of labels is disallowed. Please use "if", "switch", "for" or function calls instead.
+// SyntaxError: (75-80): 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.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol
index c3c82ce8..6cb35d6d 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol
@@ -6,5 +6,4 @@ contract C {
}
}
// ----
-// Warning: (75-82): 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: (75-82): Function declared as pure, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
+// SyntaxError: (75-82): 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.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol
index 56043ccf..8538a2a0 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol
@@ -6,5 +6,5 @@ contract C {
}
}
// ----
-// Warning: (75-83): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
+// SyntaxError: (75-83): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
// DeclarationError: (61-93): Unbalanced stack at the end of a block: 1 surplus item(s).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol
index 56fc4051..d052dab5 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol
@@ -8,4 +8,5 @@ contract C {
}
}
// ----
+// DeclarationError: (150-179): Identifier already declared.
// DeclarationError: (114-120): Identifier not found or not unique.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/570_function_type_undeclared_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/570_function_type_undeclared_type.sol
new file mode 100644
index 00000000..962f4fe4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/570_function_type_undeclared_type.sol
@@ -0,0 +1,5 @@
+contract C {
+ function a(function(Nested)) external pure {}
+}
+// ----
+// DeclarationError: (37-43): Identifier not found or not unique.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/571_function_type_undeclared_type_external.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/571_function_type_undeclared_type_external.sol
new file mode 100644
index 00000000..735af9e9
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/571_function_type_undeclared_type_external.sol
@@ -0,0 +1,5 @@
+contract C {
+ function a(function(Nested) external) external pure {}
+}
+// ----
+// DeclarationError: (37-43): Identifier not found or not unique.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/572_function_type_undeclared_type_multi_nested.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/572_function_type_undeclared_type_multi_nested.sol
new file mode 100644
index 00000000..ffb467cd
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/572_function_type_undeclared_type_multi_nested.sol
@@ -0,0 +1,5 @@
+contract C {
+ function a(function(function(function(Nested)))) external pure {}
+}
+// ----
+// DeclarationError: (55-61): Identifier not found or not unique.
diff --git a/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol b/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol
index 9f714aea..b66253e4 100644
--- a/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol
+++ b/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol
@@ -3,9 +3,9 @@ contract A {
}
}
contract B {
- constructor(address) public {
+ constructor(C) public {
}
- function b(address) public returns (A) {
+ function b(C) public returns (A) {
return new A();
}
}
diff --git a/test/libsolidity/syntaxTests/parsing/tuples_decl_without_rhs.sol b/test/libsolidity/syntaxTests/parsing/tuples_decl_without_rhs.sol
new file mode 100644
index 00000000..dba3e7ac
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/tuples_decl_without_rhs.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public pure {
+ (uint a, uint b, uint c);
+ }
+}
+// ----
+// ParserError: (76-77): Expected '=' but got ';'
diff --git a/test/libsolidity/syntaxTests/scoping/function_state_variable_conflict.sol b/test/libsolidity/syntaxTests/scoping/function_state_variable_conflict.sol
new file mode 100644
index 00000000..d717981b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/scoping/function_state_variable_conflict.sol
@@ -0,0 +1,6 @@
+contract C {
+ function f(uint) public pure {}
+ uint public f = 0;
+}
+// ----
+// DeclarationError: (53-70): Identifier already declared.
diff --git a/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict.sol b/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict.sol
new file mode 100644
index 00000000..0c732f7f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict.sol
@@ -0,0 +1,6 @@
+contract C {
+ uint public f = 0;
+ function f(uint) public pure {}
+}
+// ----
+// DeclarationError: (40-71): Identifier already declared.
diff --git a/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict_former_crash.sol b/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict_former_crash.sol
new file mode 100644
index 00000000..fb9180c6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict_former_crash.sol
@@ -0,0 +1,14 @@
+// This used to crash with some compiler versions.
+contract SomeContract {
+
+ uint public balance = 0;
+
+ function balance(uint number) public {}
+
+ function doSomething() public {
+ balance(3);
+ }
+}
+// ----
+// DeclarationError: (106-145): Identifier already declared.
+// TypeError: (185-195): Type is not callable
diff --git a/test/libsolidity/syntaxTests/types/address_to_contract.sol b/test/libsolidity/syntaxTests/types/address_to_contract.sol
new file mode 100644
index 00000000..629a3df0
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address_to_contract.sol
@@ -0,0 +1,6 @@
+contract C {
+ function f() public pure returns (C c) {
+ c = C(address(2));
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/types/address_to_contract_implicitly.sol b/test/libsolidity/syntaxTests/types/address_to_contract_implicitly.sol
new file mode 100644
index 00000000..efab7c27
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address_to_contract_implicitly.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public view {
+ C c = address(2);
+ }
+}
+// ----
+// TypeError: (46-62): Type address is not implicitly convertible to expected type contract C.
diff --git a/test/libsolidity/syntaxTests/types/contract_to_address.sol b/test/libsolidity/syntaxTests/types/contract_to_address.sol
new file mode 100644
index 00000000..ec2f8184
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/contract_to_address.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public view {
+ address a = address(this);
+ a;
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/types/contract_to_address_implicitly.sol b/test/libsolidity/syntaxTests/types/contract_to_address_implicitly.sol
new file mode 100644
index 00000000..8be9daac
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/contract_to_address_implicitly.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() public view {
+ address a = this;
+ a;
+ }
+}
+// ----
+// TypeError: (46-62): Type contract C is not implicitly convertible to expected type address.
diff --git a/test/libsolidity/syntaxTests/types/contract_to_base.sol b/test/libsolidity/syntaxTests/types/contract_to_base.sol
new file mode 100644
index 00000000..b0a24e62
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/contract_to_base.sol
@@ -0,0 +1,9 @@
+contract A {}
+contract B is A {}
+contract C {
+ function f() public {
+ A a = new B();
+ a;
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/types/contract_to_base_base.sol b/test/libsolidity/syntaxTests/types/contract_to_base_base.sol
new file mode 100644
index 00000000..e99e5cdc
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/contract_to_base_base.sol
@@ -0,0 +1,10 @@
+contract A {}
+contract B is A {}
+contract C is B {}
+contract D {
+ function f() public {
+ A a = new C();
+ a;
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/types/contract_to_derived.sol b/test/libsolidity/syntaxTests/types/contract_to_derived.sol
new file mode 100644
index 00000000..ac8df5d1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/contract_to_derived.sol
@@ -0,0 +1,9 @@
+contract B {}
+contract A is B {}
+contract C {
+ function f() public pure {
+ A a = A(new B());
+ }
+}
+// ----
+// TypeError: (85-95): Explicit type conversion not allowed from "contract B" to "contract A".
diff --git a/test/libsolidity/syntaxTests/types/contract_to_unrelated_contract.sol b/test/libsolidity/syntaxTests/types/contract_to_unrelated_contract.sol
new file mode 100644
index 00000000..b0a4875f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/contract_to_unrelated_contract.sol
@@ -0,0 +1,9 @@
+contract A {}
+contract B {}
+contract C {
+ function f() public pure {
+ B b = B(new A());
+ }
+}
+// ----
+// TypeError: (80-90): Explicit type conversion not allowed from "contract A" to "contract B".
diff --git a/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_exhausted.sol b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_exhausted.sol
new file mode 100644
index 00000000..c6669746
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_exhausted.sol
@@ -0,0 +1,262 @@
+contract A {}
+contract Main {
+ A constant B = C;
+ A constant C = D;
+ A constant D = E;
+ A constant E = F;
+ A constant F = G;
+ A constant G = H;
+ A constant H = I;
+ A constant I = J;
+ A constant J = K;
+ A constant K = L;
+ A constant L = M;
+ A constant M = N;
+ A constant N = O;
+ A constant O = P;
+ A constant P = Q;
+ A constant Q = R;
+ A constant R = S;
+ A constant S = T;
+ A constant T = U;
+ A constant U = V;
+ A constant V = W;
+ A constant W = X;
+ A constant X = Y;
+ A constant Y = Z;
+ A constant Z = BA;
+ A constant BA = BB;
+ A constant BB = BC;
+ A constant BC = BD;
+ A constant BD = BE;
+ A constant BE = BF;
+ A constant BF = BG;
+ A constant BG = BH;
+ A constant BH = BI;
+ A constant BI = BJ;
+ A constant BJ = BK;
+ A constant BK = BL;
+ A constant BL = BM;
+ A constant BM = BN;
+ A constant BN = BO;
+ A constant BO = BP;
+ A constant BP = BQ;
+ A constant BQ = BR;
+ A constant BR = BS;
+ A constant BS = BT;
+ A constant BT = BU;
+ A constant BU = BV;
+ A constant BV = BW;
+ A constant BW = BX;
+ A constant BX = BY;
+ A constant BY = BZ;
+ A constant BZ = CA;
+ A constant CA = CB;
+ A constant CB = CC;
+ A constant CC = CD;
+ A constant CD = CE;
+ A constant CE = CF;
+ A constant CF = CG;
+ A constant CG = CH;
+ A constant CH = CI;
+ A constant CI = CJ;
+ A constant CJ = CK;
+ A constant CK = CL;
+ A constant CL = CM;
+ A constant CM = CN;
+ A constant CN = CO;
+ A constant CO = CP;
+ A constant CP = CQ;
+ A constant CQ = CR;
+ A constant CR = CS;
+ A constant CS = CT;
+ A constant CT = CU;
+ A constant CU = CV;
+ A constant CV = CW;
+ A constant CW = CX;
+ A constant CX = CY;
+ A constant CY = CZ;
+ A constant CZ = DA;
+ A constant DA = DB;
+ A constant DB = DC;
+ A constant DC = DD;
+ A constant DD = DE;
+ A constant DE = DF;
+ A constant DF = DG;
+ A constant DG = DH;
+ A constant DH = DI;
+ A constant DI = DJ;
+ A constant DJ = DK;
+ A constant DK = DL;
+ A constant DL = DM;
+ A constant DM = DN;
+ A constant DN = DO;
+ A constant DO = DP;
+ A constant DP = DQ;
+ A constant DQ = DR;
+ A constant DR = DS;
+ A constant DS = DT;
+ A constant DT = DU;
+ A constant DU = DV;
+ A constant DV = DW;
+ A constant DW = DX;
+ A constant DX = DY;
+ A constant DY = DZ;
+ A constant DZ = EA;
+ A constant EA = EB;
+ A constant EB = EC;
+ A constant EC = ED;
+ A constant ED = EE;
+ A constant EE = EF;
+ A constant EF = EG;
+ A constant EG = EH;
+ A constant EH = EI;
+ A constant EI = EJ;
+ A constant EJ = EK;
+ A constant EK = EL;
+ A constant EL = EM;
+ A constant EM = EN;
+ A constant EN = EO;
+ A constant EO = EP;
+ A constant EP = EQ;
+ A constant EQ = ER;
+ A constant ER = ES;
+ A constant ES = ET;
+ A constant ET = EU;
+ A constant EU = EV;
+ A constant EV = EW;
+ A constant EW = EX;
+ A constant EX = EY;
+ A constant EY = EZ;
+ A constant EZ = FA;
+ A constant FA = FB;
+ A constant FB = FC;
+ A constant FC = FD;
+ A constant FD = FE;
+ A constant FE = FF;
+ A constant FF = FG;
+ A constant FG = FH;
+ A constant FH = FI;
+ A constant FI = FJ;
+ A constant FJ = FK;
+ A constant FK = FL;
+ A constant FL = FM;
+ A constant FM = FN;
+ A constant FN = FO;
+ A constant FO = FP;
+ A constant FP = FQ;
+ A constant FQ = FR;
+ A constant FR = FS;
+ A constant FS = FT;
+ A constant FT = FU;
+ A constant FU = FV;
+ A constant FV = FW;
+ A constant FW = FX;
+ A constant FX = FY;
+ A constant FY = FZ;
+ A constant FZ = GA;
+ A constant GA = GB;
+ A constant GB = GC;
+ A constant GC = GD;
+ A constant GD = GE;
+ A constant GE = GF;
+ A constant GF = GG;
+ A constant GG = GH;
+ A constant GH = GI;
+ A constant GI = GJ;
+ A constant GJ = GK;
+ A constant GK = GL;
+ A constant GL = GM;
+ A constant GM = GN;
+ A constant GN = GO;
+ A constant GO = GP;
+ A constant GP = GQ;
+ A constant GQ = GR;
+ A constant GR = GS;
+ A constant GS = GT;
+ A constant GT = GU;
+ A constant GU = GV;
+ A constant GV = GW;
+ A constant GW = GX;
+ A constant GX = GY;
+ A constant GY = GZ;
+ A constant GZ = HA;
+ A constant HA = HB;
+ A constant HB = HC;
+ A constant HC = HD;
+ A constant HD = HE;
+ A constant HE = HF;
+ A constant HF = HG;
+ A constant HG = HH;
+ A constant HH = HI;
+ A constant HI = HJ;
+ A constant HJ = HK;
+ A constant HK = HL;
+ A constant HL = HM;
+ A constant HM = HN;
+ A constant HN = HO;
+ A constant HO = HP;
+ A constant HP = HQ;
+ A constant HQ = HR;
+ A constant HR = HS;
+ A constant HS = HT;
+ A constant HT = HU;
+ A constant HU = HV;
+ A constant HV = HW;
+ A constant HW = HX;
+ A constant HX = HY;
+ A constant HY = HZ;
+ A constant HZ = IA;
+ A constant IA = IB;
+ A constant IB = IC;
+ A constant IC = ID;
+ A constant ID = IE;
+ A constant IE = IF;
+ A constant IF = IG;
+ A constant IG = IH;
+ A constant IH = II;
+ A constant II = IJ;
+ A constant IJ = IK;
+ A constant IK = IL;
+ A constant IL = IM;
+ A constant IM = IN;
+ A constant IN = IO;
+ A constant IO = IP;
+ A constant IP = IQ;
+ A constant IQ = IR;
+ A constant IR = IS;
+ A constant IS = IT;
+ A constant IT = IU;
+ A constant IU = IV;
+ A constant IV = IW;
+ A constant IW = IX;
+ A constant IX = IY;
+ A constant IY = IZ;
+ A constant IZ = JA;
+ A constant JA = JB;
+ A constant JB = JC;
+ A constant JC = JD;
+ A constant JD = JE;
+ A constant JE = JF;
+ A constant JF = JG;
+ A constant JG = JH;
+ A constant JH = JI;
+ A constant JI = JJ;
+ A constant JJ = JK;
+ A constant JK = JL;
+ A constant JL = JM;
+ A constant JM = JN;
+ A constant JN = JO;
+ A constant JO = JP;
+ A constant JP = JQ;
+ A constant JQ = JR;
+ A constant JR = JS;
+ A constant JS = JT;
+ A constant JT = JU;
+ A constant JU = JV;
+ A constant JV = JW;
+ A constant JW = JX;
+ A constant JX = A(0x00);
+}
+// ----
+// DeclarationError: (6105-6123): Variable definition exhausting cyclic dependency validator.
diff --git a/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_good.sol b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_good.sol
new file mode 100644
index 00000000..7f8c6189
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_good.sol
@@ -0,0 +1,135 @@
+contract A {}
+contract Main {
+ A constant B = C;
+ A constant C = D;
+ A constant D = E;
+ A constant E = F;
+ A constant F = G;
+ A constant G = H;
+ A constant H = I;
+ A constant I = J;
+ A constant J = K;
+ A constant K = L;
+ A constant L = M;
+ A constant M = N;
+ A constant N = O;
+ A constant O = P;
+ A constant P = Q;
+ A constant Q = R;
+ A constant R = S;
+ A constant S = T;
+ A constant T = U;
+ A constant U = V;
+ A constant V = W;
+ A constant W = X;
+ A constant X = Y;
+ A constant Y = Z;
+ A constant Z = BA;
+ A constant BA = BB;
+ A constant BB = BC;
+ A constant BC = BD;
+ A constant BD = BE;
+ A constant BE = BF;
+ A constant BF = BG;
+ A constant BG = BH;
+ A constant BH = BI;
+ A constant BI = BJ;
+ A constant BJ = BK;
+ A constant BK = BL;
+ A constant BL = BM;
+ A constant BM = BN;
+ A constant BN = BO;
+ A constant BO = BP;
+ A constant BP = BQ;
+ A constant BQ = BR;
+ A constant BR = BS;
+ A constant BS = BT;
+ A constant BT = BU;
+ A constant BU = BV;
+ A constant BV = BW;
+ A constant BW = BX;
+ A constant BX = BY;
+ A constant BY = BZ;
+ A constant BZ = CA;
+ A constant CA = CB;
+ A constant CB = CC;
+ A constant CC = CD;
+ A constant CD = CE;
+ A constant CE = CF;
+ A constant CF = CG;
+ A constant CG = CH;
+ A constant CH = CI;
+ A constant CI = CJ;
+ A constant CJ = CK;
+ A constant CK = CL;
+ A constant CL = CM;
+ A constant CM = CN;
+ A constant CN = CO;
+ A constant CO = CP;
+ A constant CP = CQ;
+ A constant CQ = CR;
+ A constant CR = CS;
+ A constant CS = CT;
+ A constant CT = CU;
+ A constant CU = CV;
+ A constant CV = CW;
+ A constant CW = CX;
+ A constant CX = CY;
+ A constant CY = CZ;
+ A constant CZ = DA;
+ A constant DA = DB;
+ A constant DB = DC;
+ A constant DC = DD;
+ A constant DD = DE;
+ A constant DE = DF;
+ A constant DF = DG;
+ A constant DG = DH;
+ A constant DH = DI;
+ A constant DI = DJ;
+ A constant DJ = DK;
+ A constant DK = DL;
+ A constant DL = DM;
+ A constant DM = DN;
+ A constant DN = DO;
+ A constant DO = DP;
+ A constant DP = DQ;
+ A constant DQ = DR;
+ A constant DR = DS;
+ A constant DS = DT;
+ A constant DT = DU;
+ A constant DU = DV;
+ A constant DV = DW;
+ A constant DW = DX;
+ A constant DX = DY;
+ A constant DY = DZ;
+ A constant DZ = EA;
+ A constant EA = EB;
+ A constant EB = EC;
+ A constant EC = ED;
+ A constant ED = EE;
+ A constant EE = EF;
+ A constant EF = EG;
+ A constant EG = EH;
+ A constant EH = EI;
+ A constant EI = EJ;
+ A constant EJ = EK;
+ A constant EK = EL;
+ A constant EL = EM;
+ A constant EM = EN;
+ A constant EN = EO;
+ A constant EO = EP;
+ A constant EP = EQ;
+ A constant EQ = ER;
+ A constant ER = ES;
+ A constant ES = ET;
+ A constant ET = EU;
+ A constant EU = EV;
+ A constant EV = EW;
+ A constant EW = EX;
+ A constant EX = EY;
+ A constant EY = EZ;
+ A constant EZ = FA;
+ A constant FA = FB;
+ A constant FB = FC;
+ A constant FC = A(0x00);
+}
diff --git a/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_exhausted.sol b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_exhausted.sol
new file mode 100644
index 00000000..db0ff4af
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_exhausted.sol
@@ -0,0 +1,260 @@
+contract Main {
+ struct B { C m; }
+ struct C { D m; }
+ struct D { E m; }
+ struct E { F m; }
+ struct F { G m; }
+ struct G { H m; }
+ struct H { I m; }
+ struct I { J m; }
+ struct J { K m; }
+ struct K { L m; }
+ struct L { M m; }
+ struct M { N m; }
+ struct N { O m; }
+ struct O { P m; }
+ struct P { Q m; }
+ struct Q { R m; }
+ struct R { S m; }
+ struct S { T m; }
+ struct T { U m; }
+ struct U { V m; }
+ struct V { W m; }
+ struct W { X m; }
+ struct X { Y m; }
+ struct Y { Z m; }
+ struct Z { BA m; }
+ struct BA { BB m; }
+ struct BB { BC m; }
+ struct BC { BD m; }
+ struct BD { BE m; }
+ struct BE { BF m; }
+ struct BF { BG m; }
+ struct BG { BH m; }
+ struct BH { BI m; }
+ struct BI { BJ m; }
+ struct BJ { BK m; }
+ struct BK { BL m; }
+ struct BL { BM m; }
+ struct BM { BN m; }
+ struct BN { BO m; }
+ struct BO { BP m; }
+ struct BP { BQ m; }
+ struct BQ { BR m; }
+ struct BR { BS m; }
+ struct BS { BT m; }
+ struct BT { BU m; }
+ struct BU { BV m; }
+ struct BV { BW m; }
+ struct BW { BX m; }
+ struct BX { BY m; }
+ struct BY { BZ m; }
+ struct BZ { CA m; }
+ struct CA { CB m; }
+ struct CB { CC m; }
+ struct CC { CD m; }
+ struct CD { CE m; }
+ struct CE { CF m; }
+ struct CF { CG m; }
+ struct CG { CH m; }
+ struct CH { CI m; }
+ struct CI { CJ m; }
+ struct CJ { CK m; }
+ struct CK { CL m; }
+ struct CL { CM m; }
+ struct CM { CN m; }
+ struct CN { CO m; }
+ struct CO { CP m; }
+ struct CP { CQ m; }
+ struct CQ { CR m; }
+ struct CR { CS m; }
+ struct CS { CT m; }
+ struct CT { CU m; }
+ struct CU { CV m; }
+ struct CV { CW m; }
+ struct CW { CX m; }
+ struct CX { CY m; }
+ struct CY { CZ m; }
+ struct CZ { DA m; }
+ struct DA { DB m; }
+ struct DB { DC m; }
+ struct DC { DD m; }
+ struct DD { DE m; }
+ struct DE { DF m; }
+ struct DF { DG m; }
+ struct DG { DH m; }
+ struct DH { DI m; }
+ struct DI { DJ m; }
+ struct DJ { DK m; }
+ struct DK { DL m; }
+ struct DL { DM m; }
+ struct DM { DN m; }
+ struct DN { DO m; }
+ struct DO { DP m; }
+ struct DP { DQ m; }
+ struct DQ { DR m; }
+ struct DR { DS m; }
+ struct DS { DT m; }
+ struct DT { DU m; }
+ struct DU { DV m; }
+ struct DV { DW m; }
+ struct DW { DX m; }
+ struct DX { DY m; }
+ struct DY { DZ m; }
+ struct DZ { EA m; }
+ struct EA { EB m; }
+ struct EB { EC m; }
+ struct EC { ED m; }
+ struct ED { EE m; }
+ struct EE { EF m; }
+ struct EF { EG m; }
+ struct EG { EH m; }
+ struct EH { EI m; }
+ struct EI { EJ m; }
+ struct EJ { EK m; }
+ struct EK { EL m; }
+ struct EL { EM m; }
+ struct EM { EN m; }
+ struct EN { EO m; }
+ struct EO { EP m; }
+ struct EP { EQ m; }
+ struct EQ { ER m; }
+ struct ER { ES m; }
+ struct ES { ET m; }
+ struct ET { EU m; }
+ struct EU { EV m; }
+ struct EV { EW m; }
+ struct EW { EX m; }
+ struct EX { EY m; }
+ struct EY { EZ m; }
+ struct EZ { FA m; }
+ struct FA { FB m; }
+ struct FB { FC m; }
+ struct FC { FD m; }
+ struct FD { FE m; }
+ struct FE { FF m; }
+ struct FF { FG m; }
+ struct FG { FH m; }
+ struct FH { FI m; }
+ struct FI { FJ m; }
+ struct FJ { FK m; }
+ struct FK { FL m; }
+ struct FL { FM m; }
+ struct FM { FN m; }
+ struct FN { FO m; }
+ struct FO { FP m; }
+ struct FP { FQ m; }
+ struct FQ { FR m; }
+ struct FR { FS m; }
+ struct FS { FT m; }
+ struct FT { FU m; }
+ struct FU { FV m; }
+ struct FV { FW m; }
+ struct FW { FX m; }
+ struct FX { FY m; }
+ struct FY { FZ m; }
+ struct FZ { GA m; }
+ struct GA { GB m; }
+ struct GB { GC m; }
+ struct GC { GD m; }
+ struct GD { GE m; }
+ struct GE { GF m; }
+ struct GF { GG m; }
+ struct GG { GH m; }
+ struct GH { GI m; }
+ struct GI { GJ m; }
+ struct GJ { GK m; }
+ struct GK { GL m; }
+ struct GL { GM m; }
+ struct GM { GN m; }
+ struct GN { GO m; }
+ struct GO { GP m; }
+ struct GP { GQ m; }
+ struct GQ { GR m; }
+ struct GR { GS m; }
+ struct GS { GT m; }
+ struct GT { GU m; }
+ struct GU { GV m; }
+ struct GV { GW m; }
+ struct GW { GX m; }
+ struct GX { GY m; }
+ struct GY { GZ m; }
+ struct GZ { HA m; }
+ struct HA { HB m; }
+ struct HB { HC m; }
+ struct HC { HD m; }
+ struct HD { HE m; }
+ struct HE { HF m; }
+ struct HF { HG m; }
+ struct HG { HH m; }
+ struct HH { HI m; }
+ struct HI { HJ m; }
+ struct HJ { HK m; }
+ struct HK { HL m; }
+ struct HL { HM m; }
+ struct HM { HN m; }
+ struct HN { HO m; }
+ struct HO { HP m; }
+ struct HP { HQ m; }
+ struct HQ { HR m; }
+ struct HR { HS m; }
+ struct HS { HT m; }
+ struct HT { HU m; }
+ struct HU { HV m; }
+ struct HV { HW m; }
+ struct HW { HX m; }
+ struct HX { HY m; }
+ struct HY { HZ m; }
+ struct HZ { IA m; }
+ struct IA { IB m; }
+ struct IB { IC m; }
+ struct IC { ID m; }
+ struct ID { IE m; }
+ struct IE { IF m; }
+ struct IF { IG m; }
+ struct IG { IH m; }
+ struct IH { II m; }
+ struct II { IJ m; }
+ struct IJ { IK m; }
+ struct IK { IL m; }
+ struct IL { IM m; }
+ struct IM { IN m; }
+ struct IN { IO m; }
+ struct IO { IP m; }
+ struct IP { IQ m; }
+ struct IQ { IR m; }
+ struct IR { IS m; }
+ struct IS { IT m; }
+ struct IT { IU m; }
+ struct IU { IV m; }
+ struct IV { IW m; }
+ struct IW { IX m; }
+ struct IX { IY m; }
+ struct IY { IZ m; }
+ struct IZ { JA m; }
+ struct JA { JB m; }
+ struct JB { JC m; }
+ struct JC { JD m; }
+ struct JD { JE m; }
+ struct JE { JF m; }
+ struct JF { JG m; }
+ struct JG { JH m; }
+ struct JH { JI m; }
+ struct JI { JJ m; }
+ struct JJ { JK m; }
+ struct JK { JL m; }
+ struct JL { JM m; }
+ struct JM { JN m; }
+ struct JN { JO m; }
+ struct JO { JP m; }
+ struct JP { JQ m; }
+ struct JQ { JR m; }
+ struct JR { JS m; }
+ struct JS { JT m; }
+ struct JT { JU m; }
+ struct JU { JV m; }
+ struct JV { JW m; }
+ struct JW { int i; }
+}
+// ----
+// DeclarationError: (6091-6111): Struct definition exhausting cyclic dependency validator.
diff --git a/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_good.sol b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_good.sol
new file mode 100644
index 00000000..0419bea6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_good.sol
@@ -0,0 +1,134 @@
+contract Main {
+ struct B { C m; }
+ struct C { D m; }
+ struct D { E m; }
+ struct E { F m; }
+ struct F { G m; }
+ struct G { H m; }
+ struct H { I m; }
+ struct I { J m; }
+ struct J { K m; }
+ struct K { L m; }
+ struct L { M m; }
+ struct M { N m; }
+ struct N { O m; }
+ struct O { P m; }
+ struct P { Q m; }
+ struct Q { R m; }
+ struct R { S m; }
+ struct S { T m; }
+ struct T { U m; }
+ struct U { V m; }
+ struct V { W m; }
+ struct W { X m; }
+ struct X { Y m; }
+ struct Y { Z m; }
+ struct Z { BA m; }
+ struct BA { BB m; }
+ struct BB { BC m; }
+ struct BC { BD m; }
+ struct BD { BE m; }
+ struct BE { BF m; }
+ struct BF { BG m; }
+ struct BG { BH m; }
+ struct BH { BI m; }
+ struct BI { BJ m; }
+ struct BJ { BK m; }
+ struct BK { BL m; }
+ struct BL { BM m; }
+ struct BM { BN m; }
+ struct BN { BO m; }
+ struct BO { BP m; }
+ struct BP { BQ m; }
+ struct BQ { BR m; }
+ struct BR { BS m; }
+ struct BS { BT m; }
+ struct BT { BU m; }
+ struct BU { BV m; }
+ struct BV { BW m; }
+ struct BW { BX m; }
+ struct BX { BY m; }
+ struct BY { BZ m; }
+ struct BZ { CA m; }
+ struct CA { CB m; }
+ struct CB { CC m; }
+ struct CC { CD m; }
+ struct CD { CE m; }
+ struct CE { CF m; }
+ struct CF { CG m; }
+ struct CG { CH m; }
+ struct CH { CI m; }
+ struct CI { CJ m; }
+ struct CJ { CK m; }
+ struct CK { CL m; }
+ struct CL { CM m; }
+ struct CM { CN m; }
+ struct CN { CO m; }
+ struct CO { CP m; }
+ struct CP { CQ m; }
+ struct CQ { CR m; }
+ struct CR { CS m; }
+ struct CS { CT m; }
+ struct CT { CU m; }
+ struct CU { CV m; }
+ struct CV { CW m; }
+ struct CW { CX m; }
+ struct CX { CY m; }
+ struct CY { CZ m; }
+ struct CZ { DA m; }
+ struct DA { DB m; }
+ struct DB { DC m; }
+ struct DC { DD m; }
+ struct DD { DE m; }
+ struct DE { DF m; }
+ struct DF { DG m; }
+ struct DG { DH m; }
+ struct DH { DI m; }
+ struct DI { DJ m; }
+ struct DJ { DK m; }
+ struct DK { DL m; }
+ struct DL { DM m; }
+ struct DM { DN m; }
+ struct DN { DO m; }
+ struct DO { DP m; }
+ struct DP { DQ m; }
+ struct DQ { DR m; }
+ struct DR { DS m; }
+ struct DS { DT m; }
+ struct DT { DU m; }
+ struct DU { DV m; }
+ struct DV { DW m; }
+ struct DW { DX m; }
+ struct DX { DY m; }
+ struct DY { DZ m; }
+ struct DZ { EA m; }
+ struct EA { EB m; }
+ struct EB { EC m; }
+ struct EC { ED m; }
+ struct ED { EE m; }
+ struct EE { EF m; }
+ struct EF { EG m; }
+ struct EG { EH m; }
+ struct EH { EI m; }
+ struct EI { EJ m; }
+ struct EJ { EK m; }
+ struct EK { EL m; }
+ struct EL { EM m; }
+ struct EM { EN m; }
+ struct EN { EO m; }
+ struct EO { EP m; }
+ struct EP { EQ m; }
+ struct EQ { ER m; }
+ struct ER { ES m; }
+ struct ES { ET m; }
+ struct ET { EU m; }
+ struct EU { EV m; }
+ struct EV { EW m; }
+ struct EW { EX m; }
+ struct EX { EY m; }
+ struct EY { EZ m; }
+ struct EZ { FA m; }
+ struct FA { FB m; }
+ struct FB { FC m; }
+ struct FC { int i; }
+}
diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_event.sol b/test/libsolidity/syntaxTests/types/empty_tuple_event.sol
index 24327db0..898ee8ba 100644
--- a/test/libsolidity/syntaxTests/types/empty_tuple_event.sol
+++ b/test/libsolidity/syntaxTests/types/empty_tuple_event.sol
@@ -1,4 +1,3 @@
-pragma solidity ^0.4.3;
contract C {
event SomeEvent();
function a() public {
@@ -6,4 +5,4 @@ contract C {
}
}
// ----
-// ParserError: (95-99): Expected primary expression.
+// ParserError: (71-75): Expected primary expression.
diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_function.sol b/test/libsolidity/syntaxTests/types/empty_tuple_function.sol
index ff31d440..a898f84a 100644
--- a/test/libsolidity/syntaxTests/types/empty_tuple_function.sol
+++ b/test/libsolidity/syntaxTests/types/empty_tuple_function.sol
@@ -1,4 +1,3 @@
-pragma solidity ^0.4.3;
contract C {
function f() private pure {}
function a() public pure {
@@ -8,5 +7,5 @@ contract C {
}
}
// ----
-// TypeError: (162-165): Tuple component cannot be empty.
-// TypeError: (181-184): Tuple component cannot be empty.
+// TypeError: (138-141): Tuple component cannot be empty.
+// TypeError: (157-160): Tuple component cannot be empty.
diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol
index 3d252f0b..63b039cd 100644
--- a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol
+++ b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol
@@ -1,4 +1,3 @@
-pragma solidity ^0.4.3;
contract C {
function f() private pure {}
function a() public {
@@ -8,6 +7,6 @@ contract C {
}
}
// ----
-// TypeError: (146-149): Tuple component cannot be empty.
-// TypeError: (151-154): Tuple component cannot be empty.
-// TypeError: (145-155): Type tuple(tuple(),tuple()) is not implicitly convertible to expected type tuple(uint256,uint256).
+// TypeError: (122-125): Tuple component cannot be empty.
+// TypeError: (127-130): Tuple component cannot be empty.
+// TypeError: (121-131): Type tuple(tuple(),tuple()) is not implicitly convertible to expected type tuple(uint256,uint256).
diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol
index f8b2ae7e..9bc21561 100644
--- a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol
+++ b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol
@@ -1,4 +1,3 @@
-pragma solidity ^0.4.3;
contract C {
function f() private pure {}
function a() public {
@@ -8,4 +7,4 @@ contract C {
}
}
// ----
-// TypeError: (146-149): Array component cannot be empty.
+// TypeError: (122-125): Array component cannot be empty.
diff --git a/test/libsolidity/syntaxTests/types/unnamed_tuple_decl.sol b/test/libsolidity/syntaxTests/types/unnamed_tuple_decl.sol
index 7ed92b58..36b3df9f 100644
--- a/test/libsolidity/syntaxTests/types/unnamed_tuple_decl.sol
+++ b/test/libsolidity/syntaxTests/types/unnamed_tuple_decl.sol
@@ -1,5 +1,3 @@
-pragma solidity ^0.4.20;
-
contract C {
function f() internal pure {}
function g() internal pure returns (uint) { return 1; }
@@ -13,6 +11,6 @@ contract C {
}
// ----
-// SyntaxError: (249-261): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty.
-// SyntaxError: (271-283): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty.
-// SyntaxError: (293-306): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty.
+// SyntaxError: (223-235): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty.
+// SyntaxError: (245-257): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty.
+// SyntaxError: (267-280): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty.
diff --git a/test/libsolidity/syntaxTests/types/var_empty_decl_0.sol b/test/libsolidity/syntaxTests/types/var_empty_decl_0.sol
new file mode 100644
index 00000000..51b949de
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/var_empty_decl_0.sol
@@ -0,0 +1,9 @@
+contract C {
+ function f() public pure {
+ var ();
+ var (,);
+ }
+}
+// ----
+// SyntaxError: (52-58): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty.
+// SyntaxError: (68-75): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty.
diff --git a/test/libsolidity/syntaxTests/types/var_empty_decl_1.sol b/test/libsolidity/syntaxTests/types/var_empty_decl_1.sol
new file mode 100644
index 00000000..20a004ff
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/var_empty_decl_1.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() public pure {
+ var a;
+ a.NeverReachedByParser();
+ }
+}
+// ----
+// TypeError: (52-57): Use of the "var" keyword is disallowed.
diff --git a/test/libsolidity/syntaxTests/types/var_empty_decl_2.sol b/test/libsolidity/syntaxTests/types/var_empty_decl_2.sol
new file mode 100644
index 00000000..de2abc9a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/var_empty_decl_2.sol
@@ -0,0 +1,9 @@
+contract C {
+ function f() public pure {
+ var (b, c);
+ b.WeMustNotReachHere();
+ c.FailsToLookupToo();
+ }
+}
+// ----
+// TypeError: (52-62): Use of the "var" keyword is disallowed.
diff --git a/test/libsolidity/syntaxTests/types/var_empty_decl_3.sol b/test/libsolidity/syntaxTests/types/var_empty_decl_3.sol
new file mode 100644
index 00000000..26ee824e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/var_empty_decl_3.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public pure {
+ var (d, e,);
+ }
+}
+// ----
+// TypeError: (52-63): Use of the "var" keyword is disallowed.
diff --git a/test/libsolidity/syntaxTests/types/var_type_suggest.sol b/test/libsolidity/syntaxTests/types/var_type_suggest.sol
index 176fab96..cc35fdd6 100644
--- a/test/libsolidity/syntaxTests/types/var_type_suggest.sol
+++ b/test/libsolidity/syntaxTests/types/var_type_suggest.sol
@@ -12,6 +12,10 @@ contract C {
var myblockhash = block.blockhash;
var (a, b) = (2, "troi");
var (x,, z) = h();
+ var (c, d) = ("");
+ var (k, l) = (2);
+ var (m, n) = 1;
+ var (o, p) = "";
}
}
// ----
@@ -21,3 +25,11 @@ contract C {
// SyntaxError: (293-326): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax.
// SyntaxError: (336-360): Use of the "var" keyword is disallowed. Use explicit declaration `(uint8 a, string memory b) = ...´ instead.
// SyntaxError: (370-387): Use of the "var" keyword is disallowed. Use explicit declaration `(uint256 x, , uint256 z) = ...´ instead.
+// TypeError: (397-414): Different number of components on the left hand side (2) than on the right hand side (1).
+// SyntaxError: (397-414): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax.
+// TypeError: (424-440): Different number of components on the left hand side (2) than on the right hand side (1).
+// SyntaxError: (424-440): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax.
+// TypeError: (450-464): Different number of components on the left hand side (2) than on the right hand side (1).
+// SyntaxError: (450-464): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax.
+// TypeError: (474-489): Different number of components on the left hand side (2) than on the right hand side (1).
+// SyntaxError: (474-489): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax.
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol
deleted file mode 100644
index 418be561..00000000
--- a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol
+++ /dev/null
@@ -1,7 +0,0 @@
-contract C {
- function k() public {
- assembly { jump(2) }
- }
-}
-// ----
-// Warning: (58-65): 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.
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol
deleted file mode 100644
index c1729db7..00000000
--- a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol
+++ /dev/null
@@ -1,8 +0,0 @@
-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/tools/CMakeLists.txt b/test/tools/CMakeLists.txt
index 257b4f24..d6df0ac8 100644
--- a/test/tools/CMakeLists.txt
+++ b/test/tools/CMakeLists.txt
@@ -3,5 +3,5 @@ target_link_libraries(solfuzzer PRIVATE libsolc evmasm ${Boost_PROGRAM_OPTIONS_L
add_executable(isoltest isoltest.cpp ../Options.cpp ../libsolidity/TestCase.cpp ../libsolidity/SyntaxTest.cpp
../libsolidity/AnalysisFramework.cpp ../libsolidity/SolidityExecutionFramework.cpp ../ExecutionFramework.cpp
- ../RPCSession.cpp)
+ ../RPCSession.cpp ../libsolidity/ASTJSONTest.cpp)
target_link_libraries(isoltest PRIVATE libsolc solidity evmasm ${Boost_PROGRAM_OPTIONS_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
diff --git a/test/tools/isoltest.cpp b/test/tools/isoltest.cpp
index bd4b0db9..7d15b07a 100644
--- a/test/tools/isoltest.cpp
+++ b/test/tools/isoltest.cpp
@@ -18,6 +18,7 @@
#include <libdevcore/CommonIO.h>
#include <test/libsolidity/AnalysisFramework.h>
#include <test/libsolidity/SyntaxTest.h>
+#include <test/libsolidity/ASTJSONTest.h>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/replace.hpp>
@@ -336,22 +337,53 @@ Allowed options)",
}
}
+ TestStats global_stats { 0, 0 };
+
fs::path syntaxTestPath = testPath / "libsolidity" / "syntaxTests";
if (fs::exists(syntaxTestPath) && fs::is_directory(syntaxTestPath))
{
auto stats = TestTool::processPath(SyntaxTest::create, testPath / "libsolidity", "syntaxTests", formatted);
- cout << endl << "Summary: ";
+ cout << endl << "Syntax Test Summary: ";
FormattedScope(cout, formatted, {BOLD, stats ? GREEN : RED}) <<
stats.successCount << "/" << stats.runCount;
- cout << " tests successful." << endl;
+ cout << " tests successful." << endl << endl;
- return stats ? 0 : 1;
+ global_stats.runCount += stats.runCount;
+ global_stats.successCount += stats.successCount;
}
else
{
cerr << "Syntax tests not found. Use the --testpath argument." << endl;
return 1;
}
+
+ fs::path astJsonTestPath = testPath / "libsolidity" / "ASTJSON";
+
+ if (fs::exists(astJsonTestPath) && fs::is_directory(astJsonTestPath))
+ {
+ auto stats = TestTool::processPath(ASTJSONTest::create, testPath / "libsolidity", "ASTJSON", formatted);
+
+ cout << endl << "JSON AST Test Summary: ";
+ FormattedScope(cout, formatted, {BOLD, stats ? GREEN : RED}) <<
+ stats.successCount << "/" << stats.runCount;
+ cout << " tests successful." << endl << endl;
+
+ global_stats.runCount += stats.runCount;
+ global_stats.successCount += stats.successCount;
+ }
+ else
+ {
+ cerr << "JSON AST tests not found." << endl;
+ return 1;
+ }
+
+ cout << endl << "Summary: ";
+ FormattedScope(cout, formatted, {BOLD, global_stats ? GREEN : RED}) <<
+ global_stats.successCount << "/" << global_stats.runCount;
+ cout << " tests successful." << endl;
+
+
+ return global_stats ? 0 : 1;
}