aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.dockerignore6
-rw-r--r--CMakeLists.txt2
-rw-r--r--Changelog.md38
-rw-r--r--circle.yml5
-rw-r--r--cmake/jsoncpp.cmake4
-rw-r--r--cmake/scripts/buildinfo.cmake2
-rw-r--r--docs/_templates/layout.html6
-rw-r--r--docs/abi-spec.rst105
-rw-r--r--docs/assembly.rst4
-rw-r--r--docs/conf.py4
-rw-r--r--docs/contracts.rst48
-rw-r--r--docs/contributing.rst4
-rw-r--r--docs/control-structures.rst99
-rw-r--r--docs/grammar.txt2
-rw-r--r--docs/index.rst2
-rw-r--r--docs/introduction-to-smart-contracts.rst8
-rw-r--r--docs/layout-of-source-files.rst2
-rw-r--r--docs/miscellaneous.rst10
-rw-r--r--docs/requirements.txt1
-rw-r--r--docs/solidity-by-example.rst2
-rw-r--r--docs/types.rst38
-rw-r--r--docs/units-and-global-variables.rst2
-rw-r--r--docs/utils/SolidityLexer.py82
-rw-r--r--docs/yul.rst (renamed from docs/julia.rst)47
-rw-r--r--libevmasm/PeepholeOptimiser.cpp19
-rw-r--r--libjulia/Exceptions.h6
-rw-r--r--libjulia/backends/evm/AbstractAssembly.h2
-rw-r--r--libjulia/backends/evm/EVMCodeTransform.cpp4
-rw-r--r--libjulia/backends/evm/EVMCodeTransform.h12
-rw-r--r--libjulia/optimiser/ASTCopier.h2
-rw-r--r--libjulia/optimiser/DataFlowAnalyzer.cpp2
-rw-r--r--libjulia/optimiser/Disambiguator.h2
-rw-r--r--libjulia/optimiser/README.md10
-rw-r--r--libjulia/optimiser/UnusedPruner.cpp4
-rw-r--r--libsolidity/analysis/ControlFlowBuilder.cpp9
-rw-r--r--libsolidity/analysis/DeclarationContainer.h2
-rw-r--r--libsolidity/analysis/NameAndTypeResolver.cpp20
-rw-r--r--libsolidity/analysis/NameAndTypeResolver.h4
-rw-r--r--libsolidity/analysis/ReferencesResolver.cpp71
-rw-r--r--libsolidity/analysis/StaticAnalyzer.cpp16
-rw-r--r--libsolidity/analysis/SyntaxChecker.cpp12
-rw-r--r--libsolidity/analysis/TypeChecker.cpp75
-rw-r--r--libsolidity/analysis/ViewPureChecker.cpp4
-rw-r--r--libsolidity/ast/AST.cpp4
-rw-r--r--libsolidity/ast/AST.h2
-rw-r--r--libsolidity/ast/ASTJsonConverter.cpp2
-rw-r--r--libsolidity/ast/ExperimentalFeatures.h2
-rw-r--r--libsolidity/ast/Types.cpp149
-rw-r--r--libsolidity/ast/Types.h4
-rw-r--r--libsolidity/codegen/ABIFunctions.cpp4
-rw-r--r--libsolidity/codegen/ABIFunctions.h2
-rw-r--r--libsolidity/codegen/ArrayUtils.cpp96
-rw-r--r--libsolidity/codegen/ArrayUtils.h5
-rw-r--r--libsolidity/codegen/CompilerUtils.cpp4
-rw-r--r--libsolidity/codegen/ContractCompiler.cpp36
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp54
-rw-r--r--libsolidity/formal/SMTChecker.cpp101
-rw-r--r--libsolidity/formal/SMTChecker.h28
-rw-r--r--libsolidity/formal/VariableUsage.cpp4
-rw-r--r--libsolidity/formal/VariableUsage.h6
-rw-r--r--libsolidity/inlineasm/AsmAnalysis.cpp6
-rw-r--r--libsolidity/inlineasm/AsmDataForward.h4
-rw-r--r--libsolidity/inlineasm/AsmParser.cpp25
-rw-r--r--libsolidity/inlineasm/AsmPrinter.cpp10
-rw-r--r--libsolidity/inlineasm/AsmPrinter.h4
-rw-r--r--libsolidity/inlineasm/AsmScope.cpp4
-rw-r--r--libsolidity/inlineasm/AsmScope.h14
-rw-r--r--libsolidity/inlineasm/AsmScopeFiller.cpp4
-rw-r--r--libsolidity/interface/AssemblyStack.cpp12
-rw-r--r--libsolidity/interface/AssemblyStack.h6
-rw-r--r--libsolidity/interface/CompilerStack.cpp77
-rw-r--r--libsolidity/interface/CompilerStack.h42
-rw-r--r--libsolidity/interface/StandardCompiler.cpp4
-rw-r--r--libsolidity/parsing/Parser.cpp30
-rw-r--r--libsolidity/parsing/Scanner.cpp8
-rw-r--r--libsolidity/parsing/Token.h27
-rw-r--r--scripts/Dockerfile39
-rwxr-xr-xscripts/docs.sh1
-rwxr-xr-xscripts/extract_test_cases.py2
-rwxr-xr-xscripts/install_deps.sh9
-rwxr-xr-xscripts/install_obsolete_jsoncpp_1_7_4.sh16
-rwxr-xr-xscripts/isolate_tests.py2
-rw-r--r--scripts/release.bat7
-rwxr-xr-xscripts/release_ppa.sh4
-rwxr-xr-xscripts/update_bugs_by_version.py2
-rw-r--r--solc/CommandLineInterface.cpp32
-rw-r--r--std/StandardToken.sol59
-rw-r--r--std/Token.sol13
-rw-r--r--std/mortal.sol10
-rw-r--r--std/owned.sol15
-rw-r--r--std/std.sol6
-rw-r--r--test/RPCSession.cpp5
-rw-r--r--test/boostTest.cpp74
-rwxr-xr-xtest/cmdlineTests.sh56
-rw-r--r--test/compilationTests/MultiSigWallet/Factory.sol2
-rw-r--r--test/compilationTests/MultiSigWallet/MultiSigWallet.sol30
-rw-r--r--test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol8
-rw-r--r--test/compilationTests/MultiSigWallet/TestToken.sol6
-rw-r--r--test/compilationTests/corion/ico.sol18
-rw-r--r--test/compilationTests/corion/module.sol4
-rw-r--r--test/compilationTests/corion/moduleHandler.sol94
-rw-r--r--test/compilationTests/corion/multiOwner.sol8
-rw-r--r--test/compilationTests/corion/owned.sol2
-rw-r--r--test/compilationTests/corion/premium.sol28
-rw-r--r--test/compilationTests/corion/provider.sol86
-rw-r--r--test/compilationTests/corion/publisher.sol14
-rw-r--r--test/compilationTests/corion/schelling.sol64
-rw-r--r--test/compilationTests/corion/token.sol48
-rw-r--r--test/compilationTests/gnosis/Events/CategoricalEvent.sol4
-rw-r--r--test/compilationTests/gnosis/Events/Event.sol12
-rw-r--r--test/compilationTests/gnosis/Events/EventFactory.sol8
-rw-r--r--test/compilationTests/gnosis/Events/ScalarEvent.sol4
-rw-r--r--test/compilationTests/gnosis/MarketMakers/LMSRMarketMaker.sol4
-rw-r--r--test/compilationTests/gnosis/Markets/Campaign.sol18
-rw-r--r--test/compilationTests/gnosis/Markets/CampaignFactory.sol2
-rw-r--r--test/compilationTests/gnosis/Markets/StandardMarket.sol16
-rw-r--r--test/compilationTests/gnosis/Markets/StandardMarketFactory.sol2
-rw-r--r--test/compilationTests/gnosis/Migrations.sol2
-rw-r--r--test/compilationTests/gnosis/Oracles/CentralizedOracle.sol6
-rw-r--r--test/compilationTests/gnosis/Oracles/CentralizedOracleFactory.sol2
-rw-r--r--test/compilationTests/gnosis/Oracles/DifficultyOracle.sol4
-rw-r--r--test/compilationTests/gnosis/Oracles/DifficultyOracleFactory.sol2
-rw-r--r--test/compilationTests/gnosis/Oracles/FutarchyOracle.sol8
-rw-r--r--test/compilationTests/gnosis/Oracles/FutarchyOracleFactory.sol6
-rw-r--r--test/compilationTests/gnosis/Oracles/MajorityOracle.sol8
-rw-r--r--test/compilationTests/gnosis/Oracles/MajorityOracleFactory.sol2
-rw-r--r--test/compilationTests/gnosis/Oracles/SignedMessageOracle.sol6
-rw-r--r--test/compilationTests/gnosis/Oracles/SignedMessageOracleFactory.sol2
-rw-r--r--test/compilationTests/gnosis/Oracles/UltimateOracle.sol14
-rw-r--r--test/compilationTests/gnosis/Oracles/UltimateOracleFactory.sol2
-rw-r--r--test/compilationTests/gnosis/Tokens/EtherToken.sol4
-rw-r--r--test/compilationTests/gnosis/Tokens/OutcomeToken.sol6
-rw-r--r--test/compilationTests/gnosis/Tokens/StandardToken.sol6
-rw-r--r--test/compilationTests/milestonetracker/MilestoneTracker.sol30
-rw-r--r--test/compilationTests/milestonetracker/RLP.sol28
-rw-r--r--test/compilationTests/stringutils/strings.sol45
-rw-r--r--test/compilationTests/zeppelin/Bounty.sol4
-rw-r--r--test/compilationTests/zeppelin/DayLimit.sol2
-rw-r--r--test/compilationTests/zeppelin/LimitBalance.sol2
-rw-r--r--test/compilationTests/zeppelin/MultisigWallet.sol16
-rw-r--r--test/compilationTests/zeppelin/crowdsale/CappedCrowdsale.sol2
-rw-r--r--test/compilationTests/zeppelin/crowdsale/Crowdsale.sol8
-rw-r--r--test/compilationTests/zeppelin/crowdsale/FinalizableCrowdsale.sol2
-rw-r--r--test/compilationTests/zeppelin/crowdsale/RefundVault.sol10
-rw-r--r--test/compilationTests/zeppelin/crowdsale/RefundableCrowdsale.sol2
-rw-r--r--test/compilationTests/zeppelin/lifecycle/Destructible.sol2
-rw-r--r--test/compilationTests/zeppelin/lifecycle/Pausable.sol4
-rw-r--r--test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol2
-rw-r--r--test/compilationTests/zeppelin/ownership/Claimable.sol2
-rw-r--r--test/compilationTests/zeppelin/ownership/DelayedClaimable.sol2
-rw-r--r--test/compilationTests/zeppelin/ownership/HasNoEther.sol2
-rw-r--r--test/compilationTests/zeppelin/ownership/Ownable.sol2
-rw-r--r--test/compilationTests/zeppelin/ownership/Shareable.sol12
-rw-r--r--test/compilationTests/zeppelin/token/BasicToken.sol2
-rw-r--r--test/compilationTests/zeppelin/token/MintableToken.sol4
-rw-r--r--test/compilationTests/zeppelin/token/SimpleToken.sol2
-rw-r--r--test/compilationTests/zeppelin/token/StandardToken.sol6
-rw-r--r--test/compilationTests/zeppelin/token/TokenTimelock.sol2
-rw-r--r--test/compilationTests/zeppelin/token/VestedToken.sol4
-rw-r--r--test/contracts/AuctionRegistrar.cpp28
-rw-r--r--test/contracts/FixedFeeRegistrar.cpp14
-rw-r--r--test/contracts/Wallet.cpp24
-rwxr-xr-xtest/externalTests.sh26
-rw-r--r--test/libevmasm/Optimiser.cpp25
-rw-r--r--test/libjulia/Common.cpp14
-rw-r--r--test/libjulia/Common.h8
-rw-r--r--test/libjulia/CommonSubexpression.cpp2
-rw-r--r--test/libjulia/Disambiguator.cpp4
-rw-r--r--test/libjulia/FunctionGrouper.cpp4
-rw-r--r--test/libjulia/FunctionHoister.cpp4
-rw-r--r--test/libjulia/Inliner.cpp20
-rw-r--r--test/libjulia/MainFunction.cpp4
-rw-r--r--test/libjulia/Parser.cpp8
-rw-r--r--test/libjulia/Rematerialiser.cpp2
-rw-r--r--test/libjulia/Simplifier.cpp2
-rw-r--r--test/libjulia/UnusedPruner.cpp2
-rw-r--r--test/libsolidity/ABIDecoderTests.cpp22
-rw-r--r--test/libsolidity/ABIEncoderTests.cpp63
-rw-r--r--test/libsolidity/InlineAssembly.cpp6
-rw-r--r--test/libsolidity/SMTChecker.cpp59
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp886
-rw-r--r--test/libsolidity/SolidityExpressionCompiler.cpp5
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp6769
-rw-r--r--test/libsolidity/SolidityOptimizer.cpp14
-rw-r--r--test/libsolidity/SolidityParser.cpp658
-rw-r--r--test/libsolidity/SolidityScanner.cpp20
-rw-r--r--test/libsolidity/SolidityTypes.cpp32
-rw-r--r--test/libsolidity/SyntaxTest.cpp147
-rw-r--r--test/libsolidity/SyntaxTest.h30
-rw-r--r--test/libsolidity/TestCase.cpp55
-rw-r--r--test/libsolidity/TestCase.h80
-rw-r--r--test/libsolidity/ViewPureChecker.cpp359
-rw-r--r--test/libsolidity/syntaxTests/array/array_pop.sol7
-rw-r--r--test/libsolidity/syntaxTests/array/array_pop_arg.sol8
-rw-r--r--test/libsolidity/syntaxTests/array/bytes_pop.sol7
-rw-r--r--test/libsolidity/syntaxTests/array/dynamic_memory_array_pop.sol8
-rw-r--r--test/libsolidity/syntaxTests/array/length/array_length_cannot_be_constant_function_parameter.sol (renamed from test/libsolidity/syntaxTests/arrayLength/array_length_cannot_be_constant_function_parameter.sol)0
-rw-r--r--test/libsolidity/syntaxTests/array/length/can_be_constant_in_function.sol (renamed from test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_function.sol)0
-rw-r--r--test/libsolidity/syntaxTests/array/length/can_be_constant_in_struct.sol (renamed from test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_struct.sol)0
-rw-r--r--test/libsolidity/syntaxTests/array/length/can_be_recursive_constant.sol (renamed from test/libsolidity/syntaxTests/arrayLength/can_be_recursive_constant.sol)0
-rw-r--r--test/libsolidity/syntaxTests/array/length/cannot_be_function.sol (renamed from test/libsolidity/syntaxTests/arrayLength/cannot_be_function.sol)0
-rw-r--r--test/libsolidity/syntaxTests/array/length/cannot_be_function_call.sol (renamed from test/libsolidity/syntaxTests/arrayLength/cannot_be_function_call.sol)0
-rw-r--r--test/libsolidity/syntaxTests/array/length/complex_cyclic_constant.sol (renamed from test/libsolidity/syntaxTests/arrayLength/complex_cyclic_constant.sol)0
-rw-r--r--test/libsolidity/syntaxTests/array/length/const_cannot_be_fractional.sol (renamed from test/libsolidity/syntaxTests/arrayLength/const_cannot_be_fractional.sol)0
-rw-r--r--test/libsolidity/syntaxTests/array/length/constant_var.sol (renamed from test/libsolidity/syntaxTests/arrayLength/constant_var.sol)0
-rw-r--r--test/libsolidity/syntaxTests/array/length/cyclic_constant.sol (renamed from test/libsolidity/syntaxTests/arrayLength/cyclic_constant.sol)0
-rw-r--r--test/libsolidity/syntaxTests/array/length/inline_array.sol (renamed from test/libsolidity/syntaxTests/arrayLength/inline_array.sol)0
-rw-r--r--test/libsolidity/syntaxTests/array/length/invalid_expression_1.sol (renamed from test/libsolidity/syntaxTests/arrayLength/invalid_expression_1.sol)0
-rw-r--r--test/libsolidity/syntaxTests/array/length/invalid_expression_2.sol (renamed from test/libsolidity/syntaxTests/arrayLength/invalid_expression_2.sol)0
-rw-r--r--test/libsolidity/syntaxTests/array/length/invalid_expression_3.sol (renamed from test/libsolidity/syntaxTests/arrayLength/invalid_expression_3.sol)0
-rw-r--r--test/libsolidity/syntaxTests/array/length/invalid_expression_4.sol (renamed from test/libsolidity/syntaxTests/arrayLength/invalid_expression_4.sol)0
-rw-r--r--test/libsolidity/syntaxTests/array/length/invalid_expression_5.sol (renamed from test/libsolidity/syntaxTests/arrayLength/invalid_expression_5.sol)0
-rw-r--r--test/libsolidity/syntaxTests/array/length/non_integer_constant_var.sol (renamed from test/libsolidity/syntaxTests/arrayLength/non_integer_constant_var.sol)0
-rw-r--r--test/libsolidity/syntaxTests/array/length/not_convertible_to_integer.sol (renamed from test/libsolidity/syntaxTests/arrayLength/not_convertible_to_integer.sol)0
-rw-r--r--test/libsolidity/syntaxTests/array/length/parentheses.sol (renamed from test/libsolidity/syntaxTests/arrayLength/parentheses.sol)0
-rw-r--r--test/libsolidity/syntaxTests/array/length/pure_functions.sol (renamed from test/libsolidity/syntaxTests/arrayLength/pure_functions.sol)0
-rw-r--r--test/libsolidity/syntaxTests/array/length/too_large.sol (renamed from test/libsolidity/syntaxTests/arrayLength/too_large.sol)0
-rw-r--r--test/libsolidity/syntaxTests/array/length/tuples.sol (renamed from test/libsolidity/syntaxTests/arrayLength/tuples.sol)0
-rw-r--r--test/libsolidity/syntaxTests/array/no_array_pop.sol8
-rw-r--r--test/libsolidity/syntaxTests/array/static_storage_array_pop.sol8
-rw-r--r--test/libsolidity/syntaxTests/array/string_pop.sol8
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_fine.sol9
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol17
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_calldata.sol4
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_memory.sol5
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_storage.sol5
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/function_argument_location_specifier_test_library.sol5
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/function_argument_location_specifier_test_non_reference_type.sol5
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_calldata.sol5
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_memory.sol4
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_storage.sol4
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_calldata.sol5
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_memory.sol4
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_storage.sol5
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_non_reference_type.sol13
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_reference_type.sol14
-rw-r--r--test/libsolidity/syntaxTests/denominations/denominations.sol3
-rw-r--r--test/libsolidity/syntaxTests/denominations/deprecated_year.sol2
-rw-r--r--test/libsolidity/syntaxTests/denominations/deprecated_year_050.sol6
-rw-r--r--test/libsolidity/syntaxTests/deprecated_functions.sol6
-rw-r--r--test/libsolidity/syntaxTests/deprecated_functions_050.sol15
-rw-r--r--test/libsolidity/syntaxTests/double_variable_declaration.sol5
-rw-r--r--test/libsolidity/syntaxTests/double_variable_declaration_050.sol11
-rw-r--r--test/libsolidity/syntaxTests/empty_string_var.sol11
-rw-r--r--test/libsolidity/syntaxTests/empty_struct.sol2
-rw-r--r--test/libsolidity/syntaxTests/empty_struct_050.sol6
-rw-r--r--test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol6
-rw-r--r--test/libsolidity/syntaxTests/functionTypes/function_type_return_parameters_with_names.sol5
-rw-r--r--test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables.sol2
-rw-r--r--test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables050.sol7
-rw-r--r--test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalid.sol8
-rw-r--r--test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol4
-rw-r--r--test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/001_name_references.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/002_undeclared_name.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/003_undeclared_name_is_not_fatal.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/004_reference_to_later_declaration.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/006_type_checking_return.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/007_type_checking_return_wrong_number.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/008_type_checking_return_wrong_type.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/009_type_checking_function_call.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/010_type_conversion_for_comparison.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/011_type_conversion_for_comparison_invalid.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/013_large_string_literal.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/014_balance.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/015_balance_invalid.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol12
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/017_assignment_to_struct.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/018_forward_function_reference.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/019_comparison_bitop_precedence.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/020_comparison_of_function_types_lt_1.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/021_comparison_of_function_types_lt_2.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/022_comparison_of_function_types_gt_1.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/023_comparison_of_function_types_gt_2.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/024_comparison_of_function_types_eq.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/025_comparison_of_mapping_types.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/029_create_abstract_contract.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/030_redeclare_implemented_abstract_function_as_abstract.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/039_functions_with_identical_structs_in_interface.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/040_functions_with_different_structs_in_interface.sol12
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/041_functions_with_stucts_of_non_external_types_in_interface.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/042_functions_with_stucts_of_non_external_types_in_interface_2.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/043_functions_with_stucts_of_non_external_types_in_interface_nested.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/044_returning_multi_dimensional_arrays_new_abi.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/045_returning_multi_dimensional_arrays.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/046_returning_multi_dimensional_static_arrays.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/047_returning_arrays_in_structs_new_abi.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/048_returning_arrays_in_structs_arrays.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/049_function_external_call_allowed_conversion.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/050_function_external_call_not_allowed_conversion.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/051_function_internal_allowed_conversion.sol13
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/052_function_internal_not_allowed_conversion.sol12
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/053_hash_collision_in_interface.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/054_inheritance_basic.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/055_inheritance_diamond_basic.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/056_cyclic_inheritance.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/057_legal_override_direct.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/058_legal_override_indirect.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/059_illegal_override_visibility.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/060_complex_inheritance.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/061_missing_base_constructor_arguments.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/062_base_constructor_arguments_override.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/063_implicit_derived_to_base_conversion.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/064_implicit_base_to_derived_conversion.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/065_super_excludes_current_contract.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/067_function_clash_with_state_variable_accessor.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/069_base_class_state_variable_accessor.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/070_struct_accessor_one_array_only.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/071_base_class_state_variable_internal_member.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/072_state_variable_member_of_wrong_class1.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/073_state_variable_member_of_wrong_class2.sol12
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/074_fallback_function.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/075_fallback_function_with_arguments.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/076_fallback_function_in_library.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/077_fallback_function_with_return_parameters.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/078_fallback_function_twice.sol (renamed from test/libsolidity/syntaxTests/functionTypes/warn_function_type_return_parameters_with_names.sol)6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/079_fallback_function_inheritance.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/080_event.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/081_event_too_many_indexed.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/082_anonymous_event_four_indexed.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/083_anonymous_event_too_many_indexed.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/084_events_with_same_name.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/085_events_with_same_name_unnamed_arguments.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/086_events_with_same_name_different_types.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/087_double_event_declaration.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/088_double_event_declaration_ignores_anonymous.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/089_double_event_declaration_ignores_indexed.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/090_event_call.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/091_event_function_inheritance_clash.sol12
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/092_function_event_inheritance_clash.sol12
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/093_function_event_in_contract_clash.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/094_event_inheritance.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/095_multiple_events_argument_clash.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/096_access_to_default_function_visibility.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/097_access_to_internal_function.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/098_access_to_default_state_variable_visibility.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/099_access_to_internal_state_variable.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/100_error_count_in_named_args.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/101_empty_in_named_args.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/102_duplicate_parameter_names_in_named_args.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/103_invalid_parameter_names_in_named_args.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/104_empty_name_input_parameter.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/105_constant_input_parameter.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/106_empty_name_return_parameter.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/107_empty_name_input_parameter_with_named_one.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/108_empty_name_return_parameter_with_named_one.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/110_no_overflow_with_large_literal.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/111_overflow_caused_by_ether_units.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/112_exp_operator_exponent_too_big.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/113_exp_warn_literal_base_1.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/114_exp_warn_literal_base_2.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/115_exp_warn_literal_base_3.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/116_shift_warn_literal_base_1.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/117_shift_warn_literal_base_2.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/118_shift_warn_literal_base_3.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/119_shift_warn_literal_base_4.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/124_enum_member_access.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/125_enum_member_access_accross_contracts.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/126_enum_invalid_member_access.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/127_enum_invalid_direct_member_access.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/128_enum_explicit_conversion_is_okay.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/129_int_to_enum_explicit_conversion_is_okay.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/130_enum_implicit_conversion_is_not_okay_256.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/131_enum_implicit_conversion_is_not_okay_64.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/132_enum_to_enum_conversion_is_not_okay.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/133_enum_duplicate_values.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/134_enum_name_resolution_under_current_contract_name.sol12
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/135_private_visibility.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/136_private_visibility_via_explicit_base_access.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/137_external_visibility.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/138_similar_name_suggestions_expected.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/139_no_name_suggestion.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/140_multiple_similar_suggestions.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/141_multiple_scopes_suggestions.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/142_inheritence_suggestions.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/143_no_spurious_identifier_suggestions_with_submatch.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/144_no_spurious_identifier_suggestions.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/145_external_base_visibility.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/146_external_argument_assign.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/147_external_argument_increment.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/148_external_argument_delete.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/149_test_for_bug_override_function_with_bytearray_type.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/150_array_with_nonconstant_length.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/151_array_with_negative_length.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/152_array_copy_with_different_types1.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/153_array_copy_with_different_types2.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/154_array_copy_with_different_types_conversion_possible.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/155_array_copy_with_different_types_static_dynamic.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/156_array_copy_with_different_types_dynamic_static.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/157_array_of_undeclared_type.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/158_storage_variable_initialization_with_incorrect_type_int.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/159_storage_variable_initialization_with_incorrect_type_string.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/160_test_byte_is_alias_of_byte1.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/161_warns_assigning_decimal_to_bytesxx.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/162_does_not_warn_assigning_hex_number_to_bytesxx.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/163_explicit_conversion_from_decimal_to_bytesxx.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/164_assigning_value_to_const_variable.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/165_assigning_state_to_const_variable.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/166_assigning_state_to_const_variable_050.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/167_constant_string_literal_disallows_assignment.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/168_assignment_to_const_var_involving_conversion.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/169_assignment_to_const_var_involving_expression.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/170_assignment_to_const_var_involving_keccak.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/171_assignment_to_const_array_vars.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/172_assignment_to_const_string_bytes.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/173_constant_struct.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/174_address_is_constant.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/175_uninitialized_const_variable.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/176_overloaded_function_cannot_resolve.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/177_ambiguous_overloaded_function.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/178_assignment_of_nonoverloaded_function.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/179_assignment_of_overloaded_function.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/180_external_types_clash.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/181_override_changes_return_types.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/182_equal_overload.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/185_invalid_utf8_implicit.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/186_invalid_utf8_explicit.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/187_large_utf8_codepoint.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/188_string_index.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/189_string_length.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/190_negative_integers_to_signed_out_of_bound.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/191_negative_integers_to_signed_min.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/192_positive_integers_to_signed_out_of_bound.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/193_positive_integers_to_signed_out_of_bound_max.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/194_negative_integers_to_unsigned.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/195_positive_integers_to_unsigned_out_of_bound.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/196_integer_boolean_or.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/197_integer_boolean_and.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/198_integer_boolean_not.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/199_integer_unsigned_exp_signed.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/200_integer_signed_exp_unsigned.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/201_integer_signed_exp_signed.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/202_bytes_reference_compare_operators.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/203_struct_reference_compare_operators.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/204_overwrite_memory_location_external.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/205_overwrite_storage_location_external.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/206_storage_location_local_variables.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/207_no_mappings_in_memory_array.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/208_assignment_mem_to_local_storage_variable.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/209_storage_assign_to_different_local_variable.sol12
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/210_uninitialized_mapping_variable.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/211_uninitialized_mapping_array_variable.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/212_uninitialized_mapping_array_variable_050.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/213_no_delete_on_storage_pointers.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/214_assignment_mem_storage_variable_directly.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/215_function_argument_mem_to_storage.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/216_function_argument_storage_to_mem.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/217_mem_array_assignment_changes_base_type.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/219_memory_arrays_not_resizeable.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/220_struct_constructor.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/221_struct_constructor_nested.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/222_struct_named_constructor.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/223_literal_strings.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/224_string_bytes_conversion.sol17
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/225_inheriting_from_library.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/226_inheriting_library.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/227_library_having_variables.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/228_valid_library.sol1
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/229_call_to_library_function.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/230_creating_contract_within_the_contract.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/231_array_out_of_bound_access.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/232_literal_string_to_storage_pointer.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/233_non_initialized_references.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/234_non_initialized_references_050.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/235_keccak256_with_large_integer_constant.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/236_cyclic_binary_dependency.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/237_cyclic_binary_dependency_via_inheritance.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/239_multi_variable_declaration_wildcards_fine.sol20
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/240_multi_variable_declaration_wildcards_fail_1.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/241_multi_variable_declaration_wildcards_fail_2.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/242_multi_variable_declaration_wildcards_fail_3.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/243_multi_variable_declaration_wildcards_fail_4.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/244_tuples.sol13
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/245_tuples_empty_components.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/246_multi_variable_declaration_wildcards_fail_5.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/247_multi_variable_declaration_wildcards_fail_6.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/249_tuple_compound_assignment.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/250_member_access_parser_ambiguity.sol17
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/251_using_for_library.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/252_using_for_not_library.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/253_using_for_function_exists.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/254_using_for_function_on_int.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/255_using_for_function_on_struct.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/256_using_for_overload.sol14
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/257_using_for_by_name.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/258_using_for_mismatch.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/259_using_for_not_used.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/260_library_memory_struct.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/261_using_for_arbitrary_mismatch.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/262_bound_function_in_var.sol13
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/263_create_memory_arrays.sol14
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/264_mapping_in_memory_array.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/265_new_for_non_array.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/266_invalid_args_creating_memory_array.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/267_invalid_args_creating_struct.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/268_function_overload_array_type.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/269_inline_array_declaration_and_passing_implicit_conversion.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/270_inline_array_declaration_and_passing_implicit_conversion_strings.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/271_inline_array_declaration_const_int_conversion.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/272_inline_array_declaration_const_string_conversion.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/273_inline_array_declaration_no_type.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/274_inline_array_declaration_no_type_strings.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/275_inline_struct_declaration_arrays.sol13
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/276_invalid_types_in_inline_array.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/277_dynamic_inline_array.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/278_lvalues_as_inline_array.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/279_break_not_in_loop.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/280_continue_not_in_loop.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/281_continue_not_in_loop_2.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/282_invalid_different_types_for_conditional_expression.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/283_left_value_in_conditional_expression_not_supported_yet.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/284_conditional_expression_with_different_struct.sol15
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/285_conditional_expression_with_different_function_type.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/286_conditional_expression_with_different_enum.sol13
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/287_conditional_expression_with_different_mapping.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/288_conditional_with_all_types.sol91
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/289_uint7_and_uintM_as_identifier.sol12
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/291_modifier_is_not_a_valid_typename.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/292_modifier_is_not_a_valid_typename_is_not_fatal.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/293_function_is_not_a_valid_typename.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/294_long_uint_variable_fails.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/295_bytes10abc_is_identifier.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/296_int10abc_is_identifier.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/297_library_functions_do_not_have_value.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/298_invalid_fixed_types_0x7_mxn.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/299_invalid_fixed_types_long_invalid_identifier.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/300_invalid_fixed_types_7x8_mxn.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/301_library_instances_cannot_be_used.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/302_invalid_fixed_type_long.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/303_fixed_type_int_conversion.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/304_fixed_type_rational_int_conversion.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/305_fixed_type_rational_fraction_conversion.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/306_invalid_int_implicit_conversion_from_fixed.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/307_rational_unary_minus_operation.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/308_rational_unary_plus_operation.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/309_rational_unary_plus_assignment.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/310_rational_unary_plus_operation_v050.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/311_rational_unary_plus_assignment_v050.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/312_leading_zero_rationals_convert.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/313_fixed_type_size_capabilities.sol13
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/314_fixed_type_zero_handling.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/315_fixed_type_invalid_implicit_conversion_size.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/316_fixed_type_invalid_implicit_conversion_lost_data.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/317_fixed_type_valid_explicit_conversions.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/318_invalid_array_declaration_with_rational.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/319_invalid_array_declaration_with_signed_fixed_type.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/320_invalid_array_declaration_with_unsigned_fixed_type.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/321_rational_to_bytes_implicit_conversion.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/322_fixed_to_bytes_implicit_conversion.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/323_mapping_with_fixed_literal.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/324_fixed_points_inside_structs.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/325_inline_array_fixed_types.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/326_inline_array_rationals.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/327_rational_index_access.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/328_rational_to_fixed_literal_expression.sol15
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/329_rational_as_exponent_value_signed.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/330_rational_as_exponent_value_unsigned.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/331_rational_as_exponent_half.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/332_rational_as_exponent_value_neg_quarter.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/333_fixed_point_casting_exponents_15.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/334_fixed_point_casting_exponents_neg.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/338_rational_bitnot_unary_operation.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/339_rational_bitor_binary_operation.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/340_rational_bitxor_binary_operation.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/341_rational_bitand_binary_operation.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/342_missing_bool_conversion.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/343_integer_and_fixed_interaction.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/344_one_divided_by_three_integer_conversion.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/345_unused_return_value.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/346_unused_return_value_send.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/347_unused_return_value_call.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/348_unused_return_value_call_value.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/350_unused_return_value_delegatecall.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/351_callcode_deprecated.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/352_callcode_deprecated_v050.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/353_callcode_not_deprecated_as_function.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/354_payable_in_library.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/355_payable_external.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/356_payable_internal.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/357_payable_private.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/358_illegal_override_payable.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/359_illegal_override_payable_nonpayable.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/360_function_variable_mixin.sol12
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/361_calling_payable.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/362_calling_nonpayable.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/363_non_payable_constructor.sol12
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/366_invalid_array_as_statement.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/367_using_directive_for_missing_selftype.sol14
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/368_shift_constant_left_negative_rvalue.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/369_shift_constant_right_negative_rvalue.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/370_shift_constant_left_excessive_rvalue.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/371_shift_constant_right_excessive_rvalue.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/372_shift_constant_right_fractional.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/375_inline_assembly_unbalanced_two_stack_load.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/376_inline_assembly_in_modifier.sol14
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/377_inline_assembly_storage.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/378_inline_assembly_storage_in_modifiers.sol14
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/379_inline_assembly_constant_assign.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/380_inline_assembly_constant_access.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/381_inline_assembly_local_variable_access_out_of_functions.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/382_inline_assembly_local_variable_access_out_of_functions_storage_ptr.sol12
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/383_inline_assembly_storage_variable_access_out_of_functions.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/384_inline_assembly_constant_variable_via_offset.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/385_inline_assembly_calldata_variables.sol10
-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.sol10
-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.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/392_inline_assembly_050_jump.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/394_inline_assembly_050_leave_items_on_stack.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/396_invalid_mobile_type.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/397_warns_msg_value_in_non_payable_public_function.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/398_does_not_warn_msg_value_in_payable_function.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/399_does_not_warn_msg_value_in_internal_function.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/400_does_not_warn_msg_value_in_library.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/401_does_not_warn_msg_value_in_modifier_following_non_payable_public_function.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/402_assignment_to_constant.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/403_return_structs.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/404_read_returned_struct.sol12
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/405_address_checksum_type_deduction.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/406_invalid_address_checksum.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/407_invalid_address_no_checksum.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/408_invalid_address_length_short.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/409_invalid_address_length_long.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/410_string_literal_not_convertible_to_address_as_assignment.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/411_string_literal_not_convertible_to_address_as_return_value.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/413_address_methods.sol12
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/414_interface.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/415_interface_functions.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/416_interface_function_bodies.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/417_interface_events.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/418_interface_inheritance.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/419_interface_structs.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/420_interface_variables.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/421_interface_function_parameters.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/422_interface_enums.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/423_using_interface.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/424_using_interface_complex.sol17
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/425_interface_implement_public_contract.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/426_throw_is_deprecated.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/427_throw_is_deprecated_v050.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/428_bare_revert.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/429_revert_with_reason.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/430_bare_selfdestruct.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/431_bare_assert.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/432_bare_require.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/433_pure_statement_in_for_loop.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/434_pure_statement_check_for_regular_for_loop.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/435_warn_unused_local.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/436_warn_unused_local_assigned.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/437_warn_unused_function_parameter.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/438_unused_unnamed_function_parameter.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/439_warn_unused_return_parameter.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/440_warn_unused_return_parameter_with_explicit_return.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/441_unused_unnamed_return_parameter.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/442_named_return_parameter.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/443_named_return_parameter_with_explicit_return.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/444_unnamed_return_parameter_with_explicit_return.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/445_no_unused_warning_interface_arguments.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/446_no_unused_warning_abstract_arguments.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/447_no_unused_warnings.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/449_no_unused_inline_asm.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/450_shadowing_builtins_with_functions.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/451_shadowing_builtins_with_variables.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/452_shadowing_builtins_with_storage_variables.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/453_shadowing_builtin_at_global_scope.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/454_shadowing_builtins_with_parameters.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/455_shadowing_builtins_with_return_parameters.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/456_shadowing_builtins_with_events.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/457_shadowing_builtins_ignores_struct.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/458_shadowing_builtins_ignores_constructor.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/459_function_overload_is_not_shadowing.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/460_function_override_is_not_shadowing.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/461_event_parameter_cannot_shadow_state_variable.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/462_callable_crash.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/463_error_transfer_non_payable_fallback.sol17
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/464_error_transfer_no_fallback.sol15
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/465_error_send_non_payable_fallback.sol17
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/466_does_not_error_transfer_payable_fallback.sol16
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/467_does_not_error_transfer_regular_function.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/470_specified_storage_no_warn.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/471_unspecified_storage_warn.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/472_unspecified_storage_v050.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/473_storage_location_non_array_or_struct_disallowed.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/474_storage_location_non_array_or_struct_disallowed_is_not_fatal.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/475_implicit_conversion_disallowed.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/476_too_large_arrays_for_calldata_external.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/477_too_large_arrays_for_calldata_internal.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/478_too_large_arrays_for_calldata_public.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/479_explicit_literal_to_memory_string_assignment.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/480_explicit_literal_to_storage_string_assignment.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/481_explicit_literal_to_unspecified_string_assignment.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/482_explicit_literal_to_unspecified_string.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/483_modifiers_access_storage_pointer.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/484_function_types_selector_1.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/485_function_types_selector_2.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/486_function_types_selector_3.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/487_function_types_selector_4.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/488_function_types_selector_5.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/489_function_types_selector_6.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/490_function_types_selector_7.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/491_using_this_in_constructor.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/492_do_not_crash_on_not_lvalue.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/493_builtin_keccak256_reject_gas.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/494_builtin_sha256_reject_gas.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/495_builtin_ripemd160_reject_gas.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/496_builtin_ecrecover_reject_gas.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/497_gasleft.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/498_msg_gas_deprecated.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/499_msg_gas_deprecated_v050.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/500_gasleft_shadowing_1.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/501_gasleft_shadowing_2.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/502_builtin_keccak256_reject_value.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/503_builtin_sha256_reject_value.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/504_builtin_ripemd160_reject_value.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/505_builtin_ecrecover_reject_value.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/506_large_storage_array_fine.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/507_large_storage_array_simple.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/508_large_storage_arrays_combined.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/509_large_storage_arrays_struct.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/510_large_storage_array_mapping.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/511_library_function_without_implementation_public.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/512_library_function_without_implementation_internal.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/513_library_function_without_implementation_private.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/514_using_for_with_non_library.sol10
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/515_experimental_pragma_empty.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/516_experimental_pragma_unknown_number_literal.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/517_experimental_pragma_unknown_string_literal.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/518_experimental_pragma_unknown_quoted_string_literal.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/519_experimental_pragma_empy_string_literal.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/520_experimental_pragma_multiple_same_line.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/521_experimental_pragma_test_warning.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/522_experimental_pragma_duplicate.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/523_reject_interface_creation.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/524_accept_library_creation.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/525_reject_interface_constructors.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external_v050.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal_v050.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private_v050.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public_v050.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/530_tuple_invalid_literal_too_large_for_uint.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/531_tuple_invalid_literal_too_large_unassigned.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/532_tuple_invalid_literal_too_large_for_uint_multi.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/533_tuple_invalid_literal_too_large_exp.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/534_tuple_invalid_literal_too_large_expression.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol21
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/536_array_length_invalid_expression_negative_bool.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/537_array_length_invalid_expression_int_divides_bool.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/538_array_length_invalid_expression_bool_divides_int.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/539_array_length_invalid_expression_scientific_literal.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/540_array_length_invalid_expression_division_by_zero.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/541_warn_about_address_members_on_contract_balance.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/542_warn_about_address_members_on_contract_transfer.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/543_warn_about_address_members_on_contract_send.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/544_warn_about_address_members_on_contract_call.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/545_warn_about_address_members_on_contract_callcode.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/546_warn_about_address_members_on_contract_delegatecall.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/547_warn_about_address_members_on_non_this_contract_balance.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/548_warn_about_address_members_on_non_this_contract_transfer.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/549_warn_about_address_members_on_non_this_contract_send.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/550_warn_about_address_members_on_non_this_contract_call.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/551_warn_about_address_members_on_non_this_contract_callcode.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/552_warn_about_address_members_on_non_this_contract_delegatecall.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/553_no_address_members_on_contract_balance_v050.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/554_no_address_members_on_contract_transfer_v050.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/555_no_address_members_on_contract_send_v050.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/556_no_address_members_on_contract_call_v050.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/557_no_address_members_on_contract_callcode_v050.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/558_no_address_members_on_contract_delegatecall_v050.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/559_no_warning_for_using_members_that_look_like_address_members.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/560_event_emit_simple.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/561_event_emit_complex.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/562_event_emit_foreign_class.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/563_event_without_emit_deprecated.sol8
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/564_events_without_emit_deprecated_v050.sol9
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/566_require_visibility_specifiers.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/567_require_visibility_specifiers_v050.sol6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/568_blockhash.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/569_block_blockhash_deprecated.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/570_block_blockhash_deprecated_v050.sol6
-rw-r--r--test/libsolidity/syntaxTests/parsing/arrays_in_events.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/arrays_in_expressions.sol8
-rw-r--r--test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol6
-rw-r--r--test/libsolidity/syntaxTests/parsing/calling_function.sol9
-rw-r--r--test/libsolidity/syntaxTests/parsing/conditional_multiple.sol9
-rw-r--r--test/libsolidity/syntaxTests/parsing/conditional_true_false_literal.sol11
-rw-r--r--test/libsolidity/syntaxTests/parsing/conditional_with_assignment.sol8
-rw-r--r--test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol11
-rw-r--r--test/libsolidity/syntaxTests/parsing/conditional_with_variables.sol13
-rw-r--r--test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol14
-rw-r--r--test/libsolidity/syntaxTests/parsing/declaring_fixed_literal_variables.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/else_if_statement.sol8
-rw-r--r--test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol10
-rw-r--r--test/libsolidity/syntaxTests/parsing/event.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/event_arguments.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/event_arguments_indexed.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/exp_expression.sol9
-rw-r--r--test/libsolidity/syntaxTests/parsing/external_function.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/fallback_function.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol13
-rw-r--r--test/libsolidity/syntaxTests/parsing/for_loop_simple_noexpr.sol13
-rw-r--r--test/libsolidity/syntaxTests/parsing/for_loop_single_stmt_body.sol11
-rw-r--r--test/libsolidity/syntaxTests/parsing/for_loop_vardef_initexpr.sol12
-rw-r--r--test/libsolidity/syntaxTests/parsing/from_is_not_keyword.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/function_normal_comments.sol10
-rw-r--r--test/libsolidity/syntaxTests/parsing/function_type_as_parameter.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol10
-rw-r--r--test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol15
-rw-r--r--test/libsolidity/syntaxTests/parsing/function_type_in_struct.sol10
-rw-r--r--test/libsolidity/syntaxTests/parsing/if_statement.sol9
-rw-r--r--test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol9
-rw-r--r--test/libsolidity/syntaxTests/parsing/library_simple.sol6
-rw-r--r--test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol16
-rw-r--r--test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol10
-rw-r--r--test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol12
-rw-r--r--test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/mapping.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/mapping_and_array_of_functions.sol6
-rw-r--r--test/libsolidity/syntaxTests/parsing/mapping_in_struct.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/mapping_to_mapping_in_struct.sol6
-rw-r--r--test/libsolidity/syntaxTests/parsing/modifier.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/modifier_arguments.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/modifier_invocation.sol8
-rw-r--r--test/libsolidity/syntaxTests/parsing/multi_arrays.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/multi_variable_declarations.sol36
-rw-r--r--test/libsolidity/syntaxTests/parsing/multiple_event_arg_trailing_comma.sol6
-rw-r--r--test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol28
-rw-r--r--test/libsolidity/syntaxTests/parsing/multiple_modifier_arg_trailing_comma.sol6
-rw-r--r--test/libsolidity/syntaxTests/parsing/multiple_return_param_trailing_comma.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol9
-rw-r--r--test/libsolidity/syntaxTests/parsing/struct_definition.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/trailing_dot1.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/trailing_dot2.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/trailing_dot3.sol4
-rw-r--r--test/libsolidity/syntaxTests/parsing/tuples.sol27
-rw-r--r--test/libsolidity/syntaxTests/parsing/two_exact_functions.sol9
-rw-r--r--test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol17
-rw-r--r--test/libsolidity/syntaxTests/parsing/while_loop.sol7
-rw-r--r--test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope.sol3
-rw-r--r--test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_050.sol10
-rw-r--r--test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation.sol3
-rw-r--r--test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation_050.sol10
-rw-r--r--test/libsolidity/syntaxTests/scoping/scoping.sol3
-rw-r--r--test/libsolidity/syntaxTests/scoping/scoping_activation.sol3
-rw-r--r--test/libsolidity/syntaxTests/scoping/scoping_activation_old.sol2
-rw-r--r--test/libsolidity/syntaxTests/scoping/scoping_for.sol1
-rw-r--r--test/libsolidity/syntaxTests/scoping/scoping_for2.sol1
-rw-r--r--test/libsolidity/syntaxTests/scoping/scoping_for3.sol3
-rw-r--r--test/libsolidity/syntaxTests/scoping/scoping_for_decl_in_body.sol3
-rw-r--r--test/libsolidity/syntaxTests/scoping/scoping_old.sol2
-rw-r--r--test/libsolidity/syntaxTests/scoping/scoping_self_use.sol2
-rw-r--r--test/libsolidity/syntaxTests/scoping/scoping_self_use_050.sol8
-rw-r--r--test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol11
-rw-r--r--test/libsolidity/syntaxTests/tight_packing_literals.sol21
-rw-r--r--test/libsolidity/syntaxTests/tight_packing_literals_fine.sol14
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/warn_fill_vardecl.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/bool_ops.sol53
-rw-r--r--test/libsolidity/syntaxTests/types/bytes1_to_uint256.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/bytes32_to_uint32.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/bytes_to_contract.sol4
-rw-r--r--test/libsolidity/syntaxTests/types/bytes_to_uint_same_size.sol20
-rw-r--r--test/libsolidity/syntaxTests/types/empty_tuple_event.sol5
-rw-r--r--test/libsolidity/syntaxTests/types/empty_tuple_event_050.sol10
-rw-r--r--test/libsolidity/syntaxTests/types/index_access_for_bytes.sol6
-rw-r--r--test/libsolidity/syntaxTests/types/uint256_to_bytes1.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/uint32_to_bytes32.sol7
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/assembly.sol23
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/assembly_jump.sol7
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol18
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/call_internal_functions_fail.sol7
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/call_internal_functions_success.sol6
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/constant.sol6
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/creation.sol4
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/function_types.sol22
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/interface.sol6
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/local_storage_variables.sol19
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/mappings.sol12
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/modifiers.sol17
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/overriding.sol7
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/returning_structs.sol14
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/selector.sol8
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/selector_complex.sol11
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/selector_complex2.sol9
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/smoke_test.sol7
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/suggest_pure.sol5
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/suggest_view.sol6
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/write_storage_fail.sol6
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/write_storage_fail_v050.sol7
-rwxr-xr-xtest/solcjsTests.sh5
-rw-r--r--test/tools/CMakeLists.txt4
-rw-r--r--test/tools/isoltest.cpp137
900 files changed, 7650 insertions, 9883 deletions
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 00000000..ab452ecf
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,6 @@
+# out-of-tree builds usually go here. This helps improving performance of uploading
+# the build context to the docker image build server
+/build
+
+# in-tree builds
+/deps
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0c05208f..f30872af 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,7 @@ include(EthPolicy)
eth_policy()
# project name and version should be set after cmake_policy CMP0048
-set(PROJECT_VERSION "0.4.24")
+set(PROJECT_VERSION "0.4.25")
project(solidity VERSION ${PROJECT_VERSION})
option(SOLC_LINK_STATIC "Link solc executable statically on supported platforms" OFF)
diff --git a/Changelog.md b/Changelog.md
index 6a408ae8..1e9b2787 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,3 +1,41 @@
+### 0.5.0 (unreleased)
+
+Breaking Changes:
+ * ABI Encoder: Properly pad data from calldata (``msg.data`` and external function parameters). Use ``abi.encodePacked`` for unpadded encoding.
+ * Code Generator: Signed right shift uses proper arithmetic shift, i.e. rounding towards negative infinity. Warning: this may silently change the semantics of existing code!
+ * Commandline interface: Remove obsolete ``--formal`` option.
+ * Commandline interface: Rename the ``--julia`` option to ``--yul``.
+ * Commandline interface: Require ``-`` if standard input is used as source.
+ * General: ``continue`` in a ``do...while`` loop jumps to the condition (it used to jump to the loop body). Warning: this may silently change the semantics of existing code.
+ * General: Disallow declaring empty structs.
+ * General: Disallow raw ``callcode`` (was already deprecated in 0.4.12). It is still possible to use it via inline assembly.
+ * General: Disallow ``sha3`` and ``suicide`` aliases.
+ * General: Disallow the ``years`` unit denomination (was already deprecated in 0.4.24)
+ * General: Introduce ``emit`` as a keyword instead of parsing it as identifier.
+ * General: New keywords: ``calldata``
+ * General: New reserved keywords: ``alias``, ``apply``, ``auto``, ``copyof``, ``define``, ``immutable``,
+ ``implements``, ``macro``, ``mutable``, ``override``, ``partial``, ``promise``, ``reference``, ``sealed``,
+ ``sizeof``, ``supports``, ``typedef`` and ``unchecked``.
+ * 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.
+ * Optimizer: Remove the no-op ``PUSH1 0 NOT AND`` sequence.
+ * Parser: Disallow trailing dots that are not followed by a number.
+ * Type Checker: Disallow arithmetic operations for boolean variables.
+ * Type Checker: Disallow conversions between ``bytesX`` and ``uintY`` of different size.
+ * Remove obsolete ``std`` directory from the Solidity repository. This means accessing ``https://github.com/ethereum/soldity/blob/develop/std/*.sol`` (or ``https://github.com/ethereum/solidity/std/*.sol`` in Remix) will not be possible.
+ * Syntax Checker: Named return values in function types are an error.
+
+Language Features:
+ * General: Allow appending ``calldata`` keyword to types, to explicitly specify data location for arguments of external functions.
+ * General: Support ``pop()`` for storage arrays.
+ * General: Scoping rules now follow the C99-style.
+
+Compiler Features:
+ * Type Checker: Show named argument in case of error.
+
+Bugfixes:
+ * Tests: Fix chain parameters to make ipc tests work with newer versions of cpp-ethereum.
+
### 0.4.24 (2018-05-16)
Language Features:
diff --git a/circle.yml b/circle.yml
index 4ce3082b..30dccead 100644
--- a/circle.yml
+++ b/circle.yml
@@ -129,6 +129,7 @@ jobs:
command: |
apt-get -qq update
apt-get -qy install cmake libboost-regex-dev libboost-filesystem-dev libboost-test-dev libboost-system-dev libboost-program-options-dev libz3-dev
+ ./scripts/install_obsolete_jsoncpp_1_7_4.sh
- run: *setup_prerelease_commit_hash
- run: *run_build
- store_artifacts: *solc_artifact
@@ -150,6 +151,8 @@ jobs:
brew install z3
brew install boost
brew install cmake
+ brew install wget
+ ./scripts/install_obsolete_jsoncpp_1_7_4.sh
- run: *setup_prerelease_commit_hash
- run: *run_build
- store_artifacts: *solc_artifact
@@ -204,7 +207,7 @@ jobs:
name: Install build dependencies
command: |
apt-get -qq update
- apt-get -qy install python-sphinx
+ apt-get -qy install python-sphinx python-pip
- run: *setup_prerelease_commit_hash
- run:
name: Build documentation
diff --git a/cmake/jsoncpp.cmake b/cmake/jsoncpp.cmake
index 3d6b37ed..0c110b53 100644
--- a/cmake/jsoncpp.cmake
+++ b/cmake/jsoncpp.cmake
@@ -6,9 +6,8 @@ else()
set(JSONCPP_CMAKE_COMMAND ${CMAKE_COMMAND})
endif()
-include(GNUInstallDirs)
set(prefix "${CMAKE_BINARY_DIR}/deps")
-set(JSONCPP_LIBRARY "${prefix}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}jsoncpp${CMAKE_STATIC_LIBRARY_SUFFIX}")
+set(JSONCPP_LIBRARY "${prefix}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}jsoncpp${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(JSONCPP_INCLUDE_DIR "${prefix}/include")
if(NOT MSVC)
@@ -30,6 +29,7 @@ ExternalProject_Add(jsoncpp-project
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
+ -DCMAKE_INSTALL_LIBDIR=lib
# Build static lib but suitable to be included in a shared lib.
-DCMAKE_POSITION_INDEPENDENT_CODE=${BUILD_SHARED_LIBS}
-DJSONCPP_WITH_TESTS=OFF
diff --git a/cmake/scripts/buildinfo.cmake b/cmake/scripts/buildinfo.cmake
index efbfb8fb..9147a1b4 100644
--- a/cmake/scripts/buildinfo.cmake
+++ b/cmake/scripts/buildinfo.cmake
@@ -19,7 +19,7 @@ if (NOT ETH_BUILD_PLATFORM)
set(ETH_BUILD_PLATFORM "unknown")
endif()
-# Logic here: If prereleases.txt exists but is empty, it is a non-pre release.
+# Logic here: If prerelease.txt exists but is empty, it is a non-pre release.
# If it does not exist, create our own prerelease string
if (EXISTS ${ETH_SOURCE_DIR}/prerelease.txt)
file(READ ${ETH_SOURCE_DIR}/prerelease.txt SOL_VERSION_PRERELEASE)
diff --git a/docs/_templates/layout.html b/docs/_templates/layout.html
new file mode 100644
index 00000000..1db4ef92
--- /dev/null
+++ b/docs/_templates/layout.html
@@ -0,0 +1,6 @@
+{% extends "!layout.html" %}
+
+ {% block menu %}
+ {{ super() }}
+ <a href="genindex.html">Keyword Index</a>
+ {% endblock %}
diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst
index 8591a07f..21e67201 100644
--- a/docs/abi-spec.rst
+++ b/docs/abi-spec.rst
@@ -72,8 +72,7 @@ The following non-fixed-size types exist:
- ``<type>[]``: a variable-length array of elements of the given type.
-Types can be combined to a tuple by enclosing a finite non-negative number
-of them inside parentheses, separated by commas:
+Types can be combined to a tuple by enclosing them inside parentheses, separated by commas:
- ``(T1,T2,...,Tn)``: tuple consisting of the types ``T1``, ..., ``Tn``, ``n >= 0``
@@ -278,6 +277,106 @@ All together, the encoding is (newline after function selector and each 32-bytes
000000000000000000000000000000000000000000000000000000000000000d
48656c6c6f2c20776f726c642100000000000000000000000000000000000000
+Let us apply the same principle to encode the data for a function with a signature ``g(uint[][],string[])`` with values ``([[1, 2], [3]], ["one", "two", "three"])`` but start from the most atomic parts of the encoding:
+
+First we encode the length and data of the first embeded dynamic array ``[1, 2]`` of the first root array ``[[1, 2], [3]]``:
+
+ - ``0x0000000000000000000000000000000000000000000000000000000000000002`` (number of elements in the first array, 2; the elements themselves are ``1`` and ``2``)
+ - ``0x0000000000000000000000000000000000000000000000000000000000000001`` (first element)
+ - ``0x0000000000000000000000000000000000000000000000000000000000000002`` (second element)
+
+Then we encode the length and data of the second embeded dynamic array ``[3]`` of the first root array ``[[1, 2], [3]]``:
+
+ - ``0x0000000000000000000000000000000000000000000000000000000000000001`` (number of elements in the second array, 1; the element is ``3``)
+ - ``0x0000000000000000000000000000000000000000000000000000000000000003`` (first element)
+
+Then we need to find the offsets ``a`` and ``b`` for their respective dynamic arrays ``[1, 2]`` and ``[3]``. To calculate the offsets we can take a look at the encoded data of the first root array ``[[1, 2], [3]]`` enumerating each line in the encoding:
+
+::
+
+ 0 - a - offset of [1, 2]
+ 1 - b - offset of [3]
+ 2 - 0000000000000000000000000000000000000000000000000000000000000002 - count for [1, 2]
+ 3 - 0000000000000000000000000000000000000000000000000000000000000001 - encoding of 1
+ 4 - 0000000000000000000000000000000000000000000000000000000000000002 - encoding of 2
+ 5 - 0000000000000000000000000000000000000000000000000000000000000001 - count for [3]
+ 6 - 0000000000000000000000000000000000000000000000000000000000000003 - encoding of 3
+
+Offset ``a`` points to the start of the content of the array ``[1, 2]`` which is line 2 (64 bytes); thus ``a = 0x0000000000000000000000000000000000000000000000000000000000000040``.
+
+Offset ``b`` points to the start of the content of the array ``[3]`` which is line 5 (160 bytes); thus ``b = 0x00000000000000000000000000000000000000000000000000000000000000a0``.
+
+
+Then we encode the embeded strings of the second root array:
+
+ - ``0x0000000000000000000000000000000000000000000000000000000000000003`` (number of characters in word ``"one"``)
+ - ``0x6f6e650000000000000000000000000000000000000000000000000000000000`` (utf8 representation of word ``"one"``)
+ - ``0x0000000000000000000000000000000000000000000000000000000000000003`` (number of characters in word ``"two"``)
+ - ``0x74776f0000000000000000000000000000000000000000000000000000000000`` (utf8 representation of word ``"two"``)
+ - ``0x0000000000000000000000000000000000000000000000000000000000000005`` (number of characters in word ``"three"``)
+ - ``0x7468726565000000000000000000000000000000000000000000000000000000`` (utf8 representation of word ``"three"``)
+
+In parallel to the first root array, since strings are dynamic elements we need to find their offsets ``c``, ``d`` and ``e``:
+
+::
+
+ 0 - c - offset for "one"
+ 1 - d - offset for "two"
+ 2 - e - offset for "three"
+ 3 - 0000000000000000000000000000000000000000000000000000000000000003 - count for "one"
+ 4 - 6f6e650000000000000000000000000000000000000000000000000000000000 - encoding of "one"
+ 5 - 0000000000000000000000000000000000000000000000000000000000000003 - count for "two"
+ 6 - 74776f0000000000000000000000000000000000000000000000000000000000 - encoding of "two"
+ 7 - 0000000000000000000000000000000000000000000000000000000000000005 - count for "three"
+ 8 - 7468726565000000000000000000000000000000000000000000000000000000 - encoding of "three"
+
+Offset ``c`` points to the start of the content of the string ``"one"`` which is line 3 (96 bytes); thus ``c = 0x0000000000000000000000000000000000000000000000000000000000000060``.
+
+Offset ``d`` points to the start of the content of the string ``"two"`` which is line 5 (160 bytes); thus ``d = 0x00000000000000000000000000000000000000000000000000000000000000a0``.
+
+Offset ``e`` points to the start of the content of the string ``"three"`` which is line 7 (224 bytes); thus ``e = 0x00000000000000000000000000000000000000000000000000000000000000e0``.
+
+
+Note that the encodings of the embeded elements of the root arrays are not dependent on each other and have the same encodings for a fuction with a signature ``g(string[],uint[][])``.
+
+Then we encode the length of the first root array:
+
+ - ``0x0000000000000000000000000000000000000000000000000000000000000002`` (number of elements in the first root array, 2; the elements themselves are ``[1, 2]`` and ``[3]``)
+
+Then we encode the length of the second root array:
+
+ - ``0x0000000000000000000000000000000000000000000000000000000000000003`` (number of strings in the second root array, 3; the strings themselves are ``"one"``, ``"two"`` and ``"three"``)
+
+Finally we find the offsets ``f`` and ``g`` for their respective root dynamic arrays ``[[1, 2], [3]]`` and ``["one", "two", "three"]``, and assemble parts in the correct order:
+
+::
+
+ 0x2289b18c - function signature
+ 0 - f - offset of [[1, 2], [3]]
+ 1 - g - offset of ["one", "two", "three"]
+ 2 - 0000000000000000000000000000000000000000000000000000000000000002 - count for [[1, 2], [3]]
+ 3 - 0000000000000000000000000000000000000000000000000000000000000040 - offset of [1, 2]
+ 4 - 00000000000000000000000000000000000000000000000000000000000000a0 - offset of [3]
+ 5 - 0000000000000000000000000000000000000000000000000000000000000002 - count for [1, 2]
+ 6 - 0000000000000000000000000000000000000000000000000000000000000001 - encoding of 1
+ 7 - 0000000000000000000000000000000000000000000000000000000000000002 - encoding of 2
+ 8 - 0000000000000000000000000000000000000000000000000000000000000001 - count for [3]
+ 9 - 0000000000000000000000000000000000000000000000000000000000000003 - encoding of 3
+ 10 - 0000000000000000000000000000000000000000000000000000000000000003 - count for ["one", "two", "three"]
+ 11 - 0000000000000000000000000000000000000000000000000000000000000060 - offset for "one"
+ 12 - 00000000000000000000000000000000000000000000000000000000000000a0 - offset for "two"
+ 13 - 00000000000000000000000000000000000000000000000000000000000000e0 - offset for "three"
+ 14 - 0000000000000000000000000000000000000000000000000000000000000003 - count for "one"
+ 15 - 6f6e650000000000000000000000000000000000000000000000000000000000 - encoding of "one"
+ 16 - 0000000000000000000000000000000000000000000000000000000000000003 - count for "two"
+ 17 - 74776f0000000000000000000000000000000000000000000000000000000000 - encoding of "two"
+ 18 - 0000000000000000000000000000000000000000000000000000000000000005 - count for "three"
+ 19 - 7468726565000000000000000000000000000000000000000000000000000000 - encoding of "three"
+
+Offset ``f`` points to the start of the content of the array ``[[1, 2], [3]]`` which is line 2 (64 bytes); thus ``f = 0x0000000000000000000000000000000000000000000000000000000000000040``.
+
+Offset ``g`` points to the start of the content of the array ``["one", "two", "three"]`` which is line 10 (320 bytes); thus ``g = 0x0000000000000000000000000000000000000000000000000000000000000140``.
+
Events
======
@@ -344,7 +443,7 @@ For example,
function Test() public { b = 0x12345678901234567890123456789012; }
event Event(uint indexed a, bytes32 b);
event Event2(uint indexed a, bytes32 b);
- function foo(uint a) public { Event(a, b); }
+ function foo(uint a) public { emit Event(a, b); }
bytes32 b;
}
diff --git a/docs/assembly.rst b/docs/assembly.rst
index 443cb7da..edc826ac 100644
--- a/docs/assembly.rst
+++ b/docs/assembly.rst
@@ -115,7 +115,7 @@ you really know what you are doing.
// Iterate until the bound is not met.
for
- { let end := add(data, len) }
+ { let end := add(data, mul(len, 0x20)) }
lt(data, end)
{ data := add(data, 0x20) }
{
@@ -220,8 +220,6 @@ In the grammar, opcodes are represented as pre-defined identifiers.
+-------------------------+-----+---+-----------------------------------------------------------------+
| keccak256(p, n) | | F | keccak(mem[p...(p+n))) |
+-------------------------+-----+---+-----------------------------------------------------------------+
-| sha3(p, n) | | F | keccak(mem[p...(p+n))) |
-+-------------------------+-----+---+-----------------------------------------------------------------+
| jump(label) | `-` | F | jump to label / code position |
+-------------------------+-----+---+-----------------------------------------------------------------+
| jumpi(label, cond) | `-` | F | jump to label if cond is nonzero |
diff --git a/docs/conf.py b/docs/conf.py
index 7e107f2a..fdb67367 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -24,7 +24,7 @@ import re
def setup(sphinx):
thisdir = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, thisdir + '/utils')
- from SolidityLexer import SolidityLexer
+ from pygments_lexer_solidity import SolidityLexer
sphinx.add_lexer('Solidity', SolidityLexer())
# -- General configuration ------------------------------------------------
@@ -112,7 +112,7 @@ highlight_language = 'Solidity'
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
-html_theme = 'default'
+html_theme = 'sphinx_rtd_theme'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
diff --git a/docs/contracts.rst b/docs/contracts.rst
index b73fe2ca..5e7eab80 100644
--- a/docs/contracts.rst
+++ b/docs/contracts.rst
@@ -194,10 +194,10 @@ In the following example, ``D``, can call ``c.getData()`` to retrieve the value
contract C {
uint private data;
- function f(uint a) private returns(uint b) { return a + 1; }
+ function f(uint a) private pure returns(uint b) { return a + 1; }
function setData(uint a) public { data = a; }
- function getData() public returns(uint) { return data; }
- function compute(uint a, uint b) internal returns (uint) { return a+b; }
+ function getData() public view returns(uint) { return data; }
+ function compute(uint a, uint b) internal pure returns (uint) { return a + b; }
}
contract D {
@@ -526,9 +526,14 @@ In addition to the list of state modifying statements explained above, the follo
It is not possible to prevent functions from reading the state at the level
of the EVM, it is only possible to prevent them from writing to the state
(i.e. only ``view`` can be enforced at the EVM level, ``pure`` can not).
+ It is a non-circumventable runtime checks done by the EVM.
.. warning::
Before version 0.4.17 the compiler didn't enforce that ``pure`` is not reading the state.
+ It is a compile-time type check, which can be circumvented doing invalid explicit conversions
+ between contract types, because the compiler can verify that the type of the contract does
+ not do state-changing operations, but it cannot check that the contract that will be called
+ at runtime is actually of that type.
.. index:: ! fallback function, function;fallback
@@ -718,26 +723,22 @@ the contract can only see the last 256 block hashes.
Up to three parameters can
receive the attribute ``indexed`` which will cause the respective arguments
-to be searched for: It is possible to filter for specific values of
-indexed arguments in the user interface.
-
-If arrays (including ``string`` and ``bytes``) are used as indexed arguments, the
-Keccak-256 hash of it is stored as topic instead.
-
-The hash of the signature of the event is one of the topics except if you
+to be stored in a special data structure as so-called "topics", which allows them to be searched for,
+for example when filtering a sequence of blocks for certain events. Events can always
+be filtered by the address of the contract that emitted the event. Also,
+the hash of the signature of the event is one of the topics except if you
declared the event with ``anonymous`` specifier. This means that it is
not possible to filter for specific anonymous events by name.
-All non-indexed arguments will be stored in the data part of the log.
+If arrays (including ``string`` and ``bytes``) are used as indexed arguments, the
+Keccak-256 hash of it is stored as topic instead. This is because a topic
+can only hold a single word (32 bytes).
-.. note::
- Indexed arguments will not be stored themselves. You can only
- search for the values, but it is impossible to retrieve the
- values themselves.
+All non-indexed arguments will be :ref:`ABI-encoded <ABI>` into the data part of the log.
::
- pragma solidity ^0.4.0;
+ pragma solidity ^0.4.21;
contract ClientReceipt {
event Deposit(
@@ -769,7 +770,7 @@ The use in the JavaScript API would be as follows:
// watch for changes
event.watch(function(error, result){
// result will contain various information
- // including the argumets given to the `Deposit`
+ // including the arguments given to the `Deposit`
// call.
if (!error)
console.log(result);
@@ -802,7 +803,7 @@ as topics. The event call above can be performed in the same way as
log3(
bytes32(msg.value),
bytes32(0x50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb20),
- bytes32(msg.sender),
+ bytes32(uint256(msg.sender)),
_id
);
}
@@ -1156,11 +1157,11 @@ Interfaces
Interfaces are similar to abstract contracts, but they cannot have any functions implemented. There are further restrictions:
-#. Cannot inherit other contracts or interfaces.
-#. Cannot define constructor.
-#. Cannot define variables.
-#. Cannot define structs.
-#. Cannot define enums.
+- Cannot inherit other contracts or interfaces.
+- Cannot define constructor.
+- Cannot define variables.
+- Cannot define structs.
+- Cannot define enums.
Some of these restrictions might be lifted in the future.
@@ -1322,6 +1323,7 @@ custom types without the overhead of external function calls:
if (carry > 0) {
// too bad, we have to add a limb
uint[] memory newLimbs = new uint[](r.limbs.length + 1);
+ uint i;
for (i = 0; i < r.limbs.length; ++i)
newLimbs[i] = r.limbs[i];
newLimbs[i] = carry;
diff --git a/docs/contributing.rst b/docs/contributing.rst
index 45436b21..481aab1e 100644
--- a/docs/contributing.rst
+++ b/docs/contributing.rst
@@ -54,6 +54,8 @@ However, if you are making a larger change, please consult with the `Solidity De
<https://gitter.im/ethereum/solidity-dev>`_ (different from the one mentioned above, this on is
focused on compiler and language development instead of language use) first.
+New features and bugfixes should be added to the ``Changelog.md`` file: please
+follow the style of previous entries, when applicable.
Finally, please make sure you respect the `coding style
<https://raw.githubusercontent.com/ethereum/solidity/develop/CODING_STYLE.md>`_
@@ -111,7 +113,7 @@ Example: ``./test/libsolidity/syntaxTests/double_stateVariable_declaration.sol``
A syntax test must contain at least the contract under test itself, followed by the seperator ``----``. The additional comments above are used to describe the
expected compiler errors or warnings. This section can be empty in case that the contract should compile without any errors or warnings.
-In the above example, the state variable ``variable`` was declared twice, which is not allowed. This will result in a ``DeclarationError`` stating that the identifer was already declared.
+In the above example, the state variable ``variable`` was declared twice, which is not allowed. This will result in a ``DeclarationError`` stating that the identifier was already declared.
The tool that is being used for those tests is called ``isoltest`` and can be found under ``./test/tools/``. It is an interactive tool which allows
editing of failing contracts using your prefered text editor. Let's try to break this test by removing the second declaration of ``variable``:
diff --git a/docs/control-structures.rst b/docs/control-structures.rst
index 7849d15a..cc1f7ca5 100644
--- a/docs/control-structures.rst
+++ b/docs/control-structures.rst
@@ -325,74 +325,7 @@ is ``false``. The default value for the ``uint`` or ``int`` types is ``0``. For
element will be initialized to the default value corresponding to its type. Finally, for dynamically-sized arrays, ``bytes``
and ``string``, the default value is an empty array or string.
-A variable declared anywhere within a function will be in scope for the *entire function*, regardless of where it is declared
-(this will change soon, see below).
-This happens because Solidity inherits its scoping rules from JavaScript.
-This is in contrast to many languages where variables are only scoped where they are declared until the end of the semantic block.
-As a result, the following code is illegal and cause the compiler to throw an error, ``Identifier already declared``:
-
-::
-
- // This will not compile
-
- pragma solidity ^0.4.16;
-
- contract ScopingErrors {
- function scoping() public {
- uint i = 0;
-
- while (i++ < 1) {
- uint same1 = 0;
- }
-
- while (i++ < 2) {
- uint same1 = 0;// Illegal, second declaration of same1
- }
- }
-
- function minimalScoping() public {
- {
- uint same2 = 0;
- }
-
- {
- uint same2 = 0;// Illegal, second declaration of same2
- }
- }
-
- function forLoopScoping() public {
- for (uint same3 = 0; same3 < 1; same3++) {
- }
-
- for (uint same3 = 0; same3 < 1; same3++) {// Illegal, second declaration of same3
- }
- }
- }
-
-In addition to this, if a variable is declared, it will be initialized at the beginning of the function to its default value.
-As a result, the following code is legal, despite being poorly written:
-
-::
-
- pragma solidity ^0.4.0;
-
- contract C {
- function foo() public pure returns (uint) {
- // baz is implicitly initialized as 0
- uint bar = 5;
- if (true) {
- bar += baz;
- } else {
- uint baz = 10;// never executes
- }
- return bar;// returns 5
- }
- }
-
-Scoping starting from Version 0.5.0
------------------------------------
-
-Starting from version 0.5.0, Solidity will change to the more widespread scoping rules of C99
+Scoping in Solidity follows the widespread scoping rules of C99
(and many other languages): Variables are visible from the point right after their declaration
until the end of a ``{ }``-block. As an exception to this rule, variables declared in the
initialization part of a for-loop are only visible until the end of the for-loop.
@@ -401,17 +334,12 @@ Variables and other items declared outside of a code block, for example function
user-defined types, etc., do not change their scoping behaviour. This means you can
use state variables before they are declared and call functions recursively.
-These rules are already introduced now as an experimental feature.
-
As a consequence, the following examples will compile without warnings, since
-the two variables have the same name but disjoint scopes. In non-0.5.0-mode,
-they have the same scope (the function ``minimalScoping``) and thus it does
-not compile there.
+the two variables have the same name but disjoint scopes.
::
- pragma solidity ^0.4.0;
- pragma experimental "v0.5.0";
+ pragma solidity >0.4.24;
contract C {
function minimalScoping() pure public {
{
@@ -430,8 +358,7 @@ In any case, you will get a warning about the outer variable being shadowed.
::
- pragma solidity ^0.4.0;
- pragma experimental "v0.5.0";
+ pragma solidity >0.4.24;
contract C {
function f() pure public returns (uint) {
uint x = 1;
@@ -443,6 +370,24 @@ In any case, you will get a warning about the outer variable being shadowed.
}
}
+.. warning::
+ Before version 0.5.0 Solidity followed the same scoping rules as JavaScript, that is, a variable declared anywhere within a function would be in scope
+ for the entire function, regardless where it was declared. Note that this is a breaking change. The following example shows a code snippet that used
+ to compile but leads to an error starting from version 0.5.0.
+
+ ::
+
+ // This will not compile
+
+ pragma solidity >0.4.24;
+ contract C {
+ function f() pure public returns (uint) {
+ x = 2;
+ uint x;
+ return x;
+ }
+ }
+
.. index:: ! exception, ! throw, ! assert, ! require, ! revert
Error handling: Assert, Require, Revert and Exceptions
diff --git a/docs/grammar.txt b/docs/grammar.txt
index 0dda4f49..5d977827 100644
--- a/docs/grammar.txt
+++ b/docs/grammar.txt
@@ -57,7 +57,7 @@ Mapping = 'mapping' '(' ElementaryTypeName '=>' TypeName ')'
ArrayTypeName = TypeName '[' Expression? ']'
FunctionTypeName = 'function' FunctionTypeParameterList ( 'internal' | 'external' | StateMutability )*
( 'returns' FunctionTypeParameterList )?
-StorageLocation = 'memory' | 'storage'
+StorageLocation = 'memory' | 'storage' | 'calldata'
StateMutability = 'pure' | 'constant' | 'view' | 'payable'
Block = '{' Statement* '}'
diff --git a/docs/index.rst b/docs/index.rst
index 80b0d6e7..a57b93e4 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -169,7 +169,7 @@ Contents
using-the-compiler.rst
metadata.rst
abi-spec.rst
- julia.rst
+ yul.rst
style-guide.rst
common-patterns.rst
bugs.rst
diff --git a/docs/introduction-to-smart-contracts.rst b/docs/introduction-to-smart-contracts.rst
index d1789c44..71f9bd8e 100644
--- a/docs/introduction-to-smart-contracts.rst
+++ b/docs/introduction-to-smart-contracts.rst
@@ -33,7 +33,7 @@ Storage
The first line simply tells that the source code is written for
Solidity version 0.4.0 or anything newer that does not break functionality
(up to, but not including, version 0.5.0). This is to ensure that the
-contract does not suddenly behave differently with a new compiler version. The keyword ``pragma`` is called that way because, in general,
+contract does not suddenly behave differently with a new compiler version. The keyword ``pragma`` is called that because, in general,
pragmas are instructions for the compiler about how to treat the
source code (e.g. `pragma once <https://en.wikipedia.org/wiki/Pragma_once>`_).
@@ -62,7 +62,7 @@ so that only you can alter the number.
the ASCII character set. It is possible to store UTF-8 encoded data in string variables.
.. warning::
- Be careful with using Unicode text as similarly looking (or even identical) characters can
+ Be careful with using Unicode text, as similar looking (or even identical) characters can
have different code points and as such will be encoded as a different byte array.
.. index:: ! subcurrency
@@ -75,7 +75,7 @@ cryptocurrency. It is possible to generate coins out of thin air, but
only the person that created the contract will be able to do that (it is trivial
to implement a different issuance scheme).
Furthermore, anyone can send coins to each other without any need for
-registering with username and password - all you need is an Ethereum keypair.
+registering with username and password — all you need is an Ethereum keypair.
::
@@ -88,7 +88,7 @@ registering with username and password - all you need is an Ethereum keypair.
address public minter;
mapping (address => uint) public balances;
- // Events allow light clients to react on
+ // Events allow light clients to react to
// changes efficiently.
event Sent(address from, address to, uint amount);
diff --git a/docs/layout-of-source-files.rst b/docs/layout-of-source-files.rst
index f9d197b7..81faf816 100644
--- a/docs/layout-of-source-files.rst
+++ b/docs/layout-of-source-files.rst
@@ -198,7 +198,7 @@ for the two input parameters and two returned values.
pragma solidity ^0.4.0;
/** @title Shape calculator. */
- contract shapeCalculator {
+ contract ShapeCalculator {
/** @dev Calculates a rectangle's surface and perimeter.
* @param w Width of the rectangle.
* @param h Height of the rectangle.
diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst
index c7c32528..f6cfdc2c 100644
--- a/docs/miscellaneous.rst
+++ b/docs/miscellaneous.rst
@@ -79,6 +79,7 @@ Solidity always places new objects at the free memory pointer and memory is neve
.. warning::
There are some operations in Solidity that need a temporary memory area larger than 64 bytes and therefore will not fit into the scratch space. They will be placed where the free memory points to, but given their short lifecycle, the pointer is not updated. The memory may or may not be zeroed out. Because of this, one shouldn't expect the free memory to be zeroed out.
+ While it may seem like a good idea to use ``msize`` to arrive at a definitely zeroed out memory area, using such a pointer non-temporarily without updating the free memory pointer can have adverse results.
.. index: calldata layout
@@ -190,7 +191,7 @@ important for static analysis tools that operate on bytecode level and
for displaying the current position in the source code inside a debugger
or for breakpoint handling.
-Both kinds of source mappings use integer indentifiers to refer to source files.
+Both kinds of source mappings use integer identifiers to refer to source files.
These are regular array indices into a list of source files usually called
``"sourceList"``, which is part of the combined-json and the output of
the json / npm compiler.
@@ -409,8 +410,11 @@ Reserved Keywords
These keywords are reserved in Solidity. They might become part of the syntax in the future:
-``abstract``, ``after``, ``case``, ``catch``, ``default``, ``final``, ``in``, ``inline``, ``let``, ``match``, ``null``,
-``of``, ``relocatable``, ``static``, ``switch``, ``try``, ``type``, ``typeof``.
+``abstract``, ``after``, ``alias``, ``apply``, ``auto``, ``case``, ``catch``, ``copyof``, ``default``,
+``define``, ``final``, ``immutable``, ``implements``, ``in``, ``inline``, ``let``, ``macro``, ``match``,
+``mutable``, ``null``, ``of``, ``override``, ``partial``, ``promise``, ``reference``, ``relocatable``,
+``sealed``, ``sizeof``, ``static``, ``supports``, ``switch``, ``try``, ``type``, ``typedef``, ``typeof``,
+``unchecked``.
Language Grammar
================
diff --git a/docs/requirements.txt b/docs/requirements.txt
index 0607b1ef..5fba631c 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -1 +1,2 @@
sphinx_rtd_theme>=0.3.1
+pygments-lexer-solidity>=0.3.1
diff --git a/docs/solidity-by-example.rst b/docs/solidity-by-example.rst
index 2b3d4b48..e8fddd61 100644
--- a/docs/solidity-by-example.rst
+++ b/docs/solidity-by-example.rst
@@ -496,7 +496,7 @@ high or low invalid bids.
if (value <= highestBid) {
return false;
}
- if (highestBidder != 0) {
+ if (highestBidder != address(0)) {
// Refund the previously highest bidder.
pendingReturns[highestBidder] += highestBid;
}
diff --git a/docs/types.rst b/docs/types.rst
index 5c20dc67..009896d5 100644
--- a/docs/types.rst
+++ b/docs/types.rst
@@ -60,15 +60,14 @@ operators are :ref:`literals<rational_literals>` (or literal expressions).
Division by zero and modulus with zero throws a runtime exception.
The result of a shift operation is the type of the left operand. The
-expression ``x << y`` is equivalent to ``x * 2**y``, and ``x >> y`` is
-equivalent to ``x / 2**y``. This means that shifting negative numbers
-sign extends. Shifting by a negative amount throws a runtime exception.
+expression ``x << y`` is equivalent to ``x * 2**y``, and, for positive integers,
+``x >> y`` is equivalent to ``x / 2**y``. For negative ``x``, ``x >> y``
+is equivalent to dividing by a power of ``2`` while rounding down (towards negative infinity).
+Shifting by a negative amount throws a runtime exception.
.. warning::
- The results produced by shift right of negative values of signed integer types is different from those produced
- by other programming languages. In Solidity, shift right maps to division so the shifted negative values
- are going to be rounded towards zero (truncated). In other programming languages the shift right of negative values
- works like division with rounding down (towards negative infinity).
+ Before version ``0.5.0`` a right shift ``x >> y`` for negative ``x`` was equivalent to ``x / 2**y``,
+ i.e. right shifts used rounding towards zero instead of rounding towards negative infinity.
.. index:: ! ufixed, ! fixed, ! fixed point number
@@ -226,10 +225,6 @@ Dynamically-sized byte array
``string``:
Dynamically-sized UTF-8-encoded string, see :ref:`arrays`. Not a value-type!
-As a rule of thumb, use ``bytes`` for arbitrary-length raw byte data and ``string``
-for arbitrary-length string (UTF-8) data. If you can limit the length to a certain
-number of bytes, always use one of ``bytes1`` to ``bytes32`` because they are much cheaper.
-
.. index:: address, literal;address
.. _address_literals:
@@ -602,8 +597,10 @@ shaves off one level in the type from the right).
Variables of type ``bytes`` and ``string`` are special arrays. A ``bytes`` is similar to ``byte[]``,
but it is packed tightly in calldata. ``string`` is equal to ``bytes`` but does not allow
length or index access (for now).
-
So ``bytes`` should always be preferred over ``byte[]`` because it is cheaper.
+As a rule of thumb, use ``bytes`` for arbitrary-length raw byte data and ``string``
+for arbitrary-length string (UTF-8) data. If you can limit the length to a certain
+number of bytes, always use one of ``bytes1`` to ``bytes32`` because they are much cheaper.
.. note::
If you want to access the byte-representation of a string ``s``, use
@@ -675,14 +672,14 @@ possible:
function f() public {
// The next line creates a type error because uint[3] memory
// cannot be converted to uint[] memory.
- uint[] x = [uint(1), 3, 4];
+ uint[] memory x = [uint(1), 3, 4];
}
}
It is planned to remove this restriction in the future but currently creates
some complications because of how arrays are passed in the ABI.
-.. index:: ! array;length, length, push, !array;push
+.. index:: ! array;length, length, push, pop, !array;push, !array;pop
Members
^^^^^^^
@@ -693,6 +690,8 @@ Members
``.length`` member. This does not happen automatically when attempting to access elements outside the current length. The size of memory arrays is fixed (but dynamic, i.e. it can depend on runtime parameters) once they are created.
**push**:
Dynamic storage arrays and ``bytes`` (not ``string``) have a member function called ``push`` that can be used to append an element at the end of the array. The function returns the new length.
+**pop**:
+ Dynamic storage arrays and ``bytes`` (not ``string``) have a member function called ``pop`` that can be used to remove an element from the end of the array.
.. warning::
It is not yet possible to use arrays of arrays in external functions.
@@ -762,7 +761,7 @@ Members
// Create a dynamic byte array:
bytes memory b = new bytes(200);
for (uint i = 0; i < b.length; i++)
- b[i] = byte(i);
+ b[i] = byte(uint8(i));
return b;
}
}
@@ -975,6 +974,15 @@ cut off::
uint32 a = 0x12345678;
uint16 b = uint16(a); // b will be 0x5678 now
+Since 0.5.0 explicit conversions between integers and fixed-size byte arrays
+are only allowed, if both have the same size. To convert between integers and
+fixed-size byte arrays of different size, they first have to be explicitly
+converted to a matching size. This makes alignment and padding explicit::
+
+ uint16 x = 0xffff;
+ bytes32(uint256(x)); // pad on the left
+ bytes32(bytes2(x)); // pad on the right
+
.. index:: ! type;deduction, ! var
.. _type-deduction:
diff --git a/docs/units-and-global-variables.rst b/docs/units-and-global-variables.rst
index a6f8ca87..3b0be438 100644
--- a/docs/units-and-global-variables.rst
+++ b/docs/units-and-global-variables.rst
@@ -32,7 +32,7 @@ Due to the fact that leap seconds cannot be predicted, an exact calendar
library has to be updated by an external oracle.
.. note::
- The suffix ``years`` has been deprecated due to the reasons above.
+ The suffix ``years`` has been deprecated due to the reasons above and cannot be used starting version 0.5.0.
These suffixes cannot be applied to variables. If you want to
interpret some input variable in e.g. days, you can do it in the following way::
diff --git a/docs/utils/SolidityLexer.py b/docs/utils/SolidityLexer.py
deleted file mode 100644
index 50f51cf4..00000000
--- a/docs/utils/SolidityLexer.py
+++ /dev/null
@@ -1,82 +0,0 @@
-# -*- coding: utf-8 -*-
-
-import re
-import copy
-
-from pygments.lexer import RegexLexer, ExtendedRegexLexer, bygroups, using, \
- include, this
-from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
- Number, Other, Punctuation, Literal
-
-__all__ = ['SolidityLexer']
-
-class SolidityLexer(RegexLexer):
- name = "Solidity"
- aliases = ['sol', 'solidity']
- filenames = ['*.sol']
- mimetypes = []
- flags = re.DOTALL
- tokens = {
- 'commentsandwhitespace': [
- (r'\s+', Text),
- (r'<!--', Comment),
- (r'///', Comment.Special, 'docstringsingle'),
- (r'//.*?\n', Comment.Single),
- (r'/\*\*', Comment.Special, 'docstringmulti'),
- (r'/\*.*?\*/', Comment.Multiline)
- ],
- 'natspec': [
- (r'@author|@dev|@notice|@return|@param|@title', Keyword),
- (r'.[^@*\n]*?', Comment.Special)
- ],
- 'docstringsingle': [
- (r'\n', Comment.Special, '#pop'),
- include('natspec')
- ],
- 'docstringmulti': [
- (r'\*/', Comment.Special, '#pop'),
- include('natspec')
- ],
- 'slashstartsregex': [
- include('commentsandwhitespace'),
- (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
- r'([gim]+\b|\B)', String.Regex, '#pop'),
- (r'(?=/)', Text, ('#pop', 'badregex')),
- (r'', Text, '#pop')
- ],
- 'badregex': [
- (r'\n', Text, '#pop')
- ],
- 'root': [
- (r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
- include('commentsandwhitespace'),
- (r'\+\+|--|\*\*|~|&&|\?|:|\|\||\\(?=\n)|'
- r'(<<|>>>?|==?|!=?|[-<>+*%&\|\^/])=?', Operator, 'slashstartsregex'),
- (r'[{(\[;,]', Punctuation, 'slashstartsregex'),
- (r'[})\].]', Punctuation),
- (r'(anonymous|as|assembly|break|constant|continue|do|delete|else|external|for|hex|if|'
- r'indexed|internal|import|is|mapping|memory|new|payable|public|pragma|'
- r'private|pure|return|returns|storage|super|this|throw|using|view|while)\b', Keyword, 'slashstartsregex'),
- (r'(var|function|event|modifier|struct|enum|contract|library|interface)\b', Keyword.Declaration, 'slashstartsregex'),
- (r'(bytes|string|address|uint|int|bool|byte|' +
- '|'.join(
- ['uint%d' % (i + 8) for i in range(0, 256, 8)] +
- ['int%d' % (i + 8) for i in range(0, 256, 8)] +
- ['bytes%d' % (i + 1) for i in range(0, 32)] +
- ['ufixed%dx%d' % ((i), (j + 8)) for i in range(0, 256, 8) for j in range(0, 256 - i, 8)] +
- ['fixed%dx%d' % ((i), (j + 8)) for i in range(0, 256, 8) for j in range(0, 256 - i, 8)]
- ) + r')\b', Keyword.Type, 'slashstartsregex'),
- (r'(wei|szabo|finney|ether|seconds|minutes|hours|days|weeks|years)\b', Keyword.Type, 'slashstartsregex'),
- (r'(abstract|after|case|catch|default|final|in|inline|let|match|'
- r'null|of|relocatable|static|switch|try|type|typeof)\b', Keyword.Reserved),
- (r'(true|false)\b', Keyword.Constant),
- (r'(block|msg|tx|now|suicide|selfdestruct|addmod|mulmod|sha3|keccak256|log[0-4]|'
- r'sha256|ecrecover|ripemd160|assert|revert|require)', Name.Builtin),
- (r'[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
- (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?', Number.Float),
- (r'0x[0-9a-fA-F]+', Number.Hex),
- (r'[0-9]+([eE][0-9]+)?', Number.Integer),
- (r'"(\\\\|\\"|[^"])*"', String.Double),
- (r"'(\\\\|\\'|[^'])*'", String.Single),
- ]
- }
diff --git a/docs/julia.rst b/docs/yul.rst
index c9b73db2..4f5ef98f 100644
--- a/docs/julia.rst
+++ b/docs/yul.rst
@@ -1,18 +1,19 @@
-#################################################
-Joyfully Universal Language for (Inline) Assembly
-#################################################
+###
+Yul
+###
-.. _julia:
+.. _yul:
-.. index:: ! assembly, ! asm, ! evmasm, ! julia
+.. index:: ! assembly, ! asm, ! evmasm, ! yul, julia, iulia
-JULIA is an intermediate language that can compile to various different backends
+Yul (previously also called JULIA or IULIA) is an intermediate language that can
+compile to various different backends
(EVM 1.0, EVM 1.5 and eWASM are planned).
Because of that, it is designed to be a usable common denominator of all three
platforms.
It can already be used for "inline assembly" inside Solidity and
-future versions of the Solidity compiler will even use JULIA as intermediate
-language. It should also be easy to build high-level optimizer stages for JULIA.
+future versions of the Solidity compiler will even use Yul as intermediate
+language. It should also be easy to build high-level optimizer stages for Yul.
.. note::
@@ -21,14 +22,14 @@ language. It should also be easy to build high-level optimizer stages for JULIA.
to the EVM opcodes. Please resort to the inline assembly documentation
for details.
-The core components of JULIA are functions, blocks, variables, literals,
+The core components of Yul are functions, blocks, variables, literals,
for-loops, if-statements, switch-statements, expressions and assignments to variables.
-JULIA is typed, both variables and literals must specify the type with postfix
+Yul is typed, both variables and literals must specify the type with postfix
notation. The supported types are ``bool``, ``u8``, ``s8``, ``u32``, ``s32``,
``u64``, ``s64``, ``u128``, ``s128``, ``u256`` and ``s256``.
-JULIA in itself does not even provide operators. If the EVM is targeted,
+Yul in itself does not even provide operators. If the EVM is targeted,
opcodes will be available as built-in functions, but they can be reimplemented
if the backend changes. For a list of mandatory built-in functions, see the section below.
@@ -69,10 +70,10 @@ and ``add`` to be available.
}
}
-Specification of JULIA
-======================
+Specification of Yul
+====================
-JULIA code is described in this chapter. JULIA code is usually placed into a JULIA object, which is described in the following chapter.
+This chapter describes Yul code. It is usually placed inside a Yul object, which is described in the following chapter.
Grammar::
@@ -156,7 +157,7 @@ Literals cannot be larger than the their type. The largest type defined is 256-b
Scoping Rules
-------------
-Scopes in JULIA are tied to Blocks (exceptions are functions and the for loop
+Scopes in Yul are tied to Blocks (exceptions are functions and the for loop
as explained below) and all declarations
(``FunctionDefinition``, ``VariableDeclaration``)
introduce new identifiers into these scopes.
@@ -186,7 +187,7 @@ outside of that function.
Formal Specification
--------------------
-We formally specify JULIA by providing an evaluation function E overloaded
+We formally specify Yul by providing an evaluation function E overloaded
on the various nodes of the AST. Any functions can have side effects, so
E takes two state objects and the AST node and returns two new
state objects and a variable number of other values.
@@ -303,7 +304,7 @@ We will use a destructuring notation for the AST nodes.
Type Conversion Functions
-------------------------
-JULIA has no support for implicit type conversion and therefore functions exists to provide explicit conversion.
+Yul has no support for implicit type conversion and therefore functions exist to provide explicit conversion.
When converting a larger type to a shorter type a runtime exception can occur in case of an overflow.
Truncating conversions are supported between the following types:
@@ -507,7 +508,7 @@ The following functions must be available:
Backends
--------
-Backends or targets are the translators from JULIA to a specific bytecode. Each of the backends can expose functions
+Backends or targets are the translators from Yul to a specific bytecode. Each of the backends can expose functions
prefixed with the name of the backend. We reserve ``evm_`` and ``ewasm_`` prefixes for the two proposed backends.
Backend: EVM
@@ -525,8 +526,8 @@ Backend: eWASM
TBD
-Specification of JULIA Object
-=============================
+Specification of Yul Object
+===========================
Grammar::
@@ -537,11 +538,11 @@ Grammar::
HexLiteral = 'hex' ('"' ([0-9a-fA-F]{2})* '"' | '\'' ([0-9a-fA-F]{2})* '\'')
StringLiteral = '"' ([^"\r\n\\] | '\\' .)* '"'
-Above, ``Block`` refers to ``Block`` in the JULIA code grammar explained in the previous chapter.
+Above, ``Block`` refers to ``Block`` in the Yul code grammar explained in the previous chapter.
-An example JULIA Object is shown below:
+An example Yul Object is shown below:
-..code::
+.. code::
// Code consists of a single object. A single "code" node is the code of the object.
// Every (other) named object or data section is serialized and
diff --git a/libevmasm/PeepholeOptimiser.cpp b/libevmasm/PeepholeOptimiser.cpp
index 8a39de24..6d8e1df6 100644
--- a/libevmasm/PeepholeOptimiser.cpp
+++ b/libevmasm/PeepholeOptimiser.cpp
@@ -249,6 +249,23 @@ struct TagConjunctions: SimplePeepholeOptimizerMethod<TagConjunctions, 3>
}
};
+struct TruthyAnd: SimplePeepholeOptimizerMethod<TruthyAnd, 3>
+{
+ static bool applySimple(
+ AssemblyItem const& _push,
+ AssemblyItem const& _not,
+ AssemblyItem const& _and,
+ std::back_insert_iterator<AssemblyItems>
+ )
+ {
+ return (
+ _push.type() == Push && _push.data() == 0 &&
+ _not == Instruction::NOT &&
+ _and == Instruction::AND
+ );
+ }
+};
+
/// Removes everything after a JUMP (or similar) until the next JUMPDEST.
struct UnreachableCode
{
@@ -305,7 +322,7 @@ bool PeepholeOptimiser::optimise()
{
OptimiserState state {m_items, 0, std::back_inserter(m_optimisedItems)};
while (state.i < m_items.size())
- applyMethods(state, PushPop(), OpPop(), DoublePush(), DoubleSwap(), CommutativeSwap(), SwapComparison(), JumpToNext(), UnreachableCode(), TagConjunctions(), Identity());
+ applyMethods(state, PushPop(), OpPop(), DoublePush(), DoubleSwap(), CommutativeSwap(), SwapComparison(), JumpToNext(), UnreachableCode(), TagConjunctions(), TruthyAnd(), Identity());
if (m_optimisedItems.size() < m_items.size() || (
m_optimisedItems.size() == m_items.size() && (
eth::bytesRequired(m_optimisedItems, 3) < eth::bytesRequired(m_items, 3) ||
diff --git a/libjulia/Exceptions.h b/libjulia/Exceptions.h
index 20ab6520..48624a56 100644
--- a/libjulia/Exceptions.h
+++ b/libjulia/Exceptions.h
@@ -15,7 +15,7 @@
along with solidity. If not, see <http://www.gnu.org/licenses/>.
*/
/**
- * Exceptions in Julia.
+ * Exceptions in Yul.
*/
#pragma once
@@ -28,8 +28,8 @@ namespace dev
namespace julia
{
-struct IuliaException: virtual Exception {};
-struct OptimizerException: virtual IuliaException {};
+struct YulException: virtual Exception {};
+struct OptimizerException: virtual YulException {};
}
}
diff --git a/libjulia/backends/evm/AbstractAssembly.h b/libjulia/backends/evm/AbstractAssembly.h
index 8e90a912..46fa7796 100644
--- a/libjulia/backends/evm/AbstractAssembly.h
+++ b/libjulia/backends/evm/AbstractAssembly.h
@@ -42,7 +42,7 @@ namespace julia
{
///
-/// Assembly class that abstracts both the libevmasm assembly and the new julia evm assembly.
+/// Assembly class that abstracts both the libevmasm assembly and the new Yul assembly.
///
class AbstractAssembly
{
diff --git a/libjulia/backends/evm/EVMCodeTransform.cpp b/libjulia/backends/evm/EVMCodeTransform.cpp
index 2a97429b..ba2d7f75 100644
--- a/libjulia/backends/evm/EVMCodeTransform.cpp
+++ b/libjulia/backends/evm/EVMCodeTransform.cpp
@@ -15,7 +15,7 @@
along with solidity. If not, see <http://www.gnu.org/licenses/>.
*/
/**
- * Common code generator for translating Julia / inline assembly to EVM and EVM1.5.
+ * Common code generator for translating Yul / inline assembly to EVM and EVM1.5.
*/
#include <libjulia/backends/evm/EVMCodeTransform.h>
@@ -331,7 +331,7 @@ void CodeTransform::operator()(FunctionDefinition const& _function)
CodeTransform(
m_assembly,
m_info,
- m_julia,
+ m_yul,
m_evm15,
m_identifierAccess,
m_useNamedLabelsForFunctions,
diff --git a/libjulia/backends/evm/EVMCodeTransform.h b/libjulia/backends/evm/EVMCodeTransform.h
index f8eec0b7..ed0785d3 100644
--- a/libjulia/backends/evm/EVMCodeTransform.h
+++ b/libjulia/backends/evm/EVMCodeTransform.h
@@ -15,7 +15,7 @@
along with solidity. If not, see <http://www.gnu.org/licenses/>.
*/
/**
- * Common code generator for translating Julia / inline assembly to EVM and EVM1.5.
+ * Common code generator for translating Yul / inline assembly to EVM and EVM1.5.
*/
#include <libjulia/backends/evm/EVMAssembly.h>
@@ -49,14 +49,14 @@ public:
CodeTransform(
julia::AbstractAssembly& _assembly,
solidity::assembly::AsmAnalysisInfo& _analysisInfo,
- bool _julia = false,
+ bool _yul = false,
bool _evm15 = false,
ExternalIdentifierAccess const& _identifierAccess = ExternalIdentifierAccess(),
bool _useNamedLabelsForFunctions = false
): CodeTransform(
_assembly,
_analysisInfo,
- _julia,
+ _yul,
_evm15,
_identifierAccess,
_useNamedLabelsForFunctions,
@@ -78,7 +78,7 @@ protected:
CodeTransform(
julia::AbstractAssembly& _assembly,
solidity::assembly::AsmAnalysisInfo& _analysisInfo,
- bool _julia,
+ bool _yul,
bool _evm15,
ExternalIdentifierAccess const& _identifierAccess,
bool _useNamedLabelsForFunctions,
@@ -87,7 +87,7 @@ protected:
):
m_assembly(_assembly),
m_info(_analysisInfo),
- m_julia(_julia),
+ m_yul(_yul),
m_evm15(_evm15),
m_useNamedLabelsForFunctions(_useNamedLabelsForFunctions),
m_identifierAccess(_identifierAccess),
@@ -142,7 +142,7 @@ private:
julia::AbstractAssembly& m_assembly;
solidity::assembly::AsmAnalysisInfo& m_info;
solidity::assembly::Scope* m_scope = nullptr;
- bool m_julia = false;
+ bool m_yul = false;
bool m_evm15 = false;
bool m_useNamedLabelsForFunctions = false;
ExternalIdentifierAccess m_identifierAccess;
diff --git a/libjulia/optimiser/ASTCopier.h b/libjulia/optimiser/ASTCopier.h
index 8681f2e0..cb2925e3 100644
--- a/libjulia/optimiser/ASTCopier.h
+++ b/libjulia/optimiser/ASTCopier.h
@@ -62,7 +62,7 @@ public:
};
/**
- * Creates a copy of a iulia AST potentially replacing identifier names.
+ * Creates a copy of a Yul AST potentially replacing identifier names.
* Base class to be extended.
*/
class ASTCopier: public ExpressionCopier, public StatementCopier
diff --git a/libjulia/optimiser/DataFlowAnalyzer.cpp b/libjulia/optimiser/DataFlowAnalyzer.cpp
index 25f0ffb4..0ad0eac9 100644
--- a/libjulia/optimiser/DataFlowAnalyzer.cpp
+++ b/libjulia/optimiser/DataFlowAnalyzer.cpp
@@ -15,7 +15,7 @@
along with solidity. If not, see <http://www.gnu.org/licenses/>.
*/
/**
- * Base class to perform data flaw analysis during AST walks.
+ * Base class to perform data flow analysis during AST walks.
* Tracks assignments and is used as base class for both Rematerialiser and
* Common Subexpression Eliminator.
*/
diff --git a/libjulia/optimiser/Disambiguator.h b/libjulia/optimiser/Disambiguator.h
index 6fc8a615..4ef43736 100644
--- a/libjulia/optimiser/Disambiguator.h
+++ b/libjulia/optimiser/Disambiguator.h
@@ -38,7 +38,7 @@ namespace julia
{
/**
- * Creates a copy of a iulia AST replacing all identifiers by unique names.
+ * Creates a copy of a Yul AST replacing all identifiers by unique names.
*/
class Disambiguator: public ASTCopier
{
diff --git a/libjulia/optimiser/README.md b/libjulia/optimiser/README.md
index e8aa777a..b1ce8931 100644
--- a/libjulia/optimiser/README.md
+++ b/libjulia/optimiser/README.md
@@ -1,6 +1,6 @@
-## IULIA Optimiser
+## Yul Optimiser
-The iulia optimiser consists of several stages and components that all transform
+The Yul optimiser consists of several stages and components that all transform
the AST in a semantically equivalent way. The goal is to end up either with code
that is shorter or at least only marginally longer but will allow further
optimisation steps.
@@ -25,13 +25,13 @@ a semantically equivalent transformation as long as it is performed after the
disambiguation stage. The reason is that moving a definition upwards cannot decrease
its visibility and it is impossible to reference variables defined in a different function.
-The benefit of this stage is that function definitions can be lookup up more easily.
+The benefit of this stage is that function definitions can be looked up more easily.
## Function Grouper
The function grouper has to be applied after the disambiguator and the function hoister.
Its effect is that all topmost elements that are not function definitions are moved
-into a single block which is the first satement of the root block.
+into a single block which is the first statement of the root block.
After this step, a program has the following normal form:
@@ -81,7 +81,7 @@ a loop or conditional, the first one is not inside), the first assignment is rem
## Expression Simplifier
-This step can only be applied for the EVM-flavoured dialect of iulia. It applies
+This step can only be applied for the EVM-flavoured dialect of Yul. It applies
simple rules like ``x + 0 == x`` to simplify expressions.
## Ineffective Statement Remover
diff --git a/libjulia/optimiser/UnusedPruner.cpp b/libjulia/optimiser/UnusedPruner.cpp
index 54e8fd6e..af503712 100644
--- a/libjulia/optimiser/UnusedPruner.cpp
+++ b/libjulia/optimiser/UnusedPruner.cpp
@@ -59,7 +59,7 @@ void UnusedPruner::operator()(Block& _block)
// Multi-variable declarations are special. We can only remove it
// if all vairables are unused and the right-hand-side is either
// movable or it return a single value. In the latter case, we
- // replace `let a := f()` by `pop(f())` (in pure IULIA, this will be
+ // replace `let a := f()` by `pop(f())` (in pure Yul, this will be
// `drop(f())`).
if (boost::algorithm::none_of(
varDecl.variables,
@@ -74,7 +74,7 @@ void UnusedPruner::operator()(Block& _block)
statement = Block{std::move(varDecl.location), {}};
}
else if (varDecl.variables.size() == 1)
- // In pure IULIA, this should be replaced by a function call to `drop`
+ // In pure Yul, this should be replaced by a function call to `drop`
// instead of `pop`.
statement = ExpressionStatement{varDecl.location, FunctionalInstruction{
varDecl.location,
diff --git a/libsolidity/analysis/ControlFlowBuilder.cpp b/libsolidity/analysis/ControlFlowBuilder.cpp
index 35d7687c..5bd39da3 100644
--- a/libsolidity/analysis/ControlFlowBuilder.cpp
+++ b/libsolidity/analysis/ControlFlowBuilder.cpp
@@ -159,15 +159,14 @@ bool ControlFlowBuilder::visit(WhileStatement const& _whileStatement)
{
auto afterWhile = newLabel();
auto whileBody = createLabelHere();
+ auto condition = newLabel();
{
- // Note that "continue" in this case currently indeed jumps to whileBody
- // and not to the condition. This is inconsistent with JavaScript and C and
- // therefore a bug. This will be fixed in the future (planned for 0.5.0)
- // and the Control Flow Graph will have to be adjusted accordingly.
- BreakContinueScope scope(*this, afterWhile, whileBody);
+ BreakContinueScope scope(*this, afterWhile, condition);
appendControlFlow(_whileStatement.body());
}
+
+ placeAndConnectLabel(condition);
appendControlFlow(_whileStatement.condition());
connect(m_currentNode, whileBody);
diff --git a/libsolidity/analysis/DeclarationContainer.h b/libsolidity/analysis/DeclarationContainer.h
index e4b3320a..a3e0bd0a 100644
--- a/libsolidity/analysis/DeclarationContainer.h
+++ b/libsolidity/analysis/DeclarationContainer.h
@@ -58,7 +58,7 @@ public:
/// @returns whether declaration is valid, and if not also returns previous declaration.
Declaration const* conflictingDeclaration(Declaration const& _declaration, ASTString const* _name = nullptr) const;
- /// Activates a previously inactive (invisible) variable. To be used in C99 scpoing for
+ /// Activates a previously inactive (invisible) variable. To be used in C99 scoping for
/// VariableDeclarationStatements.
void activateVariable(ASTString const& _name);
diff --git a/libsolidity/analysis/NameAndTypeResolver.cpp b/libsolidity/analysis/NameAndTypeResolver.cpp
index 0a356f04..b856544a 100644
--- a/libsolidity/analysis/NameAndTypeResolver.cpp
+++ b/libsolidity/analysis/NameAndTypeResolver.cpp
@@ -54,11 +54,10 @@ NameAndTypeResolver::NameAndTypeResolver(
bool NameAndTypeResolver::registerDeclarations(SourceUnit& _sourceUnit, ASTNode const* _currentScope)
{
- bool useC99Scoping = _sourceUnit.annotation().experimentalFeatures.count(ExperimentalFeature::V050);
// The helper registers all declarations in m_scopes as a side-effect of its construction.
try
{
- DeclarationRegistrationHelper registrar(m_scopes, _sourceUnit, useC99Scoping, m_errorReporter, _currentScope);
+ DeclarationRegistrationHelper registrar(m_scopes, _sourceUnit, m_errorReporter, _currentScope);
}
catch (FatalError const&)
{
@@ -449,11 +448,9 @@ string NameAndTypeResolver::similarNameSuggestions(ASTString const& _name) const
DeclarationRegistrationHelper::DeclarationRegistrationHelper(
map<ASTNode const*, shared_ptr<DeclarationContainer>>& _scopes,
ASTNode& _astRoot,
- bool _useC99Scoping,
ErrorReporter& _errorReporter,
ASTNode const* _currentScope
):
- m_useC99Scoping(_useC99Scoping),
m_scopes(_scopes),
m_currentScope(_currentScope),
m_errorReporter(_errorReporter)
@@ -629,29 +626,25 @@ void DeclarationRegistrationHelper::endVisit(ModifierDefinition&)
bool DeclarationRegistrationHelper::visit(Block& _block)
{
_block.setScope(m_currentScope);
- if (m_useC99Scoping)
- enterNewSubScope(_block);
+ enterNewSubScope(_block);
return true;
}
void DeclarationRegistrationHelper::endVisit(Block&)
{
- if (m_useC99Scoping)
- closeCurrentScope();
+ closeCurrentScope();
}
bool DeclarationRegistrationHelper::visit(ForStatement& _for)
{
_for.setScope(m_currentScope);
- if (m_useC99Scoping)
- enterNewSubScope(_for);
+ enterNewSubScope(_for);
return true;
}
void DeclarationRegistrationHelper::endVisit(ForStatement&)
{
- if (m_useC99Scoping)
- closeCurrentScope();
+ closeCurrentScope();
}
void DeclarationRegistrationHelper::endVisit(VariableDeclarationStatement& _variableDeclarationStatement)
@@ -716,9 +709,8 @@ void DeclarationRegistrationHelper::registerDeclaration(Declaration& _declaratio
if (fun->isConstructor())
warnAboutShadowing = false;
- // Register declaration as inactive if we are in block scope and C99 mode.
+ // Register declaration as inactive if we are in block scope.
bool inactive =
- m_useC99Scoping &&
(dynamic_cast<Block const*>(m_currentScope) || dynamic_cast<ForStatement const*>(m_currentScope));
registerDeclaration(*m_scopes[m_currentScope], _declaration, nullptr, nullptr, warnAboutShadowing, inactive, m_errorReporter);
diff --git a/libsolidity/analysis/NameAndTypeResolver.h b/libsolidity/analysis/NameAndTypeResolver.h
index 3d10fbd8..8178ee17 100644
--- a/libsolidity/analysis/NameAndTypeResolver.h
+++ b/libsolidity/analysis/NameAndTypeResolver.h
@@ -69,7 +69,7 @@ public:
/// that create their own scope.
/// @returns false in case of error.
bool updateDeclaration(Declaration const& _declaration);
- /// Activates a previously inactive (invisible) variable. To be used in C99 scpoing for
+ /// Activates a previously inactive (invisible) variable. To be used in C99 scoping for
/// VariableDeclarationStatements.
void activateVariable(std::string const& _name);
@@ -142,7 +142,6 @@ public:
DeclarationRegistrationHelper(
std::map<ASTNode const*, std::shared_ptr<DeclarationContainer>>& _scopes,
ASTNode& _astRoot,
- bool _useC99Scoping,
ErrorReporter& _errorReporter,
ASTNode const* _currentScope = nullptr
);
@@ -190,7 +189,6 @@ private:
/// @returns the canonical name of the current scope.
std::string currentCanonicalName() const;
- bool m_useC99Scoping = false;
std::map<ASTNode const*, std::shared_ptr<DeclarationContainer>>& m_scopes;
ASTNode const* m_currentScope = nullptr;
VariableScope* m_currentFunction = nullptr;
diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp
index f91eaf6e..58b659f7 100644
--- a/libsolidity/analysis/ReferencesResolver.cpp
+++ b/libsolidity/analysis/ReferencesResolver.cpp
@@ -48,9 +48,7 @@ bool ReferencesResolver::visit(Block const& _block)
if (!m_resolveInsideCode)
return false;
m_experimental050Mode = _block.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050);
- // C99-scoped variables
- if (m_experimental050Mode)
- m_resolver.setScope(&_block);
+ m_resolver.setScope(&_block);
return true;
}
@@ -59,9 +57,7 @@ void ReferencesResolver::endVisit(Block const& _block)
if (!m_resolveInsideCode)
return;
- // C99-scoped variables
- if (m_experimental050Mode)
- m_resolver.setScope(_block.scope());
+ m_resolver.setScope(_block.scope());
}
bool ReferencesResolver::visit(ForStatement const& _for)
@@ -69,9 +65,7 @@ bool ReferencesResolver::visit(ForStatement const& _for)
if (!m_resolveInsideCode)
return false;
m_experimental050Mode = _for.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050);
- // C99-scoped variables
- if (m_experimental050Mode)
- m_resolver.setScope(&_for);
+ m_resolver.setScope(&_for);
return true;
}
@@ -79,18 +73,16 @@ void ReferencesResolver::endVisit(ForStatement const& _for)
{
if (!m_resolveInsideCode)
return;
- if (m_experimental050Mode)
- m_resolver.setScope(_for.scope());
+ m_resolver.setScope(_for.scope());
}
void ReferencesResolver::endVisit(VariableDeclarationStatement const& _varDeclStatement)
{
if (!m_resolveInsideCode)
return;
- if (m_experimental050Mode)
- for (auto const& var: _varDeclStatement.declarations())
- if (var)
- m_resolver.activateVariable(var->name());
+ for (auto const& var: _varDeclStatement.declarations())
+ if (var)
+ m_resolver.activateVariable(var->name());
}
bool ReferencesResolver::visit(Identifier const& _identifier)
@@ -99,9 +91,14 @@ bool ReferencesResolver::visit(Identifier const& _identifier)
if (declarations.empty())
{
string suggestions = m_resolver.similarNameSuggestions(_identifier.name());
- string errorMessage =
- "Undeclared identifier." +
- (suggestions.empty()? "": " Did you mean " + std::move(suggestions) + "?");
+ string errorMessage = "Undeclared identifier.";
+ if (!suggestions.empty())
+ {
+ if ("\"" + _identifier.name() + "\"" == suggestions)
+ errorMessage += " " + std::move(suggestions) + " is not (or not yet) visible at this point.";
+ else
+ errorMessage += " Did you mean " + std::move(suggestions) + "?";
+ }
declarationError(_identifier.location(), errorMessage);
}
else if (declarations.size() == 1)
@@ -327,7 +324,7 @@ void ReferencesResolver::endVisit(VariableDeclaration const& _variable)
else
{
// force location of external function parameters (not return) to calldata
- if (varLoc != Location::Default)
+ if (varLoc != Location::CallData && varLoc != Location::Default)
fatalTypeError(_variable.location(),
"Location has to be calldata for external functions "
"(remove the \"memory\" or \"storage\" keyword)."
@@ -344,15 +341,22 @@ void ReferencesResolver::endVisit(VariableDeclaration const& _variable)
*dynamic_cast<Declaration const&>(*_variable.scope()).scope()
);
// force locations of public or external function (return) parameters to memory
- if (varLoc == Location::Storage && !contract.isLibrary())
+ if (varLoc != Location::Memory && varLoc != Location::Default && !contract.isLibrary())
fatalTypeError(_variable.location(),
"Location has to be memory for publicly visible functions "
- "(remove the \"storage\" keyword)."
+ "(remove the \"storage\" or \"calldata\" keyword)."
);
if (varLoc == Location::Default || !contract.isLibrary())
typeLoc = DataLocation::Memory;
else
+ {
+ if (varLoc == Location::CallData)
+ fatalTypeError(_variable.location(),
+ "Location cannot be calldata for non-external functions "
+ "(remove the \"calldata\" keyword)."
+ );
typeLoc = varLoc == Location::Memory ? DataLocation::Memory : DataLocation::Storage;
+ }
}
else
{
@@ -361,7 +365,7 @@ void ReferencesResolver::endVisit(VariableDeclaration const& _variable)
if (varLoc != Location::Default && varLoc != Location::Memory)
fatalTypeError(
_variable.location(),
- "Storage location has to be \"memory\" (or unspecified) for constants."
+ "Data location has to be \"memory\" (or unspecified) for constants."
);
typeLoc = DataLocation::Memory;
}
@@ -377,7 +381,7 @@ void ReferencesResolver::endVisit(VariableDeclaration const& _variable)
if (_variable.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050))
typeError(
_variable.location(),
- "Storage location must be specified as either \"memory\" or \"storage\"."
+ "Data location must be specified as either \"memory\" or \"storage\"."
);
else
m_errorReporter.warning(
@@ -389,14 +393,31 @@ void ReferencesResolver::endVisit(VariableDeclaration const& _variable)
}
}
else
- typeLoc = varLoc == Location::Memory ? DataLocation::Memory : DataLocation::Storage;
+ {
+ switch (varLoc)
+ {
+ case Location::Memory:
+ typeLoc = DataLocation::Memory;
+ break;
+ case Location::Storage:
+ typeLoc = DataLocation::Storage;
+ break;
+ case Location::CallData:
+ fatalTypeError(_variable.location(),
+ "Variable cannot be declared as \"calldata\" (remove the \"calldata\" keyword)."
+ );
+ break;
+ default:
+ solAssert(false, "Unknown data location");
+ }
+ }
isPointer = !_variable.isStateVariable();
}
type = ref->copyForLocation(typeLoc, isPointer);
}
else if (varLoc != Location::Default && !ref)
- typeError(_variable.location(), "Storage location can only be given for array or struct types.");
+ typeError(_variable.location(), "Data location can only be given for array or struct types.");
_variable.annotation().type = type;
}
diff --git a/libsolidity/analysis/StaticAnalyzer.cpp b/libsolidity/analysis/StaticAnalyzer.cpp
index 00a581d0..dad4cc7f 100644
--- a/libsolidity/analysis/StaticAnalyzer.cpp
+++ b/libsolidity/analysis/StaticAnalyzer.cpp
@@ -193,18 +193,10 @@ bool StaticAnalyzer::visit(MemberAccess const& _memberAccess)
if (_memberAccess.memberName() == "callcode")
if (auto const* type = dynamic_cast<FunctionType const*>(_memberAccess.annotation().type.get()))
if (type->kind() == FunctionType::Kind::BareCallCode)
- {
- if (v050)
- m_errorReporter.typeError(
- _memberAccess.location(),
- "\"callcode\" has been deprecated in favour of \"delegatecall\"."
- );
- else
- m_errorReporter.warning(
- _memberAccess.location(),
- "\"callcode\" has been deprecated in favour of \"delegatecall\"."
- );
- }
+ m_errorReporter.typeError(
+ _memberAccess.location(),
+ "\"callcode\" has been deprecated in favour of \"delegatecall\"."
+ );
if (m_constructor)
{
diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp
index 396058f4..c408b393 100644
--- a/libsolidity/analysis/SyntaxChecker.cpp
+++ b/libsolidity/analysis/SyntaxChecker.cpp
@@ -255,7 +255,7 @@ bool SyntaxChecker::visit(FunctionTypeName const& _node)
for (auto const& decl: _node.returnParameterTypeList()->parameters())
if (!decl->name().empty())
- m_errorReporter.warning(decl->location(), "Naming function type return parameters is deprecated.");
+ m_errorReporter.syntaxError(decl->location(), "Return parameters in function types may not be named.");
return true;
}
@@ -276,14 +276,8 @@ bool SyntaxChecker::visit(VariableDeclaration const& _declaration)
bool SyntaxChecker::visit(StructDefinition const& _struct)
{
- bool const v050 = m_sourceUnit->annotation().experimentalFeatures.count(ExperimentalFeature::V050);
-
if (_struct.members().empty())
- {
- if (v050)
- m_errorReporter.syntaxError(_struct.location(), "Defining empty structs is disallowed.");
- else
- m_errorReporter.warning(_struct.location(), "Defining empty structs is deprecated.");
- }
+ m_errorReporter.syntaxError(_struct.location(), "Defining empty structs is disallowed.");
+
return true;
}
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 30302908..e833b8fe 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -41,15 +41,13 @@ bool typeSupportedByOldABIEncoder(Type const& _type)
{
if (_type.dataStoredIn(DataLocation::Storage))
return true;
- else if (_type.category() == Type::Category::Struct)
+ if (_type.category() == Type::Category::Struct)
return false;
- else if (_type.category() == Type::Category::Array)
+ if (_type.category() == Type::Category::Array)
{
auto const& arrayType = dynamic_cast<ArrayType const&>(_type);
auto base = arrayType.baseType();
- if (!typeSupportedByOldABIEncoder(*base))
- return false;
- else if (base->category() == Type::Category::Array && base->isDynamicallySized())
+ if (!typeSupportedByOldABIEncoder(*base) || (base->category() == Type::Category::Array && base->isDynamicallySized()))
return false;
}
return true;
@@ -351,7 +349,7 @@ void TypeChecker::annotateBaseConstructorArguments(
SourceLocation const* mainLocation = nullptr;
SecondarySourceLocation ssl;
-
+
if (
_currentContract.location().contains(previousNode->location()) ||
_currentContract.location().contains(_argumentNode->location())
@@ -1708,26 +1706,13 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
if (auto functionName = dynamic_cast<Identifier const*>(&_functionCall.expression()))
{
- string msg;
if (functionName->name() == "sha3" && functionType->kind() == FunctionType::Kind::SHA3)
- msg = "\"sha3\" has been deprecated in favour of \"keccak256\"";
+ m_errorReporter.typeError(_functionCall.location(), "\"sha3\" has been deprecated in favour of \"keccak256\"");
else if (functionName->name() == "suicide" && functionType->kind() == FunctionType::Kind::Selfdestruct)
- msg = "\"suicide\" has been deprecated in favour of \"selfdestruct\"";
- if (!msg.empty())
- {
- if (v050)
- m_errorReporter.typeError(_functionCall.location(), msg);
- else
- m_errorReporter.warning(_functionCall.location(), msg);
- }
+ m_errorReporter.typeError(_functionCall.location(), "\"suicide\" has been deprecated in favour of \"selfdestruct\"");
}
if (!m_insideEmitStatement && functionType->kind() == FunctionType::Kind::Event)
- {
- if (m_scope->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050))
- m_errorReporter.typeError(_functionCall.location(), "Event invocations have to be prefixed by \"emit\".");
- else
- m_errorReporter.warning(_functionCall.location(), "Invoking events without \"emit\" prefix is deprecated.");
- }
+ m_errorReporter.typeError(_functionCall.location(), "Event invocations have to be prefixed by \"emit\".");
TypePointers parameterTypes = functionType->parameterTypes();
@@ -1918,7 +1903,7 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
if (!found)
m_errorReporter.typeError(
_functionCall.location(),
- "Named argument does not match function declaration."
+ "Named argument \"" + *argumentNames[i] + "\" does not match function declaration."
);
}
}
@@ -2297,14 +2282,28 @@ void TypeChecker::endVisit(Literal const& _literal)
if (_literal.looksLikeAddress())
{
- if (_literal.passesAddressChecksum())
- _literal.annotation().type = make_shared<IntegerType>(160, IntegerType::Modifier::Address);
- else
- m_errorReporter.warning(
+ // Assign type here if it even looks like an address. This prevents double error in 050 mode for invalid address
+ _literal.annotation().type = make_shared<IntegerType>(160, IntegerType::Modifier::Address);
+
+ string msg;
+ if (_literal.value().length() != 42) // "0x" + 40 hex digits
+ // looksLikeAddress enforces that it is a hex literal starting with "0x"
+ msg =
+ "This looks like an address but is not exactly 40 hex digits. It is " +
+ to_string(_literal.value().length() - 2) +
+ " hex digits.";
+ else if (!_literal.passesAddressChecksum())
+ {
+ msg = "This looks like an address but has an invalid checksum.";
+ if (!_literal.getChecksummedAddress().empty())
+ msg += " Correct checksummed address: \"" + _literal.getChecksummedAddress() + "\".";
+ }
+
+ if (!msg.empty())
+ m_errorReporter.syntaxError(
_literal.location(),
- "This looks like an address but has an invalid checksum. "
- "If this is not used as an address, please prepend '00'. " +
- (!_literal.getChecksummedAddress().empty() ? "Correct checksummed address: '" + _literal.getChecksummedAddress() + "'. " : "") +
+ msg +
+ " If this is not used as an address, please prepend '00'. " +
"For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals"
);
}
@@ -2326,18 +2325,10 @@ void TypeChecker::endVisit(Literal const& _literal)
}
if (_literal.subDenomination() == Literal::SubDenomination::Year)
- {
- if (v050)
- m_errorReporter.typeError(
- _literal.location(),
- "Using \"years\" as a unit denomination is deprecated."
- );
- else
- m_errorReporter.warning(
- _literal.location(),
- "Using \"years\" as a unit denomination is deprecated."
- );
- }
+ m_errorReporter.typeError(
+ _literal.location(),
+ "Using \"years\" as a unit denomination is deprecated."
+ );
if (!_literal.annotation().type)
_literal.annotation().type = Type::forLiteral(_literal);
diff --git a/libsolidity/analysis/ViewPureChecker.cpp b/libsolidity/analysis/ViewPureChecker.cpp
index d9843012..107eb3aa 100644
--- a/libsolidity/analysis/ViewPureChecker.cpp
+++ b/libsolidity/analysis/ViewPureChecker.cpp
@@ -117,7 +117,7 @@ private:
bool ViewPureChecker::check()
{
// The bool means "enforce view with errors".
- map<ContractDefinition const*, bool> contracts;
+ vector<pair<ContractDefinition const*, bool>> contracts;
for (auto const& node: m_ast)
{
@@ -125,7 +125,7 @@ bool ViewPureChecker::check()
solAssert(source, "");
bool enforceView = source->annotation().experimentalFeatures.count(ExperimentalFeature::V050);
for (ContractDefinition const* c: source->filteredNodes<ContractDefinition>(source->nodes()))
- contracts[c] = enforceView;
+ contracts.emplace_back(c, enforceView);
}
// Check modifiers first to infer their state mutability.
diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp
index 80f5d642..16c9b2d2 100644
--- a/libsolidity/ast/AST.cpp
+++ b/libsolidity/ast/AST.cpp
@@ -312,7 +312,7 @@ FunctionTypePointer FunctionDefinition::functionType(bool _internal) const
case Declaration::Visibility::External:
return {};
default:
- solAssert(false, "visibility() should not return a Visibility");
+ solAssert(false, "visibility() should return a Visibility");
}
}
else
@@ -328,7 +328,7 @@ FunctionTypePointer FunctionDefinition::functionType(bool _internal) const
case Declaration::Visibility::External:
return make_shared<FunctionType>(*this, _internal);
default:
- solAssert(false, "visibility() should not return a Visibility");
+ solAssert(false, "visibility() should return a Visibility");
}
}
diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h
index fa0d6921..d703ae53 100644
--- a/libsolidity/ast/AST.h
+++ b/libsolidity/ast/AST.h
@@ -656,7 +656,7 @@ private:
class VariableDeclaration: public Declaration
{
public:
- enum Location { Default, Storage, Memory };
+ enum Location { Default, Storage, Memory, CallData };
VariableDeclaration(
SourceLocation const& _sourceLocation,
diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp
index b8e00b60..b7855668 100644
--- a/libsolidity/ast/ASTJsonConverter.cpp
+++ b/libsolidity/ast/ASTJsonConverter.cpp
@@ -751,6 +751,8 @@ string ASTJsonConverter::location(VariableDeclaration::Location _location)
return "storage";
case VariableDeclaration::Location::Memory:
return "memory";
+ case VariableDeclaration::Location::CallData:
+ return "calldata";
default:
solAssert(false, "Unknown declaration location.");
}
diff --git a/libsolidity/ast/ExperimentalFeatures.h b/libsolidity/ast/ExperimentalFeatures.h
index 30ea7ec5..c66a3659 100644
--- a/libsolidity/ast/ExperimentalFeatures.h
+++ b/libsolidity/ast/ExperimentalFeatures.h
@@ -29,7 +29,7 @@ namespace solidity
enum class ExperimentalFeature
{
- ABIEncoderV2, // new ABI encoder that makes use of JULIA
+ ABIEncoderV2, // new ABI encoder that makes use of Yul
SMTChecker,
V050, // v0.5.0 breaking changes
Test,
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index 60e3183c..69124705 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -33,6 +33,8 @@
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/predicate.hpp>
+#include <boost/algorithm/string/classification.hpp>
+#include <boost/algorithm/string/split.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/copy.hpp>
#include <boost/range/adaptor/sliced.hpp>
@@ -312,22 +314,34 @@ TypePointer Type::fromElementaryTypeName(ElementaryTypeNameToken const& _type)
TypePointer Type::fromElementaryTypeName(string const& _name)
{
- string name = _name;
- DataLocation location = DataLocation::Storage;
- if (boost::algorithm::ends_with(name, " memory"))
- {
- name = name.substr(0, name.length() - 7);
- location = DataLocation::Memory;
- }
- unsigned short firstNum;
- unsigned short secondNum;
+ vector<string> nameParts;
+ boost::split(nameParts, _name, boost::is_any_of(" "));
+ solAssert(nameParts.size() == 1 || nameParts.size() == 2, "Cannot parse elementary type: " + _name);
Token::Value token;
- tie(token, firstNum, secondNum) = Token::fromIdentifierOrKeyword(name);
+ unsigned short firstNum, secondNum;
+ tie(token, firstNum, secondNum) = Token::fromIdentifierOrKeyword(nameParts[0]);
auto t = fromElementaryTypeName(ElementaryTypeNameToken(token, firstNum, secondNum));
if (auto* ref = dynamic_cast<ReferenceType const*>(t.get()))
+ {
+ DataLocation location = DataLocation::Storage;
+ if (nameParts.size() == 2)
+ {
+ if (nameParts[1] == "storage")
+ location = DataLocation::Storage;
+ else if (nameParts[1] == "calldata")
+ location = DataLocation::CallData;
+ else if (nameParts[1] == "memory")
+ location = DataLocation::Memory;
+ else
+ solAssert(false, "Unknown data location: " + nameParts[1]);
+ }
return ref->copyForLocation(location, true);
+ }
else
+ {
+ solAssert(nameParts.size() == 1, "Storage location suffix only allowed for reference types");
return t;
+ }
}
TypePointer Type::forLiteral(Literal const& _literal)
@@ -476,7 +490,7 @@ bool IntegerType::isExplicitlyConvertibleTo(Type const& _convertTo) const
return _convertTo.category() == category() ||
_convertTo.category() == Category::Contract ||
_convertTo.category() == Category::Enum ||
- _convertTo.category() == Category::FixedBytes ||
+ (_convertTo.category() == Category::FixedBytes && numBits() == dynamic_cast<FixedBytesType const&>(_convertTo).numBytes() * 8) ||
_convertTo.category() == Category::FixedPoint;
}
@@ -664,7 +678,7 @@ string FixedPointType::toString(bool) const
bigint FixedPointType::maxIntegerValue() const
{
bigint maxValue = (bigint(1) << (m_totalBits - (isSigned() ? 1 : 0))) - 1;
- return maxValue / pow(bigint(10), m_fractionalDigits);
+ return maxValue / boost::multiprecision::pow(bigint(10), m_fractionalDigits);
}
bigint FixedPointType::minIntegerValue() const
@@ -672,7 +686,7 @@ bigint FixedPointType::minIntegerValue() const
if (isSigned())
{
bigint minValue = -(bigint(1) << (m_totalBits - (isSigned() ? 1 : 0)));
- return minValue / pow(bigint(10), m_fractionalDigits);
+ return minValue / boost::multiprecision::pow(bigint(10), m_fractionalDigits);
}
else
return bigint(0);
@@ -842,49 +856,58 @@ tuple<bool, rational> RationalNumberType::isValidLiteral(Literal const& _literal
bool RationalNumberType::isImplicitlyConvertibleTo(Type const& _convertTo) const
{
- if (_convertTo.category() == Category::Integer)
+ switch (_convertTo.category())
+ {
+ case Category::Integer:
{
- if (m_value == rational(0))
- return true;
if (isFractional())
return false;
IntegerType const& targetType = dynamic_cast<IntegerType const&>(_convertTo);
+ if (targetType.isAddress())
+ return false;
+ if (m_value == rational(0))
+ return true;
unsigned forSignBit = (targetType.isSigned() ? 1 : 0);
if (m_value > rational(0))
{
if (m_value.numerator() <= (u256(-1) >> (256 - targetType.numBits() + forSignBit)))
return true;
+ return false;
+ }
+ if (targetType.isSigned())
+ {
+ if (-m_value.numerator() <= (u256(1) << (targetType.numBits() - forSignBit)))
+ return true;
}
- else if (targetType.isSigned() && -m_value.numerator() <= (u256(1) << (targetType.numBits() - forSignBit)))
- return true;
return false;
}
- else if (_convertTo.category() == Category::FixedPoint)
+ case Category::FixedPoint:
{
if (auto fixed = fixedPointType())
return fixed->isImplicitlyConvertibleTo(_convertTo);
- else
- return false;
+ return false;
}
- else if (_convertTo.category() == Category::FixedBytes)
+ case Category::FixedBytes:
{
FixedBytesType const& fixedBytes = dynamic_cast<FixedBytesType const&>(_convertTo);
- if (!isFractional())
- {
- if (integerType())
- return fixedBytes.numBytes() * 8 >= integerType()->numBits();
- return false;
- }
- else
+ if (isFractional())
return false;
+ if (integerType())
+ return fixedBytes.numBytes() * 8 >= integerType()->numBits();
+ return false;
+ }
+ default:
+ return false;
}
- return false;
}
bool RationalNumberType::isExplicitlyConvertibleTo(Type const& _convertTo) const
{
TypePointer mobType = mobileType();
- return mobType && mobType->isExplicitlyConvertibleTo(_convertTo);
+ return
+ (mobType && mobType->isExplicitlyConvertibleTo(_convertTo)) ||
+ (!isFractional() && _convertTo.category() == Category::FixedBytes)
+ ;
}
TypePointer RationalNumberType::unaryOperatorResult(Token::Value _operator) const
@@ -982,10 +1005,9 @@ TypePointer RationalNumberType::binaryOperatorResult(Token::Value _operator, Typ
}
else
value = m_value.numerator() % other.m_value.numerator();
- break;
+ break;
case Token::Exp:
{
- using boost::multiprecision::pow;
if (other.isFractional())
return TypePointer();
solAssert(other.m_value.denominator() == 1, "");
@@ -1019,7 +1041,7 @@ TypePointer RationalNumberType::binaryOperatorResult(Token::Value _operator, Typ
else if (_base == -1)
return 1 - 2 * int(_exponent & 1);
else
- return pow(_base, _exponent);
+ return boost::multiprecision::pow(_base, _exponent);
};
bigint numerator = optimizedPow(m_value.numerator(), absExp);
@@ -1035,7 +1057,6 @@ TypePointer RationalNumberType::binaryOperatorResult(Token::Value _operator, Typ
}
case Token::SHL:
{
- using boost::multiprecision::pow;
if (fractional)
return TypePointer();
else if (other.m_value < 0)
@@ -1049,7 +1070,7 @@ TypePointer RationalNumberType::binaryOperatorResult(Token::Value _operator, Typ
uint32_t exponent = other.m_value.numerator().convert_to<uint32_t>();
if (!fitsPrecisionBase2(abs(m_value.numerator()), exponent))
return TypePointer();
- value = m_value.numerator() * pow(bigint(2), exponent);
+ value = m_value.numerator() * boost::multiprecision::pow(bigint(2), exponent);
}
break;
}
@@ -1057,7 +1078,6 @@ TypePointer RationalNumberType::binaryOperatorResult(Token::Value _operator, Typ
// determines the resulting type and the type of shift (SAR or SHR).
case Token::SAR:
{
- namespace mp = boost::multiprecision;
if (fractional)
return TypePointer();
else if (other.m_value < 0)
@@ -1069,10 +1089,22 @@ TypePointer RationalNumberType::binaryOperatorResult(Token::Value _operator, Typ
else
{
uint32_t exponent = other.m_value.numerator().convert_to<uint32_t>();
- if (exponent > mostSignificantBit(mp::abs(m_value.numerator())))
- value = 0;
+ if (exponent > mostSignificantBit(boost::multiprecision::abs(m_value.numerator())))
+ value = m_value.numerator() < 0 ? -1 : 0;
else
- value = rational(m_value.numerator() / mp::pow(bigint(2), exponent), 1);
+ {
+ if (m_value.numerator() < 0)
+ // Add 1 to the negative value before dividing to get a result that is strictly too large,
+ // then subtract 1 afterwards to round towards negative infinity.
+ // This is the same algorithm as used in ExpressionCompiler::appendShiftOperatorCode(...).
+ // To see this note that for negative x, xor(x,all_ones) = (-x-1) and
+ // therefore xor(div(xor(x,all_ones), exp(2, shift_amount)), all_ones) is
+ // -(-x - 1) / 2^shift_amount - 1, which is the same as
+ // (x + 1) / 2^shift_amount - 1.
+ value = rational((m_value.numerator() + 1) / boost::multiprecision::pow(bigint(2), exponent) - bigint(1), 1);
+ else
+ value = rational(m_value.numerator() / boost::multiprecision::pow(bigint(2), exponent), 1);
+ }
}
break;
}
@@ -1128,7 +1160,7 @@ u256 RationalNumberType::literalValue(Literal const*) const
// its value.
u256 value;
- bigint shiftedValue;
+ bigint shiftedValue;
if (!isFractional())
shiftedValue = m_value.numerator();
@@ -1137,7 +1169,7 @@ u256 RationalNumberType::literalValue(Literal const*) const
auto fixed = fixedPointType();
solAssert(fixed, "");
int fractionalDigits = fixed->fractionalDigits();
- shiftedValue = m_value.numerator() * pow(bigint(10), fractionalDigits) / m_value.denominator();
+ shiftedValue = m_value.numerator() * boost::multiprecision::pow(bigint(10), fractionalDigits) / m_value.denominator();
}
// we ignore the literal and hope that the type was correctly determined
@@ -1180,7 +1212,7 @@ shared_ptr<FixedPointType const> RationalNumberType::fixedPointType() const
bool negative = (m_value < 0);
unsigned fractionalDigits = 0;
rational value = abs(m_value); // We care about the sign later.
- rational maxValue = negative ?
+ rational maxValue = negative ?
rational(bigint(1) << 255, 1):
rational((bigint(1) << 256) - 1, 1);
@@ -1189,7 +1221,7 @@ shared_ptr<FixedPointType const> RationalNumberType::fixedPointType() const
value *= 10;
fractionalDigits++;
}
-
+
if (value > maxValue)
return shared_ptr<FixedPointType const>();
// This means we round towards zero for positive and negative values.
@@ -1281,7 +1313,7 @@ bool FixedBytesType::isImplicitlyConvertibleTo(Type const& _convertTo) const
bool FixedBytesType::isExplicitlyConvertibleTo(Type const& _convertTo) const
{
- return _convertTo.category() == Category::Integer ||
+ return (_convertTo.category() == Category::Integer && numBytes() * 8 == dynamic_cast<IntegerType const&>(_convertTo).numBits()) ||
_convertTo.category() == Category::FixedPoint ||
_convertTo.category() == category();
}
@@ -1358,7 +1390,7 @@ TypePointer BoolType::binaryOperatorResult(Token::Value _operator, TypePointer c
{
if (category() != _other->category())
return TypePointer();
- if (Token::isCompareOp(_operator) || _operator == Token::And || _operator == Token::Or)
+ if (_operator == Token::Equal || _operator == Token::NotEqual || _operator == Token::And || _operator == Token::Or)
return _other;
else
return TypePointer();
@@ -1452,12 +1484,20 @@ string ReferenceType::stringForReferencePart() const
string ReferenceType::identifierLocationSuffix() const
{
string id;
- if (location() == DataLocation::Storage)
+ switch (location())
+ {
+ case DataLocation::Storage:
id += "_storage";
- else if (location() == DataLocation::Memory)
+ break;
+ case DataLocation::Memory:
id += "_memory";
- else
+ break;
+ case DataLocation::CallData:
id += "_calldata";
+ break;
+ default:
+ solAssert(false, "Unknown location returned by location()");
+ }
if (isPointer())
id += "_ptr";
return id;
@@ -1672,6 +1712,7 @@ MemberList::MemberMap ArrayType::nativeMembers(ContractDefinition const*) const
{
members.push_back({"length", make_shared<IntegerType>(256)});
if (isDynamicallySized() && location() == DataLocation::Storage)
+ {
members.push_back({"push", make_shared<FunctionType>(
TypePointers{baseType()},
TypePointers{make_shared<IntegerType>(256)},
@@ -1679,6 +1720,14 @@ MemberList::MemberMap ArrayType::nativeMembers(ContractDefinition const*) const
strings{string()},
isByteArray() ? FunctionType::Kind::ByteArrayPush : FunctionType::Kind::ArrayPush
)});
+ members.push_back({"pop", make_shared<FunctionType>(
+ TypePointers{},
+ TypePointers{},
+ strings{string()},
+ strings{string()},
+ FunctionType::Kind::ArrayPop
+ )});
+ }
}
return members;
}
@@ -2495,6 +2544,7 @@ string FunctionType::richIdentifier() const
case Kind::AddMod: id += "addmod"; break;
case Kind::MulMod: id += "mulmod"; break;
case Kind::ArrayPush: id += "arraypush"; break;
+ case Kind::ArrayPop: id += "arraypop"; break;
case Kind::ByteArrayPush: id += "bytearraypush"; break;
case Kind::ObjectCreation: id += "objectcreation"; break;
case Kind::Assert: id += "assert"; break;
@@ -2649,6 +2699,7 @@ unsigned FunctionType::sizeOnStack() const
case Kind::BareDelegateCall:
case Kind::Internal:
case Kind::ArrayPush:
+ case Kind::ArrayPop:
case Kind::ByteArrayPush:
size = 1;
break;
diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h
index 95821634..b2f34dee 100644
--- a/libsolidity/ast/Types.h
+++ b/libsolidity/ast/Types.h
@@ -151,7 +151,8 @@ public:
/// @name Factory functions
/// Factory functions that convert an AST @ref TypeName to a Type.
static TypePointer fromElementaryTypeName(ElementaryTypeNameToken const& _type);
- /// Converts a given elementary type name with optional suffix " memory" to a type pointer.
+ /// Converts a given elementary type name with optional data location
+ /// suffix " storage", " calldata" or " memory" to a type pointer. If suffix not given, defaults to " storage".
static TypePointer fromElementaryTypeName(std::string const& _name);
/// @}
@@ -913,6 +914,7 @@ public:
AddMod, ///< ADDMOD
MulMod, ///< MULMOD
ArrayPush, ///< .push() to a dynamically sized array in storage
+ ArrayPop, ///< .pop() from a dynamically sized array in storage
ByteArrayPush, ///< .push() to a dynamically sized byte array in storage
ObjectCreation, ///< array creation using new
Assert, ///< assert()
diff --git a/libsolidity/codegen/ABIFunctions.cpp b/libsolidity/codegen/ABIFunctions.cpp
index 3e3aa0ae..4818e111 100644
--- a/libsolidity/codegen/ABIFunctions.cpp
+++ b/libsolidity/codegen/ABIFunctions.cpp
@@ -17,7 +17,7 @@
/**
* @author Christian <chris@ethereum.org>
* @date 2017
- * Routines that generate JULIA code related to ABI encoding, decoding and type conversions.
+ * Routines that generate Yul code related to ABI encoding, decoding and type conversions.
*/
#include <libsolidity/codegen/ABIFunctions.h>
@@ -989,7 +989,7 @@ string ABIFunctions::abiEncodingFunctionStringLiteral(
)");
templ("functionName", functionName);
- // TODO this can make use of CODECOPY for large strings once we have that in JULIA
+ // TODO this can make use of CODECOPY for large strings once we have that in Yul
size_t words = (value.size() + 31) / 32;
templ("overallSize", to_string(32 + words * 32));
templ("length", to_string(value.size()));
diff --git a/libsolidity/codegen/ABIFunctions.h b/libsolidity/codegen/ABIFunctions.h
index db4d40f5..6bfb3f15 100644
--- a/libsolidity/codegen/ABIFunctions.h
+++ b/libsolidity/codegen/ABIFunctions.h
@@ -17,7 +17,7 @@
/**
* @author Christian <chris@ethereum.org>
* @date 2017
- * Routines that generate JULIA code related to ABI encoding, decoding and type conversions.
+ * Routines that generate Yul code related to ABI encoding, decoding and type conversions.
*/
#pragma once
diff --git a/libsolidity/codegen/ArrayUtils.cpp b/libsolidity/codegen/ArrayUtils.cpp
index 0fe66d2d..2b77db8f 100644
--- a/libsolidity/codegen/ArrayUtils.cpp
+++ b/libsolidity/codegen/ArrayUtils.cpp
@@ -303,12 +303,17 @@ void ArrayUtils::copyArrayToMemory(ArrayType const& _sourceType, bool _padToWord
m_context << _sourceType.length();
if (baseSize > 1)
m_context << u256(baseSize) << Instruction::MUL;
- // stack: target source_offset source_len
- m_context << Instruction::DUP1 << Instruction::DUP3 << Instruction::DUP5;
- // stack: target source_offset source_len source_len source_offset target
- m_context << Instruction::CALLDATACOPY;
- m_context << Instruction::DUP3 << Instruction::ADD;
- m_context << Instruction::SWAP2 << Instruction::POP << Instruction::POP;
+
+ string routine = "calldatacopy(target, source, len)\n";
+ if (_padToWordBoundaries)
+ routine += R"(
+ // Set padding suffix to zero
+ mstore(add(target, len), 0)
+ len := and(add(len, 0x1f), not(0x1f))
+ )";
+ routine += "target := add(target, len)\n";
+ m_context.appendInlineAssembly("{" + routine + "}", {"target", "source", "len"});
+ m_context << Instruction::POP << Instruction::POP;
}
else if (_sourceType.location() == DataLocation::Memory)
{
@@ -823,6 +828,85 @@ void ArrayUtils::incrementDynamicArraySize(ArrayType const& _type) const
})", {"ref"});
}
+void ArrayUtils::popStorageArrayElement(ArrayType const& _type) const
+{
+ solAssert(_type.location() == DataLocation::Storage, "");
+ solAssert(_type.isDynamicallySized(), "");
+ if (!_type.isByteArray() && _type.baseType()->storageBytes() < 32)
+ solAssert(_type.baseType()->isValueType(), "Invalid storage size for non-value type.");
+
+ if (_type.isByteArray())
+ {
+ m_context.appendInlineAssembly(R"({
+ let slot_value := sload(ref)
+ switch and(slot_value, 1)
+ case 0 {
+ // short byte array
+ let length := and(div(slot_value, 2), 0x1f)
+ if iszero(length) { invalid() }
+
+ // Zero-out the suffix including the least significant byte.
+ let mask := sub(exp(0x100, sub(33, length)), 1)
+ length := sub(length, 1)
+ slot_value := or(and(not(mask), slot_value), mul(length, 2))
+ sstore(ref, slot_value)
+ }
+ case 1 {
+ // long byte array
+ mstore(0, ref)
+ let length := div(slot_value, 2)
+ let slot := keccak256(0, 0x20)
+ switch length
+ case 32
+ {
+ let data := sload(slot)
+ sstore(slot, 0)
+ data := and(data, not(0xff))
+ sstore(ref, or(data, 62))
+ }
+ default
+ {
+ let offset_inside_slot := and(sub(length, 1), 0x1f)
+ slot := add(slot, div(sub(length, 1), 32))
+ let data := sload(slot)
+
+ // Zero-out the suffix of the byte array by masking it.
+ // ((1<<(8 * (32 - offset))) - 1)
+ let mask := sub(exp(0x100, sub(32, offset_inside_slot)), 1)
+ data := and(not(mask), data)
+ sstore(slot, data)
+
+ // Reduce the length by 1
+ slot_value := sub(slot_value, 2)
+ sstore(ref, slot_value)
+ }
+ }
+ })", {"ref"});
+ m_context << Instruction::POP;
+ }
+ else
+ {
+ // stack: ArrayReference
+ retrieveLength(_type);
+ // stack: ArrayReference oldLength
+ m_context << Instruction::DUP1;
+ // stack: ArrayReference oldLength oldLength
+ m_context << Instruction::ISZERO;
+ m_context.appendConditionalInvalid();
+
+ // Stack: ArrayReference oldLength
+ m_context << u256(1) << Instruction::SWAP1 << Instruction::SUB;
+ // Stack ArrayReference newLength
+ m_context << Instruction::DUP2 << Instruction::DUP2;
+ // Stack ArrayReference newLength ArrayReference newLength;
+ accessIndex(_type, false);
+ // Stack: ArrayReference newLength storage_slot byte_offset
+ StorageItem(m_context, *_type.baseType()).setToZero(SourceLocation(), true);
+ // Stack: ArrayReference newLength
+ m_context << Instruction::SWAP1 << Instruction::SSTORE;
+ }
+}
+
void ArrayUtils::clearStorageLoop(TypePointer const& _type) const
{
m_context.callLowLevelFunction(
diff --git a/libsolidity/codegen/ArrayUtils.h b/libsolidity/codegen/ArrayUtils.h
index 99786397..daf50bf5 100644
--- a/libsolidity/codegen/ArrayUtils.h
+++ b/libsolidity/codegen/ArrayUtils.h
@@ -73,6 +73,11 @@ public:
/// Stack pre: reference (excludes byte offset)
/// Stack post: new_length
void incrementDynamicArraySize(ArrayType const& _type) const;
+ /// Decrements the size of a dynamic array by one if length is nonzero. Causes an invalid instruction otherwise.
+ /// Clears the removed data element. In case of a byte array, this might move the data.
+ /// Stack pre: reference
+ /// Stack post:
+ void popStorageArrayElement(ArrayType const& _type) const;
/// Appends a loop that clears a sequence of storage slots of the given type (excluding end).
/// Stack pre: end_ref start_ref
/// Stack post: end_ref
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp
index d9f17263..3446be55 100644
--- a/libsolidity/codegen/CompilerUtils.cpp
+++ b/libsolidity/codegen/CompilerUtils.cpp
@@ -186,7 +186,7 @@ void CompilerUtils::abiDecode(TypePointers const& _typeParameters, bool _fromMem
/// Stack: <source_offset> <length>
if (m_context.experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2))
{
- // Use the new JULIA-based decoding function
+ // Use the new Yul-based decoding function
auto stackHeightBefore = m_context.stackHeight();
abiDecodeV2(_typeParameters, _fromMemory);
solAssert(m_context.stackHeight() - stackHeightBefore == sizeOnStack(_typeParameters) - 2, "");
@@ -368,7 +368,7 @@ void CompilerUtils::encodeToMemory(
m_context.experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2)
)
{
- // Use the new JULIA-based encoding function
+ // Use the new Yul-based encoding function
auto stackHeightBefore = m_context.stackHeight();
abiEncodeV2(_givenTypes, targetTypes, _encodeAsLibraryTypes);
solAssert(stackHeightBefore - m_context.stackHeight() == sizeOnStack(_givenTypes), "");
diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp
index 0889ac7c..81aba21e 100644
--- a/libsolidity/codegen/ContractCompiler.cpp
+++ b/libsolidity/codegen/ContractCompiler.cpp
@@ -666,32 +666,36 @@ bool ContractCompiler::visit(WhileStatement const& _whileStatement)
{
StackHeightChecker checker(m_context);
CompilerContext::LocationSetter locationSetter(m_context, _whileStatement);
+
eth::AssemblyItem loopStart = m_context.newTag();
eth::AssemblyItem loopEnd = m_context.newTag();
- m_continueTags.push_back(loopStart);
m_breakTags.push_back(loopEnd);
m_context << loopStart;
- // While loops have the condition prepended
- if (!_whileStatement.isDoWhile())
+ if (_whileStatement.isDoWhile())
{
- compileExpression(_whileStatement.condition());
- m_context << Instruction::ISZERO;
- m_context.appendConditionalJumpTo(loopEnd);
- }
+ eth::AssemblyItem condition = m_context.newTag();
+ m_continueTags.push_back(condition);
- _whileStatement.body().accept(*this);
+ _whileStatement.body().accept(*this);
- // Do-while loops have the condition appended
- if (_whileStatement.isDoWhile())
+ m_context << condition;
+ compileExpression(_whileStatement.condition());
+ m_context << Instruction::ISZERO << Instruction::ISZERO;
+ m_context.appendConditionalJumpTo(loopStart);
+ }
+ else
{
+ m_continueTags.push_back(loopStart);
compileExpression(_whileStatement.condition());
m_context << Instruction::ISZERO;
m_context.appendConditionalJumpTo(loopEnd);
- }
- m_context.appendJumpTo(loopStart);
+ _whileStatement.body().accept(*this);
+
+ m_context.appendJumpTo(loopStart);
+ }
m_context << loopEnd;
m_continueTags.pop_back();
@@ -745,16 +749,16 @@ bool ContractCompiler::visit(ForStatement const& _forStatement)
bool ContractCompiler::visit(Continue const& _continueStatement)
{
CompilerContext::LocationSetter locationSetter(m_context, _continueStatement);
- if (!m_continueTags.empty())
- m_context.appendJumpTo(m_continueTags.back());
+ solAssert(!m_continueTags.empty(), "");
+ m_context.appendJumpTo(m_continueTags.back());
return false;
}
bool ContractCompiler::visit(Break const& _breakStatement)
{
CompilerContext::LocationSetter locationSetter(m_context, _breakStatement);
- if (!m_breakTags.empty())
- m_context.appendJumpTo(m_breakTags.back());
+ solAssert(!m_breakTags.empty(), "");
+ m_context.appendJumpTo(m_breakTags.back());
return false;
}
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp
index 4bcc1fa9..0470c3ec 100644
--- a/libsolidity/codegen/ExpressionCompiler.cpp
+++ b/libsolidity/codegen/ExpressionCompiler.cpp
@@ -866,6 +866,19 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
StorageByteArrayElement(m_context).storeValue(*type, _functionCall.location(), true);
break;
}
+ case FunctionType::Kind::ArrayPop:
+ {
+ _functionCall.expression().accept(*this);
+ solAssert(function.parameterTypes().empty(), "");
+
+ ArrayType const& arrayType = dynamic_cast<ArrayType const&>(
+ *dynamic_cast<MemberAccess const&>(_functionCall.expression()).expression().annotation().type
+ );
+ solAssert(arrayType.dataStoredIn(DataLocation::Storage), "");
+
+ ArrayUtils(m_context).popStorageArrayElement(arrayType);
+ break;
+ }
case FunctionType::Kind::ObjectCreation:
{
ArrayType const& arrayType = dynamic_cast<ArrayType const&>(*_functionCall.annotation().type);
@@ -1345,11 +1358,13 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
break;
}
}
- else if (member == "push")
+ else if (member == "push" || member == "pop")
{
solAssert(
- type.isDynamicallySized() && type.location() == DataLocation::Storage,
- "Tried to use .push() on a non-dynamically sized array"
+ type.isDynamicallySized() &&
+ type.location() == DataLocation::Storage &&
+ type.category() == Type::Category::Array,
+ "Tried to use ." + member + "() on a non-dynamically sized array"
);
}
else
@@ -1722,11 +1737,36 @@ void ExpressionCompiler::appendShiftOperatorCode(Token::Value _operator, Type co
m_context << u256(2) << Instruction::EXP << Instruction::MUL;
break;
case Token::SAR:
- // NOTE: SAR rounds differently than SDIV
- if (m_context.evmVersion().hasBitwiseShifting() && !c_valueSigned)
- m_context << Instruction::SHR;
+ if (m_context.evmVersion().hasBitwiseShifting())
+ m_context << (c_valueSigned ? Instruction::SAR : Instruction::SHR);
else
- m_context << u256(2) << Instruction::EXP << Instruction::SWAP1 << (c_valueSigned ? Instruction::SDIV : Instruction::DIV);
+ {
+ if (c_valueSigned)
+ // In the following assembly snippet, xor_mask will be zero, if value_to_shift is positive.
+ // Therefor xor'ing with xor_mask is the identity and the computation reduces to
+ // div(value_to_shift, exp(2, shift_amount)), which is correct, since for positive values
+ // arithmetic right shift is dividing by a power of two (which, as a bitwise operation, results
+ // in discarding bits on the right and filling with zeros from the left).
+ // For negative values arithmetic right shift, viewed as a bitwise operation, discards bits to the
+ // right and fills in ones from the left. This is achieved as follows:
+ // If value_to_shift is negative, then xor_mask will have all bits set, so xor'ing with xor_mask
+ // will flip all bits. First all bits in value_to_shift are flipped. As for the positive case,
+ // dividing by a power of two using integer arithmetic results in discarding bits to the right
+ // and filling with zeros from the left. Flipping all bits in the result again, turns all zeros
+ // on the left to ones and restores the non-discarded, shifted bits to their original value (they
+ // have now been flipped twice). In summary we now have discarded bits to the right and filled with
+ // ones from the left, i.e. we have performed an arithmetic right shift.
+ m_context.appendInlineAssembly(R"({
+ let xor_mask := sub(0, slt(value_to_shift, 0))
+ value_to_shift := xor(div(xor(value_to_shift, xor_mask), exp(2, shift_amount)), xor_mask)
+ })", {"value_to_shift", "shift_amount"});
+ else
+ m_context.appendInlineAssembly(R"({
+ value_to_shift := div(value_to_shift, exp(2, shift_amount))
+ })", {"value_to_shift", "shift_amount"});
+ m_context << Instruction::POP;
+
+ }
break;
case Token::SHR:
default:
diff --git a/libsolidity/formal/SMTChecker.cpp b/libsolidity/formal/SMTChecker.cpp
index 425c5c1e..a4d9500b 100644
--- a/libsolidity/formal/SMTChecker.cpp
+++ b/libsolidity/formal/SMTChecker.cpp
@@ -68,7 +68,7 @@ bool SMTChecker::visit(ContractDefinition const& _contract)
void SMTChecker::endVisit(ContractDefinition const&)
{
- m_stateVariables.clear();
+ m_variables.clear();
}
void SMTChecker::endVisit(VariableDeclaration const& _varDecl)
@@ -86,12 +86,10 @@ bool SMTChecker::visit(FunctionDefinition const& _function)
);
m_currentFunction = &_function;
m_interface->reset();
- m_variables.clear();
- m_variables.insert(m_stateVariables.begin(), m_stateVariables.end());
m_pathConditions.clear();
m_loopExecutionHappened = false;
- initializeLocalVariables(_function);
resetStateVariables();
+ initializeLocalVariables(_function);
return true;
}
@@ -100,6 +98,7 @@ void SMTChecker::endVisit(FunctionDefinition const&)
// TOOD we could check for "reachability", i.e. satisfiability here.
// We only handle local variables, so we clear at the beginning of the function.
// If we add storage variables, those should be cleared differently.
+ removeLocalVariables();
m_currentFunction = nullptr;
}
@@ -110,7 +109,7 @@ bool SMTChecker::visit(IfStatement const& _node)
checkBooleanNotConstant(_node.condition(), "Condition is always $VALUE.");
auto countersEndTrue = visitBranch(_node.trueStatement(), expr(_node.condition()));
- vector<Declaration const*> touchedVariables = m_variableUsage->touchedVariables(_node.trueStatement());
+ vector<VariableDeclaration const*> touchedVariables = m_variableUsage->touchedVariables(_node.trueStatement());
decltype(countersEndTrue) countersEndFalse;
if (_node.falseStatement())
{
@@ -230,10 +229,10 @@ void SMTChecker::endVisit(Assignment const& _assignment)
);
else if (Identifier const* identifier = dynamic_cast<Identifier const*>(&_assignment.leftHandSide()))
{
- Declaration const* decl = identifier->annotation().referencedDeclaration;
- if (knownVariable(*decl))
+ VariableDeclaration const& decl = dynamic_cast<VariableDeclaration const&>(*identifier->annotation().referencedDeclaration);
+ if (knownVariable(decl))
{
- assignment(*decl, _assignment.rightHandSide(), _assignment.location());
+ assignment(decl, _assignment.rightHandSide(), _assignment.location());
defineExpr(_assignment, expr(_assignment.rightHandSide()));
}
else
@@ -296,12 +295,12 @@ void SMTChecker::endVisit(UnaryOperation const& _op)
solAssert(_op.subExpression().annotation().lValueRequested, "");
if (Identifier const* identifier = dynamic_cast<Identifier const*>(&_op.subExpression()))
{
- Declaration const* decl = identifier->annotation().referencedDeclaration;
- if (knownVariable(*decl))
+ VariableDeclaration const& decl = dynamic_cast<VariableDeclaration const&>(*identifier->annotation().referencedDeclaration);
+ if (knownVariable(decl))
{
- auto innerValue = currentValue(*decl);
+ auto innerValue = currentValue(decl);
auto newValue = _op.getOperator() == Token::Inc ? innerValue + 1 : innerValue - 1;
- assignment(*decl, newValue, _op.location());
+ assignment(decl, newValue, _op.location());
defineExpr(_op, _op.isPrefixOperation() ? newValue : innerValue);
}
else
@@ -383,14 +382,15 @@ void SMTChecker::endVisit(FunctionCall const& _funCall)
void SMTChecker::endVisit(Identifier const& _identifier)
{
- Declaration const* decl = _identifier.annotation().referencedDeclaration;
- solAssert(decl, "");
if (_identifier.annotation().lValueRequested)
{
// Will be translated as part of the node that requested the lvalue.
}
else if (SSAVariable::isSupportedType(_identifier.annotation().type->category()))
- defineExpr(_identifier, currentValue(*decl));
+ {
+ VariableDeclaration const& decl = dynamic_cast<VariableDeclaration const&>(*(_identifier.annotation().referencedDeclaration));
+ defineExpr(_identifier, currentValue(decl));
+ }
else if (FunctionType const* fun = dynamic_cast<FunctionType const*>(_identifier.annotation().type.get()))
{
if (fun->kind() == FunctionType::Kind::Assert || fun->kind() == FunctionType::Kind::Require)
@@ -485,11 +485,7 @@ void SMTChecker::compareOperation(BinaryOperation const& _op)
solUnimplementedAssert(SSAVariable::isBool(_op.annotation().commonType->category()), "Operation not yet supported");
value = make_shared<smt::Expression>(
op == Token::Equal ? (left == right) :
- op == Token::NotEqual ? (left != right) :
- op == Token::LessThan ? (!left && right) :
- op == Token::LessThanOrEqual ? (!left || right) :
- op == Token::GreaterThan ? (left && !right) :
- /*op == Token::GreaterThanOrEqual*/ (left || !right)
+ /*op == Token::NotEqual*/ (left != right)
);
}
// TODO: check that other values for op are not possible.
@@ -534,12 +530,12 @@ smt::Expression SMTChecker::division(smt::Expression _left, smt::Expression _rig
return _left / _right;
}
-void SMTChecker::assignment(Declaration const& _variable, Expression const& _value, SourceLocation const& _location)
+void SMTChecker::assignment(VariableDeclaration const& _variable, Expression const& _value, SourceLocation const& _location)
{
assignment(_variable, expr(_value), _location);
}
-void SMTChecker::assignment(Declaration const& _variable, smt::Expression const& _value, SourceLocation const& _location)
+void SMTChecker::assignment(VariableDeclaration const& _variable, smt::Expression const& _value, SourceLocation const& _location)
{
TypePointer type = _variable.type();
if (auto const* intType = dynamic_cast<IntegerType const*>(type.get()))
@@ -587,19 +583,7 @@ void SMTChecker::checkCondition(
expressionsToEvaluate.emplace_back(*_additionalValue);
expressionNames.push_back(_additionalValueName);
}
- for (auto const& param: m_currentFunction->parameters())
- if (knownVariable(*param))
- {
- expressionsToEvaluate.emplace_back(currentValue(*param));
- expressionNames.push_back(param->name());
- }
- for (auto const& var: m_currentFunction->localVariables())
- if (knownVariable(*var))
- {
- expressionsToEvaluate.emplace_back(currentValue(*var));
- expressionNames.push_back(var->name());
- }
- for (auto const& var: m_stateVariables)
+ for (auto const& var: m_variables)
if (knownVariable(*var.first))
{
expressionsToEvaluate.emplace_back(currentValue(*var.first));
@@ -744,14 +728,17 @@ void SMTChecker::initializeLocalVariables(FunctionDefinition const& _function)
void SMTChecker::resetStateVariables()
{
- for (auto const& variable: m_stateVariables)
+ for (auto const& variable: m_variables)
{
- newValue(*variable.first);
- setUnknownValue(*variable.first);
+ if (variable.first->isStateVariable())
+ {
+ newValue(*variable.first);
+ setUnknownValue(*variable.first);
+ }
}
}
-void SMTChecker::resetVariables(vector<Declaration const*> _variables)
+void SMTChecker::resetVariables(vector<VariableDeclaration const*> _variables)
{
for (auto const* decl: _variables)
{
@@ -760,9 +747,9 @@ void SMTChecker::resetVariables(vector<Declaration const*> _variables)
}
}
-void SMTChecker::mergeVariables(vector<Declaration const*> const& _variables, smt::Expression const& _condition, VariableSequenceCounters const& _countersEndTrue, VariableSequenceCounters const& _countersEndFalse)
+void SMTChecker::mergeVariables(vector<VariableDeclaration const*> const& _variables, smt::Expression const& _condition, VariableSequenceCounters const& _countersEndTrue, VariableSequenceCounters const& _countersEndFalse)
{
- set<Declaration const*> uniqueVars(_variables.begin(), _variables.end());
+ set<VariableDeclaration const*> uniqueVars(_variables.begin(), _variables.end());
for (auto const* decl: uniqueVars)
{
int trueCounter = _countersEndTrue.at(decl).index();
@@ -781,14 +768,7 @@ bool SMTChecker::createVariable(VariableDeclaration const& _varDecl)
if (SSAVariable::isSupportedType(_varDecl.type()->category()))
{
solAssert(m_variables.count(&_varDecl) == 0, "");
- solAssert(m_stateVariables.count(&_varDecl) == 0, "");
- if (_varDecl.isLocalVariable())
- m_variables.emplace(&_varDecl, SSAVariable(_varDecl, *m_interface));
- else
- {
- solAssert(_varDecl.isStateVariable(), "");
- m_stateVariables.emplace(&_varDecl, SSAVariable(_varDecl, *m_interface));
- }
+ m_variables.emplace(&_varDecl, SSAVariable(_varDecl, *m_interface));
return true;
}
else
@@ -806,37 +786,37 @@ string SMTChecker::uniqueSymbol(Expression const& _expr)
return "expr_" + to_string(_expr.id());
}
-bool SMTChecker::knownVariable(Declaration const& _decl)
+bool SMTChecker::knownVariable(VariableDeclaration const& _decl)
{
return m_variables.count(&_decl);
}
-smt::Expression SMTChecker::currentValue(Declaration const& _decl)
+smt::Expression SMTChecker::currentValue(VariableDeclaration const& _decl)
{
solAssert(knownVariable(_decl), "");
return m_variables.at(&_decl)();
}
-smt::Expression SMTChecker::valueAtSequence(Declaration const& _decl, int _sequence)
+smt::Expression SMTChecker::valueAtSequence(VariableDeclaration const& _decl, int _sequence)
{
solAssert(knownVariable(_decl), "");
return m_variables.at(&_decl)(_sequence);
}
-smt::Expression SMTChecker::newValue(Declaration const& _decl)
+smt::Expression SMTChecker::newValue(VariableDeclaration const& _decl)
{
solAssert(knownVariable(_decl), "");
++m_variables.at(&_decl);
return m_variables.at(&_decl)();
}
-void SMTChecker::setZeroValue(Declaration const& _decl)
+void SMTChecker::setZeroValue(VariableDeclaration const& _decl)
{
solAssert(knownVariable(_decl), "");
m_variables.at(&_decl).setZeroValue();
}
-void SMTChecker::setUnknownValue(Declaration const& _decl)
+void SMTChecker::setUnknownValue(VariableDeclaration const& _decl)
{
solAssert(knownVariable(_decl), "");
m_variables.at(&_decl).setUnknownValue();
@@ -913,3 +893,14 @@ void SMTChecker::addPathImpliedExpression(smt::Expression const& _e)
{
m_interface->addAssertion(smt::Expression::implies(currentPathConditions(), _e));
}
+
+void SMTChecker::removeLocalVariables()
+{
+ for (auto it = m_variables.begin(); it != m_variables.end(); )
+ {
+ if (it->first->isLocalVariable())
+ it = m_variables.erase(it);
+ else
+ ++it;
+ }
+}
diff --git a/libsolidity/formal/SMTChecker.h b/libsolidity/formal/SMTChecker.h
index 50d40ab9..6cf4e48a 100644
--- a/libsolidity/formal/SMTChecker.h
+++ b/libsolidity/formal/SMTChecker.h
@@ -76,11 +76,11 @@ private:
/// of rounding for signed division.
smt::Expression division(smt::Expression _left, smt::Expression _right, IntegerType const& _type);
- void assignment(Declaration const& _variable, Expression const& _value, SourceLocation const& _location);
- void assignment(Declaration const& _variable, smt::Expression const& _value, SourceLocation const& _location);
+ void assignment(VariableDeclaration const& _variable, Expression const& _value, SourceLocation const& _location);
+ void assignment(VariableDeclaration const& _variable, smt::Expression const& _value, SourceLocation const& _location);
/// Maps a variable to an SSA index.
- using VariableSequenceCounters = std::map<Declaration const*, SSAVariable>;
+ using VariableSequenceCounters = std::map<VariableDeclaration const*, SSAVariable>;
/// Visits the branch given by the statement, pushes and pops the current path conditions.
/// @param _condition if present, asserts that this condition is true within the branch.
@@ -114,11 +114,11 @@ private:
void initializeLocalVariables(FunctionDefinition const& _function);
void resetStateVariables();
- void resetVariables(std::vector<Declaration const*> _variables);
+ void resetVariables(std::vector<VariableDeclaration const*> _variables);
/// Given two different branches and the touched variables,
/// merge the touched variables into after-branch ite variables
/// using the branch condition as guard.
- void mergeVariables(std::vector<Declaration const*> const& _variables, smt::Expression const& _condition, VariableSequenceCounters const& _countersEndTrue, VariableSequenceCounters const& _countersEndFalse);
+ void mergeVariables(std::vector<VariableDeclaration const*> const& _variables, smt::Expression const& _condition, VariableSequenceCounters const& _countersEndTrue, VariableSequenceCounters const& _countersEndFalse);
/// Tries to create an uninitialized variable and returns true on success.
/// This fails if the type is not supported.
bool createVariable(VariableDeclaration const& _varDecl);
@@ -127,21 +127,21 @@ private:
/// @returns true if _delc is a variable that is known at the current point, i.e.
/// has a valid sequence number
- bool knownVariable(Declaration const& _decl);
+ bool knownVariable(VariableDeclaration const& _decl);
/// @returns an expression denoting the value of the variable declared in @a _decl
/// at the current point.
- smt::Expression currentValue(Declaration const& _decl);
+ smt::Expression currentValue(VariableDeclaration const& _decl);
/// @returns an expression denoting the value of the variable declared in @a _decl
/// at the given sequence point. Does not ensure that this sequence point exists.
- smt::Expression valueAtSequence(Declaration const& _decl, int _sequence);
+ smt::Expression valueAtSequence(VariableDeclaration const& _decl, int _sequence);
/// Allocates a new sequence number for the declaration, updates the current
/// sequence number to this value and returns the expression.
- smt::Expression newValue(Declaration const& _decl);
+ smt::Expression newValue(VariableDeclaration const& _decl);
/// Sets the value of the declaration to zero.
- void setZeroValue(Declaration const& _decl);
+ void setZeroValue(VariableDeclaration const& _decl);
/// Resets the variable to an unknown value (in its range).
- void setUnknownValue(Declaration const& decl);
+ void setUnknownValue(VariableDeclaration const& decl);
/// Returns the expression corresponding to the AST node. Throws if the expression does not exist.
smt::Expression expr(Expression const& _e);
@@ -161,12 +161,14 @@ private:
/// Add to the solver: the given expression implied by the current path conditions
void addPathImpliedExpression(smt::Expression const& _e);
+ /// Removes the local variables of a function.
+ void removeLocalVariables();
+
std::shared_ptr<smt::SolverInterface> m_interface;
std::shared_ptr<VariableUsage> m_variableUsage;
bool m_loopExecutionHappened = false;
std::map<Expression const*, smt::Expression> m_expressions;
- std::map<Declaration const*, SSAVariable> m_variables;
- std::map<Declaration const*, SSAVariable> m_stateVariables;
+ std::map<VariableDeclaration const*, SSAVariable> m_variables;
std::vector<smt::Expression> m_pathConditions;
ErrorReporter& m_errorReporter;
diff --git a/libsolidity/formal/VariableUsage.cpp b/libsolidity/formal/VariableUsage.cpp
index c2dea844..9282a560 100644
--- a/libsolidity/formal/VariableUsage.cpp
+++ b/libsolidity/formal/VariableUsage.cpp
@@ -50,12 +50,12 @@ VariableUsage::VariableUsage(ASTNode const& _node)
_node.accept(reducer);
}
-vector<Declaration const*> VariableUsage::touchedVariables(ASTNode const& _node) const
+vector<VariableDeclaration const*> VariableUsage::touchedVariables(ASTNode const& _node) const
{
if (!m_children.count(&_node) && !m_touchedVariable.count(&_node))
return {};
- set<Declaration const*> touched;
+ set<VariableDeclaration const*> touched;
vector<ASTNode const*> toVisit;
toVisit.push_back(&_node);
diff --git a/libsolidity/formal/VariableUsage.h b/libsolidity/formal/VariableUsage.h
index 62561cce..dda13de2 100644
--- a/libsolidity/formal/VariableUsage.h
+++ b/libsolidity/formal/VariableUsage.h
@@ -27,7 +27,7 @@ namespace solidity
{
class ASTNode;
-class Declaration;
+class VariableDeclaration;
/**
* This class collects information about which local variables of value type
@@ -38,11 +38,11 @@ class VariableUsage
public:
explicit VariableUsage(ASTNode const& _node);
- std::vector<Declaration const*> touchedVariables(ASTNode const& _node) const;
+ std::vector<VariableDeclaration const*> touchedVariables(ASTNode const& _node) const;
private:
// Variable touched by a specific AST node.
- std::map<ASTNode const*, Declaration const*> m_touchedVariable;
+ std::map<ASTNode const*, VariableDeclaration const*> m_touchedVariable;
std::map<ASTNode const*, std::vector<ASTNode const*>> m_children;
};
diff --git a/libsolidity/inlineasm/AsmAnalysis.cpp b/libsolidity/inlineasm/AsmAnalysis.cpp
index 9f505889..d5580dd2 100644
--- a/libsolidity/inlineasm/AsmAnalysis.cpp
+++ b/libsolidity/inlineasm/AsmAnalysis.cpp
@@ -99,7 +99,7 @@ bool AsmAnalyzer::operator()(assembly::Literal const& _literal)
}
else if (_literal.kind == assembly::LiteralKind::Boolean)
{
- solAssert(m_flavour == AsmFlavour::IULIA, "");
+ solAssert(m_flavour == AsmFlavour::Yul, "");
solAssert(_literal.value == "true" || _literal.value == "false", "");
}
m_info.stackHeightInfo[&_literal] = m_stackHeight;
@@ -162,7 +162,7 @@ bool AsmAnalyzer::operator()(assembly::Identifier const& _identifier)
bool AsmAnalyzer::operator()(FunctionalInstruction const& _instr)
{
- solAssert(m_flavour != AsmFlavour::IULIA, "");
+ solAssert(m_flavour != AsmFlavour::Yul, "");
bool success = true;
for (auto const& arg: _instr.arguments | boost::adaptors::reversed)
if (!expectExpression(arg))
@@ -550,7 +550,7 @@ Scope& AsmAnalyzer::scope(Block const* _block)
}
void AsmAnalyzer::expectValidType(string const& type, SourceLocation const& _location)
{
- if (m_flavour != AsmFlavour::IULIA)
+ if (m_flavour != AsmFlavour::Yul)
return;
if (!builtinTypes.count(type))
diff --git a/libsolidity/inlineasm/AsmDataForward.h b/libsolidity/inlineasm/AsmDataForward.h
index 3a9600fe..69cf8f1d 100644
--- a/libsolidity/inlineasm/AsmDataForward.h
+++ b/libsolidity/inlineasm/AsmDataForward.h
@@ -17,7 +17,7 @@
/**
* @author Christian <c@ethdev.com>
* @date 2016
- * Forward declaration of classes for inline assembly / JULIA AST
+ * Forward declaration of classes for inline assembly / Yul AST
*/
#pragma once
@@ -57,7 +57,7 @@ enum class AsmFlavour
{
Loose, // no types, EVM instructions as function, jumps and direct stack manipulations
Strict, // no types, EVM instructions as functions, but no jumps and no direct stack manipulations
- IULIA // same as Strict mode with types
+ Yul // same as Strict mode with types
};
}
diff --git a/libsolidity/inlineasm/AsmParser.cpp b/libsolidity/inlineasm/AsmParser.cpp
index d3b0808b..7df9ab88 100644
--- a/libsolidity/inlineasm/AsmParser.cpp
+++ b/libsolidity/inlineasm/AsmParser.cpp
@@ -173,7 +173,7 @@ assembly::Statement Parser::parseStatement()
if (currentToken() == Token::Assign && peekNextToken() != Token::Colon)
{
assembly::Assignment assignment = createWithLocation<assembly::Assignment>(identifier.location);
- if (m_flavour != AsmFlavour::IULIA && instructions().count(identifier.name))
+ if (m_flavour != AsmFlavour::Yul && instructions().count(identifier.name))
fatalParserError("Cannot use instruction names for identifier names.");
advance();
assignment.variableNames.emplace_back(identifier);
@@ -318,11 +318,6 @@ std::map<string, dev::solidity::Instruction> const& Parser::instructions()
transform(name.begin(), name.end(), name.begin(), [](unsigned char _c) { return tolower(_c); });
s_instructions[name] = instruction.second;
}
-
- // add alias for suicide
- s_instructions["suicide"] = solidity::Instruction::SELFDESTRUCT;
- // add alis for sha3
- s_instructions["sha3"] = solidity::Instruction::KECCAK256;
}
return s_instructions;
}
@@ -362,7 +357,7 @@ Parser::ElementaryOperation Parser::parseElementaryOperation()
else
literal = currentLiteral();
// first search the set of instructions.
- if (m_flavour != AsmFlavour::IULIA && instructions().count(literal))
+ if (m_flavour != AsmFlavour::Yul && instructions().count(literal))
{
dev::solidity::Instruction const& instr = instructions().at(literal);
ret = Instruction{location(), instr};
@@ -403,7 +398,7 @@ Parser::ElementaryOperation Parser::parseElementaryOperation()
""
};
advance();
- if (m_flavour == AsmFlavour::IULIA)
+ if (m_flavour == AsmFlavour::Yul)
{
expectToken(Token::Colon);
literal.location.end = endPosition();
@@ -416,7 +411,7 @@ Parser::ElementaryOperation Parser::parseElementaryOperation()
}
default:
fatalParserError(
- m_flavour == AsmFlavour::IULIA ?
+ m_flavour == AsmFlavour::Yul ?
"Literal or identifier expected." :
"Literal, identifier or instruction expected."
);
@@ -486,7 +481,7 @@ assembly::Expression Parser::parseCall(Parser::ElementaryOperation&& _initialOp)
RecursionGuard recursionGuard(*this);
if (_initialOp.type() == typeid(Instruction))
{
- solAssert(m_flavour != AsmFlavour::IULIA, "Instructions are invalid in JULIA");
+ solAssert(m_flavour != AsmFlavour::Yul, "Instructions are invalid in Yul");
Instruction& instruction = boost::get<Instruction>(_initialOp);
FunctionalInstruction ret;
ret.instruction = instruction.instruction;
@@ -557,7 +552,7 @@ assembly::Expression Parser::parseCall(Parser::ElementaryOperation&& _initialOp)
}
else
fatalParserError(
- m_flavour == AsmFlavour::IULIA ?
+ m_flavour == AsmFlavour::Yul ?
"Function name expected." :
"Assembly instruction or function name required in front of \"(\")"
);
@@ -570,7 +565,7 @@ TypedName Parser::parseTypedName()
RecursionGuard recursionGuard(*this);
TypedName typedName = createWithLocation<TypedName>();
typedName.name = expectAsmIdentifier();
- if (m_flavour == AsmFlavour::IULIA)
+ if (m_flavour == AsmFlavour::Yul)
{
expectToken(Token::Colon);
typedName.location.end = endPosition();
@@ -582,7 +577,7 @@ TypedName Parser::parseTypedName()
string Parser::expectAsmIdentifier()
{
string name = currentLiteral();
- if (m_flavour == AsmFlavour::IULIA)
+ if (m_flavour == AsmFlavour::Yul)
{
switch (currentToken())
{
@@ -606,7 +601,9 @@ bool Parser::isValidNumberLiteral(string const& _literal)
{
try
{
- u256(_literal);
+ // Try to convert _literal to u256.
+ auto tmp = u256(_literal);
+ (void) tmp;
}
catch (...)
{
diff --git a/libsolidity/inlineasm/AsmPrinter.cpp b/libsolidity/inlineasm/AsmPrinter.cpp
index bacd7a94..1a15d7eb 100644
--- a/libsolidity/inlineasm/AsmPrinter.cpp
+++ b/libsolidity/inlineasm/AsmPrinter.cpp
@@ -40,7 +40,7 @@ using namespace dev::solidity::assembly;
string AsmPrinter::operator()(assembly::Instruction const& _instruction)
{
- solAssert(!m_julia, "");
+ solAssert(!m_yul, "");
return boost::to_lower_copy(instructionInfo(_instruction.instruction).name);
}
@@ -92,7 +92,7 @@ string AsmPrinter::operator()(assembly::Identifier const& _identifier)
string AsmPrinter::operator()(assembly::FunctionalInstruction const& _functionalInstruction)
{
- solAssert(!m_julia, "");
+ solAssert(!m_yul, "");
return
boost::to_lower_copy(instructionInfo(_functionalInstruction.instruction).name) +
"(" +
@@ -109,13 +109,13 @@ string AsmPrinter::operator()(ExpressionStatement const& _statement)
string AsmPrinter::operator()(assembly::Label const& _label)
{
- solAssert(!m_julia, "");
+ solAssert(!m_yul, "");
return _label.name + ":";
}
string AsmPrinter::operator()(assembly::StackAssignment const& _assignment)
{
- solAssert(!m_julia, "");
+ solAssert(!m_yul, "");
return "=: " + (*this)(_assignment.variableName);
}
@@ -225,7 +225,7 @@ string AsmPrinter::operator()(Block const& _block)
string AsmPrinter::appendTypeName(std::string const& _type) const
{
- if (m_julia)
+ if (m_yul)
return ":" + _type;
return "";
}
diff --git a/libsolidity/inlineasm/AsmPrinter.h b/libsolidity/inlineasm/AsmPrinter.h
index 5bd87aba..9f2b842a 100644
--- a/libsolidity/inlineasm/AsmPrinter.h
+++ b/libsolidity/inlineasm/AsmPrinter.h
@@ -36,7 +36,7 @@ namespace assembly
class AsmPrinter: public boost::static_visitor<std::string>
{
public:
- explicit AsmPrinter(bool _julia = false): m_julia(_julia) {}
+ explicit AsmPrinter(bool _yul = false): m_yul(_yul) {}
std::string operator()(assembly::Instruction const& _instruction);
std::string operator()(assembly::Literal const& _literal);
@@ -57,7 +57,7 @@ public:
private:
std::string appendTypeName(std::string const& _type) const;
- bool m_julia = false;
+ bool m_yul = false;
};
}
diff --git a/libsolidity/inlineasm/AsmScope.cpp b/libsolidity/inlineasm/AsmScope.cpp
index 64d5bd9a..af81b301 100644
--- a/libsolidity/inlineasm/AsmScope.cpp
+++ b/libsolidity/inlineasm/AsmScope.cpp
@@ -32,7 +32,7 @@ bool Scope::registerLabel(string const& _name)
return true;
}
-bool Scope::registerVariable(string const& _name, JuliaType const& _type)
+bool Scope::registerVariable(string const& _name, YulType const& _type)
{
if (exists(_name))
return false;
@@ -42,7 +42,7 @@ bool Scope::registerVariable(string const& _name, JuliaType const& _type)
return true;
}
-bool Scope::registerFunction(string const& _name, std::vector<JuliaType> const& _arguments, std::vector<JuliaType> const& _returns)
+bool Scope::registerFunction(string const& _name, std::vector<YulType> const& _arguments, std::vector<YulType> const& _returns)
{
if (exists(_name))
return false;
diff --git a/libsolidity/inlineasm/AsmScope.h b/libsolidity/inlineasm/AsmScope.h
index 447d6490..c8c63f8f 100644
--- a/libsolidity/inlineasm/AsmScope.h
+++ b/libsolidity/inlineasm/AsmScope.h
@@ -62,27 +62,27 @@ struct GenericVisitor<>: public boost::static_visitor<> {
struct Scope
{
- using JuliaType = std::string;
+ using YulType = std::string;
using LabelID = size_t;
- struct Variable { JuliaType type; };
+ struct Variable { YulType type; };
struct Label { };
struct Function
{
- std::vector<JuliaType> arguments;
- std::vector<JuliaType> returns;
+ std::vector<YulType> arguments;
+ std::vector<YulType> returns;
};
using Identifier = boost::variant<Variable, Label, Function>;
using Visitor = GenericVisitor<Variable const, Label const, Function const>;
using NonconstVisitor = GenericVisitor<Variable, Label, Function>;
- bool registerVariable(std::string const& _name, JuliaType const& _type);
+ bool registerVariable(std::string const& _name, YulType const& _type);
bool registerLabel(std::string const& _name);
bool registerFunction(
std::string const& _name,
- std::vector<JuliaType> const& _arguments,
- std::vector<JuliaType> const& _returns
+ std::vector<YulType> const& _arguments,
+ std::vector<YulType> const& _returns
);
/// Looks up the identifier in this or super scopes and returns a valid pointer if found
diff --git a/libsolidity/inlineasm/AsmScopeFiller.cpp b/libsolidity/inlineasm/AsmScopeFiller.cpp
index 86f3809c..2d15c820 100644
--- a/libsolidity/inlineasm/AsmScopeFiller.cpp
+++ b/libsolidity/inlineasm/AsmScopeFiller.cpp
@@ -75,10 +75,10 @@ bool ScopeFiller::operator()(assembly::VariableDeclaration const& _varDecl)
bool ScopeFiller::operator()(assembly::FunctionDefinition const& _funDef)
{
bool success = true;
- vector<Scope::JuliaType> arguments;
+ vector<Scope::YulType> arguments;
for (auto const& _argument: _funDef.parameters)
arguments.push_back(_argument.type);
- vector<Scope::JuliaType> returns;
+ vector<Scope::YulType> returns;
for (auto const& _return: _funDef.returnVariables)
returns.push_back(_return.type);
if (!m_currentScope->registerFunction(_funDef.name, arguments, returns))
diff --git a/libsolidity/interface/AssemblyStack.cpp b/libsolidity/interface/AssemblyStack.cpp
index 7f97336b..a4b0265e 100644
--- a/libsolidity/interface/AssemblyStack.cpp
+++ b/libsolidity/interface/AssemblyStack.cpp
@@ -15,7 +15,7 @@
along with solidity. If not, see <http://www.gnu.org/licenses/>.
*/
/**
- * Full assembly stack that can support EVM-assembly and JULIA as input and EVM, EVM1.5 and
+ * Full assembly stack that can support EVM-assembly and Yul as input and EVM, EVM1.5 and
* eWasm as output.
*/
@@ -48,11 +48,11 @@ assembly::AsmFlavour languageToAsmFlavour(AssemblyStack::Language _language)
return assembly::AsmFlavour::Loose;
case AssemblyStack::Language::StrictAssembly:
return assembly::AsmFlavour::Strict;
- case AssemblyStack::Language::JULIA:
- return assembly::AsmFlavour::IULIA;
+ case AssemblyStack::Language::Yul:
+ return assembly::AsmFlavour::Yul;
}
solAssert(false, "");
- return assembly::AsmFlavour::IULIA;
+ return assembly::AsmFlavour::Yul;
}
}
@@ -117,7 +117,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const
{
MachineAssemblyObject object;
julia::EVMAssembly assembly(true);
- julia::CodeTransform(assembly, *m_analysisInfo, m_language == Language::JULIA, true)(*m_parserResult);
+ julia::CodeTransform(assembly, *m_analysisInfo, m_language == Language::Yul, true)(*m_parserResult);
object.bytecode = make_shared<eth::LinkerObject>(assembly.finalize());
/// TOOD: fill out text representation
return object;
@@ -132,5 +132,5 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const
string AssemblyStack::print() const
{
solAssert(m_parserResult, "");
- return assembly::AsmPrinter(m_language == Language::JULIA)(*m_parserResult);
+ return assembly::AsmPrinter(m_language == Language::Yul)(*m_parserResult);
}
diff --git a/libsolidity/interface/AssemblyStack.h b/libsolidity/interface/AssemblyStack.h
index 720220ab..8132ce63 100644
--- a/libsolidity/interface/AssemblyStack.h
+++ b/libsolidity/interface/AssemblyStack.h
@@ -15,7 +15,7 @@
along with solidity. If not, see <http://www.gnu.org/licenses/>.
*/
/**
- * Full assembly stack that can support EVM-assembly and JULIA as input and EVM, EVM1.5 and
+ * Full assembly stack that can support EVM-assembly and Yul as input and EVM, EVM1.5 and
* eWasm as output.
*/
@@ -47,13 +47,13 @@ struct MachineAssemblyObject
};
/*
- * Full assembly stack that can support EVM-assembly and JULIA as input and EVM, EVM1.5 and
+ * Full assembly stack that can support EVM-assembly and Yul as input and EVM, EVM1.5 and
* eWasm as output.
*/
class AssemblyStack
{
public:
- enum class Language { JULIA, Assembly, StrictAssembly };
+ enum class Language { Yul, Assembly, StrictAssembly };
enum class Machine { EVM, EVM15, eWasm };
explicit AssemblyStack(EVMVersion _evmVersion = EVMVersion(), Language _language = Language::Assembly):
diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp
index 47dc30cf..aa33bad8 100644
--- a/libsolidity/interface/CompilerStack.cpp
+++ b/libsolidity/interface/CompilerStack.cpp
@@ -669,7 +669,7 @@ void CompilerStack::resolveImports()
swap(m_sourceOrder, sourceOrder);
}
-string CompilerStack::absolutePath(string const& _path, string const& _reference) const
+string CompilerStack::absolutePath(string const& _path, string const& _reference)
{
using path = boost::filesystem::path;
path p(_path);
@@ -711,39 +711,33 @@ void CompilerStack::compileContract(
for (auto const* dependency: _contract.annotation().contractDependencies)
compileContract(*dependency, _compiledContracts);
- shared_ptr<Compiler> compiler = make_shared<Compiler>(m_evmVersion, m_optimize, m_optimizeRuns);
Contract& compiledContract = m_contracts.at(_contract.fullyQualifiedName());
- string metadata = createMetadata(compiledContract);
- bytes cborEncodedHash =
- // CBOR-encoding of the key "bzzr0"
- bytes{0x65, 'b', 'z', 'z', 'r', '0'}+
- // CBOR-encoding of the hash
- bytes{0x58, 0x20} + dev::swarmHash(metadata).asBytes();
- bytes cborEncodedMetadata;
- if (onlySafeExperimentalFeaturesActivated(_contract.sourceUnit().annotation().experimentalFeatures))
- cborEncodedMetadata =
- // CBOR-encoding of {"bzzr0": dev::swarmHash(metadata)}
- bytes{0xa1} +
- cborEncodedHash;
- else
- cborEncodedMetadata =
- // CBOR-encoding of {"bzzr0": dev::swarmHash(metadata), "experimental": true}
- bytes{0xa2} +
- cborEncodedHash +
- bytes{0x6c, 'e', 'x', 'p', 'e', 'r', 'i', 'm', 'e', 'n', 't', 'a', 'l', 0xf5};
- solAssert(cborEncodedMetadata.size() <= 0xffff, "Metadata too large");
- // 16-bit big endian length
- cborEncodedMetadata += toCompactBigEndian(cborEncodedMetadata.size(), 2);
- compiler->compileContract(_contract, _compiledContracts, cborEncodedMetadata);
+
+ shared_ptr<Compiler> compiler = make_shared<Compiler>(m_evmVersion, m_optimize, m_optimizeRuns);
compiledContract.compiler = compiler;
+ string metadata = createMetadata(compiledContract);
+ compiledContract.metadata = metadata;
+
+ bytes cborEncodedMetadata = createCBORMetadata(
+ metadata,
+ !onlySafeExperimentalFeaturesActivated(_contract.sourceUnit().annotation().experimentalFeatures)
+ );
+
try
{
- compiledContract.object = compiler->assembledObject();
+ // Run optimiser and compile the contract.
+ compiler->compileContract(_contract, _compiledContracts, cborEncodedMetadata);
}
catch(eth::OptimizerException const&)
{
- solAssert(false, "Assembly optimizer exception for bytecode");
+ solAssert(false, "Optimizer exception during compilation");
+ }
+
+ try
+ {
+ // Assemble deployment (incl. runtime) object.
+ compiledContract.object = compiler->assembledObject();
}
catch(eth::AssemblyException const&)
{
@@ -752,18 +746,14 @@ void CompilerStack::compileContract(
try
{
+ // Assemble runtime object.
compiledContract.runtimeObject = compiler->runtimeObject();
}
- catch(eth::OptimizerException const&)
- {
- solAssert(false, "Assembly optimizer exception for deployed bytecode");
- }
catch(eth::AssemblyException const&)
{
solAssert(false, "Assembly exception for deployed bytecode");
}
- compiledContract.metadata = metadata;
_compiledContracts[compiledContract.contract] = &compiler->assembly();
try
@@ -894,6 +884,31 @@ string CompilerStack::createMetadata(Contract const& _contract) const
return jsonCompactPrint(meta);
}
+bytes CompilerStack::createCBORMetadata(string _metadata, bool _experimentalMode)
+{
+ bytes cborEncodedHash =
+ // CBOR-encoding of the key "bzzr0"
+ bytes{0x65, 'b', 'z', 'z', 'r', '0'}+
+ // CBOR-encoding of the hash
+ bytes{0x58, 0x20} + dev::swarmHash(_metadata).asBytes();
+ bytes cborEncodedMetadata;
+ if (_experimentalMode)
+ cborEncodedMetadata =
+ // CBOR-encoding of {"bzzr0": dev::swarmHash(metadata), "experimental": true}
+ bytes{0xa2} +
+ cborEncodedHash +
+ bytes{0x6c, 'e', 'x', 'p', 'e', 'r', 'i', 'm', 'e', 'n', 't', 'a', 'l', 0xf5};
+ else
+ cborEncodedMetadata =
+ // CBOR-encoding of {"bzzr0": dev::swarmHash(metadata)}
+ bytes{0xa1} +
+ cborEncodedHash;
+ solAssert(cborEncodedMetadata.size() <= 0xffff, "Metadata too large");
+ // 16-bit big endian length
+ cborEncodedMetadata += toCompactBigEndian(cborEncodedMetadata.size(), 2);
+ return cborEncodedMetadata;
+}
+
string CompilerStack::computeSourceMapping(eth::AssemblyItems const& _items) const
{
string ret;
diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h
index 13c9cc7a..4359c3fa 100644
--- a/libsolidity/interface/CompilerStack.h
+++ b/libsolidity/interface/CompilerStack.h
@@ -122,6 +122,8 @@ public:
m_optimizeRuns = _runs;
}
+ /// Set the EVM version used before running compile.
+ /// When called without an argument it will revert to the default version.
void setEVMVersion(EVMVersion _version = EVMVersion{});
/// Sets the list of requested contract names. If empty, no filtering is performed and every contract
@@ -240,9 +242,7 @@ public:
Json::Value gasEstimates(std::string const& _contractName) const;
private:
- /**
- * Information pertaining to one source unit, filled gradually during parsing and compilation.
- */
+ /// The state per source unit. Filled gradually during parsing.
struct Source
{
std::shared_ptr<Scanner> scanner;
@@ -251,13 +251,14 @@ private:
void reset() { scanner.reset(); ast.reset(); }
};
+ /// The state per contract. Filled gradually during compilation.
struct Contract
{
ContractDefinition const* contract = nullptr;
std::shared_ptr<Compiler> compiler;
- eth::LinkerObject object;
- eth::LinkerObject runtimeObject;
- eth::LinkerObject cloneObject;
+ eth::LinkerObject object; ///< Deployment object (includes the runtime sub-object).
+ eth::LinkerObject runtimeObject; ///< Runtime object.
+ eth::LinkerObject cloneObject; ///< Clone object (deprecated).
std::string metadata; ///< The metadata json that will be hashed into the chain.
mutable std::unique_ptr<Json::Value const> abi;
mutable std::unique_ptr<Json::Value const> userDocumentation;
@@ -272,10 +273,12 @@ private:
StringMap loadMissingSources(SourceUnit const& _ast, std::string const& _path);
std::string applyRemapping(std::string const& _path, std::string const& _context);
void resolveImports();
+
/// @returns the absolute path corresponding to @a _path relative to @a _reference.
- std::string absolutePath(std::string const& _path, std::string const& _reference) const;
+ static std::string absolutePath(std::string const& _path, std::string const& _reference);
+
/// Helper function to return path converted strings.
- std::string sanitizePath(std::string const& _path) const { return boost::filesystem::path(_path).generic_string(); }
+ static std::string sanitizePath(std::string const& _path) { return boost::filesystem::path(_path).generic_string(); }
/// @returns true if the contract is requested to be compiled.
bool isRequestedContract(ContractDefinition const& _contract) const;
@@ -285,19 +288,42 @@ private:
ContractDefinition const& _contract,
std::map<ContractDefinition const*, eth::Assembly const*>& _compiledContracts
);
+
+ /// Links all the known library addresses in the available objects. Any unknown
+ /// library will still be kept as an unlinked placeholder in the objects.
void link();
+ /// @returns the contract object for the given @a _contractName.
+ /// Can only be called after state is CompilationSuccessful.
Contract const& contract(std::string const& _contractName) const;
+
+ /// @returns the source object for the given @a _sourceName.
+ /// Can only be called after state is SourcesSet.
Source const& source(std::string const& _sourceName) const;
/// @returns the parsed contract with the supplied name. Throws an exception if the contract
/// does not exist.
ContractDefinition const& contractDefinition(std::string const& _contractName) const;
+ /// @returns the metadata JSON as a compact string for the given contract.
std::string createMetadata(Contract const& _contract) const;
+
+ /// @returns the metadata CBOR for the given serialised metadata JSON.
+ static bytes createCBORMetadata(std::string _metadata, bool _experimentalMode);
+
+ /// @returns the computer source mapping string.
std::string computeSourceMapping(eth::AssemblyItems const& _items) const;
+
+ /// @returns the contract ABI as a JSON object.
+ /// This will generate the JSON object and store it in the Contract object if it is not present yet.
Json::Value const& contractABI(Contract const&) const;
+
+ /// @returns the Natspec User documentation as a JSON object.
+ /// This will generate the JSON object and store it in the Contract object if it is not present yet.
Json::Value const& natspecUser(Contract const&) const;
+
+ /// @returns the Natspec Developer documentation as a JSON object.
+ /// This will generate the JSON object and store it in the Contract object if it is not present yet.
Json::Value const& natspecDev(Contract const&) const;
/// @returns the offset of the entry point of the given function into the list of assembly items
diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp
index ee9b1440..c8d43e9f 100644
--- a/libsolidity/interface/StandardCompiler.cpp
+++ b/libsolidity/interface/StandardCompiler.cpp
@@ -117,7 +117,7 @@ bool hashMatchesContent(string const& _hash, string const& _content)
{
return dev::h256(_hash) == dev::keccak256(_content);
}
- catch (dev::BadHexCharacter)
+ catch (dev::BadHexCharacter const&)
{
return false;
}
@@ -366,7 +366,7 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
// @TODO use libraries only for the given source
libraries[library] = h160(address);
}
- catch (dev::BadHexCharacter)
+ catch (dev::BadHexCharacter const&)
{
return formatFatalError(
"JSONError",
diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp
index e2e1eebc..e9810fe3 100644
--- a/libsolidity/parsing/Parser.cpp
+++ b/libsolidity/parsing/Parser.cpp
@@ -592,11 +592,22 @@ ASTPointer<VariableDeclaration> Parser::parseVariableDeclaration(
else if (!type)
parserError(string("Location specifier needs explicit type name."));
else
- location = (
- token == Token::Memory ?
- VariableDeclaration::Location::Memory :
- VariableDeclaration::Location::Storage
- );
+ {
+ switch (token)
+ {
+ case Token::Storage:
+ location = VariableDeclaration::Location::Storage;
+ break;
+ case Token::Memory:
+ location = VariableDeclaration::Location::Memory;
+ break;
+ case Token::CallData:
+ location = VariableDeclaration::Location::CallData;
+ break;
+ default:
+ solAssert(false, "Unknown data location.");
+ }
+ }
}
else
break;
@@ -928,10 +939,11 @@ ASTPointer<Statement> Parser::parseStatement()
}
case Token::Assembly:
return parseInlineAssembly(docString);
+ case Token::Emit:
+ statement = parseEmitStatement(docString);
+ break;
case Token::Identifier:
- if (m_scanner->currentLiteral() == "emit")
- statement = parseEmitStatement(docString);
- else if (m_insideModifier && m_scanner->currentLiteral() == "_")
+ if (m_insideModifier && m_scanner->currentLiteral() == "_")
{
statement = ASTNodeFactory(*this).createNode<PlaceholderStatement>(docString);
m_scanner->next();
@@ -1051,6 +1063,8 @@ ASTPointer<ForStatement> Parser::parseForStatement(ASTPointer<ASTString> const&
ASTPointer<EmitStatement> Parser::parseEmitStatement(ASTPointer<ASTString> const& _docString)
{
+ expectToken(Token::Emit, false);
+
ASTNodeFactory nodeFactory(*this);
m_scanner->next();
ASTNodeFactory eventCallNodeFactory(*this);
diff --git a/libsolidity/parsing/Scanner.cpp b/libsolidity/parsing/Scanner.cpp
index 6541f6c2..801d2cc4 100644
--- a/libsolidity/parsing/Scanner.cpp
+++ b/libsolidity/parsing/Scanner.cpp
@@ -768,8 +768,14 @@ Token::Value Scanner::scanNumber(char _charSeen)
scanDecimalDigits(); // optional
if (m_char == '.')
{
+ // A '.' has to be followed by a number.
+ if (m_source.isPastEndOfInput() || !isDecimalDigit(m_source.get(1)))
+ {
+ literal.complete();
+ return Token::Number;
+ }
addLiteralCharAndAdvance();
- scanDecimalDigits(); // optional
+ scanDecimalDigits();
}
}
}
diff --git a/libsolidity/parsing/Token.h b/libsolidity/parsing/Token.h
index 4d7a7bc6..cb855cbe 100644
--- a/libsolidity/parsing/Token.h
+++ b/libsolidity/parsing/Token.h
@@ -149,6 +149,7 @@ namespace solidity
K(Do, "do", 0) \
K(Else, "else", 0) \
K(Enum, "enum", 0) \
+ K(Emit, "emit", 0) \
K(Event, "event", 0) \
K(External, "external", 0) \
K(For, "for", 0) \
@@ -173,6 +174,7 @@ namespace solidity
K(Return, "return", 0) \
K(Returns, "returns", 0) \
K(Storage, "storage", 0) \
+ K(CallData, "calldata", 0) \
K(Struct, "struct", 0) \
K(Throw, "throw", 0) \
K(Using, "using", 0) \
@@ -221,22 +223,41 @@ namespace solidity
/* Keywords reserved for future use. */ \
K(Abstract, "abstract", 0) \
K(After, "after", 0) \
+ K(Alias, "alias", 0) \
+ K(Apply, "apply", 0) \
+ K(Auto, "auto", 0) \
K(Case, "case", 0) \
K(Catch, "catch", 0) \
+ K(CopyOf, "copyof", 0) \
K(Default, "default", 0) \
+ K(Define, "define", 0) \
K(Final, "final", 0) \
+ K(Immutable, "immutable", 0) \
+ K(Implements, "implements", 0) \
K(In, "in", 0) \
K(Inline, "inline", 0) \
K(Let, "let", 0) \
+ K(Macro, "macro", 0) \
K(Match, "match", 0) \
+ K(Mutable, "mutable", 0) \
K(NullLiteral, "null", 0) \
K(Of, "of", 0) \
+ K(Override, "override", 0) \
+ K(Partial, "partial", 0) \
+ K(Promise, "promise", 0) \
+ K(Reference, "reference", 0) \
K(Relocatable, "relocatable", 0) \
+ K(Sealed, "sealed", 0) \
+ K(Sizeof, "sizeof", 0) \
K(Static, "static", 0) \
+ K(Supports, "supports", 0) \
K(Switch, "switch", 0) \
K(Try, "try", 0) \
K(Type, "type", 0) \
+ K(Typedef, "typedef", 0) \
K(TypeOf, "typeof", 0) \
+ K(Unchecked, "unchecked", 0) \
+ \
/* Illegal token - not able to scan. */ \
T(Illegal, "ILLEGAL", 0) \
\
@@ -289,11 +310,11 @@ public:
static bool isShiftOp(Value op) { return (SHL <= op) && (op <= SHR); }
static bool isVisibilitySpecifier(Value op) { return isVariableVisibilitySpecifier(op) || op == External; }
static bool isVariableVisibilitySpecifier(Value op) { return op == Public || op == Private || op == Internal; }
- static bool isLocationSpecifier(Value op) { return op == Memory || op == Storage; }
+ static bool isLocationSpecifier(Value op) { return op == Memory || op == Storage || op == CallData; }
static bool isStateMutabilitySpecifier(Value op) { return op == Pure || op == Constant || op == View || op == Payable; }
static bool isEtherSubdenomination(Value op) { return op == SubWei || op == SubSzabo || op == SubFinney || op == SubEther; }
static bool isTimeSubdenomination(Value op) { return op == SubSecond || op == SubMinute || op == SubHour || op == SubDay || op == SubWeek || op == SubYear; }
- static bool isReservedKeyword(Value op) { return (Abstract <= op && op <= TypeOf); }
+ static bool isReservedKeyword(Value op) { return (Abstract <= op && op <= Unchecked); }
// @returns a string corresponding to the JS token string
// (.e., "<" for the token LT) or NULL if the token doesn't
@@ -348,7 +369,7 @@ public:
unsigned int secondNumber() const { return m_secondNumber; }
Token::Value token() const { return m_token; }
///if tokValue is set to true, then returns the actual token type name, otherwise, returns full type
- std::string toString(bool const& tokenValue = false) const
+ std::string toString(bool const& tokenValue = false) const
{
std::string name = Token::toString(m_token);
if (tokenValue || (firstNumber() == 0 && secondNumber() == 0))
diff --git a/scripts/Dockerfile b/scripts/Dockerfile
index 654a9f29..2b2de1e2 100644
--- a/scripts/Dockerfile
+++ b/scripts/Dockerfile
@@ -1,18 +1,39 @@
-FROM alpine
+FROM alpine AS build
MAINTAINER chriseth <chris@ethereum.org>
#Official solidity docker image
#Establish working directory as solidity
WORKDIR /solidity
+
+# Build dependencies
+ADD /scripts/install_deps.sh /solidity/scripts/install_deps.sh
+RUN ./scripts/install_deps.sh
+
#Copy working directory on travis to the image
COPY / $WORKDIR
-#Install dependencies, eliminate annoying warnings, and build release, delete all remaining points and statically link.
-RUN ./scripts/install_deps.sh && sed -i -E -e 's/include <sys\/poll.h>/include <poll.h>/' /usr/include/boost/asio/detail/socket_types.hpp &&\
-cmake -DCMAKE_BUILD_TYPE=Release -DTESTS=0 -DSOLC_LINK_STATIC=1 &&\
-make solc && install -s solc/solc /usr/bin &&\
-cd / && rm -rf solidity &&\
-apk del sed build-base git make cmake gcc g++ musl-dev curl-dev boost-dev &&\
-rm -rf /var/cache/apk/*
+# Number of parallel jobs during build
+# or 0 for auto-computing (max(1, CPU_core_count * 2/3), a greedy value)
+ARG BUILD_CONCURRENCY="0"
+
+#Install dependencies, eliminate annoying warnings
+RUN sed -i -E -e 's/include <sys\/poll.h>/include <poll.h>/' /usr/include/boost/asio/detail/socket_types.hpp
+RUN cmake -DCMAKE_BUILD_TYPE=Release -DTESTS=0 -DSOLC_LINK_STATIC=1
+RUN make solc \
+ -j$(awk "BEGIN { \
+ if (${BUILD_CONCURRENCY} != 0) { \
+ print(${BUILD_CONCURRENCY}); \
+ } else { \
+ x=($(grep -c ^processor /proc/cpuinfo) * 2/3); \
+ if (x > 1) { \
+ printf(\"%d\n\", x); \
+ } else { \
+ print(1); \
+ } \
+ } \
+ }")
+RUN strip solc/solc
-ENTRYPOINT ["/usr/bin/solc"] \ No newline at end of file
+FROM scratch
+COPY --from=build /solidity/solc/solc /usr/bin/solc
+ENTRYPOINT ["/usr/bin/solc"]
diff --git a/scripts/docs.sh b/scripts/docs.sh
index 42400bc7..2c08a82b 100755
--- a/scripts/docs.sh
+++ b/scripts/docs.sh
@@ -28,5 +28,6 @@
set -e
cd docs
+pip install -r requirements.txt
sphinx-build -nW -b html -d _build/doctrees . _build/html
cd ..
diff --git a/scripts/extract_test_cases.py b/scripts/extract_test_cases.py
index 07ef9a96..47c53f3c 100755
--- a/scripts/extract_test_cases.py
+++ b/scripts/extract_test_cases.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2
#
# This script reads C++ or RST source files and writes all
# multi-line strings into individual files.
diff --git a/scripts/install_deps.sh b/scripts/install_deps.sh
index fa5551bf..ace6580a 100755
--- a/scripts/install_deps.sh
+++ b/scripts/install_deps.sh
@@ -133,19 +133,18 @@ case $(uname -s) in
# Arch Linux
#------------------------------------------------------------------------------
- Arch)
+ Arch*)
#Arch
echo "Installing solidity dependencies on Arch Linux."
# All our dependencies can be found in the Arch Linux official repositories.
# See https://wiki.archlinux.org/index.php/Official_repositories
- # Also adding ethereum-git to allow for testing with the `eth` client
sudo pacman -Syu \
base-devel \
boost \
cmake \
git \
- ethereum-git \
+ cvc4
;;
#------------------------------------------------------------------------------
@@ -160,7 +159,7 @@ case $(uname -s) in
# See https://pkgs.alpinelinux.org/
apk update
- apk add boost-dev build-base cmake
+ apk add boost-dev build-base cmake git
;;
@@ -329,7 +328,7 @@ case $(uname -s) in
"$install_z3"
if [ "$CI" = true ]; then
# install Z3 from PPA if the distribution does not provide it
- if ! dpkg -l libz3-dev > /dev/null 2>&1
+ if ! dpkg -l libz3-dev > /dev/null 2>&1
then
sudo apt-add-repository -y ppa:hvr/z3
sudo apt-get -y update
diff --git a/scripts/install_obsolete_jsoncpp_1_7_4.sh b/scripts/install_obsolete_jsoncpp_1_7_4.sh
new file mode 100755
index 00000000..0ae7b34c
--- /dev/null
+++ b/scripts/install_obsolete_jsoncpp_1_7_4.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env sh
+set -e
+
+TEMPDIR=$(mktemp -d)
+(
+ cd $TEMPDIR
+ wget https://github.com/open-source-parsers/jsoncpp/archive/1.7.4.tar.gz
+ tar xvzf "1.7.4.tar.gz"
+ cd "jsoncpp-1.7.4"
+ mkdir -p build
+ cd build
+ cmake -DARCHIVE_INSTALL_DIR=. -G "Unix Makefiles" ..
+ make
+ make install
+)
+rm -rf $TEMPDIR
diff --git a/scripts/isolate_tests.py b/scripts/isolate_tests.py
index 5bf577d3..82dff1e0 100755
--- a/scripts/isolate_tests.py
+++ b/scripts/isolate_tests.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2
#
# This script reads C++ or RST source files and writes all
# multi-line strings into individual files.
diff --git a/scripts/release.bat b/scripts/release.bat
index be95b35e..6415a040 100644
--- a/scripts/release.bat
+++ b/scripts/release.bat
@@ -32,11 +32,10 @@ set VERSION=%2
IF "%VERSION%"=="2015" (
set "DLLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x86\Microsoft.VC140.CRT\msvc*.dll"
) ELSE (
-
- IF EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Redist\MSVC\14.13.26020\x86\Microsoft.VC141.CRT\" (
- set "DLLS=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Redist\MSVC\14.13.26020\x86\Microsoft.VC141.CRT\msvc*.dll"
+ IF EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Redist\MSVC\14.14.26405\x86\Microsoft.VC141.CRT\" (
+ set "DLLS=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Redist\MSVC\14.14.26405\x86\Microsoft.VC141.CRT\msvc*.dll"
) ELSE (
- set "DLLS=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Redist\MSVC\14.13.26020\x86\Microsoft.VC141.CRT\msvc*.dll"
+ set "DLLS=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Redist\MSVC\14.14.26405\x86\Microsoft.VC141.CRT\msvc*.dll"
)
)
diff --git a/scripts/release_ppa.sh b/scripts/release_ppa.sh
index b1601336..ae565a02 100755
--- a/scripts/release_ppa.sh
+++ b/scripts/release_ppa.sh
@@ -50,11 +50,11 @@ else
ppafilesurl=https://launchpad.net/~ethereum/+archive/ubuntu/ethereum/+files
fi
-keyid=703F83D0
+keyid=70D110489D66E2F6
email=builds@ethereum.org
packagename=solc
-for distribution in trusty vivid xenial zesty artful bionic
+for distribution in trusty xenial artful bionic
do
cd /tmp/
rm -rf $distribution
diff --git a/scripts/update_bugs_by_version.py b/scripts/update_bugs_by_version.py
index cbedf1a5..68ccd72a 100755
--- a/scripts/update_bugs_by_version.py
+++ b/scripts/update_bugs_by_version.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
#
# This script is used to generate the list of bugs per compiler version
# from the list of bugs.
diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp
index 1f04c68a..8b331c75 100644
--- a/solc/CommandLineInterface.cpp
+++ b/solc/CommandLineInterface.cpp
@@ -88,12 +88,11 @@ static string const g_strEVM = "evm";
static string const g_strEVM15 = "evm15";
static string const g_strEVMVersion = "evm-version";
static string const g_streWasm = "ewasm";
-static string const g_strFormal = "formal";
static string const g_strGas = "gas";
static string const g_strHelp = "help";
static string const g_strInputFile = "input-file";
static string const g_strInterface = "interface";
-static string const g_strJulia = "julia";
+static string const g_strYul = "yul";
static string const g_strLicense = "license";
static string const g_strLibraries = "libraries";
static string const g_strLink = "link";
@@ -132,11 +131,10 @@ static string const g_argBinaryRuntime = g_strBinaryRuntime;
static string const g_argCloneBinary = g_strCloneBinary;
static string const g_argCombinedJson = g_strCombinedJson;
static string const g_argCompactJSON = g_strCompactJSON;
-static string const g_argFormal = g_strFormal;
static string const g_argGas = g_strGas;
static string const g_argHelp = g_strHelp;
static string const g_argInputFile = g_strInputFile;
-static string const g_argJulia = g_strJulia;
+static string const g_argYul = g_strYul;
static string const g_argLibraries = g_strLibraries;
static string const g_argLink = g_strLink;
static string const g_argMachine = g_strMachine;
@@ -216,7 +214,6 @@ static bool needsHumanTargetedStdout(po::variables_map const& _args)
g_argBinary,
g_argBinaryRuntime,
g_argCloneBinary,
- g_argFormal,
g_argMetadata,
g_argNatspecUser,
g_argNatspecDev,
@@ -404,9 +401,7 @@ bool CommandLineInterface::readInputFilesAndConfigureRemappings()
{
bool ignoreMissing = m_args.count(g_argIgnoreMissingFiles);
bool addStdin = false;
- if (!m_args.count(g_argInputFile))
- addStdin = true;
- else
+ if (m_args.count(g_argInputFile))
for (string path: m_args[g_argInputFile].as<vector<string>>())
{
auto eq = find(path.begin(), path.end(), '=');
@@ -450,6 +445,11 @@ bool CommandLineInterface::readInputFilesAndConfigureRemappings()
}
if (addStdin)
m_sourceCodes[g_stdinFileName] = dev::readStandardInput();
+ if (m_sourceCodes.size() == 0)
+ {
+ cerr << "No input files given. If you wish to use the standard input please specify \"-\" explicity." << endl;
+ return false;
+ }
return true;
}
@@ -597,8 +597,8 @@ Allowed options)",
"Switch to assembly mode, ignoring all options except --machine and assumes input is assembly."
)
(
- g_argJulia.c_str(),
- "Switch to JULIA mode, ignoring all options except --machine and assumes input is JULIA."
+ g_argYul.c_str(),
+ "Switch to Yul mode, ignoring all options except --machine and assumes input is Yul."
)
(
g_argStrictAssembly.c_str(),
@@ -607,7 +607,7 @@ Allowed options)",
(
g_argMachine.c_str(),
po::value<string>()->value_name(boost::join(g_machineArgs, ",")),
- "Target machine in assembly or JULIA mode."
+ "Target machine in assembly or Yul mode."
)
(
g_argLink.c_str(),
@@ -636,8 +636,7 @@ Allowed options)",
(g_argSignatureHashes.c_str(), "Function signature hashes of the contracts.")
(g_argNatspecUser.c_str(), "Natspec user documentation of all contracts.")
(g_argNatspecDev.c_str(), "Natspec developer documentation of all contracts.")
- (g_argMetadata.c_str(), "Combined Metadata JSON whose Swarm hash is stored on-chain.")
- (g_argFormal.c_str(), "Translated source suitable for formal analysis. (Deprecated)");
+ (g_argMetadata.c_str(), "Combined Metadata JSON whose Swarm hash is stored on-chain.");
desc.add(outputComponents);
po::options_description allOptions = desc;
@@ -782,13 +781,13 @@ bool CommandLineInterface::processInput()
m_evmVersion = *versionOption;
}
- if (m_args.count(g_argAssemble) || m_args.count(g_argStrictAssembly) || m_args.count(g_argJulia))
+ if (m_args.count(g_argAssemble) || m_args.count(g_argStrictAssembly) || m_args.count(g_argYul))
{
// switch to assembly mode
m_onlyAssemble = true;
using Input = AssemblyStack::Language;
using Machine = AssemblyStack::Machine;
- Input inputLanguage = m_args.count(g_argJulia) ? Input::JULIA : (m_args.count(g_argStrictAssembly) ? Input::StrictAssembly : Input::Assembly);
+ Input inputLanguage = m_args.count(g_argYul) ? Input::Yul : (m_args.count(g_argStrictAssembly) ? Input::StrictAssembly : Input::Assembly);
Machine targetMachine = Machine::EVM;
if (m_args.count(g_argMachine))
{
@@ -1233,9 +1232,6 @@ void CommandLineInterface::outputCompilationResults()
handleNatspec(true, contract);
handleNatspec(false, contract);
} // end of contracts iteration
-
- if (m_args.count(g_argFormal))
- cerr << "Support for the Why3 output was removed." << endl;
}
}
diff --git a/std/StandardToken.sol b/std/StandardToken.sol
deleted file mode 100644
index c2fc3a66..00000000
--- a/std/StandardToken.sol
+++ /dev/null
@@ -1,59 +0,0 @@
-pragma solidity ^0.4.22;
-
-import "./Token.sol";
-
-contract StandardToken is Token {
- uint256 supply;
- mapping (address => uint256) balance;
- mapping (address =>
- mapping (address => uint256)) m_allowance;
-
- constructor(address _initialOwner, uint256 _supply) public {
- supply = _supply;
- balance[_initialOwner] = _supply;
- }
-
- function balanceOf(address _account) view public returns (uint) {
- return balance[_account];
- }
-
- function totalSupply() view public returns (uint) {
- return supply;
- }
-
- function transfer(address _to, uint256 _value) public returns (bool success) {
- return doTransfer(msg.sender, _to, _value);
- }
-
- function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
- if (m_allowance[_from][msg.sender] >= _value) {
- if (doTransfer(_from, _to, _value)) {
- m_allowance[_from][msg.sender] -= _value;
- }
- return true;
- } else {
- return false;
- }
- }
-
- function doTransfer(address _from, address _to, uint _value) internal returns (bool success) {
- if (balance[_from] >= _value && balance[_to] + _value >= balance[_to]) {
- balance[_from] -= _value;
- balance[_to] += _value;
- emit Transfer(_from, _to, _value);
- return true;
- } else {
- return false;
- }
- }
-
- function approve(address _spender, uint256 _value) public returns (bool success) {
- m_allowance[msg.sender][_spender] = _value;
- emit Approval(msg.sender, _spender, _value);
- return true;
- }
-
- function allowance(address _owner, address _spender) view public returns (uint256) {
- return m_allowance[_owner][_spender];
- }
-}
diff --git a/std/Token.sol b/std/Token.sol
deleted file mode 100644
index 7348a8f5..00000000
--- a/std/Token.sol
+++ /dev/null
@@ -1,13 +0,0 @@
-pragma solidity ^0.4.0;
-
-contract Token {
- event Transfer(address indexed _from, address indexed _to, uint256 _value);
- event Approval(address indexed _owner, address indexed _spender, uint256 _value);
-
- function totalSupply() view public returns (uint256 supply);
- function balanceOf(address _owner) view public returns (uint256 balance);
- function transfer(address _to, uint256 _value) public returns (bool success);
- function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
- function approve(address _spender, uint256 _value) public returns (bool success);
- function allowance(address _owner, address _spender) view public returns (uint256 remaining);
-}
diff --git a/std/mortal.sol b/std/mortal.sol
deleted file mode 100644
index c43f1e4f..00000000
--- a/std/mortal.sol
+++ /dev/null
@@ -1,10 +0,0 @@
-pragma solidity ^0.4.0;
-
-import "./owned.sol";
-
-contract mortal is owned {
- function kill() public {
- if (msg.sender == owner)
- selfdestruct(owner);
- }
-}
diff --git a/std/owned.sol b/std/owned.sol
deleted file mode 100644
index 75007f3e..00000000
--- a/std/owned.sol
+++ /dev/null
@@ -1,15 +0,0 @@
-pragma solidity ^0.4.22;
-
-contract owned {
- address owner;
-
- modifier onlyowner() {
- if (msg.sender == owner) {
- _;
- }
- }
-
- constructor() public {
- owner = msg.sender;
- }
-}
diff --git a/std/std.sol b/std/std.sol
deleted file mode 100644
index 4d65bef2..00000000
--- a/std/std.sol
+++ /dev/null
@@ -1,6 +0,0 @@
-pragma solidity ^0.4.0;
-
-import "./owned.sol";
-import "./mortal.sol";
-import "./Token.sol";
-import "./StandardToken.sol";
diff --git a/test/RPCSession.cpp b/test/RPCSession.cpp
index f4eae865..160b0047 100644
--- a/test/RPCSession.cpp
+++ b/test/RPCSession.cpp
@@ -244,7 +244,10 @@ void RPCSession::test_setChainParams(vector<string> const& _accounts)
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x",
- "gasLimit": "0x1000000000000"
+ "gasLimit": "0x1000000000000",
+ "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
+ "nonce": "0x0000000000000042",
+ "difficulty": "1"
},
"accounts": {
"0000000000000000000000000000000000000001": { "wei": "1", "precompiled": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
diff --git a/test/boostTest.cpp b/test/boostTest.cpp
index f16973b5..145be6e4 100644
--- a/test/boostTest.cpp
+++ b/test/boostTest.cpp
@@ -38,7 +38,26 @@
#include <test/Options.h>
#include <test/libsolidity/SyntaxTest.h>
+#include <boost/algorithm/string.hpp>
+#include <boost/algorithm/string/predicate.hpp>
+#include <boost/filesystem.hpp>
+
using namespace boost::unit_test;
+using namespace dev::solidity::test;
+namespace fs = boost::filesystem;
+using namespace std;
+
+#if BOOST_VERSION < 105900
+test_case *make_test_case(
+ function<void()> const& _fn,
+ string const& _name,
+ string const& /* _filename */,
+ size_t /* _line */
+)
+{
+ return make_test_case(_fn, _name);
+}
+#endif
namespace
{
@@ -49,6 +68,56 @@ void removeTestSuite(std::string const& _name)
assert(id != INV_TEST_UNIT_ID);
master.remove(id);
}
+
+int registerTests(
+ boost::unit_test::test_suite& _suite,
+ boost::filesystem::path const& _basepath,
+ boost::filesystem::path const& _path,
+ TestCase::TestCaseCreator _testCaseCreator
+)
+{
+ int numTestsAdded = 0;
+ fs::path fullpath = _basepath / _path;
+ if (fs::is_directory(fullpath))
+ {
+ test_suite* sub_suite = BOOST_TEST_SUITE(_path.filename().string());
+ for (auto const& entry: boost::iterator_range<fs::directory_iterator>(
+ fs::directory_iterator(fullpath),
+ fs::directory_iterator()
+ ))
+ if (fs::is_directory(entry.path()) || TestCase::isTestFilename(entry.path().filename()))
+ numTestsAdded += registerTests(*sub_suite, _basepath, _path / entry.path().filename(), _testCaseCreator);
+ _suite.add(sub_suite);
+ }
+ else
+ {
+ static vector<unique_ptr<string>> filenames;
+
+ filenames.emplace_back(new string(_path.string()));
+ _suite.add(make_test_case(
+ [fullpath, _testCaseCreator]
+ {
+ BOOST_REQUIRE_NO_THROW({
+ try
+ {
+ stringstream errorStream;
+ if (!_testCaseCreator(fullpath.string())->run(errorStream))
+ BOOST_ERROR("Test expectation mismatch.\n" + errorStream.str());
+ }
+ catch (boost::exception const& _e)
+ {
+ BOOST_ERROR("Exception during extracted test: " << boost::diagnostic_information(_e));
+ }
+ });
+ },
+ _path.stem().string(),
+ *filenames.back(),
+ 0
+ ));
+ numTestsAdded = 1;
+ }
+ return numTestsAdded;
+}
}
test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] )
@@ -56,10 +125,11 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] )
master_test_suite_t& master = framework::master_test_suite();
master.p_name.value = "SolidityTests";
dev::test::Options::get().validate();
- solAssert(dev::solidity::test::SyntaxTest::registerTests(
+ solAssert(registerTests(
master,
dev::test::Options::get().testPath / "libsolidity",
- "syntaxTests"
+ "syntaxTests",
+ SyntaxTest::create
) > 0, "no syntax tests found");
if (dev::test::Options::get().disableIPC)
{
diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh
index 1137c7b0..bc0ee786 100755
--- a/test/cmdlineTests.sh
+++ b/test/cmdlineTests.sh
@@ -37,10 +37,6 @@ FULLARGS="--optimize --ignore-missing --combined-json abi,asm,ast,bin,bin-runtim
echo "Checking that the bug list is up to date..."
"$REPO_ROOT"/scripts/update_bugs_by_version.py
-echo "Checking that StandardToken.sol, owned.sol and mortal.sol produce bytecode..."
-output=$("$REPO_ROOT"/build/solc/solc --bin "$REPO_ROOT"/std/*.sol 2>/dev/null | grep "ffff" | wc -l)
-test "${output//[[:blank:]]/}" = "3"
-
function printTask() { echo "$(tput bold)$(tput setaf 2)$1$(tput sgr0)"; }
function printError() { echo "$(tput setaf 1)$1$(tput sgr0)"; }
@@ -113,14 +109,6 @@ do
done
)
-printTask "Compiling all files in std and examples..."
-
-for f in "$REPO_ROOT"/std/*.sol
-do
- echo "$f"
- compileWithoutWarning "$f"
-done
-
printTask "Compiling all examples from the documentation..."
TMPDIR=$(mktemp -d)
(
@@ -139,25 +127,55 @@ rm -rf "$TMPDIR"
echo "Done."
printTask "Testing library checksum..."
-echo '' | "$SOLC" --link --libraries a:0x90f20564390eAe531E810af625A22f51385Cd222
-! echo '' | "$SOLC" --link --libraries a:0x80f20564390eAe531E810af625A22f51385Cd222 2>/dev/null
+echo '' | "$SOLC" - --link --libraries a:0x90f20564390eAe531E810af625A22f51385Cd222 >/dev/null
+! echo '' | "$SOLC" - --link --libraries a:0x80f20564390eAe531E810af625A22f51385Cd222 &>/dev/null
printTask "Testing long library names..."
-echo '' | "$SOLC" --link --libraries aveeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeerylonglibraryname:0x90f20564390eAe531E810af625A22f51385Cd222
+echo '' | "$SOLC" - --link --libraries aveeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeerylonglibraryname:0x90f20564390eAe531E810af625A22f51385Cd222 >/dev/null
-printTask "Testing overwriting files"
+printTask "Testing overwriting files..."
TMPDIR=$(mktemp -d)
(
set -e
# First time it works
- echo 'contract C {} ' | "$SOLC" --bin -o "$TMPDIR/non-existing-stuff-to-create" 2>/dev/null
+ echo 'contract C {} ' | "$SOLC" - --bin -o "$TMPDIR/non-existing-stuff-to-create" 2>/dev/null
# Second time it fails
- ! echo 'contract C {} ' | "$SOLC" --bin -o "$TMPDIR/non-existing-stuff-to-create" 2>/dev/null
+ ! echo 'contract C {} ' | "$SOLC" - --bin -o "$TMPDIR/non-existing-stuff-to-create" 2>/dev/null
# Unless we force
- echo 'contract C {} ' | "$SOLC" --overwrite --bin -o "$TMPDIR/non-existing-stuff-to-create" 2>/dev/null
+ echo 'contract C {} ' | "$SOLC" - --overwrite --bin -o "$TMPDIR/non-existing-stuff-to-create" 2>/dev/null
)
rm -rf "$TMPDIR"
+printTask "Testing assemble, yul, strict-assembly..."
+echo '{}' | "$SOLC" - --assemble &>/dev/null
+echo '{}' | "$SOLC" - --yul &>/dev/null
+echo '{}' | "$SOLC" - --strict-assembly &>/dev/null
+
+printTask "Testing standard input..."
+TMPDIR=$(mktemp -d)
+(
+ set +e
+ output=$("$SOLC" --bin 2>&1)
+ result=$?
+ set -e
+
+ # This should fail
+ if [[ !("$output" =~ "No input files given") || ($result == 0) ]] ; then
+ printError "Incorrect response to empty input arg list: $STDERR"
+ exit 1
+ fi
+
+ set +e
+ output=$(echo 'contract C {} ' | "$SOLC" - --bin 2>/dev/null | grep -q "<stdin>:C")
+ result=$?
+ set -e
+
+ # The contract should be compiled
+ if [[ "$result" != 0 ]] ; then
+ exit 1
+ fi
+)
+
printTask "Testing soljson via the fuzzer..."
TMPDIR=$(mktemp -d)
(
diff --git a/test/compilationTests/MultiSigWallet/Factory.sol b/test/compilationTests/MultiSigWallet/Factory.sol
index f1be6884..f7a96cbd 100644
--- a/test/compilationTests/MultiSigWallet/Factory.sol
+++ b/test/compilationTests/MultiSigWallet/Factory.sol
@@ -23,6 +23,6 @@ contract Factory {
{
isInstantiation[instantiation] = true;
instantiations[msg.sender].push(instantiation);
- ContractInstantiation(msg.sender, instantiation);
+ emit ContractInstantiation(msg.sender, instantiation);
}
}
diff --git a/test/compilationTests/MultiSigWallet/MultiSigWallet.sol b/test/compilationTests/MultiSigWallet/MultiSigWallet.sol
index a6f67c7a..78e18f3c 100644
--- a/test/compilationTests/MultiSigWallet/MultiSigWallet.sol
+++ b/test/compilationTests/MultiSigWallet/MultiSigWallet.sol
@@ -50,7 +50,7 @@ contract MultiSigWallet {
}
modifier transactionExists(uint transactionId) {
- if (transactions[transactionId].destination == 0)
+ if (transactions[transactionId].destination == address(0))
throw;
_;
}
@@ -74,7 +74,7 @@ contract MultiSigWallet {
}
modifier notNull(address _address) {
- if (_address == 0)
+ if (_address == address(0))
throw;
_;
}
@@ -93,7 +93,7 @@ contract MultiSigWallet {
payable
{
if (msg.value > 0)
- Deposit(msg.sender, msg.value);
+ emit Deposit(msg.sender, msg.value);
}
/*
@@ -102,12 +102,12 @@ contract MultiSigWallet {
/// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations.
- function MultiSigWallet(address[] _owners, uint _required)
+ constructor(address[] _owners, uint _required)
public
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
- if (isOwner[_owners[i]] || _owners[i] == 0)
+ if (isOwner[_owners[i]] || _owners[i] == address(0))
throw;
isOwner[_owners[i]] = true;
}
@@ -126,7 +126,7 @@ contract MultiSigWallet {
{
isOwner[owner] = true;
owners.push(owner);
- OwnerAddition(owner);
+ emit OwnerAddition(owner);
}
/// @dev Allows to remove an owner. Transaction has to be sent by wallet.
@@ -145,7 +145,7 @@ contract MultiSigWallet {
owners.length -= 1;
if (required > owners.length)
changeRequirement(owners.length);
- OwnerRemoval(owner);
+ emit OwnerRemoval(owner);
}
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
@@ -164,8 +164,8 @@ contract MultiSigWallet {
}
isOwner[owner] = false;
isOwner[newOwner] = true;
- OwnerRemoval(owner);
- OwnerAddition(newOwner);
+ emit OwnerRemoval(owner);
+ emit OwnerAddition(newOwner);
}
/// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
@@ -176,7 +176,7 @@ contract MultiSigWallet {
validRequirement(owners.length, _required)
{
required = _required;
- RequirementChange(_required);
+ emit RequirementChange(_required);
}
/// @dev Allows an owner to submit and confirm a transaction.
@@ -201,7 +201,7 @@ contract MultiSigWallet {
notConfirmed(transactionId, msg.sender)
{
confirmations[transactionId][msg.sender] = true;
- Confirmation(msg.sender, transactionId);
+ emit Confirmation(msg.sender, transactionId);
executeTransaction(transactionId);
}
@@ -214,7 +214,7 @@ contract MultiSigWallet {
notExecuted(transactionId)
{
confirmations[transactionId][msg.sender] = false;
- Revocation(msg.sender, transactionId);
+ emit Revocation(msg.sender, transactionId);
}
/// @dev Allows anyone to execute a confirmed transaction.
@@ -227,9 +227,9 @@ contract MultiSigWallet {
Transaction tx = transactions[transactionId];
tx.executed = true;
if (tx.destination.call.value(tx.value)(tx.data))
- Execution(transactionId);
+ emit Execution(transactionId);
else {
- ExecutionFailure(transactionId);
+ emit ExecutionFailure(transactionId);
tx.executed = false;
}
}
@@ -273,7 +273,7 @@ contract MultiSigWallet {
executed: false
});
transactionCount += 1;
- Submission(transactionId);
+ emit Submission(transactionId);
}
/*
diff --git a/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol b/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol
index 024d3ef4..0ca9fa54 100644
--- a/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol
+++ b/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol
@@ -19,7 +19,7 @@ contract MultiSigWalletWithDailyLimit is MultiSigWallet {
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations.
/// @param _dailyLimit Amount in wei, which can be withdrawn without confirmations on a daily basis.
- function MultiSigWalletWithDailyLimit(address[] _owners, uint _required, uint _dailyLimit)
+ constructor(address[] _owners, uint _required, uint _dailyLimit)
public
MultiSigWallet(_owners, _required)
{
@@ -33,7 +33,7 @@ contract MultiSigWalletWithDailyLimit is MultiSigWallet {
onlyWallet
{
dailyLimit = _dailyLimit;
- DailyLimitChange(_dailyLimit);
+ emit DailyLimitChange(_dailyLimit);
}
/// @dev Allows anyone to execute a confirmed transaction or ether withdraws until daily limit is reached.
@@ -49,9 +49,9 @@ contract MultiSigWalletWithDailyLimit is MultiSigWallet {
if (!confirmed)
spentToday += tx.value;
if (tx.destination.call.value(tx.value)(tx.data))
- Execution(transactionId);
+ emit Execution(transactionId);
else {
- ExecutionFailure(transactionId);
+ emit ExecutionFailure(transactionId);
tx.executed = false;
if (!confirmed)
spentToday -= tx.value;
diff --git a/test/compilationTests/MultiSigWallet/TestToken.sol b/test/compilationTests/MultiSigWallet/TestToken.sol
index 0f6cd20e..69727cbd 100644
--- a/test/compilationTests/MultiSigWallet/TestToken.sol
+++ b/test/compilationTests/MultiSigWallet/TestToken.sol
@@ -31,7 +31,7 @@ contract TestToken {
}
balances[msg.sender] -= _value;
balances[_to] += _value;
- Transfer(msg.sender, _to, _value);
+ emit Transfer(msg.sender, _to, _value);
return true;
}
@@ -45,7 +45,7 @@ contract TestToken {
balances[_to] += _value;
balances[_from] -= _value;
allowed[_from][msg.sender] -= _value;
- Transfer(_from, _to, _value);
+ emit Transfer(_from, _to, _value);
return true;
}
@@ -54,7 +54,7 @@ contract TestToken {
returns (bool success)
{
allowed[msg.sender][_spender] = _value;
- Approval(msg.sender, _spender, _value);
+ emit Approval(msg.sender, _spender, _value);
return true;
}
diff --git a/test/compilationTests/corion/ico.sol b/test/compilationTests/corion/ico.sol
index 6c9f8cb2..cb437624 100644
--- a/test/compilationTests/corion/ico.sol
+++ b/test/compilationTests/corion/ico.sol
@@ -50,7 +50,7 @@ contract ico is safeMath {
uint256 public totalMint;
uint256 public totalPremiumMint;
- function ico(address foundation, address priceSet, uint256 exchangeRate, uint256 startBlockNum, address[] genesisAddr, uint256[] genesisValue) {
+ constructor(address foundation, address priceSet, uint256 exchangeRate, uint256 startBlockNum, address[] genesisAddr, uint256[] genesisValue) {
/*
Installation function.
@@ -162,7 +162,7 @@ contract ico is safeMath {
interest_s memory _idb;
address _addr = beneficiary;
uint256 _to = (block.number - startBlock) / interestBlockDelay;
- if ( _addr == 0x00 ) { _addr = msg.sender; }
+ if ( _addr == address(0x00) ) { _addr = msg.sender; }
require( block.number > icoDelay );
require( ! aborted );
@@ -257,7 +257,7 @@ contract ico is safeMath {
@premiumContractAddr Address of the corion premium token contract
*/
require( msg.sender == owner );
- require( tokenAddr == 0x00 && premiumAddr == 0x00 );
+ require( tokenAddr == address(0x00) && premiumAddr == address(0x00) );
tokenAddr = tokenContractAddr;
premiumAddr = premiumContractAddr;
}
@@ -281,7 +281,7 @@ contract ico is safeMath {
If they call the contract without any function then this process will be taken place.
*/
require( isICO() );
- require( buy(msg.sender, 0x00) );
+ require( buy(msg.sender, address(0x00)) );
}
function buy(address beneficiaryAddress, address affilateAddress) payable returns (bool success) {
@@ -300,16 +300,16 @@ contract ico is safeMath {
@affilateAddress The address of the person who offered who will get the referral reward. It can not be equal with the beneficiaryAddress.
*/
require( isICO() );
- if ( beneficiaryAddress == 0x00) { beneficiaryAddress = msg.sender; }
+ if ( beneficiaryAddress == address(0x00)) { beneficiaryAddress = msg.sender; }
if ( beneficiaryAddress == affilateAddress ) {
- affilateAddress = 0x00;
+ affilateAddress = address(0x00);
}
uint256 _value = msg.value;
if ( beneficiaryAddress.balance < 0.2 ether ) {
require( beneficiaryAddress.send(0.2 ether) );
_value = safeSub(_value, 0.2 ether);
}
- var _reward = getIcoReward(_value);
+ uint256 _reward = getIcoReward(_value);
require( _reward > 0 );
require( token(tokenAddr).mint(beneficiaryAddress, _reward) );
brought[beneficiaryAddress].eth = safeAdd(brought[beneficiaryAddress].eth, _value);
@@ -317,7 +317,7 @@ contract ico is safeMath {
totalMint = safeAdd(totalMint, _reward);
require( foundationAddress.send(_value * 10 / 100) );
uint256 extra;
- if ( affilateAddress != 0x00 && ( brought[affilateAddress].eth > 0 || interestDB[affilateAddress][0].amount > 0 ) ) {
+ if ( affilateAddress != address(0x00) && ( brought[affilateAddress].eth > 0 || interestDB[affilateAddress][0].amount > 0 ) ) {
affiliate[affilateAddress].weight = safeAdd(affiliate[affilateAddress].weight, _reward);
extra = affiliate[affilateAddress].weight;
uint256 rate;
@@ -337,7 +337,7 @@ contract ico is safeMath {
token(tokenAddr).mint(affilateAddress, extra);
}
checkPremium(beneficiaryAddress);
- EICO(beneficiaryAddress, _reward, affilateAddress, extra);
+ emit EICO(beneficiaryAddress, _reward, affilateAddress, extra);
return true;
}
diff --git a/test/compilationTests/corion/module.sol b/test/compilationTests/corion/module.sol
index d64044cb..5f13215f 100644
--- a/test/compilationTests/corion/module.sol
+++ b/test/compilationTests/corion/module.sol
@@ -90,7 +90,7 @@ contract module {
@newModuleAddress New module handler address
*/
require( moduleStatus != status.New && moduleStatus != status.Disconnected);
- var (_success, _balance) = abstractModuleHandler(moduleHandlerAddress).balanceOf(address(this));
+ (bool _success, uint256 _balance) = abstractModuleHandler(moduleHandlerAddress).balanceOf(address(this));
require( _success );
if ( _balance > 0 ) {
require( abstractModuleHandler(moduleHandlerAddress).transfer(address(this), newModuleAddress, _balance, false) );
@@ -123,7 +123,7 @@ contract module {
@ret This is the module handler address or not
*/
- if ( moduleHandlerAddress == 0x00 ) { return true; }
+ if ( moduleHandlerAddress == address(0x00) ) { return true; }
if ( moduleStatus != status.Connected ) { return false; }
return addr == moduleHandlerAddress;
}
diff --git a/test/compilationTests/corion/moduleHandler.sol b/test/compilationTests/corion/moduleHandler.sol
index 682f81dd..080f599c 100644
--- a/test/compilationTests/corion/moduleHandler.sol
+++ b/test/compilationTests/corion/moduleHandler.sol
@@ -35,8 +35,8 @@ contract moduleHandler is multiOwner, announcementTypes {
address public foundationAddress;
uint256 debugModeUntil = block.number + 1000000;
- function moduleHandler(address[] newOwners) multiOwner(newOwners) {}
+ constructor(address[] newOwners) multiOwner(newOwners) {}
function load(address foundation, bool forReplace, address Token, address Premium, address Publisher, address Schelling, address Provider) {
/*
Loading modulest to ModuleHandler.
@@ -54,11 +54,11 @@ contract moduleHandler is multiOwner, announcementTypes {
require( owners[msg.sender] );
require( modules.length == 0 );
foundationAddress = foundation;
- addModule( modules_s(Token, sha3('Token'), false, false), ! forReplace);
- addModule( modules_s(Premium, sha3('Premium'), false, false), ! forReplace);
- addModule( modules_s(Publisher, sha3('Publisher'), false, true), ! forReplace);
- addModule( modules_s(Schelling, sha3('Schelling'), false, true), ! forReplace);
- addModule( modules_s(Provider, sha3('Provider'), true, true), ! forReplace);
+ addModule( modules_s(Token, keccak256('Token'), false, false), ! forReplace);
+ addModule( modules_s(Premium, keccak256('Premium'), false, false), ! forReplace);
+ addModule( modules_s(Publisher, keccak256('Publisher'), false, true), ! forReplace);
+ addModule( modules_s(Schelling, keccak256('Schelling'), false, true), ! forReplace);
+ addModule( modules_s(Provider, keccak256('Provider'), true, true), ! forReplace);
}
function addModule(modules_s input, bool call) internal {
/*
@@ -69,11 +69,11 @@ contract moduleHandler is multiOwner, announcementTypes {
@call Is connect to the module or not.
*/
if ( call ) { require( abstractModule(input.addr).connectModule() ); }
- var (success, found, id) = getModuleIDByAddress(input.addr);
+ (bool success, bool found, uint256 id) = getModuleIDByAddress(input.addr);
require( success && ! found );
(success, found, id) = getModuleIDByHash(input.name);
require( success && ! found );
- (success, found, id) = getModuleIDByAddress(0x00);
+ (success, found, id) = getModuleIDByAddress(address(0x00));
require( success );
if ( ! found ) {
id = modules.length;
@@ -90,9 +90,9 @@ contract moduleHandler is multiOwner, announcementTypes {
@found Is there any result.
@success Was the transaction succesfull or not.
*/
- var (_success, _found, _id) = getModuleIDByName(name);
+ (bool _success, bool _found, uint256 _id) = getModuleIDByName(name);
if ( _success && _found ) { return (true, true, modules[_id].addr); }
- return (true, false, 0x00);
+ return (true, false, address(0x00));
}
function getModuleIDByHash(bytes32 hashOfName) public constant returns( bool success, bool found, uint256 id ) {
/*
@@ -117,7 +117,7 @@ contract moduleHandler is multiOwner, announcementTypes {
@id Index of module.
@found Was there any result or not.
*/
- bytes32 _name = sha3(name);
+ bytes32 _name = keccak256(name);
for ( uint256 a=0 ; a<modules.length ; a++ ) {
if ( modules[a].name == _name ) {
return (true, true, a);
@@ -149,11 +149,11 @@ contract moduleHandler is multiOwner, announcementTypes {
@bool Was there any result or not.
@callCallback Call the replaceable module to confirm replacement or not.
*/
- var (_success, _found, _id) = getModuleIDByAddress(msg.sender);
+ (bool _success, bool _found, uint256 _id) = getModuleIDByAddress(msg.sender);
require( _success );
- if ( ! ( _found && modules[_id].name == sha3('Publisher') )) {
+ if ( ! ( _found && modules[_id].name == keccak256('Publisher') )) {
require( block.number < debugModeUntil );
- if ( ! insertAndCheckDo(calcDoHash("replaceModule", sha3(name, addr, callCallback))) ) {
+ if ( ! insertAndCheckDo(calcDoHash("replaceModule", keccak256(name, addr, callCallback))) ) {
return true;
}
}
@@ -169,10 +169,10 @@ contract moduleHandler is multiOwner, announcementTypes {
function callReplaceCallback(string moduleName, address newModule) external returns (bool success) {
require( block.number < debugModeUntil );
- if ( ! insertAndCheckDo(calcDoHash("callReplaceCallback", sha3(moduleName, newModule))) ) {
+ if ( ! insertAndCheckDo(calcDoHash("callReplaceCallback", keccak256(moduleName, newModule))) ) {
return true;
}
- var (_success, _found, _id) = getModuleIDByName(moduleName);
+ (bool _success, bool _found, uint256 _id) = getModuleIDByName(moduleName);
require( _success);
require( abstractModule(modules[_id].addr).replaceModule(newModule) );
return true;
@@ -188,15 +188,15 @@ contract moduleHandler is multiOwner, announcementTypes {
@transferEvent Gets it new transaction notification?
@bool Was there any result or not.
*/
- var (_success, _found, _id) = getModuleIDByAddress(msg.sender);
+ (bool _success, bool _found, uint256 _id) = getModuleIDByAddress(msg.sender);
require( _success );
- if ( ! ( _found && modules[_id].name == sha3('Publisher') )) {
+ if ( ! ( _found && modules[_id].name == keccak256('Publisher') )) {
require( block.number < debugModeUntil );
- if ( ! insertAndCheckDo(calcDoHash("newModule", sha3(name, addr, schellingEvent, transferEvent))) ) {
+ if ( ! insertAndCheckDo(calcDoHash("newModule", keccak256(name, addr, schellingEvent, transferEvent))) ) {
return true;
}
}
- addModule( modules_s(addr, sha3(name), schellingEvent, transferEvent), true);
+ addModule( modules_s(addr, keccak256(name), schellingEvent, transferEvent), true);
return true;
}
function dropModule(string name, bool callCallback) external returns (bool success) {
@@ -207,11 +207,11 @@ contract moduleHandler is multiOwner, announcementTypes {
@bool Was the function successfull?
@callCallback Call the replaceable module to confirm replacement or not.
*/
- var (_success, _found, _id) = getModuleIDByAddress(msg.sender);
+ (bool _success, bool _found, uint256 _id) = getModuleIDByAddress(msg.sender);
require( _success );
- if ( ! ( _found && modules[_id].name == sha3('Publisher') )) {
+ if ( ! ( _found && modules[_id].name == keccak256('Publisher') )) {
require( block.number < debugModeUntil );
- if ( ! insertAndCheckDo(calcDoHash("replaceModule", sha3(name, callCallback))) ) {
+ if ( ! insertAndCheckDo(calcDoHash("replaceModule", keccak256(name, callCallback))) ) {
return true;
}
}
@@ -226,10 +226,10 @@ contract moduleHandler is multiOwner, announcementTypes {
function callDisableCallback(string moduleName) external returns (bool success) {
require( block.number < debugModeUntil );
- if ( ! insertAndCheckDo(calcDoHash("callDisableCallback", sha3(moduleName))) ) {
+ if ( ! insertAndCheckDo(calcDoHash("callDisableCallback", keccak256(moduleName))) ) {
return true;
}
- var (_success, _found, _id) = getModuleIDByName(moduleName);
+ (bool _success, bool _found, uint256 _id) = getModuleIDByName(moduleName);
require( _success);
require( abstractModule(modules[_id].addr).disableModule(true) );
return true;
@@ -247,8 +247,8 @@ contract moduleHandler is multiOwner, announcementTypes {
@value amount.
@bool Was the function successfull?
*/
- var (_success, _found, _id) = getModuleIDByAddress(msg.sender);
- require( _success && _found && modules[_id].name == sha3('Token') );
+ (bool _success, bool _found, uint256 _id) = getModuleIDByAddress(msg.sender);
+ require( _success && _found && modules[_id].name == keccak256('Token') );
for ( uint256 a=0 ; a<modules.length ; a++ ) {
if ( modules[a].transferEvent && abstractModule(modules[a].addr).isActive() ) {
require( abstractModule(modules[a].addr).transferEvent(from, to, value) );
@@ -266,8 +266,8 @@ contract moduleHandler is multiOwner, announcementTypes {
@reward Coin emission in this Schelling round.
@bool Was the function successfull?
*/
- var (_success, _found, _id) = getModuleIDByAddress(msg.sender);
- require( _success && _found && modules[_id].name == sha3('Schelling') );
+ (bool _success, bool _found, uint256 _id) = getModuleIDByAddress(msg.sender);
+ require( _success && _found && modules[_id].name == keccak256('Schelling') );
for ( uint256 a=0 ; a<modules.length ; a++ ) {
if ( modules[a].schellingEvent && abstractModule(modules[a].addr).isActive() ) {
require( abstractModule(modules[a].addr).newSchellingRoundEvent(roundID, reward) );
@@ -285,11 +285,11 @@ contract moduleHandler is multiOwner, announcementTypes {
@newHandler Address of the new ModuleHandler.
@bool Was the function successfull?
*/
- var (_success, _found, _id) = getModuleIDByAddress(msg.sender);
+ (bool _success, bool _found, uint256 _id) = getModuleIDByAddress(msg.sender);
require( _success );
- if ( ! ( _found && modules[_id].name == sha3('Publisher') )) {
+ if ( ! ( _found && modules[_id].name == keccak256('Publisher') )) {
require( block.number < debugModeUntil );
- if ( ! insertAndCheckDo(calcDoHash("replaceModuleHandler", sha3(newHandler))) ) {
+ if ( ! insertAndCheckDo(calcDoHash("replaceModuleHandler", keccak256(newHandler))) ) {
return true;
}
}
@@ -306,7 +306,7 @@ contract moduleHandler is multiOwner, announcementTypes {
@value balance.
@success was the function successfull?
*/
- var (_success, _found, _id) = getModuleIDByName('Token');
+ (bool _success, bool _found, uint256 _id) = getModuleIDByName('Token');
require( _success && _found );
return (true, token(modules[_id].addr).balanceOf(owner));
}
@@ -317,7 +317,7 @@ contract moduleHandler is multiOwner, announcementTypes {
@value amount.
@success was the function successfull?
*/
- var (_success, _found, _id) = getModuleIDByName('Token');
+ (bool _success, bool _found, uint256 _id) = getModuleIDByName('Token');
require( _success && _found );
return (true, token(modules[_id].addr).totalSupply());
}
@@ -328,7 +328,7 @@ contract moduleHandler is multiOwner, announcementTypes {
@ico Is ICO in progress?.
@success was the function successfull?
*/
- var (_success, _found, _id) = getModuleIDByName('Token');
+ (bool _success, bool _found, uint256 _id) = getModuleIDByName('Token');
require( _success && _found );
return (true, token(modules[_id].addr).isICO());
}
@@ -339,7 +339,7 @@ contract moduleHandler is multiOwner, announcementTypes {
@round Schelling round.
@success was the function successfull?
*/
- var (_success, _found, _id) = getModuleIDByName('Schelling');
+ (bool _success, bool _found, uint256 _id) = getModuleIDByName('Schelling');
require( _success && _found );
return (true, schelling(modules[_id].addr).getCurrentSchellingRoundID());
}
@@ -352,8 +352,8 @@ contract moduleHandler is multiOwner, announcementTypes {
@success Was the function successfull?
*/
- var (_success, _found, _id) = getModuleIDByAddress(msg.sender);
- require( _success && _found && modules[_id].name == sha3('Provider') );
+ (bool _success, bool _found, uint256 _id) = getModuleIDByAddress(msg.sender);
+ require( _success && _found && modules[_id].name == keccak256('Provider') );
(_success, _found, _id) = getModuleIDByName('Token');
require( _success && _found );
require( token(modules[_id].addr).mint(to, value) );
@@ -369,7 +369,7 @@ contract moduleHandler is multiOwner, announcementTypes {
@fee Transaction fee will be charged or not?
@success Was the function successfull?
*/
- var (_success, _found, _id) = getModuleIDByAddress(msg.sender);
+ (bool _success, bool _found, uint256 _id) = getModuleIDByAddress(msg.sender);
require( _success && _found );
(_success, _found, _id) = getModuleIDByName('Token');
require( _success && _found );
@@ -384,8 +384,8 @@ contract moduleHandler is multiOwner, announcementTypes {
@value Token amount.
@success Was the function successfull?
*/
- var (_success, _found, _id) = getModuleIDByAddress(msg.sender);
- require( _success && _found && modules[_id].name == sha3('Provider') );
+ (bool _success, bool _found, uint256 _id) = getModuleIDByAddress(msg.sender);
+ require( _success && _found && modules[_id].name == keccak256('Provider') );
(_success, _found, _id) = getModuleIDByName('Token');
require( _success && _found );
require( token(modules[_id].addr).processTransactionFee(from, value) );
@@ -399,8 +399,8 @@ contract moduleHandler is multiOwner, announcementTypes {
@value Token amount.
@success Was the function successfull?
*/
- var (_success, _found, _id) = getModuleIDByAddress(msg.sender);
- require( _success && _found && modules[_id].name == sha3('Schelling') );
+ (bool _success, bool _found, uint256 _id) = getModuleIDByAddress(msg.sender);
+ require( _success && _found && modules[_id].name == keccak256('Schelling') );
(_success, _found, _id) = getModuleIDByName('Token');
require( _success && _found );
require( token(modules[_id].addr).burn(from, value) );
@@ -415,11 +415,11 @@ contract moduleHandler is multiOwner, announcementTypes {
@value New value
@success Was the function successfull?
*/
- var (_success, _found, _id) = getModuleIDByAddress(msg.sender);
+ (bool _success, bool _found, uint256 _id) = getModuleIDByAddress(msg.sender);
require( _success );
- if ( ! ( _found && modules[_id].name == sha3('Publisher') )) {
+ if ( ! ( _found && modules[_id].name == keccak256('Publisher') )) {
require( block.number < debugModeUntil );
- if ( ! insertAndCheckDo(calcDoHash("configureModule", sha3(moduleName, aType, value))) ) {
+ if ( ! insertAndCheckDo(calcDoHash("configureModule", keccak256(moduleName, aType, value))) ) {
return true;
}
}
@@ -437,7 +437,7 @@ contract moduleHandler is multiOwner, announcementTypes {
*/
require( owners[msg.sender] );
if ( forever ) {
- if ( ! insertAndCheckDo(calcDoHash("freezing", sha3(forever))) ) {
+ if ( ! insertAndCheckDo(calcDoHash("freezing", keccak256(forever))) ) {
return;
}
}
diff --git a/test/compilationTests/corion/multiOwner.sol b/test/compilationTests/corion/multiOwner.sol
index 9aae0ebd..0a0a44c5 100644
--- a/test/compilationTests/corion/multiOwner.sol
+++ b/test/compilationTests/corion/multiOwner.sol
@@ -12,7 +12,7 @@ contract multiOwner is safeMath {
/*
Constructor
*/
- function multiOwner(address[] newOwners) {
+ constructor(address[] newOwners) {
for ( uint256 a=0 ; a<newOwners.length ; a++ ) {
_addOwner(newOwners[a]);
}
@@ -21,12 +21,12 @@ contract multiOwner is safeMath {
Externals
*/
function insertOwner(address addr) external {
- if ( insertAndCheckDo(calcDoHash("insertOwner", sha3(addr))) ) {
+ if ( insertAndCheckDo(calcDoHash("insertOwner", keccak256(addr))) ) {
_addOwner(addr);
}
}
function dropOwner(address addr) external {
- if ( insertAndCheckDo(calcDoHash("dropOwner", sha3(addr))) ) {
+ if ( insertAndCheckDo(calcDoHash("dropOwner", keccak256(addr))) ) {
_delOwner(addr);
}
}
@@ -42,7 +42,7 @@ contract multiOwner is safeMath {
return ownerCount * 75 / 100;
}
function calcDoHash(string job, bytes32 data) public constant returns (bytes32 hash) {
- return sha3(job, data);
+ return keccak256(job, data);
}
function validDoHash(bytes32 doHash) public constant returns (bool valid) {
return doDB[doHash].length > 0;
diff --git a/test/compilationTests/corion/owned.sol b/test/compilationTests/corion/owned.sol
index bd187775..4a5ba673 100644
--- a/test/compilationTests/corion/owned.sol
+++ b/test/compilationTests/corion/owned.sol
@@ -20,7 +20,7 @@ contract ownedDB {
@bool Owner has called the contract or not
*/
- if ( owner == 0x00 ) {
+ 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 be2c5de0..5a80ecc6 100644
--- a/test/compilationTests/corion/premium.sol
+++ b/test/compilationTests/corion/premium.sol
@@ -19,7 +19,7 @@ contract premium is module, safeMath {
return true;
}
modifier isReady {
- var (_success, _active) = super.isActive();
+ (bool _success, bool _active) = super.isActive();
require( _success && _active );
_;
}
@@ -40,7 +40,7 @@ contract premium is module, safeMath {
mapping(address => bool) public genesis;
- function premium(bool forReplace, address moduleHandler, address dbAddress, address icoContractAddr, address[] genesisAddr, uint256[] genesisValue) {
+ constructor(bool forReplace, address moduleHandler, address dbAddress, address icoContractAddr, address[] genesisAddr, uint256[] genesisValue) {
/*
Setup function.
If an ICOaddress is defined then the balance of the genesis addresses will be set as well.
@@ -53,7 +53,7 @@ contract premium is module, safeMath {
@genesisValue Array of the balance of the genesis addresses
*/
super.registerModuleHandler(moduleHandler);
- require( dbAddress != 0x00 );
+ require( dbAddress != address(0x00) );
db = ptokenDB(dbAddress);
if ( ! forReplace ) {
require( db.replaceOwner(this) );
@@ -63,7 +63,7 @@ contract premium is module, safeMath {
for ( uint256 a=0 ; a<genesisAddr.length ; a++ ) {
genesis[genesisAddr[a]] = true;
require( db.increase(genesisAddr[a], genesisValue[a]) );
- Mint(genesisAddr[a], genesisValue[a]);
+ emit Mint(genesisAddr[a], genesisValue[a]);
}
}
}
@@ -137,7 +137,7 @@ contract premium is module, safeMath {
require( msg.sender != spender );
require( db.balanceOf(msg.sender) >= amount );
require( db.setAllowance(msg.sender, spender, amount, nonce) );
- Approval(msg.sender, spender, amount);
+ emit Approval(msg.sender, spender, amount);
}
function allowance(address owner, address spender) constant returns (uint256 remaining, uint256 nonce) {
@@ -150,7 +150,7 @@ contract premium is module, safeMath {
@remaining Tokens to be spent
@nonce Transaction count
*/
- var (_success, _remaining, _nonce) = db.getAllowance(owner, spender);
+ (bool _success, uint256 _remaining, uint256 _nonce) = db.getAllowance(owner, spender);
require( _success );
return (_remaining, _nonce);
}
@@ -178,7 +178,7 @@ contract premium is module, safeMath {
} else {
_transfer(msg.sender, to, amount);
}
- Transfer(msg.sender, to, amount, _data);
+ emit Transfer(msg.sender, to, amount, _data);
return true;
}
@@ -202,12 +202,12 @@ contract premium is module, safeMath {
@success If the function was successful.
*/
if ( from != msg.sender ) {
- var (_success, _reamining, _nonce) = db.getAllowance(from, msg.sender);
+ (bool _success, uint256 _reamining, uint256 _nonce) = db.getAllowance(from, msg.sender);
require( _success );
_reamining = safeSub(_reamining, amount);
_nonce = safeAdd(_nonce, 1);
require( db.setAllowance(from, msg.sender, _reamining, _nonce) );
- AllowanceUsed(msg.sender, from, amount);
+ emit AllowanceUsed(msg.sender, from, amount);
}
bytes memory _data;
if ( isContract(to) ) {
@@ -215,7 +215,7 @@ contract premium is module, safeMath {
} else {
_transfer( from, to, amount);
}
- Transfer(from, to, amount, _data);
+ emit Transfer(from, to, amount, _data);
return true;
}
@@ -242,7 +242,7 @@ contract premium is module, safeMath {
} else {
_transfer( msg.sender, to, amount);
}
- Transfer(msg.sender, to, amount, extraData);
+ emit Transfer(msg.sender, to, amount, extraData);
return true;
}
@@ -255,7 +255,7 @@ contract premium is module, safeMath {
@extraData Extra data that will be given to the receiver
*/
_transfer(from, to, amount);
- var (_success, _back) = thirdPartyPContractAbstract(to).receiveCorionPremiumToken(from, amount, extraData);
+ (bool _success, uint256 _back) = thirdPartyPContractAbstract(to).receiveCorionPremiumToken(from, amount, extraData);
require( _success );
require( amount > _back );
if ( _back > 0 ) {
@@ -273,7 +273,7 @@ contract premium is module, safeMath {
@to For who?
@amount Amount
*/
- require( from != 0x00 && to != 0x00 && to != 0xa636a97578d26a3b76b060bbc18226d954cf3757 );
+ require( from != address(0x00) && to != address(0x00) && to != 0xa636A97578d26A3b76B060Bbc18226d954cf3757 );
require( ( ! isICO) || genesis[from] );
require( db.decrease(from, amount) );
require( db.increase(to, amount) );
@@ -301,7 +301,7 @@ contract premium is module, safeMath {
@value Amount
*/
require( db.increase(owner, value) );
- Mint(owner, value);
+ emit Mint(owner, value);
}
function isContract(address addr) internal returns (bool success) {
diff --git a/test/compilationTests/corion/provider.sol b/test/compilationTests/corion/provider.sol
index 5fa90fcd..0c1f69e5 100644
--- a/test/compilationTests/corion/provider.sol
+++ b/test/compilationTests/corion/provider.sol
@@ -12,7 +12,7 @@ contract provider is module, safeMath, announcementTypes {
function connectModule() external returns (bool success) {
require( super.isModuleHandler(msg.sender) );
super._connectModule();
- var (_success, currentSchellingRound) = moduleHandler(moduleHandlerAddress).getCurrentSchellingRoundID();
+ (bool _success, uint256 currentSchellingRound) = moduleHandler(moduleHandlerAddress).getCurrentSchellingRoundID();
require( _success );
return true;
}
@@ -49,7 +49,7 @@ contract provider is module, safeMath, announcementTypes {
return true;
}
modifier isReady {
- var (_success, _active) = super.isActive();
+ (bool _success, bool _active) = super.isActive();
require( _success && _active );
_;
}
@@ -118,7 +118,7 @@ contract provider is module, safeMath, announcementTypes {
uint256 private currentSchellingRound = 1;
- function provider(address _moduleHandler) {
+ constructor(address _moduleHandler) {
/*
Install function.
@@ -161,7 +161,7 @@ contract provider is module, safeMath, announcementTypes {
if ( schellingRound == 0 ) {
schellingRound = currentSchellingRound;
}
- if ( clients[addr].providerAddress != 0 ) {
+ if ( clients[addr].providerAddress != address(0x00) ) {
ProviderAddress = clients[addr].providerAddress;
ProviderHeight = clients[addr].providerHeight;
ConnectedOn = clients[addr].providerConnected;
@@ -192,8 +192,8 @@ contract provider is module, safeMath, announcementTypes {
@newValue new
@priv Is the provider private?
*/
- var a = rightForInterest(oldValue, priv);
- var b = rightForInterest(newValue, priv);
+ bool a = rightForInterest(oldValue, priv);
+ bool b = rightForInterest(newValue, priv);
if ( a && b ) {
globalFunds[currentSchellingRound].supply = globalFunds[currentSchellingRound].supply - oldValue + newValue;
} else if ( a && ! b ) {
@@ -233,7 +233,7 @@ contract provider is module, safeMath, announcementTypes {
@admin The admin’s address
*/
require( ! providers[msg.sender].data[providers[msg.sender].currentHeight].valid );
- require( clients[msg.sender].providerAddress == 0x00 );
+ require( clients[msg.sender].providerAddress == address(0x00) );
require( ! checkICO() );
if ( priv ) {
require( getTokenBalance(msg.sender) >= minFundsForPrivate );
@@ -243,9 +243,9 @@ contract provider is module, safeMath, announcementTypes {
require( checkCorrectRate(priv, rate) );
providers[msg.sender].currentHeight++;
- var currHeight = providers[msg.sender].currentHeight;
+ uint256 currHeight = providers[msg.sender].currentHeight;
providers[msg.sender].data[currHeight].valid = true;
- if ( admin == 0x00 ) {
+ if ( admin == address(0x00) ) {
providers[msg.sender].data[currHeight].admin = msg.sender;
} else {
providers[msg.sender].data[currHeight].admin = admin;
@@ -268,7 +268,7 @@ contract provider is module, safeMath, announcementTypes {
} else {
delete providers[msg.sender].data[currHeight].supply[currentSchellingRound];
}
- EProviderOpen(msg.sender, currHeight);
+ emit EProviderOpen(msg.sender, currHeight);
}
function setProviderDetails(address addr, string website, string country, string info, uint8 rate, address admin) isReady external {
/*
@@ -284,11 +284,11 @@ contract provider is module, safeMath, announcementTypes {
@info Short intro.
@rate Rate of the emission what will be given to the client.
*/
- var currHeight = providers[addr].currentHeight;
+ uint256 currHeight = providers[addr].currentHeight;
require( providers[addr].data[currHeight].valid );
require( checkCorrectRate(providers[addr].data[currHeight].priv, rate) );
require( providers[addr].data[currHeight].admin == msg.sender || msg.sender == addr );
- if ( admin != 0x00 ) {
+ if ( admin != address(0x00) ) {
require( msg.sender == addr );
providers[addr].data[currHeight].admin = admin;
}
@@ -297,7 +297,7 @@ contract provider is module, safeMath, announcementTypes {
providers[addr].data[currHeight].country = country;
providers[addr].data[currHeight].info = info;
providers[addr].data[currHeight].currentRate = rate;
- EProviderDetailsChanged(addr, currHeight, website, country, info, rate, admin);
+ emit EProviderDetailsChanged(addr, currHeight, website, country, info, rate, admin);
}
function getProviderInfo(address addr, uint256 height) public constant returns (string name, string website, string country, string info, uint256 create) {
/*
@@ -360,14 +360,14 @@ contract provider is module, safeMath, announcementTypes {
It is only possible to close that active provider which is owned by the sender itself after calling the whole share of the emission.
Whom were connected to the provider those clients will have to disconnect after they’ve called their share of emission which was not called before.
*/
- var currHeight = providers[msg.sender].currentHeight;
+ 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);
- EProviderClose(msg.sender, currHeight);
+ emit EProviderClose(msg.sender, currHeight);
}
function allowUsers(address provider, address[] addr) isReady external {
/*
@@ -377,7 +377,7 @@ contract provider is module, safeMath, announcementTypes {
@addr Array of the addresses for whom the connection is allowed.
*/
- var currHeight = providers[provider].currentHeight;
+ uint256 currHeight = providers[provider].currentHeight;
require( providers[provider].data[currHeight].valid );
require( providers[provider].data[currHeight].priv );
require( providers[provider].data[currHeight].admin == msg.sender );
@@ -395,7 +395,7 @@ contract provider is module, safeMath, announcementTypes {
@addr Array of the addresses for whom the connection is allowed.
*/
- var currHeight = providers[provider].currentHeight;
+ uint256 currHeight = providers[provider].currentHeight;
require( providers[provider].data[currHeight].valid );
require( providers[provider].data[currHeight].priv );
require( providers[provider].data[currHeight].admin == msg.sender );
@@ -417,15 +417,15 @@ contract provider is module, safeMath, announcementTypes {
@provider Address of the provider.
*/
- var currHeight = providers[provider].currentHeight;
+ uint256 currHeight = providers[provider].currentHeight;
require( ! providers[msg.sender].data[currHeight].valid );
- require( clients[msg.sender].providerAddress == 0x00 );
+ require( clients[msg.sender].providerAddress == address(0x00) );
require( providers[provider].data[currHeight].valid );
if ( providers[provider].data[currHeight].priv ) {
require( providers[provider].data[currHeight].allowedUsers[msg.sender] &&
providers[provider].data[currHeight].clientsCount < privateProviderLimit );
}
- var bal = getTokenBalance(msg.sender);
+ uint256 bal = getTokenBalance(msg.sender);
require( moduleHandler(moduleHandlerAddress).processTransactionFee(msg.sender, bal) );
checkFloatingSupply(provider, currHeight, false, bal);
@@ -437,7 +437,7 @@ contract provider is module, safeMath, announcementTypes {
clients[msg.sender].paidUpTo = currentSchellingRound;
clients[msg.sender].lastRate = providers[provider].data[currHeight].currentRate;
clients[msg.sender].providerConnected = now;
- ENewClient(msg.sender, provider, currHeight, bal);
+ emit ENewClient(msg.sender, provider, currHeight, bal);
}
function partProvider() isReady external {
/*
@@ -445,9 +445,9 @@ contract provider is module, safeMath, announcementTypes {
Before disconnecting we should poll our share from the token emission even if there was nothing factually.
It is only possible to disconnect those providers who were connected by us before.
*/
- var provider = clients[msg.sender].providerAddress;
- require( provider != 0x0 );
- var currHeight = clients[msg.sender].providerHeight;
+ address provider = clients[msg.sender].providerAddress;
+ require( provider != address(0x00) );
+ uint256 currHeight = clients[msg.sender].providerHeight;
bool providerHasClosed = false;
if ( providers[provider].data[currHeight].close > 0 ) {
providerHasClosed = true;
@@ -456,7 +456,7 @@ contract provider is module, safeMath, announcementTypes {
require( clients[msg.sender].paidUpTo == currentSchellingRound );
}
- var bal = getTokenBalance(msg.sender);
+ uint256 bal = getTokenBalance(msg.sender);
if ( ! providerHasClosed ) {
providers[provider].data[currHeight].clientsCount--;
checkFloatingSupply(provider, currHeight, true, bal);
@@ -467,7 +467,7 @@ contract provider is module, safeMath, announcementTypes {
delete clients[msg.sender].paidUpTo;
delete clients[msg.sender].lastRate;
delete clients[msg.sender].providerConnected;
- EClientLost(msg.sender, provider, currHeight, bal);
+ emit EClientLost(msg.sender, provider, currHeight, bal);
}
function checkReward(address addr) public constant returns (uint256 reward) {
/*
@@ -479,7 +479,7 @@ contract provider is module, safeMath, announcementTypes {
if ( providers[addr].data[providers[addr].currentHeight].valid ) {
uint256 a;
(reward, a) = getProviderReward(addr, 0);
- } else if ( clients[addr].providerAddress != 0x0 ) {
+ } else if ( clients[addr].providerAddress != address(0x00) ) {
reward = getClientReward(0);
}
}
@@ -500,18 +500,18 @@ contract provider is module, safeMath, announcementTypes {
@provider Address of the provider
@reward Accumulated amount from the previous rounds.
*/
- var _limit = limit;
- var _beneficiary = beneficiary;
- var _provider = provider;
+ uint256 _limit = limit;
+ address _beneficiary = beneficiary;
+ address _provider = provider;
if ( _limit == 0 ) { _limit = gasProtectMaxRounds; }
- if ( _beneficiary == 0x00 ) { _beneficiary = msg.sender; }
- if ( _provider == 0x00 ) { _provider = msg.sender; }
+ if ( _beneficiary == address(0x00) ) { _beneficiary = msg.sender; }
+ if ( _provider == address(0x00) ) { _provider = msg.sender; }
uint256 clientReward;
uint256 providerReward;
if ( providers[_provider].data[providers[_provider].currentHeight].valid ) {
require( providers[_provider].data[providers[_provider].currentHeight].admin == msg.sender || msg.sender == _provider );
(providerReward, clientReward) = getProviderReward(_provider, _limit);
- } else if ( clients[msg.sender].providerAddress != 0x00 ) {
+ } else if ( clients[msg.sender].providerAddress != address(0x00) ) {
clientReward = getClientReward(_limit);
} else {
throw;
@@ -522,7 +522,7 @@ contract provider is module, safeMath, announcementTypes {
if ( providerReward > 0 ) {
require( moduleHandler(moduleHandlerAddress).transfer(address(this), provider, providerReward, false) );
}
- EReward(msg.sender, provider, clientReward, providerReward);
+ emit EReward(msg.sender, provider, clientReward, providerReward);
}
function getClientReward(uint256 limit) internal returns (uint256 reward) {
/*
@@ -536,8 +536,9 @@ contract provider is module, safeMath, announcementTypes {
address provAddr;
uint256 provHeight;
bool interest = false;
- var rate = clients[msg.sender].lastRate;
- for ( uint256 a = (clients[msg.sender].paidUpTo + 1) ; a <= currentSchellingRound ; a++ ) {
+ uint256 a;
+ uint8 rate = clients[msg.sender].lastRate;
+ for ( a = (clients[msg.sender].paidUpTo + 1) ; a <= currentSchellingRound ; a++ ) {
if (globalFunds[a].reward > 0 && globalFunds[a].supply > 0) {
provAddr = clients[msg.sender].providerAddress;
provHeight = clients[msg.sender].providerHeight;
@@ -585,8 +586,9 @@ contract provider is module, safeMath, announcementTypes {
uint256 steps;
uint256 currHeight = providers[addr].currentHeight;
uint256 LTSID = providers[addr].data[currHeight].lastSupplyID;
- var rate = providers[addr].data[currHeight].lastPaidRate;
- for ( uint256 a = (providers[addr].data[currHeight].paidUpTo + 1) ; a <= currentSchellingRound ; a++ ) {
+ uint256 a;
+ uint8 rate = providers[addr].data[currHeight].lastPaidRate;
+ for ( a = (providers[addr].data[currHeight].paidUpTo + 1) ; a <= currentSchellingRound ; a++ ) {
if (globalFunds[a].reward > 0 && globalFunds[a].supply > 0) {
if ( providers[addr].data[currHeight].rateHistory[a].valid ) {
rate = providers[addr].data[currHeight].rateHistory[a].value;
@@ -743,7 +745,7 @@ contract provider is module, safeMath, announcementTypes {
@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.
*/
- if ( clients[addr].providerAddress != 0 ) {
+ if ( clients[addr].providerAddress != address(0x00) ) {
checkFloatingSupply(clients[addr].providerAddress, providers[clients[addr].providerAddress].currentHeight, ! neg, value);
if (clients[addr].lastSupplyID != currentSchellingRound) {
clients[addr].supply[currentSchellingRound] = TEMath(clients[addr].supply[clients[addr].lastSupplyID], value, neg);
@@ -752,7 +754,7 @@ contract provider is module, safeMath, announcementTypes {
clients[addr].supply[currentSchellingRound] = TEMath(clients[addr].supply[currentSchellingRound], value, neg);
}
} else if ( providers[addr].data[providers[addr].currentHeight].valid ) {
- var currentHeight = providers[addr].currentHeight;
+ uint256 currentHeight = providers[addr].currentHeight;
if ( neg ) {
uint256 balance = getTokenBalance(addr);
if ( providers[addr].data[currentHeight].priv ) {
@@ -774,7 +776,7 @@ contract provider is module, safeMath, announcementTypes {
@balance Balance of the address.
*/
- var (_success, _balance) = moduleHandler(moduleHandlerAddress).balanceOf(addr);
+ (bool _success, uint256 _balance) = moduleHandler(moduleHandlerAddress).balanceOf(addr);
require( _success );
return _balance;
}
@@ -784,7 +786,7 @@ contract provider is module, safeMath, announcementTypes {
@isICO Is the ICO in proccess or not?
*/
- var (_success, _isICO) = moduleHandler(moduleHandlerAddress).isICO();
+ (bool _success, bool _isICO) = moduleHandler(moduleHandlerAddress).isICO();
require( _success );
return _isICO;
}
diff --git a/test/compilationTests/corion/publisher.sol b/test/compilationTests/corion/publisher.sol
index e94b9a92..0e8f825f 100644
--- a/test/compilationTests/corion/publisher.sol
+++ b/test/compilationTests/corion/publisher.sol
@@ -61,7 +61,7 @@ contract publisher is announcementTypes, module, safeMath {
mapping (address => uint256[]) public opponents;
- function publisher(address moduleHandler) {
+ constructor(address moduleHandler) {
/*
Installation function. The installer will be registered in the admin list automatically
@@ -111,7 +111,7 @@ contract publisher is announcementTypes, module, safeMath {
@success Opposed or not
*/
if ( ! oppositable ) { return false; }
- var (_success, _amount) = moduleHandler(moduleHandlerAddress).totalSupply();
+ (bool _success, uint256 _amount) = moduleHandler(moduleHandlerAddress).totalSupply();
require( _success );
return _amount * oppositeRate / 100 > weight;
}
@@ -148,7 +148,7 @@ contract publisher is announcementTypes, module, safeMath {
announcements[announcementsLength]._str = _str;
announcements[announcementsLength]._uint = _uint;
announcements[announcementsLength]._addr = _addr;
- ENewAnnouncement(announcementsLength, Type);
+ emit ENewAnnouncement(announcementsLength, Type);
}
function closeAnnouncement(uint256 id) onlyOwner external {
@@ -229,7 +229,7 @@ contract publisher is announcementTypes, module, safeMath {
newArrayID = a;
}
}
- var (_success, _balance) = moduleHandler(moduleHandlerAddress).balanceOf(msg.sender);
+ (bool _success, uint256 _balance) = moduleHandler(moduleHandlerAddress).balanceOf(msg.sender);
require( _success );
require( _balance > 0);
if ( foundEmptyArrayID ) {
@@ -238,7 +238,7 @@ contract publisher is announcementTypes, module, safeMath {
opponents[msg.sender].push(id);
}
announcements[id].oppositionWeight += _balance;
- EOppositeAnnouncement(id, msg.sender, _balance);
+ emit EOppositeAnnouncement(id, msg.sender, _balance);
}
function invalidateAnnouncement(uint256 id) onlyOwner external {
@@ -250,7 +250,7 @@ contract publisher is announcementTypes, module, safeMath {
require( announcements[id].open );
announcements[id].end = block.number;
announcements[id].open = false;
- EInvalidateAnnouncement(id);
+ emit EInvalidateAnnouncement(id);
}
modifier onlyOwner() {
@@ -266,7 +266,7 @@ contract publisher is announcementTypes, module, safeMath {
Inner function to check the ICO status.
@bool Is the ICO in proccess or not?
*/
- var (_success, _isICO) = moduleHandler(moduleHandlerAddress).isICO();
+ (bool _success, bool _isICO) = moduleHandler(moduleHandlerAddress).isICO();
require( _success );
return _isICO;
}
diff --git a/test/compilationTests/corion/schelling.sol b/test/compilationTests/corion/schelling.sol
index 8c8e093c..e092e311 100644
--- a/test/compilationTests/corion/schelling.sol
+++ b/test/compilationTests/corion/schelling.sol
@@ -37,7 +37,7 @@ contract schellingDB is safeMath, schellingVars {
*/
address private owner;
function replaceOwner(address newOwner) external returns(bool) {
- require( owner == 0x00 || msg.sender == owner );
+ require( owner == address(0x00) || msg.sender == owner );
owner = newOwner;
return true;
}
@@ -45,7 +45,7 @@ contract schellingDB is safeMath, schellingVars {
/*
Constructor
*/
- function schellingDB() {
+ constructor() {
rounds.length = 2;
rounds[0].blockHeight = block.number;
currentSchellingRound = 1;
@@ -151,15 +151,15 @@ contract schelling is module, announcementTypes, schellingVars {
*/
require( super.isModuleHandler(msg.sender) );
if ( to == address(this) ) {
- var currentRound = getCurrentRound();
- var round = getRound(currentRound);
+ uint256 currentRound = getCurrentRound();
+ schellingVars._rounds memory round = getRound(currentRound);
round.reward += value;
setRound(currentRound, round);
}
return true;
}
modifier isReady {
- var (_success, _active) = super.isActive();
+ (bool _success, bool _active) = super.isActive();
require( _success && _active );
_;
}
@@ -167,7 +167,7 @@ contract schelling is module, announcementTypes, schellingVars {
Schelling database functions.
*/
function getFunds(address addr) internal returns (uint256) {
- var (a, b) = db.getFunds(addr);
+ (bool a, uint256 b) = db.getFunds(addr);
require( a );
return b;
}
@@ -184,7 +184,7 @@ contract schelling is module, announcementTypes, schellingVars {
) );
}
function getVoter(address addr) internal returns (_voter) {
- var (a, b, c, d, e, f) = db.getVoter(addr);
+ (bool a, uint256 b, bytes32 c, schellingVars.voterStatus d, bool e, uint256 f) = db.getVoter(addr);
require( a );
return _voter(b, c, d, e, f);
}
@@ -198,7 +198,7 @@ contract schelling is module, announcementTypes, schellingVars {
) );
}
function pushRound(_rounds round) internal returns (uint256) {
- var (a, b) = db.pushRound(
+ (bool a, uint256 b) = db.pushRound(
round.totalAboveWeight,
round.totalBelowWeight,
round.reward,
@@ -209,12 +209,12 @@ contract schelling is module, announcementTypes, schellingVars {
return b;
}
function getRound(uint256 id) internal returns (_rounds) {
- var (a, b, c, d, e, f) = db.getRound(id);
+ (bool a, uint256 b, uint256 c, uint256 d, uint256 e, bool f) = db.getRound(id);
require( a );
return _rounds(b, c, d, e, f);
}
function getCurrentRound() internal returns (uint256) {
- var (a, b) = db.getCurrentRound();
+ (bool a, uint256 b) = db.getCurrentRound();
require( a );
return b;
}
@@ -222,7 +222,7 @@ contract schelling is module, announcementTypes, schellingVars {
require( db.setCurrentSchellingRound(id) );
}
function getCurrentSchellingRound() internal returns(uint256) {
- var (a, b) = db.getCurrentSchellingRound();
+ (bool a, uint256 b) = db.getCurrentSchellingRound();
require( a );
return b;
}
@@ -230,7 +230,7 @@ contract schelling is module, announcementTypes, schellingVars {
require( db.setSchellingExpansion(id, amount) );
}
function getSchellingExpansion(uint256 id) internal returns(uint256) {
- var (a, b) = db.getSchellingExpansion(id);
+ (bool a, uint256 b) = db.getSchellingExpansion(id);
require( a );
return b;
}
@@ -247,7 +247,7 @@ contract schelling is module, announcementTypes, schellingVars {
bytes1 public belowChar = 0x30;
schellingDB private db;
- function schelling(address _moduleHandler, address _db, bool _forReplace) {
+ constructor(address _moduleHandler, address _db, bool _forReplace) {
/*
Installation function.
@@ -289,8 +289,8 @@ contract schelling is module, announcementTypes, schellingVars {
*/
nextRound();
- var currentRound = getCurrentRound();
- var round = getRound(currentRound);
+ uint256 currentRound = getCurrentRound();
+ schellingVars._rounds memory round = getRound(currentRound);
_voter memory voter;
uint256 funds;
@@ -323,7 +323,7 @@ contract schelling is module, announcementTypes, schellingVars {
*/
nextRound();
- var currentRound = getCurrentRound();
+ uint256 currentRound = getCurrentRound();
_rounds memory round;
_voter memory voter;
uint256 funds;
@@ -335,7 +335,7 @@ contract schelling is module, announcementTypes, schellingVars {
require( voter.status == voterStatus.afterPrepareVote );
require( voter.roundID < currentRound );
- if ( sha3(vote) == voter.hash ) {
+ if ( keccak256(vote) == voter.hash ) {
delete voter.hash;
if (round.blockHeight+roundBlockDelay/2 >= block.number) {
if ( bytes(vote)[0] == aboveChar ) {
@@ -369,7 +369,7 @@ contract schelling is module, announcementTypes, schellingVars {
*/
nextRound();
- var currentRound = getCurrentRound();
+ uint256 currentRound = getCurrentRound();
_rounds memory round;
_voter memory voter;
uint256 funds;
@@ -403,11 +403,11 @@ contract schelling is module, announcementTypes, schellingVars {
@beneficiary Address of the beneficiary
*/
- var voter = getVoter(msg.sender);
- var funds = getFunds(msg.sender);
+ schellingVars._voter memory voter = getVoter(msg.sender);
+ uint256 funds = getFunds(msg.sender);
address _beneficiary = msg.sender;
- if (beneficiary != 0x0) { _beneficiary = beneficiary; }
+ if (beneficiary != address(0x00)) { _beneficiary = beneficiary; }
uint256 reward;
require( voter.rewards > 0 );
require( voter.status == voterStatus.base );
@@ -423,18 +423,18 @@ contract schelling is module, announcementTypes, schellingVars {
@reward Prize
*/
- var voter = getVoter(msg.sender);
+ schellingVars._voter memory voter = getVoter(msg.sender);
return voter.rewards;
}
function nextRound() internal returns (bool) {
/*
Inside function, checks the time of the Schelling round and if its needed, creates a new Schelling round.
*/
- var currentRound = getCurrentRound();
- var round = getRound(currentRound);
+ uint256 currentRound = getCurrentRound();
+ _rounds memory round = getRound(currentRound);
_rounds memory newRound;
_rounds memory prevRound;
- var currentSchellingRound = getCurrentSchellingRound();
+ uint256 currentSchellingRound = getCurrentSchellingRound();
if ( round.blockHeight+roundBlockDelay > block.number) { return false; }
@@ -469,10 +469,10 @@ contract schelling is module, announcementTypes, schellingVars {
@amount Amount of deposit.
*/
- var voter = getVoter(msg.sender);
- var funds = getFunds(msg.sender);
+ _voter memory voter = getVoter(msg.sender);
+ uint256 funds = getFunds(msg.sender);
- var (a, b) = moduleHandler(moduleHandlerAddress).isICO();
+ (bool a, bool b) = moduleHandler(moduleHandlerAddress).isICO();
require( b && b );
require( voter.status == voterStatus.base );
require( amount > 0 );
@@ -487,8 +487,8 @@ contract schelling is module, announcementTypes, schellingVars {
If the deposit isn’t lost, it can be withdrawn.
By withdrawn, the deposit will be sent from Schelling address to the users address, charged with transaction fee..
*/
- var voter = getVoter(msg.sender);
- var funds = getFunds(msg.sender);
+ _voter memory voter = getVoter(msg.sender);
+ uint256 funds = getFunds(msg.sender);
require( funds > 0 );
require( voter.status == voterStatus.base );
@@ -550,7 +550,7 @@ contract schelling is module, announcementTypes, schellingVars {
@uint256 Whole token amount
*/
- var (_success, _amount) = moduleHandler(moduleHandlerAddress).totalSupply();
+ (bool _success, uint256 _amount) = moduleHandler(moduleHandlerAddress).totalSupply();
require( _success );
return _amount;
}
@@ -563,7 +563,7 @@ contract schelling is module, announcementTypes, schellingVars {
@balance Balance of the address.
*/
- var (_success, _balance) = moduleHandler(moduleHandlerAddress).balanceOf(addr);
+ (bool _success, uint256 _balance) = moduleHandler(moduleHandlerAddress).balanceOf(addr);
require( _success );
return _balance;
}
diff --git a/test/compilationTests/corion/token.sol b/test/compilationTests/corion/token.sol
index 3aa0bf23..0709baca 100644
--- a/test/compilationTests/corion/token.sol
+++ b/test/compilationTests/corion/token.sol
@@ -22,7 +22,7 @@ contract token is safeMath, module, announcementTypes {
return true;
}
modifier isReady {
- var (_success, _active) = super.isActive();
+ (bool _success, bool _active) = super.isActive();
require( _success && _active );
_;
}
@@ -48,7 +48,7 @@ contract token is safeMath, module, announcementTypes {
mapping(address => bool) public genesis;
- function token(bool forReplace, address moduleHandler, address dbAddr, address icoContractAddr, address exchangeContractAddress, address[] genesisAddr, uint256[] genesisValue) payable {
+ constructor(bool forReplace, address moduleHandler, address dbAddr, address icoContractAddr, address exchangeContractAddress, address[] genesisAddr, uint256[] genesisValue) payable {
/*
Installation function
@@ -63,9 +63,9 @@ contract token is safeMath, module, announcementTypes {
@genesisValue Array of balance of genesis addresses
*/
super.registerModuleHandler(moduleHandler);
- require( dbAddr != 0x00 );
- require( icoContractAddr != 0x00 );
- require( exchangeContractAddress != 0x00 );
+ require( dbAddr != address(0x00) );
+ require( icoContractAddr != address(0x00) );
+ require( exchangeContractAddress != address(0x00) );
db = tokenDB(dbAddr);
icoAddr = icoContractAddr;
exchangeAddress = exchangeContractAddress;
@@ -78,7 +78,7 @@ contract token is safeMath, module, announcementTypes {
genesis[genesisAddr[a]] = true;
require( db.increase(genesisAddr[a], genesisValue[a]) );
if ( ! genesisAddr[a].send(0.2 ether) ) {}
- Mint(genesisAddr[a], genesisValue[a]);
+ emit Mint(genesisAddr[a], genesisValue[a]);
}
}
}
@@ -152,7 +152,7 @@ contract token is safeMath, module, announcementTypes {
require( msg.sender != spender );
require( db.balanceOf(msg.sender) >= amount );
require( db.setAllowance(msg.sender, spender, amount, nonce) );
- Approval(msg.sender, spender, amount);
+ emit Approval(msg.sender, spender, amount);
}
function allowance(address owner, address spender) constant returns (uint256 remaining, uint256 nonce) {
@@ -165,7 +165,7 @@ contract token is safeMath, module, announcementTypes {
@remaining Tokens to be spent
@nonce Transaction count
*/
- var (_success, _remaining, _nonce) = db.getAllowance(owner, spender);
+ (bool _success, uint256 _remaining, uint256 _nonce) = db.getAllowance(owner, spender);
require( _success );
return (_remaining, _nonce);
}
@@ -193,7 +193,7 @@ contract token is safeMath, module, announcementTypes {
} else {
_transfer( msg.sender, to, amount, true);
}
- Transfer(msg.sender, to, amount, _data);
+ emit Transfer(msg.sender, to, amount, _data);
return true;
}
@@ -217,12 +217,12 @@ contract token is safeMath, module, announcementTypes {
@success Was the Function successful?
*/
if ( from != msg.sender ) {
- var (_success, _reamining, _nonce) = db.getAllowance(from, msg.sender);
+ (bool _success, uint256 _reamining, uint256 _nonce) = db.getAllowance(from, msg.sender);
require( _success );
_reamining = safeSub(_reamining, amount);
_nonce = safeAdd(_nonce, 1);
require( db.setAllowance(from, msg.sender, _reamining, _nonce) );
- AllowanceUsed(msg.sender, from, amount);
+ emit AllowanceUsed(msg.sender, from, amount);
}
bytes memory _data;
if ( isContract(to) ) {
@@ -230,7 +230,7 @@ contract token is safeMath, module, announcementTypes {
} else {
_transfer( from, to, amount, true);
}
- Transfer(from, to, amount, _data);
+ emit Transfer(from, to, amount, _data);
return true;
}
@@ -256,7 +256,7 @@ contract token is safeMath, module, announcementTypes {
bytes memory _data;
require( super.isModuleHandler(msg.sender) );
_transfer( from, to, amount, fee);
- Transfer(from, to, amount, _data);
+ emit Transfer(from, to, amount, _data);
return true;
}
@@ -284,7 +284,7 @@ contract token is safeMath, module, announcementTypes {
} else {
_transfer( msg.sender, to, amount, true);
}
- Transfer(msg.sender, to, amount, extraData);
+ emit Transfer(msg.sender, to, amount, extraData);
return true;
}
@@ -298,7 +298,7 @@ contract token is safeMath, module, announcementTypes {
@extraData Extra data the receiver will get
*/
_transfer(from, to, amount, exchangeAddress == to);
- var (_success, _back) = thirdPartyContractAbstract(to).receiveCorionToken(from, amount, extraData);
+ (bool _success, uint256 _back) = thirdPartyContractAbstract(to).receiveCorionToken(from, amount, extraData);
require( _success );
require( amount > _back );
if ( _back > 0 ) {
@@ -321,11 +321,11 @@ contract token is safeMath, module, announcementTypes {
@fee Deduct transaction fee - yes or no?
*/
if( fee ) {
- var (success, _fee) = getTransactionFee(amount);
+ (bool success, uint256 _fee) = getTransactionFee(amount);
require( success );
require( db.balanceOf(from) >= amount + _fee );
}
- require( from != 0x00 && to != 0x00 && to != 0xa636a97578d26a3b76b060bbc18226d954cf3757 );
+ require( from != address(0x00) && to != address(0x00) && to != 0xa636A97578d26A3b76B060Bbc18226d954cf3757 );
require( ( ! isICO) || genesis[from] );
require( db.decrease(from, amount) );
require( db.increase(to, amount) );
@@ -366,7 +366,7 @@ contract token is safeMath, module, announcementTypes {
@value Quantity to calculate the fee
*/
if ( isICO ) { return; }
- var (_success, _fee) = getTransactionFee(value);
+ (bool _success, uint256 _fee) = getTransactionFee(value);
require( _success );
uint256 _forBurn = _fee * transactionFeeBurn / 100;
uint256 _forSchelling = _fee - _forBurn;
@@ -374,12 +374,12 @@ contract token is safeMath, module, announcementTypes {
address _schellingAddr;
(_success, _found, _schellingAddr) = moduleHandler(moduleHandlerAddress).getModuleAddressByName('Schelling');
require( _success );
- if ( _schellingAddr != 0x00 && _found) {
+ if ( _schellingAddr != address(0x00) && _found) {
require( db.decrease(owner, _forSchelling) );
require( db.increase(_schellingAddr, _forSchelling) );
_burn(owner, _forBurn);
bytes memory _data;
- Transfer(owner, _schellingAddr, _forSchelling, _data);
+ emit Transfer(owner, _schellingAddr, _forSchelling, _data);
require( moduleHandler(moduleHandlerAddress).broadcastTransfer(owner, _schellingAddr, _forSchelling) );
} else {
_burn(owner, _fee);
@@ -424,11 +424,11 @@ contract token is safeMath, module, announcementTypes {
@value Quantity
*/
require( db.increase(owner, value) );
- require( moduleHandler(moduleHandlerAddress).broadcastTransfer(0x00, owner, value) );
+ require( moduleHandler(moduleHandlerAddress).broadcastTransfer(address(0x00), owner, value) );
if ( isICO ) {
require( ico(icoAddr).setInterestDB(owner, db.balanceOf(owner)) );
}
- Mint(owner, value);
+ emit Mint(owner, value);
}
function burn(address owner, uint256 value) isReady external returns (bool success) {
@@ -453,8 +453,8 @@ contract token is safeMath, module, announcementTypes {
@value Quantity
*/
require( db.decrease(owner, value) );
- require( moduleHandler(moduleHandlerAddress).broadcastTransfer(owner, 0x00, value) );
- Burn(owner, value);
+ require( moduleHandler(moduleHandlerAddress).broadcastTransfer(owner, address(0x00), value) );
+ emit Burn(owner, value);
}
function isContract(address addr) internal returns (bool success) {
diff --git a/test/compilationTests/gnosis/Events/CategoricalEvent.sol b/test/compilationTests/gnosis/Events/CategoricalEvent.sol
index fbd1d744..4433bdfd 100644
--- a/test/compilationTests/gnosis/Events/CategoricalEvent.sol
+++ b/test/compilationTests/gnosis/Events/CategoricalEvent.sol
@@ -13,7 +13,7 @@ contract CategoricalEvent is Event {
/// @param _collateralToken Tokens used as collateral in exchange for outcome tokens
/// @param _oracle Oracle contract used to resolve the event
/// @param outcomeCount Number of event outcomes
- function CategoricalEvent(
+ constructor(
Token _collateralToken,
Oracle _oracle,
uint8 outcomeCount
@@ -38,7 +38,7 @@ contract CategoricalEvent is Event {
outcomeTokens[uint(outcome)].revoke(msg.sender, winnings);
// Payout winnings
require(collateralToken.transfer(msg.sender, winnings));
- WinningsRedemption(msg.sender, winnings);
+ emit WinningsRedemption(msg.sender, winnings);
}
/// @dev Calculates and returns event hash
diff --git a/test/compilationTests/gnosis/Events/Event.sol b/test/compilationTests/gnosis/Events/Event.sol
index 9aa257c4..a6edb778 100644
--- a/test/compilationTests/gnosis/Events/Event.sol
+++ b/test/compilationTests/gnosis/Events/Event.sol
@@ -33,18 +33,18 @@ contract Event {
/// @param _collateralToken Tokens used as collateral in exchange for outcome tokens
/// @param _oracle Oracle contract used to resolve the event
/// @param outcomeCount Number of event outcomes
- function Event(Token _collateralToken, Oracle _oracle, uint8 outcomeCount)
+ constructor(Token _collateralToken, Oracle _oracle, uint8 outcomeCount)
public
{
// Validate input
- require(address(_collateralToken) != 0 && address(_oracle) != 0 && outcomeCount >= 2);
+ require(address(_collateralToken) != address(0) && address(_oracle) != address(0) && outcomeCount >= 2);
collateralToken = _collateralToken;
oracle = _oracle;
// Create an outcome token for each outcome
for (uint8 i = 0; i < outcomeCount; i++) {
OutcomeToken outcomeToken = new OutcomeToken();
outcomeTokens.push(outcomeToken);
- OutcomeTokenCreation(outcomeToken, i);
+ emit OutcomeTokenCreation(outcomeToken, i);
}
}
@@ -58,7 +58,7 @@ contract Event {
// Issue new outcome tokens to sender
for (uint8 i = 0; i < outcomeTokens.length; i++)
outcomeTokens[i].issue(msg.sender, collateralTokenCount);
- OutcomeTokenSetIssuance(msg.sender, collateralTokenCount);
+ emit OutcomeTokenSetIssuance(msg.sender, collateralTokenCount);
}
/// @dev Sells equal number of tokens of all outcomes, exchanging collateral tokens and sets of outcome tokens 1:1
@@ -71,7 +71,7 @@ contract Event {
outcomeTokens[i].revoke(msg.sender, outcomeTokenCount);
// Transfer collateral tokens to sender
require(collateralToken.transfer(msg.sender, outcomeTokenCount));
- OutcomeTokenSetRevocation(msg.sender, outcomeTokenCount);
+ emit OutcomeTokenSetRevocation(msg.sender, outcomeTokenCount);
}
/// @dev Sets winning event outcome
@@ -83,7 +83,7 @@ contract Event {
// Set winning outcome
outcome = oracle.getOutcome();
isOutcomeSet = true;
- OutcomeAssignment(outcome);
+ emit OutcomeAssignment(outcome);
}
/// @dev Returns outcome count
diff --git a/test/compilationTests/gnosis/Events/EventFactory.sol b/test/compilationTests/gnosis/Events/EventFactory.sol
index dfb1a579..acef3330 100644
--- a/test/compilationTests/gnosis/Events/EventFactory.sol
+++ b/test/compilationTests/gnosis/Events/EventFactory.sol
@@ -37,7 +37,7 @@ contract EventFactory {
{
bytes32 eventHash = keccak256(collateralToken, oracle, outcomeCount);
// Event should not exist yet
- require(address(categoricalEvents[eventHash]) == 0);
+ require(address(categoricalEvents[eventHash]) == address(0));
// Create event
eventContract = new CategoricalEvent(
collateralToken,
@@ -45,7 +45,7 @@ contract EventFactory {
outcomeCount
);
categoricalEvents[eventHash] = eventContract;
- CategoricalEventCreation(msg.sender, eventContract, collateralToken, oracle, outcomeCount);
+ emit CategoricalEventCreation(msg.sender, eventContract, collateralToken, oracle, outcomeCount);
}
/// @dev Creates a new scalar event and adds it to the event mapping
@@ -65,7 +65,7 @@ contract EventFactory {
{
bytes32 eventHash = keccak256(collateralToken, oracle, lowerBound, upperBound);
// Event should not exist yet
- require(address(scalarEvents[eventHash]) == 0);
+ require(address(scalarEvents[eventHash]) == address(0));
// Create event
eventContract = new ScalarEvent(
collateralToken,
@@ -74,6 +74,6 @@ contract EventFactory {
upperBound
);
scalarEvents[eventHash] = eventContract;
- ScalarEventCreation(msg.sender, eventContract, collateralToken, oracle, lowerBound, upperBound);
+ emit ScalarEventCreation(msg.sender, eventContract, collateralToken, oracle, lowerBound, upperBound);
}
}
diff --git a/test/compilationTests/gnosis/Events/ScalarEvent.sol b/test/compilationTests/gnosis/Events/ScalarEvent.sol
index 2e5718ef..4f268a38 100644
--- a/test/compilationTests/gnosis/Events/ScalarEvent.sol
+++ b/test/compilationTests/gnosis/Events/ScalarEvent.sol
@@ -28,7 +28,7 @@ contract ScalarEvent is Event {
/// @param _oracle Oracle contract used to resolve the event
/// @param _lowerBound Lower bound for event outcome
/// @param _upperBound Lower bound for event outcome
- function ScalarEvent(
+ constructor(
Token _collateralToken,
Oracle _oracle,
int _lowerBound,
@@ -72,7 +72,7 @@ contract ScalarEvent is Event {
outcomeTokens[LONG].revoke(msg.sender, longOutcomeTokenCount);
// Payout winnings to sender
require(collateralToken.transfer(msg.sender, winnings));
- WinningsRedemption(msg.sender, winnings);
+ emit WinningsRedemption(msg.sender, winnings);
}
/// @dev Calculates and returns event hash
diff --git a/test/compilationTests/gnosis/MarketMakers/LMSRMarketMaker.sol b/test/compilationTests/gnosis/MarketMakers/LMSRMarketMaker.sol
index 1529129d..344dd8d2 100644
--- a/test/compilationTests/gnosis/MarketMakers/LMSRMarketMaker.sol
+++ b/test/compilationTests/gnosis/MarketMakers/LMSRMarketMaker.sol
@@ -95,7 +95,7 @@ contract LMSRMarketMaker is MarketMaker {
// The price function is exp(quantities[i]/b) / sum(exp(q/b) for q in quantities)
// To avoid overflow, calculate with
// exp(quantities[i]/b - offset) / sum(exp(q/b - offset) for q in quantities)
- var (sum, , outcomeExpTerm) = sumExpOffset(logN, netOutcomeTokensSold, funding, outcomeTokenIndex);
+ (uint256 sum, , uint256 outcomeExpTerm) = sumExpOffset(logN, netOutcomeTokensSold, funding, outcomeTokenIndex);
return outcomeExpTerm / (sum / ONE);
}
@@ -116,7 +116,7 @@ contract LMSRMarketMaker is MarketMaker {
// The cost function is C = b * log(sum(exp(q/b) for q in quantities)).
// To avoid overflow, we need to calc with an exponent offset:
// C = b * (offset + log(sum(exp(q/b - offset) for q in quantities)))
- var (sum, offset, ) = sumExpOffset(logN, netOutcomeTokensSold, funding, 0);
+ (uint256 sum, int256 offset, ) = sumExpOffset(logN, netOutcomeTokensSold, funding, 0);
costLevel = Math.ln(sum);
costLevel = costLevel.add(offset);
costLevel = (costLevel.mul(int(ONE)) / logN).mul(int(funding));
diff --git a/test/compilationTests/gnosis/Markets/Campaign.sol b/test/compilationTests/gnosis/Markets/Campaign.sol
index 9aee1033..f99ede53 100644
--- a/test/compilationTests/gnosis/Markets/Campaign.sol
+++ b/test/compilationTests/gnosis/Markets/Campaign.sol
@@ -70,7 +70,7 @@ contract Campaign {
/// @param _fee Market fee
/// @param _funding Initial funding for market
/// @param _deadline Campaign deadline
- function Campaign(
+ constructor(
Event _eventContract,
MarketFactory _marketFactory,
MarketMaker _marketMaker,
@@ -81,9 +81,9 @@ contract Campaign {
public
{
// Validate input
- require( address(_eventContract) != 0
- && address(_marketFactory) != 0
- && address(_marketMaker) != 0
+ require( address(_eventContract) != address(0)
+ && address(_marketFactory) != address(0)
+ && address(_marketMaker) != address(0)
&& _fee < FEE_RANGE
&& _funding > 0
&& now < _deadline);
@@ -111,7 +111,7 @@ contract Campaign {
contributions[msg.sender] = contributions[msg.sender].add(amount);
if (amount == maxAmount)
stage = Stages.AuctionSuccessful;
- CampaignFunding(msg.sender, amount);
+ emit CampaignFunding(msg.sender, amount);
}
/// @dev Withdraws refund amount
@@ -126,7 +126,7 @@ contract Campaign {
contributions[msg.sender] = 0;
// Refund collateral tokens
require(eventContract.collateralToken().transfer(msg.sender, refundAmount));
- CampaignRefund(msg.sender, refundAmount);
+ emit CampaignRefund(msg.sender, refundAmount);
}
/// @dev Allows to create market after successful funding
@@ -141,7 +141,7 @@ contract Campaign {
require(eventContract.collateralToken().approve(market, funding));
market.fund(funding);
stage = Stages.MarketCreated;
- MarketCreation(market);
+ emit MarketCreation(market);
return market;
}
@@ -158,7 +158,7 @@ contract Campaign {
eventContract.redeemWinnings();
finalBalance = eventContract.collateralToken().balanceOf(this);
stage = Stages.MarketClosed;
- MarketClosing();
+ emit MarketClosing();
}
/// @dev Allows to withdraw fees from campaign contract to contributor
@@ -172,6 +172,6 @@ contract Campaign {
contributions[msg.sender] = 0;
// Send fee share to contributor
require(eventContract.collateralToken().transfer(msg.sender, fees));
- FeeWithdrawal(msg.sender, fees);
+ emit FeeWithdrawal(msg.sender, fees);
}
}
diff --git a/test/compilationTests/gnosis/Markets/CampaignFactory.sol b/test/compilationTests/gnosis/Markets/CampaignFactory.sol
index 930ec2e2..d80d7d63 100644
--- a/test/compilationTests/gnosis/Markets/CampaignFactory.sol
+++ b/test/compilationTests/gnosis/Markets/CampaignFactory.sol
@@ -34,6 +34,6 @@ contract CampaignFactory {
returns (Campaign campaign)
{
campaign = new Campaign(eventContract, marketFactory, marketMaker, fee, funding, deadline);
- CampaignCreation(msg.sender, campaign, eventContract, marketFactory, marketMaker, fee, funding, deadline);
+ emit CampaignCreation(msg.sender, campaign, eventContract, marketFactory, marketMaker, fee, funding, deadline);
}
}
diff --git a/test/compilationTests/gnosis/Markets/StandardMarket.sol b/test/compilationTests/gnosis/Markets/StandardMarket.sol
index b973119a..84f30386 100644
--- a/test/compilationTests/gnosis/Markets/StandardMarket.sol
+++ b/test/compilationTests/gnosis/Markets/StandardMarket.sol
@@ -38,11 +38,11 @@ contract StandardMarket is Market {
/// @param _eventContract Event contract
/// @param _marketMaker Market maker contract
/// @param _fee Market fee
- function StandardMarket(address _creator, Event _eventContract, MarketMaker _marketMaker, uint24 _fee)
+ constructor(address _creator, Event _eventContract, MarketMaker _marketMaker, uint24 _fee)
public
{
// Validate inputs
- require(address(_eventContract) != 0 && address(_marketMaker) != 0 && _fee < FEE_RANGE);
+ require(address(_eventContract) != address(0) && address(_marketMaker) != address(0) && _fee < FEE_RANGE);
creator = _creator;
createdAtBlock = block.number;
eventContract = _eventContract;
@@ -65,7 +65,7 @@ contract StandardMarket is Market {
eventContract.buyAllOutcomes(_funding);
funding = _funding;
stage = Stages.MarketFunded;
- MarketFunding(funding);
+ emit MarketFunding(funding);
}
/// @dev Allows market creator to close the markets by transferring all remaining outcome tokens to the creator
@@ -78,7 +78,7 @@ contract StandardMarket is Market {
for (uint8 i = 0; i < outcomeCount; i++)
require(eventContract.outcomeTokens(i).transfer(creator, eventContract.outcomeTokens(i).balanceOf(this)));
stage = Stages.MarketClosed;
- MarketClosing();
+ emit MarketClosing();
}
/// @dev Allows market creator to withdraw fees generated by trades
@@ -91,7 +91,7 @@ contract StandardMarket is Market {
fees = eventContract.collateralToken().balanceOf(this);
// Transfer fees
require(eventContract.collateralToken().transfer(creator, fees));
- FeeWithdrawal(fees);
+ emit FeeWithdrawal(fees);
}
/// @dev Allows to buy outcome tokens from market maker
@@ -121,7 +121,7 @@ contract StandardMarket is Market {
// Add outcome token count to market maker net balance
require(int(outcomeTokenCount) >= 0);
netOutcomeTokensSold[outcomeTokenIndex] = netOutcomeTokensSold[outcomeTokenIndex].add(int(outcomeTokenCount));
- OutcomeTokenPurchase(msg.sender, outcomeTokenIndex, outcomeTokenCount, cost);
+ emit OutcomeTokenPurchase(msg.sender, outcomeTokenIndex, outcomeTokenCount, cost);
}
/// @dev Allows to sell outcome tokens to market maker
@@ -150,7 +150,7 @@ contract StandardMarket is Market {
// Subtract outcome token count from market maker net balance
require(int(outcomeTokenCount) >= 0);
netOutcomeTokensSold[outcomeTokenIndex] = netOutcomeTokensSold[outcomeTokenIndex].sub(int(outcomeTokenCount));
- OutcomeTokenSale(msg.sender, outcomeTokenIndex, outcomeTokenCount, profit);
+ emit OutcomeTokenSale(msg.sender, outcomeTokenIndex, outcomeTokenCount, profit);
}
/// @dev Buys all outcomes, then sells all shares of selected outcome which were bought, keeping
@@ -178,7 +178,7 @@ contract StandardMarket is Market {
require(eventContract.outcomeTokens(i).transfer(msg.sender, outcomeTokenCount));
// Send change back to buyer
require(eventContract.collateralToken().transfer(msg.sender, profit));
- OutcomeTokenShortSale(msg.sender, outcomeTokenIndex, outcomeTokenCount, cost);
+ emit OutcomeTokenShortSale(msg.sender, outcomeTokenIndex, outcomeTokenCount, cost);
}
/// @dev Calculates fee to be paid to market maker
diff --git a/test/compilationTests/gnosis/Markets/StandardMarketFactory.sol b/test/compilationTests/gnosis/Markets/StandardMarketFactory.sol
index 101c37a2..88dcbe79 100644
--- a/test/compilationTests/gnosis/Markets/StandardMarketFactory.sol
+++ b/test/compilationTests/gnosis/Markets/StandardMarketFactory.sol
@@ -20,6 +20,6 @@ contract StandardMarketFactory is MarketFactory {
returns (Market market)
{
market = new StandardMarket(msg.sender, eventContract, marketMaker, fee);
- MarketCreation(msg.sender, market, eventContract, marketMaker, fee);
+ emit MarketCreation(msg.sender, market, eventContract, marketMaker, fee);
}
}
diff --git a/test/compilationTests/gnosis/Migrations.sol b/test/compilationTests/gnosis/Migrations.sol
index 7e7fe8d4..c7d09bd2 100644
--- a/test/compilationTests/gnosis/Migrations.sol
+++ b/test/compilationTests/gnosis/Migrations.sol
@@ -8,7 +8,7 @@ contract Migrations {
if (msg.sender == owner) _;
}
- function Migrations() {
+ constructor() {
owner = msg.sender;
}
diff --git a/test/compilationTests/gnosis/Oracles/CentralizedOracle.sol b/test/compilationTests/gnosis/Oracles/CentralizedOracle.sol
index 26acf526..362c514c 100644
--- a/test/compilationTests/gnosis/Oracles/CentralizedOracle.sol
+++ b/test/compilationTests/gnosis/Oracles/CentralizedOracle.sol
@@ -34,7 +34,7 @@ contract CentralizedOracle is Oracle {
*/
/// @dev Constructor sets owner address and IPFS hash
/// @param _ipfsHash Hash identifying off chain event description
- function CentralizedOracle(address _owner, bytes _ipfsHash)
+ constructor(address _owner, bytes _ipfsHash)
public
{
// Description hash cannot be null
@@ -52,7 +52,7 @@ contract CentralizedOracle is Oracle {
// Result is not set yet
require(!isSet);
owner = newOwner;
- OwnerReplacement(newOwner);
+ emit OwnerReplacement(newOwner);
}
/// @dev Sets event outcome
@@ -65,7 +65,7 @@ contract CentralizedOracle is Oracle {
require(!isSet);
isSet = true;
outcome = _outcome;
- OutcomeAssignment(_outcome);
+ emit OutcomeAssignment(_outcome);
}
/// @dev Returns if winning outcome is set
diff --git a/test/compilationTests/gnosis/Oracles/CentralizedOracleFactory.sol b/test/compilationTests/gnosis/Oracles/CentralizedOracleFactory.sol
index 62a12cf4..ca4e37d2 100644
--- a/test/compilationTests/gnosis/Oracles/CentralizedOracleFactory.sol
+++ b/test/compilationTests/gnosis/Oracles/CentralizedOracleFactory.sol
@@ -22,6 +22,6 @@ contract CentralizedOracleFactory {
returns (CentralizedOracle centralizedOracle)
{
centralizedOracle = new CentralizedOracle(msg.sender, ipfsHash);
- CentralizedOracleCreation(msg.sender, centralizedOracle, ipfsHash);
+ emit CentralizedOracleCreation(msg.sender, centralizedOracle, ipfsHash);
}
}
diff --git a/test/compilationTests/gnosis/Oracles/DifficultyOracle.sol b/test/compilationTests/gnosis/Oracles/DifficultyOracle.sol
index 87351dfa..94fc70ca 100644
--- a/test/compilationTests/gnosis/Oracles/DifficultyOracle.sol
+++ b/test/compilationTests/gnosis/Oracles/DifficultyOracle.sol
@@ -22,7 +22,7 @@ contract DifficultyOracle is Oracle {
*/
/// @dev Contract constructor validates and sets target block number
/// @param _blockNumber Target block number
- function DifficultyOracle(uint _blockNumber)
+ constructor(uint _blockNumber)
public
{
// Block has to be in the future
@@ -37,7 +37,7 @@ contract DifficultyOracle is Oracle {
// Block number was reached and outcome was not set yet
require(block.number >= blockNumber && difficulty == 0);
difficulty = block.difficulty;
- OutcomeAssignment(difficulty);
+ emit OutcomeAssignment(difficulty);
}
/// @dev Returns if difficulty is set
diff --git a/test/compilationTests/gnosis/Oracles/DifficultyOracleFactory.sol b/test/compilationTests/gnosis/Oracles/DifficultyOracleFactory.sol
index 2e97362c..fc5dcc3b 100644
--- a/test/compilationTests/gnosis/Oracles/DifficultyOracleFactory.sol
+++ b/test/compilationTests/gnosis/Oracles/DifficultyOracleFactory.sol
@@ -22,6 +22,6 @@ contract DifficultyOracleFactory {
returns (DifficultyOracle difficultyOracle)
{
difficultyOracle = new DifficultyOracle(blockNumber);
- DifficultyOracleCreation(msg.sender, difficultyOracle, blockNumber);
+ emit DifficultyOracleCreation(msg.sender, difficultyOracle, blockNumber);
}
}
diff --git a/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol b/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol
index 524103d8..7105f247 100644
--- a/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol
+++ b/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol
@@ -55,7 +55,7 @@ contract FutarchyOracle is Oracle {
/// @param marketMaker Market maker contract
/// @param fee Market fee
/// @param _deadline Decision deadline
- function FutarchyOracle(
+ constructor(
address _creator,
EventFactory eventFactory,
Token collateralToken,
@@ -105,7 +105,7 @@ contract FutarchyOracle is Oracle {
require(market.eventContract().collateralToken().approve(market, funding));
market.fund(funding);
}
- FutarchyFunding(funding);
+ emit FutarchyFunding(funding);
}
/// @dev Closes market for winning outcome and redeems winnings and sends all collateral tokens to creator
@@ -123,7 +123,7 @@ contract FutarchyOracle is Oracle {
// Redeem collateral token for winning outcome tokens and transfer collateral tokens to creator
categoricalEvent.redeemWinnings();
require(categoricalEvent.collateralToken().transfer(creator, categoricalEvent.collateralToken().balanceOf(this)));
- FutarchyClosing();
+ emit FutarchyClosing();
}
/// @dev Allows to set the oracle outcome based on the market with largest long position
@@ -144,7 +144,7 @@ contract FutarchyOracle is Oracle {
}
winningMarketIndex = highestIndex;
isSet = true;
- OutcomeAssignment(winningMarketIndex);
+ emit OutcomeAssignment(winningMarketIndex);
}
/// @dev Returns if winning outcome is set
diff --git a/test/compilationTests/gnosis/Oracles/FutarchyOracleFactory.sol b/test/compilationTests/gnosis/Oracles/FutarchyOracleFactory.sol
index 62eab4f0..3c6e5c15 100644
--- a/test/compilationTests/gnosis/Oracles/FutarchyOracleFactory.sol
+++ b/test/compilationTests/gnosis/Oracles/FutarchyOracleFactory.sol
@@ -33,10 +33,10 @@ contract FutarchyOracleFactory {
*/
/// @dev Constructor sets event factory contract
/// @param _eventFactory Event factory contract
- function FutarchyOracleFactory(EventFactory _eventFactory)
+ constructor(EventFactory _eventFactory)
public
{
- require(address(_eventFactory) != 0);
+ require(address(_eventFactory) != address(0));
eventFactory = _eventFactory;
}
@@ -78,7 +78,7 @@ contract FutarchyOracleFactory {
fee,
deadline
);
- FutarchyOracleCreation(
+ emit FutarchyOracleCreation(
msg.sender,
futarchyOracle,
collateralToken,
diff --git a/test/compilationTests/gnosis/Oracles/MajorityOracle.sol b/test/compilationTests/gnosis/Oracles/MajorityOracle.sol
index 1562ce48..24cf9dea 100644
--- a/test/compilationTests/gnosis/Oracles/MajorityOracle.sol
+++ b/test/compilationTests/gnosis/Oracles/MajorityOracle.sol
@@ -16,14 +16,14 @@ contract MajorityOracle is Oracle {
*/
/// @dev Allows to create an oracle for a majority vote based on other oracles
/// @param _oracles List of oracles taking part in the majority vote
- function MajorityOracle(Oracle[] _oracles)
+ constructor(Oracle[] _oracles)
public
{
// At least 2 oracles should be defined
require(_oracles.length > 2);
for (uint i = 0; i < _oracles.length; i++)
// Oracle address cannot be null
- require(address(_oracles[i]) != 0);
+ require(address(_oracles[i]) != address(0));
oracles = _oracles;
}
@@ -72,7 +72,7 @@ contract MajorityOracle is Oracle {
constant
returns (bool)
{
- var (outcomeSet, ) = getStatusAndOutcome();
+ (bool outcomeSet, ) = getStatusAndOutcome();
return outcomeSet;
}
@@ -83,7 +83,7 @@ contract MajorityOracle is Oracle {
constant
returns (int)
{
- var (, winningOutcome) = getStatusAndOutcome();
+ (, int winningOutcome) = getStatusAndOutcome();
return winningOutcome;
}
}
diff --git a/test/compilationTests/gnosis/Oracles/MajorityOracleFactory.sol b/test/compilationTests/gnosis/Oracles/MajorityOracleFactory.sol
index 0024516a..3c02fef4 100644
--- a/test/compilationTests/gnosis/Oracles/MajorityOracleFactory.sol
+++ b/test/compilationTests/gnosis/Oracles/MajorityOracleFactory.sol
@@ -22,6 +22,6 @@ contract MajorityOracleFactory {
returns (MajorityOracle majorityOracle)
{
majorityOracle = new MajorityOracle(oracles);
- MajorityOracleCreation(msg.sender, majorityOracle, oracles);
+ emit MajorityOracleCreation(msg.sender, majorityOracle, oracles);
}
}
diff --git a/test/compilationTests/gnosis/Oracles/SignedMessageOracle.sol b/test/compilationTests/gnosis/Oracles/SignedMessageOracle.sol
index d541ab46..83990b9b 100644
--- a/test/compilationTests/gnosis/Oracles/SignedMessageOracle.sol
+++ b/test/compilationTests/gnosis/Oracles/SignedMessageOracle.sol
@@ -38,7 +38,7 @@ contract SignedMessageOracle is Oracle {
/// @param v Signature parameter
/// @param r Signature parameter
/// @param s Signature parameter
- function SignedMessageOracle(bytes32 _descriptionHash, uint8 v, bytes32 r, bytes32 s)
+ constructor(bytes32 _descriptionHash, uint8 v, bytes32 r, bytes32 s)
public
{
signer = ecrecover(_descriptionHash, v, r, s);
@@ -61,7 +61,7 @@ contract SignedMessageOracle is Oracle {
&& signer == ecrecover(keccak256(descriptionHash, newSigner, _nonce), v, r, s));
nonce = _nonce;
signer = newSigner;
- SignerReplacement(newSigner);
+ emit SignerReplacement(newSigner);
}
/// @dev Sets outcome based on signed message
@@ -77,7 +77,7 @@ contract SignedMessageOracle is Oracle {
&& signer == ecrecover(keccak256(descriptionHash, _outcome), v, r, s));
isSet = true;
outcome = _outcome;
- OutcomeAssignment(_outcome);
+ emit OutcomeAssignment(_outcome);
}
/// @dev Returns if winning outcome
diff --git a/test/compilationTests/gnosis/Oracles/SignedMessageOracleFactory.sol b/test/compilationTests/gnosis/Oracles/SignedMessageOracleFactory.sol
index 0884d8ca..ea70b2aa 100644
--- a/test/compilationTests/gnosis/Oracles/SignedMessageOracleFactory.sol
+++ b/test/compilationTests/gnosis/Oracles/SignedMessageOracleFactory.sol
@@ -26,6 +26,6 @@ contract SignedMessageOracleFactory {
{
signedMessageOracle = new SignedMessageOracle(descriptionHash, v, r, s);
address oracle = ecrecover(descriptionHash, v, r, s);
- SignedMessageOracleCreation(msg.sender, signedMessageOracle, oracle);
+ emit SignedMessageOracleCreation(msg.sender, signedMessageOracle, oracle);
}
}
diff --git a/test/compilationTests/gnosis/Oracles/UltimateOracle.sol b/test/compilationTests/gnosis/Oracles/UltimateOracle.sol
index fe8b4ec7..dd66c9ab 100644
--- a/test/compilationTests/gnosis/Oracles/UltimateOracle.sol
+++ b/test/compilationTests/gnosis/Oracles/UltimateOracle.sol
@@ -46,7 +46,7 @@ contract UltimateOracle is Oracle {
/// @param _challengePeriod Time to challenge oracle outcome
/// @param _challengeAmount Amount to challenge the outcome
/// @param _frontRunnerPeriod Time to overbid the front-runner
- function UltimateOracle(
+ constructor(
Oracle _forwardedOracle,
Token _collateralToken,
uint8 _spreadMultiplier,
@@ -57,8 +57,8 @@ contract UltimateOracle is Oracle {
public
{
// Validate inputs
- require( address(_forwardedOracle) != 0
- && address(_collateralToken) != 0
+ require( address(_forwardedOracle) != address(0)
+ && address(_collateralToken) != address(0)
&& _spreadMultiplier >= 2
&& _challengePeriod > 0
&& _challengeAmount > 0
@@ -81,7 +81,7 @@ contract UltimateOracle is Oracle {
&& forwardedOracle.isOutcomeSet());
forwardedOutcome = forwardedOracle.getOutcome();
forwardedOutcomeSetTimestamp = now;
- ForwardedOracleOutcomeAssignment(forwardedOutcome);
+ emit ForwardedOracleOutcomeAssignment(forwardedOutcome);
}
/// @dev Allows to challenge the oracle outcome
@@ -98,7 +98,7 @@ contract UltimateOracle is Oracle {
totalAmount = challengeAmount;
frontRunner = _outcome;
frontRunnerSetTimestamp = now;
- OutcomeChallenge(msg.sender, _outcome);
+ emit OutcomeChallenge(msg.sender, _outcome);
}
/// @dev Allows to challenge the oracle outcome
@@ -122,7 +122,7 @@ contract UltimateOracle is Oracle {
frontRunner = _outcome;
frontRunnerSetTimestamp = now;
}
- OutcomeVote(msg.sender, _outcome, amount);
+ emit OutcomeVote(msg.sender, _outcome, amount);
}
/// @dev Withdraws winnings for user
@@ -137,7 +137,7 @@ contract UltimateOracle is Oracle {
outcomeAmounts[msg.sender][frontRunner] = 0;
// Transfer earnings to contributor
require(collateralToken.transfer(msg.sender, amount));
- Withdrawal(msg.sender, amount);
+ emit Withdrawal(msg.sender, amount);
}
/// @dev Checks if time to challenge the outcome is over
diff --git a/test/compilationTests/gnosis/Oracles/UltimateOracleFactory.sol b/test/compilationTests/gnosis/Oracles/UltimateOracleFactory.sol
index 67f8a96e..51f5610e 100644
--- a/test/compilationTests/gnosis/Oracles/UltimateOracleFactory.sol
+++ b/test/compilationTests/gnosis/Oracles/UltimateOracleFactory.sol
@@ -50,7 +50,7 @@ contract UltimateOracleFactory {
challengeAmount,
frontRunnerPeriod
);
- UltimateOracleCreation(
+ emit UltimateOracleCreation(
msg.sender,
ultimateOracle,
oracle,
diff --git a/test/compilationTests/gnosis/Tokens/EtherToken.sol b/test/compilationTests/gnosis/Tokens/EtherToken.sol
index f6e73e5a..32e64583 100644
--- a/test/compilationTests/gnosis/Tokens/EtherToken.sol
+++ b/test/compilationTests/gnosis/Tokens/EtherToken.sol
@@ -30,7 +30,7 @@ contract EtherToken is StandardToken {
{
balances[msg.sender] = balances[msg.sender].add(msg.value);
totalTokens = totalTokens.add(msg.value);
- Deposit(msg.sender, msg.value);
+ emit Deposit(msg.sender, msg.value);
}
/// @dev Sells tokens in exchange for Ether, exchanging them 1:1
@@ -42,6 +42,6 @@ contract EtherToken is StandardToken {
balances[msg.sender] = balances[msg.sender].sub(value);
totalTokens = totalTokens.sub(value);
msg.sender.transfer(value);
- Withdrawal(msg.sender, value);
+ emit Withdrawal(msg.sender, value);
}
}
diff --git a/test/compilationTests/gnosis/Tokens/OutcomeToken.sol b/test/compilationTests/gnosis/Tokens/OutcomeToken.sol
index fd1fa590..0bc7307d 100644
--- a/test/compilationTests/gnosis/Tokens/OutcomeToken.sol
+++ b/test/compilationTests/gnosis/Tokens/OutcomeToken.sol
@@ -31,7 +31,7 @@ contract OutcomeToken is StandardToken {
* Public functions
*/
/// @dev Constructor sets events contract address
- function OutcomeToken()
+ constructor()
public
{
eventContract = msg.sender;
@@ -46,7 +46,7 @@ contract OutcomeToken is StandardToken {
{
balances[_for] = balances[_for].add(outcomeTokenCount);
totalTokens = totalTokens.add(outcomeTokenCount);
- Issuance(_for, outcomeTokenCount);
+ emit Issuance(_for, outcomeTokenCount);
}
/// @dev Events contract revokes tokens for address. Returns success
@@ -58,6 +58,6 @@ contract OutcomeToken is StandardToken {
{
balances[_for] = balances[_for].sub(outcomeTokenCount);
totalTokens = totalTokens.sub(outcomeTokenCount);
- Revocation(_for, outcomeTokenCount);
+ emit Revocation(_for, outcomeTokenCount);
}
}
diff --git a/test/compilationTests/gnosis/Tokens/StandardToken.sol b/test/compilationTests/gnosis/Tokens/StandardToken.sol
index fc899ca6..b7d0d37a 100644
--- a/test/compilationTests/gnosis/Tokens/StandardToken.sol
+++ b/test/compilationTests/gnosis/Tokens/StandardToken.sol
@@ -30,7 +30,7 @@ contract StandardToken is Token {
return false;
balances[msg.sender] -= value;
balances[to] += value;
- Transfer(msg.sender, to, value);
+ emit Transfer(msg.sender, to, value);
return true;
}
@@ -50,7 +50,7 @@ contract StandardToken is Token {
balances[from] -= value;
allowances[from][msg.sender] -= value;
balances[to] += value;
- Transfer(from, to, value);
+ emit Transfer(from, to, value);
return true;
}
@@ -63,7 +63,7 @@ contract StandardToken is Token {
returns (bool)
{
allowances[msg.sender][spender] = value;
- Approval(msg.sender, spender, value);
+ emit Approval(msg.sender, spender, value);
return true;
}
diff --git a/test/compilationTests/milestonetracker/MilestoneTracker.sol b/test/compilationTests/milestonetracker/MilestoneTracker.sol
index 318330df..56422169 100644
--- a/test/compilationTests/milestonetracker/MilestoneTracker.sol
+++ b/test/compilationTests/milestonetracker/MilestoneTracker.sol
@@ -108,7 +108,7 @@ contract MilestoneTracker {
/// @param _arbitrator Address assigned to be the arbitrator
/// @param _donor Address assigned to be the donor
/// @param _recipient Address assigned to be the recipient
- function MilestoneTracker (
+ constructor (
address _arbitrator,
address _donor,
address _recipient
@@ -179,7 +179,7 @@ contract MilestoneTracker {
) onlyRecipient campaignNotCanceled {
proposedMilestones = _newMilestones;
changingMilestones = true;
- NewMilestoneListProposed();
+ emit NewMilestoneListProposed();
}
@@ -192,11 +192,11 @@ contract MilestoneTracker {
function unproposeMilestones() onlyRecipient campaignNotCanceled {
delete proposedMilestones;
changingMilestones = false;
- NewMilestoneListUnproposed();
+ emit NewMilestoneListUnproposed();
}
/// @notice `onlyDonor` Approves the proposed milestone list
- /// @param _hashProposals The sha3() of the proposed milestone list's
+ /// @param _hashProposals The keccak256() of the proposed milestone list's
/// bytecode; this confirms that the `donor` knows the set of milestones
/// they are approving
function acceptProposedMilestones(bytes32 _hashProposals
@@ -205,7 +205,7 @@ contract MilestoneTracker {
uint i;
if (!changingMilestones) throw;
- if (sha3(proposedMilestones) != _hashProposals) throw;
+ if (keccak256(proposedMilestones) != _hashProposals) throw;
// Cancel all the unfinished milestones
for (i=0; i<milestones.length; i++) {
@@ -216,22 +216,22 @@ contract MilestoneTracker {
// Decode the RLP encoded milestones and add them to the milestones list
bytes memory mProposedMilestones = proposedMilestones;
- var itmProposals = mProposedMilestones.toRLPItem(true);
+ RLP.RLPItem memory itmProposals = mProposedMilestones.toRLPItem(true);
if (!itmProposals.isList()) throw;
- var itrProposals = itmProposals.iterator();
+ RLP.Iterator memory itrProposals = itmProposals.iterator();
while(itrProposals.hasNext()) {
- var itmProposal = itrProposals.next();
+ RLP.RLPItem memory itmProposal = itrProposals.next();
Milestone milestone = milestones[milestones.length ++];
if (!itmProposal.isList()) throw;
- var itrProposal = itmProposal.iterator();
+ RLP.Iterator memory itrProposal = itmProposal.iterator();
milestone.description = itrProposal.next().toAscii();
milestone.url = itrProposal.next().toAscii();
@@ -249,7 +249,7 @@ contract MilestoneTracker {
delete proposedMilestones;
changingMilestones = false;
- NewMilestoneListAccepted();
+ emit NewMilestoneListAccepted();
}
/// @notice `onlyRecipientOrLeadLink`Marks a milestone as DONE and
@@ -268,7 +268,7 @@ contract MilestoneTracker {
if (now > milestone.maxCompletionDate) throw;
milestone.status = MilestoneStatus.Completed;
milestone.doneTime = now;
- ProposalStatusChanged(_idMilestone, milestone.status);
+ emit ProposalStatusChanged(_idMilestone, milestone.status);
}
/// @notice `onlyReviewer` Approves a specific milestone
@@ -297,7 +297,7 @@ contract MilestoneTracker {
(milestone.status != MilestoneStatus.Completed)) throw;
milestone.status = MilestoneStatus.AcceptedAndInProgress;
- ProposalStatusChanged(_idMilestone, milestone.status);
+ emit ProposalStatusChanged(_idMilestone, milestone.status);
}
/// @notice `onlyRecipientOrLeadLink` Sends the milestone payment as
@@ -330,7 +330,7 @@ contract MilestoneTracker {
throw;
milestone.status = MilestoneStatus.Canceled;
- ProposalStatusChanged(_idMilestone, milestone.status);
+ emit ProposalStatusChanged(_idMilestone, milestone.status);
}
/// @notice `onlyArbitrator` Forces a milestone to be paid out as long as it
@@ -350,7 +350,7 @@ contract MilestoneTracker {
/// milestones.
function arbitrateCancelCampaign() onlyArbitrator campaignNotCanceled {
campaignCanceled = true;
- CampaignCanceled();
+ emit CampaignCanceled();
}
// @dev This internal function is executed when the milestone is paid out
@@ -362,6 +362,6 @@ contract MilestoneTracker {
milestone.status = MilestoneStatus.AuthorizedForPayment;
if (!milestone.paymentSource.call.value(0)(milestone.payData))
throw;
- ProposalStatusChanged(_idMilestone, milestone.status);
+ emit ProposalStatusChanged(_idMilestone, milestone.status);
}
}
diff --git a/test/compilationTests/milestonetracker/RLP.sol b/test/compilationTests/milestonetracker/RLP.sol
index 5bb27bb2..e71d567e 100644
--- a/test/compilationTests/milestonetracker/RLP.sol
+++ b/test/compilationTests/milestonetracker/RLP.sol
@@ -32,8 +32,8 @@ library RLP {
function next(Iterator memory self) internal constant returns (RLPItem memory subItem) {
if(hasNext(self)) {
- var ptr = self._unsafe_nextPtr;
- var itemLength = _itemLength(ptr);
+ uint ptr = self._unsafe_nextPtr;
+ uint itemLength = _itemLength(ptr);
subItem._unsafe_memPtr = ptr;
subItem._unsafe_length = itemLength;
self._unsafe_nextPtr = ptr + itemLength;
@@ -50,7 +50,7 @@ library RLP {
}
function hasNext(Iterator memory self) internal constant returns (bool) {
- var item = self._unsafe_item;
+ RLPItem memory item = self._unsafe_item;
return self._unsafe_nextPtr < item._unsafe_memPtr + item._unsafe_length;
}
@@ -76,7 +76,7 @@ library RLP {
/// @param strict Will throw if the data is not RLP encoded.
/// @return An RLPItem
function toRLPItem(bytes memory self, bool strict) internal constant returns (RLPItem memory) {
- var item = toRLPItem(self);
+ RLPItem memory item = toRLPItem(self);
if(strict) {
uint len = self.length;
if(_payloadOffset(item) > len)
@@ -170,7 +170,7 @@ library RLP {
/// @param self The RLPItem.
/// @return The bytes.
function toBytes(RLPItem memory self) internal constant returns (bytes memory bts) {
- var len = self._unsafe_length;
+ uint len = self._unsafe_length;
if (len == 0)
return;
bts = new bytes(len);
@@ -184,7 +184,7 @@ library RLP {
function toData(RLPItem memory self) internal constant returns (bytes memory bts) {
if(!isData(self))
throw;
- var (rStartPos, len) = _decode(self);
+ (uint rStartPos, uint len) = _decode(self);
bts = new bytes(len);
_copyToBytes(rStartPos, bts, len);
}
@@ -196,9 +196,9 @@ library RLP {
function toList(RLPItem memory self) internal constant returns (RLPItem[] memory list) {
if(!isList(self))
throw;
- var numItems = items(self);
+ uint numItems = items(self);
list = new RLPItem[](numItems);
- var it = iterator(self);
+ Iterator memory it = iterator(self);
uint idx;
while(hasNext(it)) {
list[idx] = next(it);
@@ -213,7 +213,7 @@ library RLP {
function toAscii(RLPItem memory self) internal constant returns (string memory str) {
if(!isData(self))
throw;
- var (rStartPos, len) = _decode(self);
+ (uint rStartPos, uint len) = _decode(self);
bytes memory bts = new bytes(len);
_copyToBytes(rStartPos, bts, len);
str = string(bts);
@@ -226,7 +226,7 @@ library RLP {
function toUint(RLPItem memory self) internal constant returns (uint data) {
if(!isData(self))
throw;
- var (rStartPos, len) = _decode(self);
+ (uint rStartPos, uint len) = _decode(self);
if (len > 32 || len == 0)
throw;
assembly {
@@ -241,7 +241,7 @@ library RLP {
function toBool(RLPItem memory self) internal constant returns (bool data) {
if(!isData(self))
throw;
- var (rStartPos, len) = _decode(self);
+ (uint rStartPos, uint len) = _decode(self);
if (len != 1)
throw;
uint temp;
@@ -260,10 +260,10 @@ library RLP {
function toByte(RLPItem memory self) internal constant returns (byte data) {
if(!isData(self))
throw;
- var (rStartPos, len) = _decode(self);
+ (uint rStartPos, uint len) = _decode(self);
if (len != 1)
throw;
- uint temp;
+ uint8 temp;
assembly {
temp := byte(0, mload(rStartPos))
}
@@ -293,7 +293,7 @@ library RLP {
function toAddress(RLPItem memory self) internal constant returns (address data) {
if(!isData(self))
throw;
- var (rStartPos, len) = _decode(self);
+ (uint rStartPos, uint len) = _decode(self);
if (len != 20)
throw;
assembly {
diff --git a/test/compilationTests/stringutils/strings.sol b/test/compilationTests/stringutils/strings.sol
index 0a2d68bd..fc46ec5a 100644
--- a/test/compilationTests/stringutils/strings.sol
+++ b/test/compilationTests/stringutils/strings.sol
@@ -135,7 +135,7 @@ library strings {
* @return A newly allocated string containing the slice's text.
*/
function toString(slice self) internal returns (string) {
- var ret = new string(self._len);
+ string memory ret = new string(self._len);
uint retptr;
assembly { retptr := add(ret, 32) }
@@ -153,9 +153,10 @@ library strings {
*/
function len(slice self) internal returns (uint) {
// Starting at ptr-31 means the LSB will be the byte we care about
- var ptr = self._ptr - 31;
- var end = ptr + self._len;
- for (uint len = 0; ptr < end; len++) {
+ uint ptr = self._ptr - 31;
+ uint end = ptr + self._len;
+ uint len;
+ for (len = 0; ptr < end; len++) {
uint8 b;
assembly { b := and(mload(ptr), 0xFF) }
if (b < 0x80) {
@@ -198,8 +199,8 @@ library strings {
if (other._len < self._len)
shortest = other._len;
- var selfptr = self._ptr;
- var otherptr = other._ptr;
+ uint selfptr = self._ptr;
+ uint otherptr = other._ptr;
for (uint idx = 0; idx < shortest; idx += 32) {
uint a;
uint b;
@@ -210,7 +211,7 @@ library strings {
if (a != b) {
// Mask out irrelevant bytes and check again
uint mask = ~(2 ** (8 * (32 - shortest + idx)) - 1);
- var diff = (a & mask) - (b & mask);
+ uint diff = (a & mask) - (b & mask);
if (diff != 0)
return int(diff);
}
@@ -299,7 +300,7 @@ library strings {
// Load the rune into the MSBs of b
assembly { word:= mload(mload(add(self, 32))) }
- var b = word / div;
+ uint b = word / div;
if (b < 0x80) {
ret = b;
len = 1;
@@ -339,7 +340,7 @@ library strings {
*/
function keccak(slice self) internal returns (bytes32 ret) {
assembly {
- ret := sha3(mload(add(self, 32)), mload(self))
+ ret := keccak256(mload(add(self, 32)), mload(self))
}
}
@@ -363,7 +364,7 @@ library strings {
let len := mload(needle)
let selfptr := mload(add(self, 0x20))
let needleptr := mload(add(needle, 0x20))
- equal := eq(sha3(selfptr, len), sha3(needleptr, len))
+ equal := eq(keccak256(selfptr, len), keccak256(needleptr, len))
}
return equal;
}
@@ -386,7 +387,7 @@ library strings {
let len := mload(needle)
let selfptr := mload(add(self, 0x20))
let needleptr := mload(add(needle, 0x20))
- equal := eq(sha3(selfptr, len), sha3(needleptr, len))
+ equal := eq(keccak256(selfptr, len), keccak256(needleptr, len))
}
}
@@ -409,7 +410,7 @@ library strings {
return false;
}
- var selfptr = self._ptr + self._len - needle._len;
+ uint selfptr = self._ptr + self._len - needle._len;
if (selfptr == needle._ptr) {
return true;
@@ -419,7 +420,7 @@ library strings {
assembly {
let len := mload(needle)
let needleptr := mload(add(needle, 0x20))
- equal := eq(sha3(selfptr, len), sha3(needleptr, len))
+ equal := eq(keccak256(selfptr, len), keccak256(needleptr, len))
}
return equal;
@@ -437,13 +438,13 @@ library strings {
return self;
}
- var selfptr = self._ptr + self._len - needle._len;
+ uint selfptr = self._ptr + self._len - needle._len;
bool equal = true;
if (selfptr != needle._ptr) {
assembly {
let len := mload(needle)
let needleptr := mload(add(needle, 0x20))
- equal := eq(sha3(selfptr, len), sha3(needleptr, len))
+ equal := eq(keccak256(selfptr, len), keccak256(needleptr, len))
}
}
@@ -479,11 +480,11 @@ library strings {
} else {
// For long needles, use hashing
bytes32 hash;
- assembly { hash := sha3(needleptr, needlelen) }
+ assembly { hash := keccak256(needleptr, needlelen) }
ptr = selfptr;
for (idx = 0; idx <= selflen - needlelen; idx++) {
bytes32 testHash;
- assembly { testHash := sha3(ptr, needlelen) }
+ assembly { testHash := keccak256(ptr, needlelen) }
if (hash == testHash)
return ptr;
ptr += 1;
@@ -519,11 +520,11 @@ library strings {
} else {
// For long needles, use hashing
bytes32 hash;
- assembly { hash := sha3(needleptr, needlelen) }
+ assembly { hash := keccak256(needleptr, needlelen) }
ptr = selfptr + (selflen - needlelen);
while (ptr >= selfptr) {
bytes32 testHash;
- assembly { testHash := sha3(ptr, needlelen) }
+ assembly { testHash := keccak256(ptr, needlelen) }
if (hash == testHash)
return ptr + needlelen;
ptr -= 1;
@@ -667,7 +668,7 @@ library strings {
* @return The concatenation of the two strings.
*/
function concat(slice self, slice other) internal returns (string) {
- var ret = new string(self._len + other._len);
+ string memory ret = new string(self._len + other._len);
uint retptr;
assembly { retptr := add(ret, 32) }
memcpy(retptr, self._ptr, self._len);
@@ -691,11 +692,11 @@ library strings {
for(uint i = 0; i < parts.length; i++)
len += parts[i]._len;
- var ret = new string(len);
+ string memory ret = new string(len);
uint retptr;
assembly { retptr := add(ret, 32) }
- for(i = 0; i < parts.length; i++) {
+ for(uint i = 0; i < parts.length; i++) {
memcpy(retptr, parts[i]._ptr, parts[i]._len);
retptr += parts[i]._len;
if (i < parts.length - 1) {
diff --git a/test/compilationTests/zeppelin/Bounty.sol b/test/compilationTests/zeppelin/Bounty.sol
index 4425b7a5..91730900 100644
--- a/test/compilationTests/zeppelin/Bounty.sol
+++ b/test/compilationTests/zeppelin/Bounty.sol
@@ -32,7 +32,7 @@ contract Bounty is PullPayment, Destructible {
function createTarget() returns(Target) {
Target target = Target(deployContract());
researchers[target] = msg.sender;
- TargetCreated(target);
+ emit TargetCreated(target);
return target;
}
@@ -48,7 +48,7 @@ contract Bounty is PullPayment, Destructible {
*/
function claim(Target target) {
address researcher = researchers[target];
- if (researcher == 0) {
+ if (researcher == address(0)) {
throw;
}
// Check Target contract invariants
diff --git a/test/compilationTests/zeppelin/DayLimit.sol b/test/compilationTests/zeppelin/DayLimit.sol
index 3c8d5b0c..0bcb341a 100644
--- a/test/compilationTests/zeppelin/DayLimit.sol
+++ b/test/compilationTests/zeppelin/DayLimit.sol
@@ -15,7 +15,7 @@ contract DayLimit {
* @dev Constructor that sets the passed value as a dailyLimit.
* @param _limit uint256 to represent the daily limit.
*/
- function DayLimit(uint256 _limit) {
+ constructor(uint256 _limit) {
dailyLimit = _limit;
lastDay = today();
}
diff --git a/test/compilationTests/zeppelin/LimitBalance.sol b/test/compilationTests/zeppelin/LimitBalance.sol
index 57477c74..40edd014 100644
--- a/test/compilationTests/zeppelin/LimitBalance.sol
+++ b/test/compilationTests/zeppelin/LimitBalance.sol
@@ -15,7 +15,7 @@ contract LimitBalance {
* @dev Constructor that sets the passed value as a limit.
* @param _limit uint256 to represent the limit.
*/
- function LimitBalance(uint256 _limit) {
+ constructor(uint256 _limit) {
limit = _limit;
}
diff --git a/test/compilationTests/zeppelin/MultisigWallet.sol b/test/compilationTests/zeppelin/MultisigWallet.sol
index 939e70f2..83df125c 100644
--- a/test/compilationTests/zeppelin/MultisigWallet.sol
+++ b/test/compilationTests/zeppelin/MultisigWallet.sol
@@ -25,8 +25,8 @@ contract MultisigWallet is Multisig, Shareable, DayLimit {
* @param _owners A list of owners.
* @param _required The amount required for a transaction to be approved.
*/
- function MultisigWallet(address[] _owners, uint256 _required, uint256 _daylimit)
- Shareable(_owners, _required)
+ constructor(address[] _owners, uint256 _required, uint256 _daylimit)
+ Shareable(_owners, _required)
DayLimit(_daylimit) { }
/**
@@ -42,7 +42,7 @@ contract MultisigWallet is Multisig, Shareable, DayLimit {
function() payable {
// just being sent some cash?
if (msg.value > 0)
- Deposit(msg.sender, msg.value);
+ emit Deposit(msg.sender, msg.value);
}
/**
@@ -58,7 +58,7 @@ contract MultisigWallet is Multisig, Shareable, DayLimit {
function execute(address _to, uint256 _value, bytes _data) external onlyOwner returns (bytes32 _r) {
// first, take the opportunity to check that we're under the daily limit.
if (underLimit(_value)) {
- SingleTransact(msg.sender, _value, _to, _data);
+ emit SingleTransact(msg.sender, _value, _to, _data);
// yes - just execute the call.
if (!_to.call.value(_value)(_data)) {
throw;
@@ -67,11 +67,11 @@ contract MultisigWallet is Multisig, Shareable, DayLimit {
}
// determine our operation hash.
_r = keccak256(msg.data, block.number);
- if (!confirm(_r) && txs[_r].to == 0) {
+ if (!confirm(_r) && txs[_r].to == address(0)) {
txs[_r].to = _to;
txs[_r].value = _value;
txs[_r].data = _data;
- ConfirmationNeeded(_r, msg.sender, _value, _to, _data);
+ emit ConfirmationNeeded(_r, msg.sender, _value, _to, _data);
}
}
@@ -81,11 +81,11 @@ contract MultisigWallet is Multisig, Shareable, DayLimit {
* @param _h The transaction hash to approve.
*/
function confirm(bytes32 _h) onlymanyowners(_h) returns (bool) {
- if (txs[_h].to != 0) {
+ if (txs[_h].to != address(0)) {
if (!txs[_h].to.call.value(txs[_h].value)(txs[_h].data)) {
throw;
}
- MultiTransact(msg.sender, _h, txs[_h].value, txs[_h].to, txs[_h].data);
+ emit MultiTransact(msg.sender, _h, txs[_h].value, txs[_h].to, txs[_h].data);
delete txs[_h];
return true;
}
diff --git a/test/compilationTests/zeppelin/crowdsale/CappedCrowdsale.sol b/test/compilationTests/zeppelin/crowdsale/CappedCrowdsale.sol
index f04649f3..afae79b7 100644
--- a/test/compilationTests/zeppelin/crowdsale/CappedCrowdsale.sol
+++ b/test/compilationTests/zeppelin/crowdsale/CappedCrowdsale.sol
@@ -12,7 +12,7 @@ contract CappedCrowdsale is Crowdsale {
uint256 public cap;
- function CappedCrowdsale(uint256 _cap) {
+ constructor(uint256 _cap) {
cap = _cap;
}
diff --git a/test/compilationTests/zeppelin/crowdsale/Crowdsale.sol b/test/compilationTests/zeppelin/crowdsale/Crowdsale.sol
index bee1efd2..a60a28f8 100644
--- a/test/compilationTests/zeppelin/crowdsale/Crowdsale.sol
+++ b/test/compilationTests/zeppelin/crowdsale/Crowdsale.sol
@@ -40,11 +40,11 @@ contract Crowdsale {
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
- function Crowdsale(uint256 _startBlock, uint256 _endBlock, uint256 _rate, address _wallet) {
+ constructor(uint256 _startBlock, uint256 _endBlock, uint256 _rate, address _wallet) {
require(_startBlock >= block.number);
require(_endBlock >= _startBlock);
require(_rate > 0);
- require(_wallet != 0x0);
+ require(_wallet != address(0x0));
token = createTokenContract();
startBlock = _startBlock;
@@ -67,7 +67,7 @@ contract Crowdsale {
// low level token purchase function
function buyTokens(address beneficiary) payable {
- require(beneficiary != 0x0);
+ require(beneficiary != address(0x0));
require(validPurchase());
uint256 weiAmount = msg.value;
@@ -80,7 +80,7 @@ contract Crowdsale {
weiRaised = updatedWeiRaised;
token.mint(beneficiary, tokens);
- TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
+ emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
diff --git a/test/compilationTests/zeppelin/crowdsale/FinalizableCrowdsale.sol b/test/compilationTests/zeppelin/crowdsale/FinalizableCrowdsale.sol
index 1a736083..7965a66d 100644
--- a/test/compilationTests/zeppelin/crowdsale/FinalizableCrowdsale.sol
+++ b/test/compilationTests/zeppelin/crowdsale/FinalizableCrowdsale.sol
@@ -23,7 +23,7 @@ contract FinalizableCrowdsale is Crowdsale, Ownable {
require(hasEnded());
finalization();
- Finalized();
+ emit Finalized();
isFinalized = true;
}
diff --git a/test/compilationTests/zeppelin/crowdsale/RefundVault.sol b/test/compilationTests/zeppelin/crowdsale/RefundVault.sol
index cc92ff9f..0be45ec4 100644
--- a/test/compilationTests/zeppelin/crowdsale/RefundVault.sol
+++ b/test/compilationTests/zeppelin/crowdsale/RefundVault.sol
@@ -22,8 +22,8 @@ contract RefundVault is Ownable {
event RefundsEnabled();
event Refunded(address indexed beneficiary, uint256 weiAmount);
- function RefundVault(address _wallet) {
- require(_wallet != 0x0);
+ constructor(address _wallet) {
+ require(_wallet != address(0x0));
wallet = _wallet;
state = State.Active;
}
@@ -36,14 +36,14 @@ contract RefundVault is Ownable {
function close() onlyOwner {
require(state == State.Active);
state = State.Closed;
- Closed();
+ emit Closed();
wallet.transfer(this.balance);
}
function enableRefunds() onlyOwner {
require(state == State.Active);
state = State.Refunding;
- RefundsEnabled();
+ emit RefundsEnabled();
}
function refund(address investor) {
@@ -51,6 +51,6 @@ contract RefundVault is Ownable {
uint256 depositedValue = deposited[investor];
deposited[investor] = 0;
investor.transfer(depositedValue);
- Refunded(investor, depositedValue);
+ emit Refunded(investor, depositedValue);
}
}
diff --git a/test/compilationTests/zeppelin/crowdsale/RefundableCrowdsale.sol b/test/compilationTests/zeppelin/crowdsale/RefundableCrowdsale.sol
index f45df1d3..5e798d45 100644
--- a/test/compilationTests/zeppelin/crowdsale/RefundableCrowdsale.sol
+++ b/test/compilationTests/zeppelin/crowdsale/RefundableCrowdsale.sol
@@ -21,7 +21,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
// refund vault used to hold funds while crowdsale is running
RefundVault public vault;
- function RefundableCrowdsale(uint256 _goal) {
+ constructor(uint256 _goal) {
vault = new RefundVault(wallet);
goal = _goal;
}
diff --git a/test/compilationTests/zeppelin/lifecycle/Destructible.sol b/test/compilationTests/zeppelin/lifecycle/Destructible.sol
index 3561e3b7..00492590 100644
--- a/test/compilationTests/zeppelin/lifecycle/Destructible.sol
+++ b/test/compilationTests/zeppelin/lifecycle/Destructible.sol
@@ -10,7 +10,7 @@ import "../ownership/Ownable.sol";
*/
contract Destructible is Ownable {
- function Destructible() payable { }
+ constructor() payable { }
/**
* @dev Transfers the current balance to the owner and terminates the contract.
diff --git a/test/compilationTests/zeppelin/lifecycle/Pausable.sol b/test/compilationTests/zeppelin/lifecycle/Pausable.sol
index b14f8767..10b0fcd8 100644
--- a/test/compilationTests/zeppelin/lifecycle/Pausable.sol
+++ b/test/compilationTests/zeppelin/lifecycle/Pausable.sol
@@ -36,7 +36,7 @@ contract Pausable is Ownable {
*/
function pause() onlyOwner whenNotPaused returns (bool) {
paused = true;
- Pause();
+ emit Pause();
return true;
}
@@ -45,7 +45,7 @@ contract Pausable is Ownable {
*/
function unpause() onlyOwner whenPaused returns (bool) {
paused = false;
- Unpause();
+ emit Unpause();
return true;
}
}
diff --git a/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol b/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol
index fe0b46b6..f88a55aa 100644
--- a/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol
+++ b/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol
@@ -12,7 +12,7 @@ import "../token/ERC20Basic.sol";
*/
contract TokenDestructible is Ownable {
- function TokenDestructible() payable { }
+ constructor() payable { }
/**
* @notice Terminate contract and refund to owner
diff --git a/test/compilationTests/zeppelin/ownership/Claimable.sol b/test/compilationTests/zeppelin/ownership/Claimable.sol
index d063502d..14d0ac6a 100644
--- a/test/compilationTests/zeppelin/ownership/Claimable.sol
+++ b/test/compilationTests/zeppelin/ownership/Claimable.sol
@@ -35,6 +35,6 @@ contract Claimable is Ownable {
*/
function claimOwnership() onlyPendingOwner {
owner = pendingOwner;
- pendingOwner = 0x0;
+ pendingOwner = address(0x0);
}
}
diff --git a/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol b/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol
index f5fee614..93177dc6 100644
--- a/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol
+++ b/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol
@@ -36,7 +36,7 @@ contract DelayedClaimable is Claimable {
if ((block.number > end) || (block.number < start))
throw;
owner = pendingOwner;
- pendingOwner = 0x0;
+ pendingOwner = address(0x0);
end = 0;
}
diff --git a/test/compilationTests/zeppelin/ownership/HasNoEther.sol b/test/compilationTests/zeppelin/ownership/HasNoEther.sol
index 2bcaf1b8..8f9edc03 100644
--- a/test/compilationTests/zeppelin/ownership/HasNoEther.sol
+++ b/test/compilationTests/zeppelin/ownership/HasNoEther.sol
@@ -21,7 +21,7 @@ contract HasNoEther is Ownable {
* constructor. By doing it this way we prevent a payable constructor from working. Alternatively
* we could use assembly to access msg.value.
*/
- function HasNoEther() payable {
+ constructor() payable {
if(msg.value > 0) {
throw;
}
diff --git a/test/compilationTests/zeppelin/ownership/Ownable.sol b/test/compilationTests/zeppelin/ownership/Ownable.sol
index f1628454..0a2257d6 100644
--- a/test/compilationTests/zeppelin/ownership/Ownable.sol
+++ b/test/compilationTests/zeppelin/ownership/Ownable.sol
@@ -14,7 +14,7 @@ contract Ownable {
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
- function Ownable() {
+ constructor() {
owner = msg.sender;
}
diff --git a/test/compilationTests/zeppelin/ownership/Shareable.sol b/test/compilationTests/zeppelin/ownership/Shareable.sol
index 9fdaccfd..f8059650 100644
--- a/test/compilationTests/zeppelin/ownership/Shareable.sol
+++ b/test/compilationTests/zeppelin/ownership/Shareable.sol
@@ -59,7 +59,7 @@ contract Shareable {
* @param _owners A list of owners.
* @param _required The amount required for a transaction to be approved.
*/
- function Shareable(address[] _owners, uint256 _required) {
+ constructor(address[] _owners, uint256 _required) {
owners[1] = msg.sender;
ownerIndex[msg.sender] = 1;
for (uint256 i = 0; i < _owners.length; ++i) {
@@ -83,11 +83,11 @@ contract Shareable {
return;
}
uint256 ownerIndexBit = 2**index;
- var pending = pendings[_operation];
+ PendingState memory pending = pendings[_operation];
if (pending.ownersDone & ownerIndexBit > 0) {
pending.yetNeeded++;
pending.ownersDone -= ownerIndexBit;
- Revoke(msg.sender, _operation);
+ emit Revoke(msg.sender, _operation);
}
}
@@ -116,7 +116,7 @@ contract Shareable {
* @return True if the owner has confirmed and false otherwise.
*/
function hasConfirmed(bytes32 _operation, address _owner) constant returns (bool) {
- var pending = pendings[_operation];
+ PendingState memory pending = pendings[_operation];
uint256 index = ownerIndex[_owner];
// make sure they're an owner
@@ -142,7 +142,7 @@ contract Shareable {
throw;
}
- var pending = pendings[_operation];
+ PendingState memory pending = pendings[_operation];
// if we're not yet working on this operation, switch over and reset the confirmation status.
if (pending.yetNeeded == 0) {
// reset count of confirmations needed.
@@ -156,7 +156,7 @@ contract Shareable {
uint256 ownerIndexBit = 2**index;
// make sure we (the message sender) haven't confirmed this operation previously.
if (pending.ownersDone & ownerIndexBit == 0) {
- Confirmation(msg.sender, _operation);
+ emit Confirmation(msg.sender, _operation);
// ok - check if count is enough to go ahead.
if (pending.yetNeeded <= 1) {
// enough confirmations: reset and run interior.
diff --git a/test/compilationTests/zeppelin/token/BasicToken.sol b/test/compilationTests/zeppelin/token/BasicToken.sol
index 5618227a..831f706e 100644
--- a/test/compilationTests/zeppelin/token/BasicToken.sol
+++ b/test/compilationTests/zeppelin/token/BasicToken.sol
@@ -22,7 +22,7 @@ contract BasicToken is ERC20Basic {
function transfer(address _to, uint256 _value) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
- Transfer(msg.sender, _to, _value);
+ emit Transfer(msg.sender, _to, _value);
}
/**
diff --git a/test/compilationTests/zeppelin/token/MintableToken.sol b/test/compilationTests/zeppelin/token/MintableToken.sol
index 505d13c3..45926afb 100644
--- a/test/compilationTests/zeppelin/token/MintableToken.sol
+++ b/test/compilationTests/zeppelin/token/MintableToken.sol
@@ -34,7 +34,7 @@ contract MintableToken is StandardToken, Ownable {
function mint(address _to, uint256 _amount) onlyOwner canMint returns (bool) {
totalSupply = totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
- Mint(_to, _amount);
+ emit Mint(_to, _amount);
return true;
}
@@ -44,7 +44,7 @@ contract MintableToken is StandardToken, Ownable {
*/
function finishMinting() onlyOwner returns (bool) {
mintingFinished = true;
- MintFinished();
+ emit MintFinished();
return true;
}
}
diff --git a/test/compilationTests/zeppelin/token/SimpleToken.sol b/test/compilationTests/zeppelin/token/SimpleToken.sol
index 898cb21d..a4ba9eb3 100644
--- a/test/compilationTests/zeppelin/token/SimpleToken.sol
+++ b/test/compilationTests/zeppelin/token/SimpleToken.sol
@@ -20,7 +20,7 @@ contract SimpleToken is StandardToken {
/**
* @dev Contructor that gives msg.sender all of existing tokens.
*/
- function SimpleToken() {
+ constructor() {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
}
diff --git a/test/compilationTests/zeppelin/token/StandardToken.sol b/test/compilationTests/zeppelin/token/StandardToken.sol
index b1b49fe3..ab9f582e 100644
--- a/test/compilationTests/zeppelin/token/StandardToken.sol
+++ b/test/compilationTests/zeppelin/token/StandardToken.sol
@@ -24,7 +24,7 @@ contract StandardToken is ERC20, BasicToken {
* @param _value uint256 the amout of tokens to be transfered
*/
function transferFrom(address _from, address _to, uint256 _value) {
- var _allowance = allowed[_from][msg.sender];
+ uint256 _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// if (_value > _allowance) throw;
@@ -32,7 +32,7 @@ contract StandardToken is ERC20, BasicToken {
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
- Transfer(_from, _to, _value);
+ emit Transfer(_from, _to, _value);
}
/**
@@ -49,7 +49,7 @@ contract StandardToken is ERC20, BasicToken {
if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) throw;
allowed[msg.sender][_spender] = _value;
- Approval(msg.sender, _spender, _value);
+ emit Approval(msg.sender, _spender, _value);
}
/**
diff --git a/test/compilationTests/zeppelin/token/TokenTimelock.sol b/test/compilationTests/zeppelin/token/TokenTimelock.sol
index 595bf8d0..e9f998ba 100644
--- a/test/compilationTests/zeppelin/token/TokenTimelock.sol
+++ b/test/compilationTests/zeppelin/token/TokenTimelock.sol
@@ -19,7 +19,7 @@ contract TokenTimelock {
// timestamp when token release is enabled
uint releaseTime;
- function TokenTimelock(ERC20Basic _token, address _beneficiary, uint _releaseTime) {
+ constructor(ERC20Basic _token, address _beneficiary, uint _releaseTime) {
require(_releaseTime > now);
token = _token;
beneficiary = _beneficiary;
diff --git a/test/compilationTests/zeppelin/token/VestedToken.sol b/test/compilationTests/zeppelin/token/VestedToken.sol
index b7748b09..e9929018 100644
--- a/test/compilationTests/zeppelin/token/VestedToken.sol
+++ b/test/compilationTests/zeppelin/token/VestedToken.sol
@@ -65,7 +65,7 @@ contract VestedToken is StandardToken, LimitedTransferToken {
transfer(_to, _value);
- NewTokenGrant(msg.sender, _to, _value, count - 1);
+ emit NewTokenGrant(msg.sender, _to, _value, count - 1);
}
/**
@@ -96,7 +96,7 @@ contract VestedToken is StandardToken, LimitedTransferToken {
balances[receiver] = balances[receiver].add(nonVested);
balances[_holder] = balances[_holder].sub(nonVested);
- Transfer(_holder, receiver, nonVested);
+ emit Transfer(_holder, receiver, nonVested);
}
diff --git a/test/contracts/AuctionRegistrar.cpp b/test/contracts/AuctionRegistrar.cpp
index 5e4991e2..f5abb83d 100644
--- a/test/contracts/AuctionRegistrar.cpp
+++ b/test/contracts/AuctionRegistrar.cpp
@@ -70,7 +70,7 @@ contract AuctionSystem {
var auction = m_auctions[_name];
if (auction.endDate > 0 && now > auction.endDate)
{
- AuctionEnded(_name, auction.highestBidder);
+ emit AuctionEnded(_name, auction.highestBidder);
onAuctionEnd(_name);
delete m_auctions[_name];
return;
@@ -84,7 +84,7 @@ contract AuctionSystem {
auction.highestBidder = _bidder;
auction.endDate = now + c_biddingTime;
- NewBid(_name, _bidder, _value);
+ emit NewBid(_name, _bidder, _value);
}
}
@@ -109,7 +109,7 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
uint renewalDate;
}
- uint constant c_renewalInterval = 1 years;
+ uint constant c_renewalInterval = 365 days;
uint constant c_freeBytes = 12;
function Registrar() {
@@ -122,8 +122,8 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
var previousOwner = record.owner;
record.renewalDate = now + c_renewalInterval;
record.owner = auction.highestBidder;
- Changed(_name);
- if (previousOwner != 0) {
+ emit Changed(_name);
+ if (previousOwner != 0x0000000000000000000000000000000000000000) {
if (!record.owner.send(auction.sumOfBids - auction.highestBid / 100))
throw;
} else {
@@ -143,10 +143,10 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
bid(_name, msg.sender, msg.value);
} else {
Record record = m_toRecord[_name];
- if (record.owner != 0)
+ if (record.owner != 0x0000000000000000000000000000000000000000)
throw;
m_toRecord[_name].owner = msg.sender;
- Changed(_name);
+ emit Changed(_name);
}
}
@@ -158,35 +158,35 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
function transfer(string _name, address _newOwner) onlyrecordowner(_name) {
m_toRecord[_name].owner = _newOwner;
- Changed(_name);
+ emit Changed(_name);
}
function disown(string _name) onlyrecordowner(_name) {
if (stringsEqual(m_toName[m_toRecord[_name].primary], _name))
{
- PrimaryChanged(_name, m_toRecord[_name].primary);
+ emit PrimaryChanged(_name, m_toRecord[_name].primary);
m_toName[m_toRecord[_name].primary] = "";
}
delete m_toRecord[_name];
- Changed(_name);
+ emit Changed(_name);
}
function setAddress(string _name, address _a, bool _primary) onlyrecordowner(_name) {
m_toRecord[_name].primary = _a;
if (_primary)
{
- PrimaryChanged(_name, _a);
+ emit PrimaryChanged(_name, _a);
m_toName[_a] = _name;
}
- Changed(_name);
+ emit Changed(_name);
}
function setSubRegistrar(string _name, address _registrar) onlyrecordowner(_name) {
m_toRecord[_name].subRegistrar = _registrar;
- Changed(_name);
+ emit Changed(_name);
}
function setContent(string _name, bytes32 _content) onlyrecordowner(_name) {
m_toRecord[_name].content = _content;
- Changed(_name);
+ emit Changed(_name);
}
function stringsEqual(string storage _a, string memory _b) internal returns (bool) {
diff --git a/test/contracts/FixedFeeRegistrar.cpp b/test/contracts/FixedFeeRegistrar.cpp
index a3a27c37..c167745c 100644
--- a/test/contracts/FixedFeeRegistrar.cpp
+++ b/test/contracts/FixedFeeRegistrar.cpp
@@ -76,32 +76,32 @@ contract FixedFeeRegistrar is Registrar {
function reserve(string _name) payable {
Record rec = m_record(_name);
- if (rec.owner == 0 && msg.value >= c_fee) {
+ if (rec.owner == 0x0000000000000000000000000000000000000000 && msg.value >= c_fee) {
rec.owner = msg.sender;
- Changed(_name);
+ emit Changed(_name);
}
}
function disown(string _name, address _refund) onlyrecordowner(_name) {
delete m_recordData[uint(keccak256(_name)) / 8];
if (!_refund.send(c_fee))
throw;
- Changed(_name);
+ emit Changed(_name);
}
function transfer(string _name, address _newOwner) onlyrecordowner(_name) {
m_record(_name).owner = _newOwner;
- Changed(_name);
+ emit Changed(_name);
}
function setAddr(string _name, address _a) onlyrecordowner(_name) {
m_record(_name).addr = _a;
- Changed(_name);
+ emit Changed(_name);
}
function setSubRegistrar(string _name, address _registrar) onlyrecordowner(_name) {
m_record(_name).subRegistrar = _registrar;
- Changed(_name);
+ emit Changed(_name);
}
function setContent(string _name, bytes32 _content) onlyrecordowner(_name) {
m_record(_name).content = _content;
- Changed(_name);
+ emit Changed(_name);
}
function record(string _name) constant returns (address o_addr, address o_subRegistrar, bytes32 o_content, address o_owner) {
diff --git a/test/contracts/Wallet.cpp b/test/contracts/Wallet.cpp
index 1031e8f1..0e42eeb1 100644
--- a/test/contracts/Wallet.cpp
+++ b/test/contracts/Wallet.cpp
@@ -123,7 +123,7 @@ contract multiowned {
if (pending.ownersDone & ownerIndexBit > 0) {
pending.yetNeeded++;
pending.ownersDone -= ownerIndexBit;
- Revoke(msg.sender, _operation);
+ emit Revoke(msg.sender, _operation);
}
}
@@ -137,7 +137,7 @@ contract multiowned {
m_owners[ownerIndex] = uint(_to);
m_ownerIndex[uint(_from)] = 0;
m_ownerIndex[uint(_to)] = ownerIndex;
- OwnerChanged(_from, _to);
+ emit OwnerChanged(_from, _to);
}
function addOwner(address _owner) onlymanyowners(keccak256(msg.data)) external {
@@ -151,7 +151,7 @@ contract multiowned {
m_numOwners++;
m_owners[m_numOwners] = uint(_owner);
m_ownerIndex[uint(_owner)] = m_numOwners;
- OwnerAdded(_owner);
+ emit OwnerAdded(_owner);
}
function removeOwner(address _owner) onlymanyowners(keccak256(msg.data)) external {
@@ -163,14 +163,14 @@ contract multiowned {
m_ownerIndex[uint(_owner)] = 0;
clearPending();
reorganizeOwners(); //make sure m_numOwner is equal to the number of owners and always points to the optimal free slot
- OwnerRemoved(_owner);
+ emit OwnerRemoved(_owner);
}
function changeRequirement(uint _newRequired) onlymanyowners(keccak256(msg.data)) external {
if (_newRequired > m_numOwners) return;
m_required = _newRequired;
clearPending();
- RequirementChanged(_newRequired);
+ emit RequirementChanged(_newRequired);
}
function isOwner(address _addr) returns (bool) {
@@ -215,7 +215,7 @@ contract multiowned {
uint ownerIndexBit = 2**ownerIndex;
// make sure we (the message sender) haven't confirmed this operation previously.
if (pending.ownersDone & ownerIndexBit == 0) {
- Confirmation(msg.sender, _operation);
+ emit Confirmation(msg.sender, _operation);
// ok - check if count is enough to go ahead.
if (pending.yetNeeded <= 1) {
// enough confirmations: reset and run interior.
@@ -382,7 +382,7 @@ contract Wallet is multisig, multiowned, daylimit {
function() payable {
// just being sent some cash?
if (msg.value > 0)
- Deposit(msg.sender, msg.value);
+ emit Deposit(msg.sender, msg.value);
}
// Outside-visible transact entry point. Executes transacion immediately if below daily spend limit.
@@ -392,27 +392,27 @@ contract Wallet is multisig, multiowned, daylimit {
function execute(address _to, uint _value, bytes _data) external onlyowner returns (bytes32 _r) {
// first, take the opportunity to check that we're under the daily limit.
if (underLimit(_value)) {
- SingleTransact(msg.sender, _value, _to, _data);
+ emit SingleTransact(msg.sender, _value, _to, _data);
// yes - just execute the call.
_to.call.value(_value)(_data);
return 0;
}
// determine our operation hash.
_r = keccak256(msg.data, block.number);
- if (!confirm(_r) && m_txs[_r].to == 0) {
+ if (!confirm(_r) && m_txs[_r].to == 0x0000000000000000000000000000000000000000) {
m_txs[_r].to = _to;
m_txs[_r].value = _value;
m_txs[_r].data = _data;
- ConfirmationNeeded(_r, msg.sender, _value, _to, _data);
+ emit ConfirmationNeeded(_r, msg.sender, _value, _to, _data);
}
}
// confirm a transaction through just the hash. we use the previous transactions map, m_txs, in order
// to determine the body of the transaction from the hash provided.
function confirm(bytes32 _h) onlymanyowners(_h) returns (bool) {
- if (m_txs[_h].to != 0) {
+ if (m_txs[_h].to != 0x0000000000000000000000000000000000000000) {
m_txs[_h].to.call.value(m_txs[_h].value)(m_txs[_h].data);
- MultiTransact(msg.sender, _h, m_txs[_h].value, m_txs[_h].to, m_txs[_h].data);
+ emit MultiTransact(msg.sender, _h, m_txs[_h].value, m_txs[_h].to, m_txs[_h].data);
delete m_txs[_h];
return true;
}
diff --git a/test/externalTests.sh b/test/externalTests.sh
index cd6deb75..f2839083 100755
--- a/test/externalTests.sh
+++ b/test/externalTests.sh
@@ -40,21 +40,41 @@ function test_truffle
{
name="$1"
repo="$2"
+ branch="$3"
echo "Running $name tests..."
DIR=$(mktemp -d)
(
- git clone --depth 1 "$repo" "$DIR"
+ if [ -n "$branch" ]
+ then
+ echo "Cloning $branch of $repo..."
+ git clone --depth 1 "$repo" -b "$branch" "$DIR"
+ else
+ echo "Cloning $repo..."
+ git clone --depth 1 "$repo" "$DIR"
+ fi
cd "$DIR"
+ echo "Current commit hash: `git rev-parse HEAD`"
npm install
find . -name soljson.js -exec cp "$SOLJSON" {} \;
if [ "$name" == "Gnosis" ]; then
+ echo "Replaced fixed-version pragmas..."
# Replace fixed-version pragmas in Gnosis (part of Consensys best practice)
find contracts test -name '*.sol' -type f -print0 | xargs -0 sed -i -e 's/pragma solidity 0/pragma solidity ^0/'
fi
+ assertsol="node_modules/truffle/build/Assert.sol"
+ if [ -f "$assertsol" ]
+ then
+ echo "Replace Truffle's Assert.sol with a known good version"
+ rm "$assertsol"
+ wget https://raw.githubusercontent.com/trufflesuite/truffle-core/ef31bcaa15dbd9bd0f6a0070a5c63f271cde2dbc/lib/testing/Assert.sol -o "$assertsol"
+ fi
npm run test
)
rm -rf "$DIR"
}
-test_truffle Gnosis https://github.com/gnosis/gnosis-contracts.git
-test_truffle Zeppelin https://github.com/OpenZeppelin/zeppelin-solidity.git
+# Using our temporary fork here. Hopefully to be merged into upstream after the 0.5.0 release.
+test_truffle Zeppelin https://github.com/axic/openzeppelin-solidity.git solidity-050
+
+# Disabled temporarily as it needs to be updated to latest Truffle first.
+#test_truffle Gnosis https://github.com/axic/pm-contracts.git solidity-050
diff --git a/test/libevmasm/Optimiser.cpp b/test/libevmasm/Optimiser.cpp
index 4b399a14..5687ffcc 100644
--- a/test/libevmasm/Optimiser.cpp
+++ b/test/libevmasm/Optimiser.cpp
@@ -967,6 +967,31 @@ BOOST_AUTO_TEST_CASE(peephole_swap_comparison)
}
}
+BOOST_AUTO_TEST_CASE(peephole_truthy_and)
+{
+ AssemblyItems items{
+ AssemblyItem(Tag, 1),
+ Instruction::BALANCE,
+ u256(0),
+ Instruction::NOT,
+ Instruction::AND,
+ AssemblyItem(PushTag, 1),
+ Instruction::JUMPI
+ };
+ AssemblyItems expectation{
+ AssemblyItem(Tag, 1),
+ Instruction::BALANCE,
+ AssemblyItem(PushTag, 1),
+ Instruction::JUMPI
+ };
+ PeepholeOptimiser peepOpt(items);
+ BOOST_REQUIRE(peepOpt.optimise());
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ items.begin(), items.end(),
+ expectation.begin(), expectation.end()
+ );
+}
+
BOOST_AUTO_TEST_CASE(jumpdest_removal)
{
AssemblyItems items{
diff --git a/test/libjulia/Common.cpp b/test/libjulia/Common.cpp
index 24519b01..a0592667 100644
--- a/test/libjulia/Common.cpp
+++ b/test/libjulia/Common.cpp
@@ -16,7 +16,7 @@
*/
/**
* @date 2017
- * Common functions the iulia tests.
+ * Common functions the Yul tests.
*/
#include <test/libjulia/Common.h>
@@ -52,9 +52,9 @@ void dev::julia::test::printErrors(ErrorList const& _errors, Scanner const& _sca
}
-pair<shared_ptr<Block>, shared_ptr<assembly::AsmAnalysisInfo>> dev::julia::test::parse(string const& _source, bool _julia)
+pair<shared_ptr<Block>, shared_ptr<assembly::AsmAnalysisInfo>> dev::julia::test::parse(string const& _source, bool _yul)
{
- auto flavour = _julia ? assembly::AsmFlavour::IULIA : assembly::AsmFlavour::Strict;
+ auto flavour = _yul ? assembly::AsmFlavour::Yul : assembly::AsmFlavour::Strict;
ErrorList errors;
ErrorReporter errorReporter(errors);
auto scanner = make_shared<Scanner>(CharStream(_source), "");
@@ -83,13 +83,13 @@ pair<shared_ptr<Block>, shared_ptr<assembly::AsmAnalysisInfo>> dev::julia::test:
return {};
}
-assembly::Block dev::julia::test::disambiguate(string const& _source, bool _julia)
+assembly::Block dev::julia::test::disambiguate(string const& _source, bool _yul)
{
- auto result = parse(_source, _julia);
+ auto result = parse(_source, _yul);
return boost::get<Block>(Disambiguator(*result.second)(*result.first));
}
-string dev::julia::test::format(string const& _source, bool _julia)
+string dev::julia::test::format(string const& _source, bool _yul)
{
- return assembly::AsmPrinter(_julia)(*parse(_source, _julia).first);
+ return assembly::AsmPrinter(_yul)(*parse(_source, _yul).first);
}
diff --git a/test/libjulia/Common.h b/test/libjulia/Common.h
index 1371101c..b9c3d2fb 100644
--- a/test/libjulia/Common.h
+++ b/test/libjulia/Common.h
@@ -16,7 +16,7 @@
*/
/**
* @date 2017
- * Common functions the iulia tests.
+ * Common functions the Yul tests.
*/
#pragma once
@@ -46,9 +46,9 @@ namespace test
void printErrors(solidity::ErrorList const& _errors, solidity::Scanner const& _scanner);
std::pair<std::shared_ptr<solidity::assembly::Block>, std::shared_ptr<solidity::assembly::AsmAnalysisInfo>>
-parse(std::string const& _source, bool _julia = true);
-solidity::assembly::Block disambiguate(std::string const& _source, bool _julia = true);
-std::string format(std::string const& _source, bool _julia = true);
+parse(std::string const& _source, bool _yul = true);
+solidity::assembly::Block disambiguate(std::string const& _source, bool _yul = true);
+std::string format(std::string const& _source, bool _yul = true);
}
}
diff --git a/test/libjulia/CommonSubexpression.cpp b/test/libjulia/CommonSubexpression.cpp
index 8a575c48..6c8edf1f 100644
--- a/test/libjulia/CommonSubexpression.cpp
+++ b/test/libjulia/CommonSubexpression.cpp
@@ -47,7 +47,7 @@ do\
}\
while(false)
-BOOST_AUTO_TEST_SUITE(IuliaCSE)
+BOOST_AUTO_TEST_SUITE(YulCSE)
BOOST_AUTO_TEST_CASE(smoke_test)
{
diff --git a/test/libjulia/Disambiguator.cpp b/test/libjulia/Disambiguator.cpp
index a6338449..48e02c7e 100644
--- a/test/libjulia/Disambiguator.cpp
+++ b/test/libjulia/Disambiguator.cpp
@@ -16,7 +16,7 @@
*/
/**
* @date 2017
- * Unit tests for the iulia name disambiguator.
+ * Unit tests for the Yul name disambiguator.
*/
#include <test/libjulia/Common.h>
@@ -39,7 +39,7 @@ do\
}\
while(false)
-BOOST_AUTO_TEST_SUITE(IuliaDisambiguator)
+BOOST_AUTO_TEST_SUITE(YulDisambiguator)
BOOST_AUTO_TEST_CASE(smoke_test)
{
diff --git a/test/libjulia/FunctionGrouper.cpp b/test/libjulia/FunctionGrouper.cpp
index 78f382cb..f1e83449 100644
--- a/test/libjulia/FunctionGrouper.cpp
+++ b/test/libjulia/FunctionGrouper.cpp
@@ -16,7 +16,7 @@
*/
/**
* @date 2017
- * Unit tests for the iulia function grouper.
+ * Unit tests for the Yul function grouper.
*/
#include <test/libjulia/Common.h>
@@ -43,7 +43,7 @@ do\
}\
while(false)
-BOOST_AUTO_TEST_SUITE(IuliaFunctionGrouper)
+BOOST_AUTO_TEST_SUITE(YulFunctionGrouper)
BOOST_AUTO_TEST_CASE(smoke_test)
{
diff --git a/test/libjulia/FunctionHoister.cpp b/test/libjulia/FunctionHoister.cpp
index 3d6fff85..348963b4 100644
--- a/test/libjulia/FunctionHoister.cpp
+++ b/test/libjulia/FunctionHoister.cpp
@@ -16,7 +16,7 @@
*/
/**
* @date 2017
- * Unit tests for the iulia function hoister.
+ * Unit tests for the Yul function hoister.
*/
#include <test/libjulia/Common.h>
@@ -43,7 +43,7 @@ do\
}\
while(false)
-BOOST_AUTO_TEST_SUITE(IuliaFunctionHoister)
+BOOST_AUTO_TEST_SUITE(YulFunctionHoister)
BOOST_AUTO_TEST_CASE(smoke_test)
{
diff --git a/test/libjulia/Inliner.cpp b/test/libjulia/Inliner.cpp
index 464dcd93..2f5b7cff 100644
--- a/test/libjulia/Inliner.cpp
+++ b/test/libjulia/Inliner.cpp
@@ -16,7 +16,7 @@
*/
/**
* @date 2017
- * Unit tests for the iulia function inliner.
+ * Unit tests for the Yul function inliner.
*/
#include <test/libjulia/Common.h>
@@ -55,24 +55,24 @@ string inlinableFunctions(string const& _source)
);
}
-string inlineFunctions(string const& _source, bool _julia = true)
+string inlineFunctions(string const& _source, bool _yul = true)
{
- auto ast = disambiguate(_source, _julia);
+ auto ast = disambiguate(_source, _yul);
ExpressionInliner(ast).run();
- return assembly::AsmPrinter(_julia)(ast);
+ return assembly::AsmPrinter(_yul)(ast);
}
-string fullInline(string const& _source, bool _julia = true)
+string fullInline(string const& _source, bool _yul = true)
{
- Block ast = disambiguate(_source, _julia);
+ Block ast = disambiguate(_source, _yul);
(FunctionHoister{})(ast);
(FunctionGrouper{})(ast);\
FullInliner(ast).run();
- return assembly::AsmPrinter(_julia)(ast);
+ return assembly::AsmPrinter(_yul)(ast);
}
}
-BOOST_AUTO_TEST_SUITE(IuliaInlinableFunctionFilter)
+BOOST_AUTO_TEST_SUITE(YulInlinableFunctionFilter)
BOOST_AUTO_TEST_CASE(smoke_test)
{
@@ -121,7 +121,7 @@ BOOST_AUTO_TEST_CASE(negative)
BOOST_AUTO_TEST_SUITE_END()
-BOOST_AUTO_TEST_SUITE(IuliaFunctionInliner)
+BOOST_AUTO_TEST_SUITE(YulFunctionInliner)
BOOST_AUTO_TEST_CASE(simple)
{
@@ -210,7 +210,7 @@ BOOST_AUTO_TEST_CASE(double_recursive_calls)
BOOST_AUTO_TEST_SUITE_END()
-BOOST_AUTO_TEST_SUITE(IuliaFullInliner)
+BOOST_AUTO_TEST_SUITE(YulFullInliner)
BOOST_AUTO_TEST_CASE(simple)
{
diff --git a/test/libjulia/MainFunction.cpp b/test/libjulia/MainFunction.cpp
index c26b002d..e7263d13 100644
--- a/test/libjulia/MainFunction.cpp
+++ b/test/libjulia/MainFunction.cpp
@@ -16,7 +16,7 @@
*/
/**
* @date 2018
- * Unit tests for the Julia MainFunction transformation.
+ * Unit tests for the Yul MainFunction transformation.
*/
#include <test/libjulia/Common.h>
@@ -45,7 +45,7 @@ do\
}\
while(false)
-BOOST_AUTO_TEST_SUITE(JuliaMainFunction)
+BOOST_AUTO_TEST_SUITE(YulMainFunction)
BOOST_AUTO_TEST_CASE(smoke_test)
{
diff --git a/test/libjulia/Parser.cpp b/test/libjulia/Parser.cpp
index 96261dec..07154718 100644
--- a/test/libjulia/Parser.cpp
+++ b/test/libjulia/Parser.cpp
@@ -16,7 +16,7 @@
*/
/**
* @date 2017
- * Unit tests for parsing Julia.
+ * Unit tests for parsing Yul.
*/
#include <test/Options.h>
@@ -52,7 +52,7 @@ bool parse(string const& _source, ErrorReporter& errorReporter)
try
{
auto scanner = make_shared<Scanner>(CharStream(_source));
- auto parserResult = assembly::Parser(errorReporter, assembly::AsmFlavour::IULIA).parse(scanner, false);
+ auto parserResult = assembly::Parser(errorReporter, assembly::AsmFlavour::Yul).parse(scanner, false);
if (parserResult)
{
assembly::AsmAnalysisInfo analysisInfo;
@@ -61,7 +61,7 @@ bool parse(string const& _source, ErrorReporter& errorReporter)
errorReporter,
dev::test::Options::get().evmVersion(),
boost::none,
- assembly::AsmFlavour::IULIA
+ assembly::AsmFlavour::Yul
)).analyze(*parserResult);
}
}
@@ -119,7 +119,7 @@ do \
BOOST_CHECK(searchErrorMessage(err, (substring))); \
} while(0)
-BOOST_AUTO_TEST_SUITE(JuliaParser)
+BOOST_AUTO_TEST_SUITE(YulParser)
BOOST_AUTO_TEST_CASE(smoke_test)
{
diff --git a/test/libjulia/Rematerialiser.cpp b/test/libjulia/Rematerialiser.cpp
index 8f928f8e..63e525d5 100644
--- a/test/libjulia/Rematerialiser.cpp
+++ b/test/libjulia/Rematerialiser.cpp
@@ -48,7 +48,7 @@ do\
}\
while(false)
-BOOST_AUTO_TEST_SUITE(IuliaRematerialiser)
+BOOST_AUTO_TEST_SUITE(YulRematerialiser)
BOOST_AUTO_TEST_CASE(smoke_test)
{
diff --git a/test/libjulia/Simplifier.cpp b/test/libjulia/Simplifier.cpp
index 4d4e8d53..8ed8287a 100644
--- a/test/libjulia/Simplifier.cpp
+++ b/test/libjulia/Simplifier.cpp
@@ -48,7 +48,7 @@ do\
}\
while(false)
-BOOST_AUTO_TEST_SUITE(IuliaSimplifier)
+BOOST_AUTO_TEST_SUITE(YulSimplifier)
BOOST_AUTO_TEST_CASE(smoke_test)
{
diff --git a/test/libjulia/UnusedPruner.cpp b/test/libjulia/UnusedPruner.cpp
index b86a54b3..649ee149 100644
--- a/test/libjulia/UnusedPruner.cpp
+++ b/test/libjulia/UnusedPruner.cpp
@@ -48,7 +48,7 @@ do\
}\
while(false)
-BOOST_AUTO_TEST_SUITE(IuliaUnusedPruner)
+BOOST_AUTO_TEST_SUITE(YulUnusedPruner)
BOOST_AUTO_TEST_CASE(smoke_test)
{
diff --git a/test/libsolidity/ABIDecoderTests.cpp b/test/libsolidity/ABIDecoderTests.cpp
index beb7b5af..b588ca1b 100644
--- a/test/libsolidity/ABIDecoderTests.cpp
+++ b/test/libsolidity/ABIDecoderTests.cpp
@@ -579,7 +579,7 @@ BOOST_AUTO_TEST_CASE(struct_simple)
a = s.a;
b = s.b;
c = s.c;
- d = uint(s.d);
+ d = uint16(s.d);
}
}
)";
@@ -659,26 +659,6 @@ BOOST_AUTO_TEST_CASE(struct_function)
)
}
-BOOST_AUTO_TEST_CASE(empty_struct)
-{
- string sourceCode = R"(
- contract C {
- struct S { }
- function f(uint a, S s, uint b) public pure returns (uint x, uint y) {
- assembly { x := a y := b }
- }
- function g() public returns (uint, uint) {
- return this.f(7, S(), 8);
- }
- }
- )";
- NEW_ENCODER(
- compileAndRun(sourceCode, 0, "C");
- ABI_CHECK(callContractFunction("f(uint256,(),uint256)", 7, 8), encodeArgs(7, 8));
- ABI_CHECK(callContractFunction("g()"), encodeArgs(7, 8));
- )
-}
-
BOOST_AUTO_TEST_CASE(mediocre_struct)
{
string sourceCode = R"(
diff --git a/test/libsolidity/ABIEncoderTests.cpp b/test/libsolidity/ABIEncoderTests.cpp
index 49db9ce1..9b6250d8 100644
--- a/test/libsolidity/ABIEncoderTests.cpp
+++ b/test/libsolidity/ABIEncoderTests.cpp
@@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(value_types)
assembly { b := 7 }
C c;
assembly { c := sub(0, 5) }
- E(10, uint16(uint256(-2)), uint24(0x12121212), int24(int256(-1)), bytes3(x), b, c);
+ emit E(10, uint16(uint256(-2)), uint24(0x12121212), int24(int256(-1)), bytes3(x), b, c);
}
}
)";
@@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE(string_literal)
contract C {
event E(string, bytes20, string);
function f() public {
- E("abcdef", "abcde", "abcdefabcdefgehabcabcasdfjklabcdefabcedefghabcabcasdfjklabcdefabcdefghabcabcasdfjklabcdeefabcdefghabcabcasdefjklabcdefabcdefghabcabcasdfjkl");
+ emit E("abcdef", "abcde", "abcdefabcdefgehabcabcasdfjklabcdefabcedefghabcabcasdfjklabcdefabcdefghabcabcasdfjklabcdeefabcdefghabcabcasdefjklabcdefabcdefghabcabcasdfjkl");
}
}
)";
@@ -133,7 +133,7 @@ BOOST_AUTO_TEST_CASE(conversion)
int8 c;
int16 d;
assembly { a := sub(0, 1) c := 0x0101ff d := 0xff01 }
- E(10, x, a, uint8(b), c, int8(d));
+ emit E(10, x, a, uint8(b), c, int8(d));
}
}
)";
@@ -159,7 +159,7 @@ BOOST_AUTO_TEST_CASE(memory_array_one_dim)
mstore(add(x, mul(add(i, 1), 0x20)), add(0xfffffffe, i))
}
}
- E(10, x, 11);
+ emit E(10, x, 11);
}
}
)";
@@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE(memory_array_two_dim)
x[0][2] = -1;
x[1][0] = 4;
x[1][1] = 5;
- E(10, x, 11);
+ emit E(10, x, 11);
}
}
)";
@@ -208,7 +208,7 @@ BOOST_AUTO_TEST_CASE(memory_byte_array)
bytes[] memory x = new bytes[](2);
x[0] = "abcabcdefghjklmnopqrsuvwabcdefgijklmnopqrstuwabcdefgijklmnoprstuvw";
x[1] = "abcdefghijklmnopqrtuvwabcfghijklmnopqstuvwabcdeghijklmopqrstuvw";
- E(10, x, 11);
+ emit E(10, x, 11);
}
}
)";
@@ -234,7 +234,7 @@ BOOST_AUTO_TEST_CASE(storage_byte_array)
function f() public {
short = "123456789012345678901234567890a";
long = "ffff123456789012345678901234567890afffffffff123456789012345678901234567890a";
- E(short, long);
+ emit E(short, long);
}
}
)";
@@ -261,7 +261,7 @@ BOOST_AUTO_TEST_CASE(storage_array)
sstore(1, sub(0, 2))
sstore(2, sub(0, 3))
}
- E(addr);
+ emit E(addr);
}
}
)";
@@ -279,10 +279,10 @@ BOOST_AUTO_TEST_CASE(storage_array_dyn)
address[] addr;
event E(address[] a);
function f() public {
- addr.push(1);
- addr.push(2);
- addr.push(3);
- E(addr);
+ addr.push(0x0000000000000000000000000000000000000001);
+ addr.push(0x0000000000000000000000000000000000000002);
+ addr.push(0x0000000000000000000000000000000000000003);
+ emit E(addr);
}
}
)";
@@ -308,7 +308,7 @@ BOOST_AUTO_TEST_CASE(storage_array_compact)
x.push(6);
x.push(-7);
x.push(8);
- E(x);
+ emit E(x);
}
}
)";
@@ -329,7 +329,7 @@ BOOST_AUTO_TEST_CASE(external_function)
function(uint) external returns (uint) g;
function f(uint) public returns (uint) {
g = this.f;
- E(this.f, g);
+ emit E(this.f, g);
}
}
)";
@@ -351,7 +351,7 @@ BOOST_AUTO_TEST_CASE(external_function_cleanup)
function f(uint) public returns (uint) {
function(uint) external returns (uint)[1] memory h;
assembly { sstore(0, sub(0, 1)) mstore(h, sub(0, 1)) }
- E(h[0], g);
+ emit E(h[0], g);
}
}
)";
@@ -368,21 +368,18 @@ BOOST_AUTO_TEST_CASE(calldata)
contract C {
event E(bytes);
function f(bytes a) external {
- E(a);
+ emit E(a);
}
}
)";
string s("abcdef");
string t("abcdefgggggggggggggggggggggggggggggggggggggggghhheeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeggg");
- bool newEncoder = false;
BOTH_ENCODERS(
compileAndRun(sourceCode);
callContractFunction("f(bytes)", 0x20, s.size(), s);
- // The old encoder did not pad to multiples of 32 bytes
- REQUIRE_LOG_DATA(encodeArgs(0x20, s.size()) + (newEncoder ? encodeArgs(s) : asBytes(s)));
+ REQUIRE_LOG_DATA(encodeArgs(0x20, s.size(), s));
callContractFunction("f(bytes)", 0x20, t.size(), t);
- REQUIRE_LOG_DATA(encodeArgs(0x20, t.size()) + (newEncoder ? encodeArgs(t) : asBytes(t)));
- newEncoder = true;
+ REQUIRE_LOG_DATA(encodeArgs(0x20, t.size(), t));
)
}
@@ -429,7 +426,7 @@ BOOST_AUTO_TEST_CASE(structs)
s.sub[0].x[0] = 11;
s.sub[1].x[0] = 12;
s.sub[2].x[1] = 13;
- e(x, s);
+ emit e(x, s);
return (x, s);
}
}
@@ -450,28 +447,6 @@ BOOST_AUTO_TEST_CASE(structs)
)
}
-BOOST_AUTO_TEST_CASE(empty_struct)
-{
- string sourceCode = R"(
- contract C {
- struct S { }
- S s;
- event e(uint16, S, uint16);
- function f() returns (uint, S, uint) {
- e(7, s, 8);
- return (7, s, 8);
- }
- }
- )";
-
- NEW_ENCODER(
- compileAndRun(sourceCode, 0, "C");
- bytes encoded = encodeArgs(7, 8);
- BOOST_CHECK(callContractFunction("f()") == encoded);
- REQUIRE_LOG_DATA(encoded);
- )
-}
-
BOOST_AUTO_TEST_CASE(structs2)
{
string sourceCode = R"(
diff --git a/test/libsolidity/InlineAssembly.cpp b/test/libsolidity/InlineAssembly.cpp
index 181ca959..3046372f 100644
--- a/test/libsolidity/InlineAssembly.cpp
+++ b/test/libsolidity/InlineAssembly.cpp
@@ -178,9 +178,9 @@ BOOST_AUTO_TEST_CASE(simple_instructions)
BOOST_CHECK(successParse("{ dup1 dup1 mul dup1 sub pop }"));
}
-BOOST_AUTO_TEST_CASE(suicide_selfdestruct)
+BOOST_AUTO_TEST_CASE(selfdestruct)
{
- BOOST_CHECK(successParse("{ 0x01 suicide 0x02 selfdestruct }"));
+ BOOST_CHECK(successParse("{ 0x02 selfdestruct }"));
}
BOOST_AUTO_TEST_CASE(keywords)
@@ -740,8 +740,6 @@ BOOST_AUTO_TEST_CASE(keccak256)
{
BOOST_CHECK(successAssemble("{ 0 0 keccak256 pop }"));
BOOST_CHECK(successAssemble("{ pop(keccak256(0, 0)) }"));
- BOOST_CHECK(successAssemble("{ 0 0 sha3 pop }"));
- BOOST_CHECK(successAssemble("{ pop(sha3(0, 0)) }"));
}
BOOST_AUTO_TEST_CASE(returndatasize)
diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp
index 71fdb906..57f414db 100644
--- a/test/libsolidity/SMTChecker.cpp
+++ b/test/libsolidity/SMTChecker.cpp
@@ -133,22 +133,6 @@ BOOST_AUTO_TEST_CASE(assignment_in_declaration)
CHECK_SUCCESS_NO_WARNINGS(text);
}
-BOOST_AUTO_TEST_CASE(use_before_declaration)
-{
- string text = R"(
- contract C {
- function f() public pure { a = 3; uint a = 2; assert(a == 2); }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
- text = R"(
- contract C {
- function f() public pure { assert(a == 0); uint a = 2; assert(a == 2); }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
BOOST_AUTO_TEST_CASE(function_call_does_not_clear_local_vars)
{
string text = R"(
@@ -388,35 +372,6 @@ BOOST_AUTO_TEST_CASE(bool_simple)
}
)";
CHECK_SUCCESS_NO_WARNINGS(text);
- text = R"(
- contract C {
- function f(bool x) public pure {
- bool y;
- assert(x <= y);
- }
- }
- )";
- CHECK_WARNING(text, "Assertion violation happens here");
- text = R"(
- contract C {
- function f(bool x) public pure {
- bool y;
- assert(x >= y);
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
- text = R"(
- contract C {
- function f(bool x) public pure {
- require(x);
- bool y;
- assert(x > y);
- assert(y < x);
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
}
BOOST_AUTO_TEST_CASE(bool_int_mixed)
@@ -478,15 +433,15 @@ BOOST_AUTO_TEST_CASE(storage_value_vars)
function f(uint x) public {
if (x == 0)
{
- a = 100;
+ a = 0x0000000000000000000000000000000000000100;
b = true;
}
else
{
- a = 200;
+ a = 0x0000000000000000000000000000000000000200;
b = false;
}
- assert(a > 0 && b);
+ assert(a > 0x0000000000000000000000000000000000000000 && b);
}
}
)";
@@ -509,19 +464,19 @@ BOOST_AUTO_TEST_CASE(storage_value_vars)
function f(uint x) public {
if (x == 0)
{
- a = 100;
+ a = 0x0000000000000000000000000000000000000100;
b = true;
}
else
{
- a = 200;
+ a = 0x0000000000000000000000000000000000000200;
b = false;
}
- assert(b == (a < 200));
+ assert(b == (a < 0x0000000000000000000000000000000000000200));
}
function g() public view {
- require(a < 100);
+ require(a < 0x0000000000000000000000000000000000000100);
assert(c >= 0);
}
address a;
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 1efcfde0..65a0a216 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -177,7 +177,8 @@ BOOST_AUTO_TEST_CASE(conditional_expression_with_return_values)
function f(bool cond, uint v) returns (uint a, uint b) {
cond ? a = v : b = v;
}
- })";
+ }
+ )";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("f(bool,uint256)", true, u256(20)), encodeArgs(u256(20), u256(0)));
ABI_CHECK(callContractFunction("f(bool,uint256)", false, u256(20)), encodeArgs(u256(0), u256(20)));
@@ -482,6 +483,27 @@ BOOST_AUTO_TEST_CASE(do_while_loop)
testContractAgainstCppOnRange("f(uint256)", do_while_loop_cpp, 0, 5);
}
+BOOST_AUTO_TEST_CASE(do_while_loop_continue)
+{
+ char const* sourceCode = R"(
+ contract test {
+ function f() public pure returns(uint r) {
+ uint i = 0;
+ do
+ {
+ if (i > 0) return 0;
+ i++;
+ continue;
+ } while (false);
+ return 42;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(42));
+}
+
BOOST_AUTO_TEST_CASE(nested_loops)
{
// tests that break and continue statements in nested loops jump to the correct place
@@ -1249,7 +1271,6 @@ BOOST_AUTO_TEST_CASE(deleteStruct)
contract test {
struct topStruct {
nestedStruct nstr;
- emptyStruct empty;
uint topValue;
mapping (uint => uint) topMapping;
}
@@ -1259,8 +1280,6 @@ BOOST_AUTO_TEST_CASE(deleteStruct)
uint nestedValue;
mapping (uint => bool) nestedMapping;
}
- struct emptyStruct{
- }
function test(){
toDelete = 5;
str.topValue = 1;
@@ -1667,7 +1686,7 @@ BOOST_AUTO_TEST_CASE(convert_fixed_bytes_to_uint_smaller_size)
char const* sourceCode = R"(
contract Test {
function bytesToUint(bytes4 s) returns (uint16 h) {
- return uint16(s);
+ return uint16(uint32(s));
}
}
)";
@@ -1683,7 +1702,7 @@ BOOST_AUTO_TEST_CASE(convert_fixed_bytes_to_uint_greater_size)
char const* sourceCode = R"(
contract Test {
function bytesToUint(bytes4 s) returns (uint64 h) {
- return uint64(s);
+ return uint64(uint32(s));
}
}
)";
@@ -1730,7 +1749,7 @@ BOOST_AUTO_TEST_CASE(convert_uint_to_fixed_bytes_smaller_size)
char const* sourceCode = R"(
contract Test {
function uintToBytes(uint32 h) returns (bytes2 s) {
- return bytes2(h);
+ return bytes2(uint16(h));
}
}
)";
@@ -1746,7 +1765,7 @@ BOOST_AUTO_TEST_CASE(convert_uint_to_fixed_bytes_greater_size)
char const* sourceCode = R"(
contract Test {
function UintToBytes(uint16 h) returns (bytes8 s) {
- return bytes8(h);
+ return bytes8(uint64(h));
}
}
)";
@@ -1949,25 +1968,6 @@ BOOST_AUTO_TEST_CASE(log_in_constructor)
BOOST_CHECK_EQUAL(m_logs[0].topics[0], h256(u256(2)));
}
-BOOST_AUTO_TEST_CASE(suicide)
-{
- char const* sourceCode = R"(
- contract test {
- function test() payable {}
- function a(address receiver) returns (uint ret) {
- suicide(receiver);
- return 10;
- }
- }
- )";
- u256 amount(130);
- compileAndRun(sourceCode, amount);
- u160 address(23);
- ABI_CHECK(callContractFunction("a(address)", address), bytes());
- BOOST_CHECK(!addressHasCode(m_contractAddress));
- BOOST_CHECK_EQUAL(balanceAt(address), amount);
-}
-
BOOST_AUTO_TEST_CASE(selfdestruct)
{
char const* sourceCode = R"(
@@ -2006,23 +2006,6 @@ BOOST_AUTO_TEST_CASE(keccak256)
testContractAgainstCpp("a(bytes32)", f, u256(-1));
}
-BOOST_AUTO_TEST_CASE(sha3)
-{
- char const* sourceCode = R"(
- contract test {
- // to confuse the optimiser
- function b(bytes32 input) returns (bytes32) {
- return sha3(input);
- }
- function a(bytes32 input) returns (bool) {
- return keccak256(input) == b(input);
- }
- }
- )";
- compileAndRun(sourceCode);
- BOOST_REQUIRE(callContractFunction("a(bytes32)", u256(42)) == encodeArgs(true));
-}
-
BOOST_AUTO_TEST_CASE(sha256)
{
char const* sourceCode = R"(
@@ -2216,7 +2199,8 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls)
function setHelper(address haddress) {
h = Helper(haddress);
}
- })";
+ }
+ )";
compileAndRun(sourceCode, 0, "Helper");
u160 const c_helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main");
@@ -2246,7 +2230,8 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_with_complex_parameters)
function setHelper(address haddress) {
h = Helper(haddress);
}
- })";
+ }
+ )";
compileAndRun(sourceCode, 0, "Helper");
u160 const c_helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main");
@@ -2277,7 +2262,8 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_accessing_this)
function setHelper(address addr) {
h = Helper(addr);
}
- })";
+ }
+ )";
compileAndRun(sourceCode, 0, "Helper");
u160 const c_helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main");
@@ -2308,7 +2294,8 @@ BOOST_AUTO_TEST_CASE(calls_to_this)
function setHelper(address addr) {
h = Helper(addr);
}
- })";
+ }
+ )";
compileAndRun(sourceCode, 0, "Helper");
u160 const c_helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main");
@@ -2343,7 +2330,8 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_with_local_vars)
function setHelper(address haddress) {
h = Helper(haddress);
}
- })";
+ }
+ )";
compileAndRun(sourceCode, 0, "Helper");
u160 const c_helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main");
@@ -2373,7 +2361,8 @@ BOOST_AUTO_TEST_CASE(fixed_bytes_in_calls)
function setHelper(address addr) {
h = Helper(addr);
}
- })";
+ }
+ )";
compileAndRun(sourceCode, 0, "Helper");
u160 const c_helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main");
@@ -2403,7 +2392,8 @@ BOOST_AUTO_TEST_CASE(constructor_arguments_internal)
}
function getFlag() returns (bool ret) { return h.getFlag(); }
function getName() returns (bytes3 ret) { return h.getName(); }
- })";
+ }
+ )";
compileAndRun(sourceCode, 0, "Main");
ABI_CHECK(callContractFunction("getFlag()"), encodeArgs(true));
ABI_CHECK(callContractFunction("getName()"), encodeArgs("abc"));
@@ -2506,7 +2496,8 @@ BOOST_AUTO_TEST_CASE(functions_called_by_constructor)
}
function getName() returns (bytes3 ret) { return name; }
function setName(bytes3 _name) private { name = _name; }
- })";
+ }
+ )";
compileAndRun(sourceCode);
BOOST_REQUIRE(callContractFunction("getName()") == encodeArgs("abc"));
}
@@ -2632,7 +2623,8 @@ BOOST_AUTO_TEST_CASE(value_for_constructor)
function getFlag() returns (bool ret) { return h.getFlag(); }
function getName() returns (bytes3 ret) { return h.getName(); }
function getBalances() returns (uint me, uint them) { me = this.balance; them = h.balance;}
- })";
+ }
+ )";
compileAndRun(sourceCode, 22, "Main");
BOOST_REQUIRE(callContractFunction("getFlag()") == encodeArgs(true));
BOOST_REQUIRE(callContractFunction("getName()") == encodeArgs("abc"));
@@ -3128,9 +3120,9 @@ BOOST_AUTO_TEST_CASE(event)
function deposit(bytes32 _id, bool _manually) payable {
if (_manually) {
bytes32 s = 0x19dacbf83c5de6658e14cbf7bcae5c15eca2eedecf1c66fbca928e4d351bea0f;
- log3(bytes32(msg.value), s, bytes32(msg.sender), _id);
+ log3(bytes32(msg.value), s, bytes32(uint256(msg.sender)), _id);
} else {
- Deposit(msg.sender, _id, msg.value);
+ emit Deposit(msg.sender, _id, msg.value);
}
}
}
@@ -3180,7 +3172,7 @@ BOOST_AUTO_TEST_CASE(event_no_arguments)
contract ClientReceipt {
event Deposit();
function deposit() {
- Deposit();
+ emit Deposit();
}
}
)";
@@ -3194,28 +3186,6 @@ BOOST_AUTO_TEST_CASE(event_no_arguments)
BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit()")));
}
-BOOST_AUTO_TEST_CASE(event_access_through_base_name)
-{
- char const* sourceCode = R"(
- contract A {
- event x();
- }
- contract B is A {
- function f() returns (uint) {
- A.x();
- return 1;
- }
- }
- )";
- compileAndRun(sourceCode);
- callContractFunction("f()");
- BOOST_REQUIRE_EQUAL(m_logs.size(), 1);
- BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
- BOOST_CHECK(m_logs[0].data.empty());
- BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
- BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("x()")));
-}
-
BOOST_AUTO_TEST_CASE(event_access_through_base_name_emit)
{
char const* sourceCode = R"(
@@ -3246,67 +3216,15 @@ BOOST_AUTO_TEST_CASE(events_with_same_name)
event Deposit(address _addr);
event Deposit(address _addr, uint _amount);
function deposit() returns (uint) {
- Deposit();
- return 1;
- }
- function deposit(address _addr) returns (uint) {
- Deposit(_addr);
- return 1;
- }
- function deposit(address _addr, uint _amount) returns (uint) {
- Deposit(_addr, _amount);
- return 1;
- }
- }
- )";
- u160 const c_loggedAddress = m_contractAddress;
-
- compileAndRun(sourceCode);
- ABI_CHECK(callContractFunction("deposit()"), encodeArgs(u256(1)));
- BOOST_REQUIRE_EQUAL(m_logs.size(), 1);
- BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
- BOOST_CHECK(m_logs[0].data.empty());
- BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
- BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit()")));
-
- ABI_CHECK(callContractFunction("deposit(address)", c_loggedAddress), encodeArgs(u256(1)));
- BOOST_REQUIRE_EQUAL(m_logs.size(), 1);
- BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
- BOOST_CHECK(m_logs[0].data == encodeArgs(c_loggedAddress));
- BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
- BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit(address)")));
-
- ABI_CHECK(callContractFunction("deposit(address,uint256)", c_loggedAddress, u256(100)), encodeArgs(u256(1)));
- BOOST_REQUIRE_EQUAL(m_logs.size(), 1);
- BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
- BOOST_CHECK(m_logs[0].data == encodeArgs(c_loggedAddress, 100));
- BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
- BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit(address,uint256)")));
-}
-
-BOOST_AUTO_TEST_CASE(events_with_same_name_inherited)
-{
- char const* sourceCode = R"(
- contract A {
- event Deposit();
- }
-
- contract B {
- event Deposit(address _addr);
- }
-
- contract ClientReceipt is A, B {
- event Deposit(address _addr, uint _amount);
- function deposit() returns (uint) {
- Deposit();
+ emit Deposit();
return 1;
}
function deposit(address _addr) returns (uint) {
- Deposit(_addr);
+ emit Deposit(_addr);
return 1;
}
function deposit(address _addr, uint _amount) returns (uint) {
- Deposit(_addr, _amount);
+ emit Deposit(_addr, _amount);
return 1;
}
}
@@ -3394,7 +3312,7 @@ BOOST_AUTO_TEST_CASE(event_anonymous)
contract ClientReceipt {
event Deposit() anonymous;
function deposit() {
- Deposit();
+ emit Deposit();
}
}
)";
@@ -3409,7 +3327,7 @@ BOOST_AUTO_TEST_CASE(event_anonymous_with_topics)
contract ClientReceipt {
event Deposit(address indexed _from, bytes32 indexed _id, uint indexed _value, uint indexed _value2, bytes32 data) anonymous;
function deposit(bytes32 _id) payable {
- Deposit(msg.sender, _id, msg.value, 2, "abc");
+ emit Deposit(msg.sender, _id, msg.value, 2, "abc");
}
}
)";
@@ -3433,7 +3351,7 @@ BOOST_AUTO_TEST_CASE(event_lots_of_data)
contract ClientReceipt {
event Deposit(address _from, bytes32 _id, uint _value, bool _flag);
function deposit(bytes32 _id) payable {
- Deposit(msg.sender, _id, msg.value, true);
+ emit Deposit(msg.sender, _id, msg.value, true);
}
}
)";
@@ -3454,7 +3372,7 @@ BOOST_AUTO_TEST_CASE(event_really_lots_of_data)
contract ClientReceipt {
event Deposit(uint fixeda, bytes dynx, uint fixedb);
function deposit() {
- Deposit(10, msg.data, 15);
+ emit Deposit(10, msg.data, 15);
}
}
)";
@@ -3462,7 +3380,7 @@ BOOST_AUTO_TEST_CASE(event_really_lots_of_data)
callContractFunction("deposit()");
BOOST_REQUIRE_EQUAL(m_logs.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
- BOOST_CHECK_EQUAL(toHex(m_logs[0].data), toHex(encodeArgs(10, 0x60, 15, 4) + FixedHash<4>(dev::keccak256("deposit()")).asBytes()));
+ BOOST_CHECK_EQUAL(toHex(m_logs[0].data), toHex(encodeArgs(10, 0x60, 15, 4, asString(FixedHash<4>(dev::keccak256("deposit()")).asBytes()))));
BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit(uint256,bytes,uint256)")));
}
@@ -3478,7 +3396,7 @@ BOOST_AUTO_TEST_CASE(event_really_lots_of_data_from_storage)
x[0] = "A";
x[1] = "B";
x[2] = "C";
- Deposit(10, x, 15);
+ emit Deposit(10, x, 15);
}
}
)";
@@ -3503,7 +3421,7 @@ BOOST_AUTO_TEST_CASE(event_really_really_lots_of_data_from_storage)
x[1] = "B";
x[2] = "C";
x[30] = "Z";
- Deposit(10, x, 15);
+ emit Deposit(10, x, 15);
}
}
)";
@@ -3525,13 +3443,13 @@ BOOST_AUTO_TEST_CASE(event_indexed_string)
event E(string indexed r, uint[4] indexed t);
function deposit() {
bytes(x).length = 90;
- for (uint i = 0; i < 90; i++)
+ for (uint8 i = 0; i < 90; i++)
bytes(x)[i] = byte(i);
y[0] = 4;
y[1] = 5;
y[2] = 6;
y[3] = 7;
- E(x, y);
+ emit E(x, y);
}
}
)";
@@ -3729,26 +3647,6 @@ BOOST_AUTO_TEST_CASE(iterated_keccak256_with_bytes)
));
}
-BOOST_AUTO_TEST_CASE(sha3_multiple_arguments)
-{
- char const* sourceCode = R"(
- contract c {
- function foo(uint a, uint b, uint c) returns (bytes32 d)
- {
- d = sha3(a, b, c);
- }
- })";
- compileAndRun(sourceCode);
-
- ABI_CHECK(callContractFunction("foo(uint256,uint256,uint256)", 10, 12, 13), encodeArgs(
- dev::keccak256(
- toBigEndian(u256(10)) +
- toBigEndian(u256(12)) +
- toBigEndian(u256(13))
- )
- ));
-}
-
BOOST_AUTO_TEST_CASE(generic_call)
{
char const* sourceCode = R"**(
@@ -3773,38 +3671,6 @@ BOOST_AUTO_TEST_CASE(generic_call)
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 50 - 2);
}
-BOOST_AUTO_TEST_CASE(generic_callcode)
-{
- char const* sourceCode = R"**(
- contract Receiver {
- uint public received;
- function receive(uint256 x) payable { received = x; }
- }
- contract Sender {
- uint public received;
- function Sender() payable { }
- function doSend(address rec) returns (uint d)
- {
- bytes4 signature = bytes4(bytes32(keccak256("receive(uint256)")));
- rec.callcode.value(2)(signature, 23);
- return Receiver(rec).received();
- }
- }
- )**";
- compileAndRun(sourceCode, 0, "Receiver");
- u160 const c_receiverAddress = m_contractAddress;
- compileAndRun(sourceCode, 50, "Sender");
- u160 const c_senderAddress = m_contractAddress;
- ABI_CHECK(callContractFunction("doSend(address)", c_receiverAddress), encodeArgs(0));
- ABI_CHECK(callContractFunction("received()"), encodeArgs(23));
- m_contractAddress = c_receiverAddress;
- ABI_CHECK(callContractFunction("received()"), encodeArgs(0));
- BOOST_CHECK(storageEmpty(c_receiverAddress));
- BOOST_CHECK(!storageEmpty(c_senderAddress));
- BOOST_CHECK_EQUAL(balanceAt(c_receiverAddress), 0);
- BOOST_CHECK_EQUAL(balanceAt(c_senderAddress), 50);
-}
-
BOOST_AUTO_TEST_CASE(generic_delegatecall)
{
char const* sourceCode = R"**(
@@ -3989,7 +3855,8 @@ BOOST_AUTO_TEST_CASE(call_forward_bytes_length)
compileAndRun(sourceCode, 0, "sender");
// No additional data, just function selector
- ABI_CHECK(callContractFunction("viaCalldata()"), encodeArgs(4));
+ ABI_CHECK(callContractFunction("viaCalldata()"), encodeArgs(0x20));
+ // Should be this with 0.5.0: encodeArgs(4));
ABI_CHECK(callContractFunction("viaMemory()"), encodeArgs(0x20));
// Should be this with 0.5.0: encodeArgs(4));
ABI_CHECK(callContractFunction("viaStorage()"), encodeArgs(0x20));
@@ -3997,7 +3864,8 @@ BOOST_AUTO_TEST_CASE(call_forward_bytes_length)
// Some additional unpadded data
bytes unpadded = asBytes(string("abc"));
- ABI_CHECK(callContractFunctionNoEncoding("viaCalldata()", unpadded), encodeArgs(7));
+ ABI_CHECK(callContractFunctionNoEncoding("viaCalldata()", unpadded), encodeArgs(0x20));
+ // Should be this with 0.5.0: encodeArgs(7));
ABI_CHECK(callContractFunctionNoEncoding("viaMemory()", unpadded), encodeArgs(0x20));
// Should be this with 0.5.0: encodeArgs(7));
ABI_CHECK(callContractFunctionNoEncoding("viaStorage()", unpadded), encodeArgs(0x20));
@@ -4304,7 +4172,7 @@ BOOST_AUTO_TEST_CASE(storing_invalid_boolean)
assembly {
tmp := 5
}
- Ev(tmp);
+ emit Ev(tmp);
return 1;
}
}
@@ -4404,7 +4272,8 @@ BOOST_AUTO_TEST_CASE(inline_member_init)
b = m_b;
c = m_c;
}
- })";
+ }
+ )";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("get()"), encodeArgs(5, 6, 8));
}
@@ -4421,7 +4290,8 @@ BOOST_AUTO_TEST_CASE(inline_member_init_inheritence)
function Derived(){}
uint m_derived = 6;
function getDMember() returns (uint i) { return m_derived; }
- })";
+ }
+ )";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("getBMember()"), encodeArgs(5));
ABI_CHECK(callContractFunction("getDMember()"), encodeArgs(6));
@@ -4437,7 +4307,8 @@ BOOST_AUTO_TEST_CASE(inline_member_init_inheritence_without_constructor)
contract Derived is Base {
uint m_derived = 6;
function getDMember() returns (uint i) { return m_derived; }
- })";
+ }
+ )";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("getBMember()"), encodeArgs(5));
ABI_CHECK(callContractFunction("getDMember()"), encodeArgs(6));
@@ -4753,7 +4624,7 @@ BOOST_AUTO_TEST_CASE(array_copy_different_packing)
function test() returns (bytes10 a, bytes10 b, bytes10 c, bytes10 d, bytes10 e) {
data1.length = 9;
for (uint i = 0; i < data1.length; ++i)
- data1[i] = bytes8(i);
+ data1[i] = bytes8(uint64(i));
data2 = data1;
a = data2[1];
b = data2[2];
@@ -4781,7 +4652,7 @@ BOOST_AUTO_TEST_CASE(array_copy_target_simple)
bytes17[10] data2; // 1 per slot, no offset counter
function test() returns (bytes17 a, bytes17 b, bytes17 c, bytes17 d, bytes17 e) {
for (uint i = 0; i < data1.length; ++i)
- data1[i] = bytes8(i);
+ data1[i] = bytes8(uint64(i));
data2[8] = data2[9] = 2;
data2 = data1;
a = data2[1];
@@ -4813,14 +4684,14 @@ BOOST_AUTO_TEST_CASE(array_copy_target_leftover)
uint i;
for (i = 0; i < data2.length; ++i)
data2[i] = 0xffff;
- check = uint(data2[31]) * 0x10000 | uint(data2[14]);
+ check = uint(uint16(data2[31])) * 0x10000 | uint(uint16(data2[14]));
for (i = 0; i < data1.length; ++i)
data1[i] = byte(uint8(1 + i));
data2 = data1;
for (i = 0; i < 16; ++i)
- res1 |= uint(data2[i]) * 0x10000**i;
+ res1 |= uint(uint16(data2[i])) * 0x10000**i;
for (i = 0; i < 16; ++i)
- res2 |= uint(data2[16 + i]) * 0x10000**i;
+ res2 |= uint(uint16(data2[16 + i])) * 0x10000**i;
}
}
)";
@@ -4846,7 +4717,7 @@ BOOST_AUTO_TEST_CASE(array_copy_target_leftover2)
data1[2] = 3;
data1[3] = 4;
for (uint i = 0; i < data2.length; ++i)
- data2[i] = bytes10(0xffff00 | (1 + i));
+ data2[i] = bytes10(uint80(0xffff00 | (1 + i)));
data2 = data1;
r1 = data2[3];
r2 = data2[4];
@@ -5060,13 +4931,13 @@ BOOST_AUTO_TEST_CASE(byte_array_push_transition)
contract c {
bytes data;
function test() returns (uint) {
- for (uint i = 1; i < 40; i++)
+ for (uint8 i = 1; i < 40; i++)
{
data.push(byte(i));
if (data.length != i) return 0x1000 + i;
if (data[data.length - 1] != byte(i)) return i;
}
- for (i = 1; i < 40; i++)
+ for (uint8 i = 1; i < 40; i++)
if (data[i - 1] != byte(i)) return 0x1000000 + i;
return 0;
}
@@ -5076,6 +4947,326 @@ BOOST_AUTO_TEST_CASE(byte_array_push_transition)
ABI_CHECK(callContractFunction("test()"), encodeArgs(0));
}
+BOOST_AUTO_TEST_CASE(array_pop)
+{
+ char const* sourceCode = R"(
+ contract c {
+ uint[] data;
+ function test() public returns (uint x, uint l) {
+ data.push(7);
+ x = data.push(3);
+ data.pop();
+ x = data.length;
+ data.pop();
+ l = data.length;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ ABI_CHECK(callContractFunction("test()"), encodeArgs(1, 0));
+}
+
+BOOST_AUTO_TEST_CASE(array_pop_uint16_transition)
+{
+ char const* sourceCode = R"(
+ contract c {
+ uint16[] data;
+ function test() public returns (uint16 x, uint16 y, uint16 z) {
+ for (uint i = 1; i <= 48; i++)
+ data.push(uint16(i));
+ for (uint j = 1; j <= 10; j++)
+ data.pop();
+ x = data[data.length - 1];
+ for (uint k = 1; k <= 10; k++)
+ data.pop();
+ y = data[data.length - 1];
+ for (uint l = 1; l <= 10; l++)
+ data.pop();
+ z = data[data.length - 1];
+ for (uint m = 1; m <= 18; m++)
+ data.pop();
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ ABI_CHECK(callContractFunction("test()"), encodeArgs(38, 28, 18));
+ BOOST_CHECK(storageEmpty(m_contractAddress));
+}
+
+BOOST_AUTO_TEST_CASE(array_pop_uint24_transition)
+{
+ char const* sourceCode = R"(
+ contract c {
+ uint256 a;
+ uint256 b;
+ uint256 c;
+ uint24[] data;
+ function test() public returns (uint24 x, uint24 y) {
+ for (uint i = 1; i <= 30; i++)
+ data.push(uint24(i));
+ for (uint j = 1; j <= 10; j++)
+ data.pop();
+ x = data[data.length - 1];
+ for (uint k = 1; k <= 10; k++)
+ data.pop();
+ y = data[data.length - 1];
+ for (uint l = 1; l <= 10; l++)
+ data.pop();
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ ABI_CHECK(callContractFunction("test()"), encodeArgs(20, 10));
+ BOOST_CHECK(storageEmpty(m_contractAddress));
+}
+
+BOOST_AUTO_TEST_CASE(array_pop_array_transition)
+{
+ char const* sourceCode = R"(
+ contract c {
+ uint256 a;
+ uint256 b;
+ uint256 c;
+ uint16[] inner = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
+ uint16[][] data;
+ function test() public returns (uint x, uint y, uint z) {
+ for (uint i = 1; i <= 48; i++)
+ data.push(inner);
+ for (uint j = 1; j <= 10; j++)
+ data.pop();
+ x = data[data.length - 1][0];
+ for (uint k = 1; k <= 10; k++)
+ data.pop();
+ y = data[data.length - 1][1];
+ for (uint l = 1; l <= 10; l++)
+ data.pop();
+ z = data[data.length - 1][2];
+ for (uint m = 1; m <= 18; m++)
+ data.pop();
+ delete inner;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ ABI_CHECK(callContractFunction("test()"), encodeArgs(1, 2, 3));
+ BOOST_CHECK(storageEmpty(m_contractAddress));
+}
+
+BOOST_AUTO_TEST_CASE(array_pop_empty_exception)
+{
+ char const* sourceCode = R"(
+ contract c {
+ uint[] data;
+ function test() public returns (bool) {
+ data.pop();
+ return true;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ ABI_CHECK(callContractFunction("test()"), encodeArgs());
+}
+
+BOOST_AUTO_TEST_CASE(array_pop_storage_empty)
+{
+ char const* sourceCode = R"(
+ contract c {
+ uint[] data;
+ function test() public {
+ data.push(7);
+ data.pop();
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ ABI_CHECK(callContractFunction("test()"), encodeArgs());
+ BOOST_CHECK(storageEmpty(m_contractAddress));
+}
+
+BOOST_AUTO_TEST_CASE(byte_array_pop)
+{
+ char const* sourceCode = R"(
+ contract c {
+ bytes data;
+ function test() public returns (uint x, uint y, uint l) {
+ data.push(7);
+ x = data.push(3);
+ data.pop();
+ data.pop();
+ y = data.push(2);
+ l = data.length;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ ABI_CHECK(callContractFunction("test()"), encodeArgs(2, 1, 1));
+}
+
+BOOST_AUTO_TEST_CASE(byte_array_pop_empty_exception)
+{
+ char const* sourceCode = R"(
+ contract c {
+ uint256 a;
+ uint256 b;
+ uint256 c;
+ bytes data;
+ function test() public returns (bool) {
+ data.pop();
+ return true;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ ABI_CHECK(callContractFunction("test()"), encodeArgs());
+}
+
+BOOST_AUTO_TEST_CASE(byte_array_pop_storage_empty)
+{
+ char const* sourceCode = R"(
+ contract c {
+ bytes data;
+ function test() public {
+ data.push(7);
+ data.push(5);
+ data.push(3);
+ data.pop();
+ data.pop();
+ data.pop();
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ ABI_CHECK(callContractFunction("test()"), encodeArgs());
+ BOOST_CHECK(storageEmpty(m_contractAddress));
+}
+
+BOOST_AUTO_TEST_CASE(byte_array_pop_long_storage_empty)
+{
+ char const* sourceCode = R"(
+ contract c {
+ uint256 a;
+ uint256 b;
+ uint256 c;
+ bytes data;
+ function test() public returns (bool) {
+ for (uint8 i = 0; i <= 40; i++)
+ data.push(byte(i+1));
+ for (int8 j = 40; j >= 0; j--) {
+ require(data[uint8(j)] == byte(j+1));
+ require(data.length == uint8(j+1));
+ data.pop();
+ }
+ return true;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ ABI_CHECK(callContractFunction("test()"), encodeArgs(true));
+ BOOST_CHECK(storageEmpty(m_contractAddress));
+}
+
+BOOST_AUTO_TEST_CASE(byte_array_pop_long_storage_empty_garbage_ref)
+{
+ char const* sourceCode = R"(
+ contract c {
+ uint256 a;
+ uint256 b;
+ bytes data;
+ function test() public {
+ for (uint8 i = 0; i <= 40; i++)
+ data.push(3);
+ for (uint8 j = 0; j <= 40; j++) {
+ assembly {
+ mstore(0, "garbage")
+ }
+ data.pop();
+ }
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ ABI_CHECK(callContractFunction("test()"), encodeArgs());
+ BOOST_CHECK(storageEmpty(m_contractAddress));
+}
+
+BOOST_AUTO_TEST_CASE(byte_array_pop_masking_long)
+{
+ char const* sourceCode = R"(
+ contract c {
+ bytes data;
+ function test() public returns (bytes) {
+ for (uint i = 0; i < 34; i++)
+ data.push(3);
+ data.pop();
+ return data;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ ABI_CHECK(callContractFunction("test()"), encodeArgs(
+ u256(0x20),
+ u256(33),
+ asString(fromHex("0303030303030303030303030303030303030303030303030303030303030303")),
+ asString(fromHex("03"))
+ ));
+}
+
+BOOST_AUTO_TEST_CASE(byte_array_pop_copy_long)
+{
+ char const* sourceCode = R"(
+ contract c {
+ bytes data;
+ function test() public returns (bytes) {
+ for (uint i = 0; i < 33; i++)
+ data.push(3);
+ for (uint j = 0; j < 4; j++)
+ data.pop();
+ return data;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ ABI_CHECK(callContractFunction("test()"), encodeArgs(
+ u256(0x20),
+ u256(29),
+ asString(fromHex("0303030303030303030303030303030303030303030303030303030303"))
+ ));
+}
+
+BOOST_AUTO_TEST_CASE(array_pop_isolated)
+{
+ char const* sourceCode = R"(
+ // This tests that the compiler knows the correct size of the function on the stack.
+ contract c {
+ uint[] data;
+ function test() public returns (uint x) {
+ x = 2;
+ data.pop;
+ x = 3;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ ABI_CHECK(callContractFunction("test()"), encodeArgs(3));
+}
+
+BOOST_AUTO_TEST_CASE(byte_array_pop_isolated)
+{
+ char const* sourceCode = R"(
+ // This tests that the compiler knows the correct size of the function on the stack.
+ contract c {
+ bytes data;
+ function test() public returns (uint x) {
+ x = 2;
+ data.pop;
+ x = 3;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ ABI_CHECK(callContractFunction("test()"), encodeArgs(3));
+}
+
BOOST_AUTO_TEST_CASE(external_array_args)
{
char const* sourceCode = R"(
@@ -5106,11 +5297,11 @@ BOOST_AUTO_TEST_CASE(bytes_index_access)
contract c {
bytes data;
function direct(bytes arg, uint index) external returns (uint) {
- return uint(arg[index]);
+ return uint(uint8(arg[index]));
}
function storageCopyRead(bytes arg, uint index) external returns (uint) {
data = arg;
- return uint(data[index]);
+ return uint(uint8(data[index]));
}
function storageWrite() external returns (uint) {
data.length = 35;
@@ -5121,7 +5312,7 @@ BOOST_AUTO_TEST_CASE(bytes_index_access)
data[31] |= 8;
data[30] = 1;
data[32] = 3;
- return uint(data[30]) * 0x100 | uint(data[31]) * 0x10 | uint(data[32]);
+ return uint(uint8(data[30])) * 0x100 | uint(uint8(data[31])) * 0x10 | uint(uint8(data[32]));
}
}
)";
@@ -5144,7 +5335,7 @@ BOOST_AUTO_TEST_CASE(bytes_delete_element)
function test1() external returns (bool) {
data.length = 100;
for (uint i = 0; i < data.length; i++)
- data[i] = byte(i);
+ data[i] = byte(uint8(i));
delete data[94];
delete data[96];
delete data[98];
@@ -5303,7 +5494,8 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base)
{}
}
contract Final is Derived(4) {
- })";
+ }
+ )";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("m_i()"), encodeArgs(4));
}
@@ -5326,7 +5518,8 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base_base)
{}
}
contract Final is Derived(4) {
- })";
+ }
+ )";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("m_i()"), encodeArgs(4));
}
@@ -5346,7 +5539,8 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base_base_with_gap)
function Derived(uint i) Base(i) {}
}
contract Final is Derived(4) {
- })";
+ }
+ )";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("m_i()"), encodeArgs(4));
}
@@ -5357,7 +5551,8 @@ BOOST_AUTO_TEST_CASE(simple_constant_variables_test)
contract Foo {
function getX() returns (uint r) { return x; }
uint constant x = 56;
- })";
+ }
+ )";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("getX()"), encodeArgs(56));
}
@@ -5370,7 +5565,8 @@ BOOST_AUTO_TEST_CASE(constant_variables)
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
ActionChoices constant choices = ActionChoices.GoLeft;
bytes32 constant st = "abc\x00\xff__";
- })";
+ }
+ )";
compileAndRun(sourceCode);
}
@@ -5764,12 +5960,12 @@ BOOST_AUTO_TEST_CASE(invalid_enum_logged)
assembly {
garbled := 5
}
- Log(garbled);
+ emit Log(garbled);
return 1;
}
function test_log_ok() returns (uint) {
X x = X.A;
- Log(x);
+ emit Log(x);
return 1;
}
}
@@ -7498,7 +7694,7 @@ BOOST_AUTO_TEST_CASE(short_strings)
if (data1[0] != "1") return 10;
if (data1[4] != "4") return 11;
for (uint i = 0; i < data1.length; i ++)
- data1[i] = byte(i * 3);
+ data1[i] = byte(uint8(i * 3));
if (data1[4] != 4 * 3) return 12;
if (data1[67] != 67 * 3) return 13;
// change length: long -> short
@@ -8259,15 +8455,15 @@ BOOST_AUTO_TEST_CASE(inline_array_return)
{
char const* sourceCode = R"(
contract C {
- uint8[] tester;
+ uint8[] tester;
function f() returns (uint8[5]) {
return ([1,2,3,4,5]);
}
function test() returns (uint8, uint8, uint8, uint8, uint8) {
- tester = f();
+ tester = f();
return (tester[0], tester[1], tester[2], tester[3], tester[4]);
}
-
+
}
)";
compileAndRun(sourceCode, 0, "C");
@@ -8291,13 +8487,13 @@ BOOST_AUTO_TEST_CASE(inline_array_singleton)
BOOST_AUTO_TEST_CASE(inline_long_string_return)
{
char const* sourceCode = R"(
- contract C {
+ contract C {
function f() returns (string) {
return (["somethingShort", "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"][1]);
}
}
)";
-
+
string strLong = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f()"), encodeDyn(strLong));
@@ -8314,7 +8510,7 @@ BOOST_AUTO_TEST_CASE(fixed_bytes_index_access)
function g(bytes32 x) returns (uint) {
data = [x[0], x[1], x[2]];
data[0] = "12345";
- return uint(data[0][4]);
+ return uint(uint8(data[0][4]));
}
}
)";
@@ -8372,7 +8568,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_memory_access)
function test() returns (bytes) {
bytes memory x = new bytes(5);
for (uint i = 0; i < x.length; ++i)
- x[i] = byte(i + 1);
+ x[i] = byte(uint8(i + 1));
assembly { mstore(add(x, 32), "12345678901234567890123456789012") }
return x;
}
@@ -8892,7 +9088,7 @@ BOOST_AUTO_TEST_CASE(cleanup_bytes_types)
function f(bytes2 a, uint16 x) returns (uint) {
if (a != "ab") return 1;
if (x != 0x0102) return 2;
- if (bytes3(x) != 0x0102) return 3;
+ if (bytes3(uint24(x)) != 0x0102) return 3;
return 0;
}
}
@@ -9190,8 +9386,8 @@ BOOST_AUTO_TEST_CASE(failing_ecrecover_invalid_input_proper)
0, // invalid v value
0x6944c77849b18048f6abe0db8084b0d0d0689cdddb53d2671c36967b58691ad4,
0xef4f06ba4f78319baafd0424365777241af4dfd3da840471b4b4b087b7750d0d,
- 0xca35b7d915458ef540ade6068dfe2f44e8fa733c,
- 0xca35b7d915458ef540ade6068dfe2f44e8fa733c
+ 0x00ca35b7d915458ef540ade6068dfe2f44e8fa733c,
+ 0x00ca35b7d915458ef540ade6068dfe2f44e8fa733c
);
}
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s, uint blockExpired, bytes32 salt)
@@ -10127,6 +10323,7 @@ BOOST_AUTO_TEST_CASE(shift_right)
ABI_CHECK(callContractFunction("f(uint256,uint256)", u256(0x4266), u256(8)), encodeArgs(u256(0x42)));
ABI_CHECK(callContractFunction("f(uint256,uint256)", u256(0x4266), u256(16)), encodeArgs(u256(0)));
ABI_CHECK(callContractFunction("f(uint256,uint256)", u256(0x4266), u256(17)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(uint256,uint256)", u256(1)<<255, u256(5)), encodeArgs(u256(1)<<250));
}
BOOST_AUTO_TEST_CASE(shift_right_garbled)
@@ -10147,6 +10344,39 @@ BOOST_AUTO_TEST_CASE(shift_right_garbled)
ABI_CHECK(callContractFunction("f(uint8,uint8)", u256(0x0), u256(0x1004)), encodeArgs(u256(0xf)));
}
+BOOST_AUTO_TEST_CASE(shift_right_garbled_signed)
+{
+ char const* sourceCode = R"(
+ contract C {
+ function f(int8 a, uint8 b) returns (int) {
+ assembly {
+ a := 0xfffffff0
+ }
+ // Higher bits should be signextended before the shift
+ return a >> b;
+ }
+ function g(int8 a, uint8 b) returns (int) {
+ assembly {
+ a := 0xf0
+ }
+ // Higher bits should be signextended before the shift
+ return a >> b;
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ ABI_CHECK(callContractFunction("f(int8,uint8)", u256(0x0), u256(3)), encodeArgs(u256(-2)));
+ ABI_CHECK(callContractFunction("f(int8,uint8)", u256(0x0), u256(4)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int8,uint8)", u256(0x0), u256(0xFF)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int8,uint8)", u256(0x0), u256(0x1003)), encodeArgs(u256(-2)));
+ ABI_CHECK(callContractFunction("f(int8,uint8)", u256(0x0), u256(0x1004)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("g(int8,uint8)", u256(0x0), u256(3)), encodeArgs(u256(-2)));
+ ABI_CHECK(callContractFunction("g(int8,uint8)", u256(0x0), u256(4)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("g(int8,uint8)", u256(0x0), u256(0xFF)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("g(int8,uint8)", u256(0x0), u256(0x1003)), encodeArgs(u256(-2)));
+ ABI_CHECK(callContractFunction("g(int8,uint8)", u256(0x0), u256(0x1004)), encodeArgs(u256(-1)));
+}
+
BOOST_AUTO_TEST_CASE(shift_right_uint32)
{
char const* sourceCode = R"(
@@ -10223,16 +10453,73 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue)
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(0)), encodeArgs(u256(-4266)));
ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(1)), encodeArgs(u256(-2133)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(4)), encodeArgs(u256(-266)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(8)), encodeArgs(u256(-16)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(16)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(17)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(4)), encodeArgs(u256(-267)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(8)), encodeArgs(u256(-17)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(16)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(17)), encodeArgs(u256(-1)));
ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(0)), encodeArgs(u256(-4267)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(1)), encodeArgs(u256(-2133)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(4)), encodeArgs(u256(-266)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(8)), encodeArgs(u256(-16)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(16)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(17)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(1)), encodeArgs(u256(-2134)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(4)), encodeArgs(u256(-267)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(8)), encodeArgs(u256(-17)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(16)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(17)), encodeArgs(u256(-1)));
+}
+
+BOOST_AUTO_TEST_CASE(shift_right_negative_literal)
+{
+ char const* sourceCode = R"(
+ contract C {
+ function f1() pure returns (bool) {
+ return (-4266 >> 0) == -4266;
+ }
+ function f2() pure returns (bool) {
+ return (-4266 >> 1) == -2133;
+ }
+ function f3() pure returns (bool) {
+ return (-4266 >> 4) == -267;
+ }
+ function f4() pure returns (bool) {
+ return (-4266 >> 8) == -17;
+ }
+ function f5() pure returns (bool) {
+ return (-4266 >> 16) == -1;
+ }
+ function f6() pure returns (bool) {
+ return (-4266 >> 17) == -1;
+ }
+ function g1() pure returns (bool) {
+ return (-4267 >> 0) == -4267;
+ }
+ function g2() pure returns (bool) {
+ return (-4267 >> 1) == -2134;
+ }
+ function g3() pure returns (bool) {
+ return (-4267 >> 4) == -267;
+ }
+ function g4() pure returns (bool) {
+ return (-4267 >> 8) == -17;
+ }
+ function g5() pure returns (bool) {
+ return (-4267 >> 16) == -1;
+ }
+ function g6() pure returns (bool) {
+ return (-4267 >> 17) == -1;
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ ABI_CHECK(callContractFunction("f1()"), encodeArgs(true));
+ ABI_CHECK(callContractFunction("f2()"), encodeArgs(true));
+ ABI_CHECK(callContractFunction("f3()"), encodeArgs(true));
+ ABI_CHECK(callContractFunction("f4()"), encodeArgs(true));
+ ABI_CHECK(callContractFunction("f5()"), encodeArgs(true));
+ ABI_CHECK(callContractFunction("f6()"), encodeArgs(true));
+ ABI_CHECK(callContractFunction("g1()"), encodeArgs(true));
+ ABI_CHECK(callContractFunction("g2()"), encodeArgs(true));
+ ABI_CHECK(callContractFunction("g3()"), encodeArgs(true));
+ ABI_CHECK(callContractFunction("g4()"), encodeArgs(true));
+ ABI_CHECK(callContractFunction("g5()"), encodeArgs(true));
+ ABI_CHECK(callContractFunction("g6()"), encodeArgs(true));
}
BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_int8)
@@ -10247,16 +10534,16 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_int8)
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f(int8,int8)", u256(-66), u256(0)), encodeArgs(u256(-66)));
ABI_CHECK(callContractFunction("f(int8,int8)", u256(-66), u256(1)), encodeArgs(u256(-33)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(-66), u256(4)), encodeArgs(u256(-4)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(-66), u256(8)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(-66), u256(16)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(-66), u256(17)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(-66), u256(4)), encodeArgs(u256(-5)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(-66), u256(8)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(-66), u256(16)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(-66), u256(17)), encodeArgs(u256(-1)));
ABI_CHECK(callContractFunction("f(int8,int8)", u256(-67), u256(0)), encodeArgs(u256(-67)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(-67), u256(1)), encodeArgs(u256(-33)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(-67), u256(4)), encodeArgs(u256(-4)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(-67), u256(8)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(-67), u256(16)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(-67), u256(17)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(-67), u256(1)), encodeArgs(u256(-34)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(-67), u256(4)), encodeArgs(u256(-5)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(-67), u256(8)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(-67), u256(16)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(-67), u256(17)), encodeArgs(u256(-1)));
}
BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int8)
@@ -10270,10 +10557,10 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int8)
)";
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(0)), encodeArgs(u256(-103)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(1)), encodeArgs(u256(-51)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(2)), encodeArgs(u256(-25)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(4)), encodeArgs(u256(-6)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(8)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(1)), encodeArgs(u256(-52)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(2)), encodeArgs(u256(-26)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(4)), encodeArgs(u256(-7)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(8)), encodeArgs(u256(-1)));
}
BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int16)
@@ -10287,10 +10574,10 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int16)
)";
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(0)), encodeArgs(u256(-103)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(1)), encodeArgs(u256(-51)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(2)), encodeArgs(u256(-25)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(4)), encodeArgs(u256(-6)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(8)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(1)), encodeArgs(u256(-52)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(2)), encodeArgs(u256(-26)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(4)), encodeArgs(u256(-7)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(8)), encodeArgs(u256(-1)));
}
BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int32)
@@ -10304,10 +10591,10 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int32)
)";
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(0)), encodeArgs(u256(-103)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(1)), encodeArgs(u256(-51)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(2)), encodeArgs(u256(-25)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(4)), encodeArgs(u256(-6)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(8)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(1)), encodeArgs(u256(-52)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(2)), encodeArgs(u256(-26)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(4)), encodeArgs(u256(-7)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(8)), encodeArgs(u256(-1)));
}
@@ -10323,16 +10610,16 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_int16)
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4266), u256(0)), encodeArgs(u256(-4266)));
ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4266), u256(1)), encodeArgs(u256(-2133)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4266), u256(4)), encodeArgs(u256(-266)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4266), u256(8)), encodeArgs(u256(-16)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4266), u256(16)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4266), u256(17)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4266), u256(4)), encodeArgs(u256(-267)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4266), u256(8)), encodeArgs(u256(-17)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4266), u256(16)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4266), u256(17)), encodeArgs(u256(-1)));
ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4267), u256(0)), encodeArgs(u256(-4267)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4267), u256(1)), encodeArgs(u256(-2133)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4267), u256(4)), encodeArgs(u256(-266)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4267), u256(8)), encodeArgs(u256(-16)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4267), u256(16)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4267), u256(17)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4267), u256(1)), encodeArgs(u256(-2134)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4267), u256(4)), encodeArgs(u256(-267)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4267), u256(8)), encodeArgs(u256(-17)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4267), u256(16)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4267), u256(17)), encodeArgs(u256(-1)));
}
BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_int32)
@@ -10347,16 +10634,16 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_int32)
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4266), u256(0)), encodeArgs(u256(-4266)));
ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4266), u256(1)), encodeArgs(u256(-2133)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4266), u256(4)), encodeArgs(u256(-266)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4266), u256(8)), encodeArgs(u256(-16)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4266), u256(16)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4266), u256(17)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4266), u256(4)), encodeArgs(u256(-267)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4266), u256(8)), encodeArgs(u256(-17)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4266), u256(16)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4266), u256(17)), encodeArgs(u256(-1)));
ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4267), u256(0)), encodeArgs(u256(-4267)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4267), u256(1)), encodeArgs(u256(-2133)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4267), u256(4)), encodeArgs(u256(-266)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4267), u256(8)), encodeArgs(u256(-16)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4267), u256(16)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4267), u256(17)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4267), u256(1)), encodeArgs(u256(-2134)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4267), u256(4)), encodeArgs(u256(-267)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4267), u256(8)), encodeArgs(u256(-17)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4267), u256(16)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4267), u256(17)), encodeArgs(u256(-1)));
}
BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_assignment)
@@ -10372,16 +10659,16 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_assignment)
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(0)), encodeArgs(u256(-4266)));
ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(1)), encodeArgs(u256(-2133)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(4)), encodeArgs(u256(-266)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(8)), encodeArgs(u256(-16)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(16)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(17)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(4)), encodeArgs(u256(-267)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(8)), encodeArgs(u256(-17)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(16)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(17)), encodeArgs(u256(-1)));
ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(0)), encodeArgs(u256(-4267)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(1)), encodeArgs(u256(-2133)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(4)), encodeArgs(u256(-266)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(8)), encodeArgs(u256(-16)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(16)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(17)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(1)), encodeArgs(u256(-2134)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(4)), encodeArgs(u256(-267)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(8)), encodeArgs(u256(-17)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(16)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(17)), encodeArgs(u256(-1)));
}
BOOST_AUTO_TEST_CASE(shift_negative_rvalue)
@@ -11105,26 +11392,11 @@ BOOST_AUTO_TEST_CASE(keccak256_assembly)
=: ret
}
}
- function h() pure returns (bytes32 ret) {
- assembly {
- ret := sha3(0, 0)
- }
- }
- function i() pure returns (bytes32 ret) {
- assembly {
- 0
- 0
- sha3
- =: ret
- }
- }
}
)";
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f()"), fromHex("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"));
ABI_CHECK(callContractFunction("g()"), fromHex("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"));
- ABI_CHECK(callContractFunction("h()"), fromHex("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"));
- ABI_CHECK(callContractFunction("i()"), fromHex("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"));
}
BOOST_AUTO_TEST_CASE(multi_modifiers)
@@ -11180,9 +11452,6 @@ BOOST_AUTO_TEST_CASE(bare_call_invalid_address)
function f() external returns (bool) {
return address(0x4242).call();
}
- function g() external returns (bool) {
- return address(0x4242).callcode();
- }
function h() external returns (bool) {
return address(0x4242).delegatecall();
}
@@ -11190,7 +11459,6 @@ BOOST_AUTO_TEST_CASE(bare_call_invalid_address)
)";
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(1)));
- ABI_CHECK(callContractFunction("g()"), encodeArgs(u256(1)));
ABI_CHECK(callContractFunction("h()"), encodeArgs(u256(1)));
}
@@ -11206,13 +11474,13 @@ BOOST_AUTO_TEST_CASE(delegatecall_return_value)
return value;
}
function get_delegated() external returns (bool) {
- return this.delegatecall(bytes4(sha3("get()")));
+ return this.delegatecall(bytes4(keccak256("get()")));
}
function assert0() external view {
assert(value == 0);
}
function assert0_delegated() external returns (bool) {
- return this.delegatecall(bytes4(sha3("assert0()")));
+ return this.delegatecall(bytes4(keccak256("assert0()")));
}
}
)DELIMITER";
@@ -11590,7 +11858,7 @@ BOOST_AUTO_TEST_CASE(snark)
input[7] = 9643208548031422463313148630985736896287522941726746581856185889848792022807;
input[8] = 18066496933330839731877828156604;
if (verify(input, proof) == 0) {
- Verified("Transaction successfully verified.");
+ emit Verified("Transaction successfully verified.");
return true;
} else {
return false;
diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp
index 90d8265c..ce8f4fe4 100644
--- a/test/libsolidity/SolidityExpressionCompiler.cpp
+++ b/test/libsolidity/SolidityExpressionCompiler.cpp
@@ -249,7 +249,8 @@ BOOST_AUTO_TEST_CASE(int_with_finney_ether_subdenomination)
{
var x = 1 finney;
}
- })";
+ }
+ )";
bytes code = compileFirstExpression(sourceCode);
bytes expectation({byte(Instruction::PUSH7), 0x3, 0x8d, 0x7e, 0xa4, 0xc6, 0x80, 0x00});
@@ -489,7 +490,7 @@ BOOST_AUTO_TEST_CASE(intermediately_overflowing_literals)
// have been applied
char const* sourceCode = R"(
contract test {
- function f() { var x = (0xffffffffffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffff01) & 0xbf; }
+ function f() { var x = (0x00ffffffffffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffff01) & 0xbf; }
}
)";
bytes code = compileFirstExpression(sourceCode);
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 5af67659..bca66d01 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -43,280 +43,6 @@ namespace test
BOOST_FIXTURE_TEST_SUITE(SolidityNameAndTypeResolution, AnalysisFramework)
-BOOST_AUTO_TEST_CASE(name_references)
-{
- char const* text = R"(
- contract test {
- uint256 variable;
- function f(uint256) public returns (uint out) { f(variable); test; out; }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(undeclared_name)
-{
- char const* text = R"(
- contract test {
- uint256 variable;
- function f(uint256 arg) public {
- f(notfound);
- }
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Undeclared identifier.");
-}
-
-BOOST_AUTO_TEST_CASE(undeclared_name_is_not_fatal)
-{
- char const* text = R"(
- contract test {
- uint256 variable;
- function f(uint256 arg) public {
- f(notfound);
- f(notfound);
- }
- }
- )";
- CHECK_ERROR_ALLOW_MULTI(text, DeclarationError, (vector<string>{"Undeclared identifier", "Undeclared identifier"}));
-}
-
-BOOST_AUTO_TEST_CASE(reference_to_later_declaration)
-{
- char const* text = R"(
- contract test {
- function g() public { f(); }
- function f() public {}
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(type_inference_smoke_test)
-{
- char const* text = R"(
- contract test {
- function f(uint256 arg1, uint32 arg2) public returns (bool ret) {
- var x = arg1 + arg2 == 8; ret = x;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(type_checking_return)
-{
- char const* text = R"(
- contract test {
- function f() public returns (bool r) { return 1 >= 2; }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(type_checking_return_wrong_number)
-{
- char const* text = R"(
- contract test {
- function f() public returns (bool r1, bool r2) { return 1 >= 2; }
- }
- )";
- CHECK_ERROR(text, TypeError, "Different number of arguments in return statement than in returns declaration.");
-}
-
-BOOST_AUTO_TEST_CASE(type_checking_return_wrong_type)
-{
- char const* text = R"(
- contract test {
- function f() public returns (uint256 r) { return 1 >= 2; }
- }
- )";
- CHECK_ERROR(text, TypeError, "Return argument type bool is not implicitly convertible to expected type (type of first return variable) uint256.");
-}
-
-BOOST_AUTO_TEST_CASE(type_checking_function_call)
-{
- char const* text = R"(
- contract test {
- function f() public returns (bool) { return g(12, true) == 3; }
- function g(uint256, bool) public returns (uint256) { }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(type_conversion_for_comparison)
-{
- char const* text = R"(
- contract test {
- function f() public { uint32(2) == int64(2); }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(type_conversion_for_comparison_invalid)
-{
- char const* text = R"(
- contract test {
- function f() public { int32(2) == uint64(2); }
- }
- )";
- CHECK_ERROR(text, TypeError, "Operator == not compatible with types int32 and uint64");
-}
-
-BOOST_AUTO_TEST_CASE(type_inference_explicit_conversion)
-{
- char const* text = R"(
- contract test {
- function f() public returns (int256 r) { var x = int256(uint32(2)); return x; }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(large_string_literal)
-{
- char const* text = R"(
- contract test {
- function f() public { var x = "123456789012345678901234567890123"; }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(balance)
-{
- char const* text = R"(
- contract test {
- function fun() public {
- uint256 x = address(0).balance;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(balance_invalid)
-{
- char const* text = R"(
- contract test {
- function fun() public {
- address(0).balance = 7;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Expression has to be an lvalue.");
-}
-
-BOOST_AUTO_TEST_CASE(assignment_to_mapping)
-{
- char const* text = R"(
- contract test {
- struct str {
- mapping(uint=>uint) map;
- }
- str data;
- function fun() public {
- var a = data.map;
- data.map = a;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Mappings cannot be assigned to.");
-}
-
-BOOST_AUTO_TEST_CASE(assignment_to_struct)
-{
- char const* text = R"(
- contract test {
- struct str {
- mapping(uint=>uint) map;
- }
- str data;
- function fun() public {
- var a = data;
- data = a;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(forward_function_reference)
-{
- char const* text = R"(
- contract First {
- function fun() public returns (bool) {
- return Second(1).fun(1, true, 3) > 0;
- }
- }
- contract Second {
- function fun(uint, bool, uint) public returns (uint) {
- if (First(2).fun() == true) return 1;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(comparison_bitop_precedence)
-{
- char const* text = R"(
- contract First {
- function fun() public returns (bool ret) {
- return 1 & 2 == 8 & 9 && 1 ^ 2 < 4 | 6;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(comparison_of_function_types)
-{
- char const* text = R"(
- contract C {
- function f() public returns (bool ret) {
- return this.f < this.f;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Operator < not compatible");
- text = R"(
- contract C {
- function f() public returns (bool ret) {
- return f < f;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Operator < not compatible");
- text = R"(
- contract C {
- function f() public returns (bool ret) {
- return f == f;
- }
- function g() public returns (bool ret) {
- return f != f;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(comparison_of_mapping_types)
-{
- char const* text = R"(
- contract C {
- mapping(uint => uint) x;
- function f() public returns (bool ret) {
- var y = x;
- return x == y;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Operator == not compatible");
-}
-
BOOST_AUTO_TEST_CASE(function_no_implementation)
{
SourceUnit const* sourceUnit = nullptr;
@@ -369,28 +95,6 @@ BOOST_AUTO_TEST_CASE(abstract_contract_with_overload)
BOOST_CHECK(!derived->annotation().unimplementedFunctions.empty());
}
-BOOST_AUTO_TEST_CASE(create_abstract_contract)
-{
- char const* text = R"(
- contract base { function foo(); }
- contract derived {
- base b;
- function foo() public { b = new base(); }
- }
- )";
- CHECK_ERROR(text, TypeError, "Trying to create an instance of an abstract contract.");
-}
-
-BOOST_AUTO_TEST_CASE(redeclare_implemented_abstract_function_as_abstract)
-{
- char const* text = R"(
- contract base { function foo(); }
- contract derived is base { function foo() public {} }
- contract wrong is derived { function foo(); }
- )";
- CHECK_ERROR(text, TypeError, "Redeclaring an already implemented function as abstract");
-}
-
BOOST_AUTO_TEST_CASE(implement_abstract_via_constructor)
{
SourceUnit const* sourceUnit = nullptr;
@@ -472,9 +176,9 @@ BOOST_AUTO_TEST_CASE(function_external_types)
BOOST_AUTO_TEST_CASE(enum_external_type)
{
- // bug #1801
SourceUnit const* sourceUnit = nullptr;
char const* text = R"(
+ // test for bug #1801
contract Test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function boo(ActionChoices enumArg) external returns (uint ret) {
@@ -499,10 +203,10 @@ BOOST_AUTO_TEST_CASE(external_structs)
pragma experimental ABIEncoderV2;
contract Test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
- struct Empty {}
+ struct Simple { uint i; }
struct Nested { X[2][] a; uint y; }
- struct X { bytes32 x; Test t; Empty[] e; }
- function f(ActionChoices, uint, Empty) external {}
+ struct X { bytes32 x; Test t; Simple[] s; }
+ function f(ActionChoices, uint, Simple) external {}
function g(Test, Nested) external {}
function h(function(Nested) external returns (uint)[]) external {}
function i(Nested[]) external {}
@@ -514,10 +218,10 @@ BOOST_AUTO_TEST_CASE(external_structs)
{
auto functions = contract->definedFunctions();
BOOST_REQUIRE(!functions.empty());
- BOOST_CHECK_EQUAL("f(uint8,uint256,())", functions[0]->externalSignature());
- BOOST_CHECK_EQUAL("g(address,((bytes32,address,()[])[2][],uint256))", functions[1]->externalSignature());
+ BOOST_CHECK_EQUAL("f(uint8,uint256,(uint256))", functions[0]->externalSignature());
+ BOOST_CHECK_EQUAL("g(address,((bytes32,address,(uint256)[])[2][],uint256))", functions[1]->externalSignature());
BOOST_CHECK_EQUAL("h(function[])", functions[2]->externalSignature());
- BOOST_CHECK_EQUAL("i(((bytes32,address,()[])[2][],uint256)[])", functions[3]->externalSignature());
+ BOOST_CHECK_EQUAL("i(((bytes32,address,(uint256)[])[2][],uint256)[])", functions[3]->externalSignature());
}
}
@@ -527,10 +231,10 @@ BOOST_AUTO_TEST_CASE(external_structs_in_libraries)
pragma experimental ABIEncoderV2;
library Test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
- struct Empty {}
+ struct Simple { uint i; }
struct Nested { X[2][] a; uint y; }
- struct X { bytes32 x; Test t; Empty[] e; }
- function f(ActionChoices, uint, Empty) external {}
+ struct X { bytes32 x; Test t; Simple[] s; }
+ function f(ActionChoices, uint, Simple) external {}
function g(Test, Nested) external {}
function h(function(Nested) external returns (uint)[]) external {}
function i(Nested[]) external {}
@@ -542,7 +246,7 @@ BOOST_AUTO_TEST_CASE(external_structs_in_libraries)
{
auto functions = contract->definedFunctions();
BOOST_REQUIRE(!functions.empty());
- BOOST_CHECK_EQUAL("f(Test.ActionChoices,uint256,Test.Empty)", functions[0]->externalSignature());
+ BOOST_CHECK_EQUAL("f(Test.ActionChoices,uint256,Test.Simple)", functions[0]->externalSignature());
BOOST_CHECK_EQUAL("g(Test,Test.Nested)", functions[1]->externalSignature());
BOOST_CHECK_EQUAL("h(function[])", functions[2]->externalSignature());
BOOST_CHECK_EQUAL("i(Test.Nested[])", functions[3]->externalSignature());
@@ -568,336 +272,6 @@ BOOST_AUTO_TEST_CASE(struct_with_mapping_in_library)
}
}
-BOOST_AUTO_TEST_CASE(functions_with_identical_structs_in_interface)
-{
- char const* text = R"(
- pragma experimental ABIEncoderV2;
-
- contract C {
- struct S1 { }
- struct S2 { }
- function f(S1) pure {}
- function f(S2) pure {}
- }
- )";
- CHECK_ERROR(text, TypeError, "Function overload clash during conversion to external types for arguments");
-}
-
-BOOST_AUTO_TEST_CASE(functions_with_different_structs_in_interface)
-{
- char const* text = R"(
- pragma experimental ABIEncoderV2;
-
- contract C {
- struct S1 { function() external a; }
- struct S2 { bytes24 a; }
- function f(S1) pure {}
- function f(S2) pure {}
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(functions_with_stucts_of_non_external_types_in_interface)
-{
- char const* text = R"(
- pragma experimental ABIEncoderV2;
-
- contract C {
- struct S { function() internal a; }
- function f(S) {}
- }
- )";
- CHECK_ERROR(text, TypeError, "Internal or recursive type is not allowed for public or external functions.");
-}
-
-BOOST_AUTO_TEST_CASE(functions_with_stucts_of_non_external_types_in_interface_2)
-{
- char const* text = R"(
- pragma experimental ABIEncoderV2;
-
- contract C {
- struct S { mapping(uint => uint) a; }
- function f(S) {}
- }
- )";
- CHECK_ERROR(text, TypeError, "Internal or recursive type is not allowed for public or external functions.");
-}
-
-BOOST_AUTO_TEST_CASE(functions_with_stucts_of_non_external_types_in_interface_nested)
-{
- char const* text = R"(
- pragma experimental ABIEncoderV2;
-
- contract C {
- struct T { mapping(uint => uint) a; }
- struct S { T[][2] b; }
- function f(S) {}
- }
- )";
- CHECK_ERROR(text, TypeError, "Internal or recursive type is not allowed for public or external functions.");
-}
-
-BOOST_AUTO_TEST_CASE(returning_multi_dimensional_arrays_new_abi)
-{
- char const* text = R"(
- pragma experimental ABIEncoderV2;
-
- contract C {
- function f() public pure returns (string[][]) {}
- }
- )";
- CHECK_WARNING(text, "Experimental features");
-}
-
-BOOST_AUTO_TEST_CASE(returning_multi_dimensional_arrays)
-{
- char const* text = R"(
- contract C {
- function f() public pure returns (string[][]) {}
- }
- )";
- CHECK_ERROR(text, TypeError, "only supported in the new experimental ABI encoder");
-}
-
-BOOST_AUTO_TEST_CASE(returning_multi_dimensional_static_arrays)
-{
- char const* text = R"(
- contract C {
- function f() public pure returns (uint[][2]) {}
- }
- )";
- CHECK_ERROR(text, TypeError, "only supported in the new experimental ABI encoder");
-}
-
-BOOST_AUTO_TEST_CASE(returning_arrays_in_structs_new_abi)
-{
- char const* text = R"(
- pragma experimental ABIEncoderV2;
-
- contract C {
- struct S { string[] s; }
- function f() public pure returns (S) {}
- }
- )";
- CHECK_WARNING(text, "Experimental features");
-}
-
-BOOST_AUTO_TEST_CASE(returning_arrays_in_structs_arrays)
-{
- char const* text = R"(
- contract C {
- struct S { string[] s; }
- function f() public pure returns (S x) {}
- }
- )";
- CHECK_ERROR(text, TypeError, "only supported in the new experimental ABI encoder");
-}
-
-BOOST_AUTO_TEST_CASE(function_external_call_allowed_conversion)
-{
- char const* text = R"(
- contract C {}
- contract Test {
- function externalCall() public {
- C arg;
- this.g(arg);
- }
- function g (C c) external {}
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(function_external_call_not_allowed_conversion)
-{
- char const* text = R"(
- contract C {}
- contract Test {
- function externalCall() public {
- address arg;
- this.g(arg);
- }
- function g (C c) external {}
- }
- )";
- CHECK_ERROR(text, TypeError, "Invalid type for argument in function call. Invalid implicit conversion from address to contract C requested.");
-}
-
-BOOST_AUTO_TEST_CASE(function_internal_allowed_conversion)
-{
- char const* text = R"(
- contract C {
- uint a;
- }
- contract Test {
- C a;
- function g (C c) public {}
- function internalCall() public {
- g(a);
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(function_internal_not_allowed_conversion)
-{
- char const* text = R"(
- contract C {
- uint a;
- }
- contract Test {
- address a;
- function g (C c) public {}
- function internalCall() public {
- g(a);
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Invalid type for argument in function call. Invalid implicit conversion from address to contract C requested.");
-}
-
-BOOST_AUTO_TEST_CASE(hash_collision_in_interface)
-{
- char const* text = R"(
- contract test {
- function gsf() public { }
- function tgeo() public { }
- }
- )";
- CHECK_ERROR(text, TypeError, "Function signature hash collision for tgeo()");
-}
-
-BOOST_AUTO_TEST_CASE(inheritance_basic)
-{
- char const* text = R"(
- contract base { uint baseMember; struct BaseType { uint element; } }
- contract derived is base {
- BaseType data;
- function f() public { baseMember = 7; }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(inheritance_diamond_basic)
-{
- char const* text = R"(
- contract root { function rootFunction() public {} }
- contract inter1 is root { function f() public {} }
- contract inter2 is root { function f() public {} }
- contract derived is root, inter2, inter1 {
- function g() public { f(); rootFunction(); }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(cyclic_inheritance)
-{
- char const* text = R"(
- contract A is B { }
- contract B is A { }
- )";
- CHECK_ERROR_ALLOW_MULTI(text, TypeError, (vector<string>{"Definition of base has to precede definition of derived contract"}));
-}
-
-BOOST_AUTO_TEST_CASE(legal_override_direct)
-{
- char const* text = R"(
- contract B { function f() public {} }
- contract C is B { function f(uint i) public {} }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(legal_override_indirect)
-{
- char const* text = R"(
- contract A { function f(uint a) public {} }
- contract B { function f() public {} }
- contract C is A, B { }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(illegal_override_visibility)
-{
- char const* text = R"(
- contract B { function f() internal {} }
- contract C is B { function f() public {} }
- )";
- CHECK_ERROR(text, TypeError, "Overriding function visibility differs");
-}
-
-BOOST_AUTO_TEST_CASE(complex_inheritance)
-{
- char const* text = R"(
- contract A { function f() public { uint8 x = C(0).g(); } }
- contract B { function f() public {} function g() public returns (uint8) {} }
- contract C is A, B { }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(missing_base_constructor_arguments)
-{
- char const* text = R"(
- contract A { function A(uint a) public { } }
- contract B is A { }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(base_constructor_arguments_override)
-{
- char const* text = R"(
- contract A { function A(uint a) public { } }
- contract B is A { }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(implicit_derived_to_base_conversion)
-{
- char const* text = R"(
- contract A { }
- contract B is A {
- function f() public { A a = B(1); }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(implicit_base_to_derived_conversion)
-{
- char const* text = R"(
- contract A { }
- contract B is A {
- function f() public { B b = A(1); }
- }
- )";
- CHECK_ERROR(text, TypeError, "Type contract A is not implicitly convertible to expected type contract B.");
-}
-
-BOOST_AUTO_TEST_CASE(super_excludes_current_contract)
-{
- char const* text = R"(
- contract A {
- function b() public {}
- }
-
- contract B is A {
- function f() public {
- super.f();
- }
- }
- )";
-
- CHECK_ERROR(text, TypeError, "Member \"f\" not found or not visible after argument-dependent lookup in contract super B");
-}
-
BOOST_AUTO_TEST_CASE(state_variable_accessors)
{
char const* text = R"(
@@ -939,20 +313,6 @@ BOOST_AUTO_TEST_CASE(state_variable_accessors)
BOOST_CHECK(function->stateMutability() == StateMutability::View);
}
-BOOST_AUTO_TEST_CASE(function_clash_with_state_variable_accessor)
-{
- char const* text = R"(
- contract test {
- function fun() public {
- uint64(2);
- }
- uint256 foo;
- function foo() public {}
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Identifier already declared.");
-}
-
BOOST_AUTO_TEST_CASE(private_state_variable)
{
char const* text = R"(
@@ -975,1498 +335,6 @@ BOOST_AUTO_TEST_CASE(private_state_variable)
BOOST_CHECK_MESSAGE(function == nullptr, "Accessor function of an internal variable should not exist");
}
-BOOST_AUTO_TEST_CASE(base_class_state_variable_accessor)
-{
- // test for issue #1126 https://github.com/ethereum/cpp-ethereum/issues/1126
- char const* text = R"(
- contract Parent {
- uint256 public m_aMember;
- }
- contract Child is Parent {
- function foo() public returns (uint256) { return Parent.m_aMember; }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(struct_accessor_one_array_only)
-{
- char const* sourceCode = R"(
- contract test {
- struct Data { uint[15] m_array; }
- Data public data;
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Internal or recursive type is not allowed for public state variables.");
-}
-
-BOOST_AUTO_TEST_CASE(base_class_state_variable_internal_member)
-{
- char const* text = R"(
- contract Parent {
- uint256 internal m_aMember;
- }
- contract Child is Parent {
- function foo() public returns (uint256) { return Parent.m_aMember; }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(state_variable_member_of_wrong_class1)
-{
- char const* text = R"(
- contract Parent1 {
- uint256 internal m_aMember1;
- }
- contract Parent2 is Parent1 {
- uint256 internal m_aMember2;
- }
- contract Child is Parent2 {
- function foo() public returns (uint256) { return Parent2.m_aMember1; }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"m_aMember1\" not found or not visible after argument-dependent lookup in type(contract Parent2)");
-}
-
-BOOST_AUTO_TEST_CASE(state_variable_member_of_wrong_class2)
-{
- char const* text = R"(
- contract Parent1 {
- uint256 internal m_aMember1;
- }
- contract Parent2 is Parent1 {
- uint256 internal m_aMember2;
- }
- contract Child is Parent2 {
- function foo() public returns (uint256) { return Child.m_aMember2; }
- uint256 public m_aMember3;
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"m_aMember2\" not found or not visible after argument-dependent lookup in type(contract Child)");
-}
-
-BOOST_AUTO_TEST_CASE(fallback_function)
-{
- char const* text = R"(
- contract C {
- uint x;
- function() public { x = 2; }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(fallback_function_with_arguments)
-{
- char const* text = R"(
- contract C {
- uint x;
- function(uint a) public { x = 2; }
- }
- )";
- CHECK_ERROR(text, TypeError, "Fallback function cannot take parameters.");
-}
-
-BOOST_AUTO_TEST_CASE(fallback_function_in_library)
-{
- char const* text = R"(
- library C {
- function() public {}
- }
- )";
- CHECK_ERROR(text, TypeError, "Libraries cannot have fallback functions.");
-}
-
-BOOST_AUTO_TEST_CASE(fallback_function_with_return_parameters)
-{
- char const* text = R"(
- contract C {
- function() public returns (uint) { }
- }
- )";
- CHECK_ERROR(text, TypeError, "Fallback function cannot return values.");
-}
-
-BOOST_AUTO_TEST_CASE(fallback_function_twice)
-{
- char const* text = R"(
- contract C {
- uint x;
- function() public { x = 2; }
- function() public { x = 3; }
- }
- )";
- CHECK_ERROR_ALLOW_MULTI(text, DeclarationError, (vector<string>{
- "Only one fallback function is"
- }));
-}
-
-BOOST_AUTO_TEST_CASE(fallback_function_inheritance)
-{
- char const* text = R"(
- contract A {
- uint x;
- function() public { x = 1; }
- }
- contract C is A {
- function() public { x = 2; }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(event)
-{
- char const* text = R"(
- contract c {
- event e(uint indexed a, bytes3 indexed s, bool indexed b);
- function f() public { e(2, "abc", true); }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(event_too_many_indexed)
-{
- char const* text = R"(
- contract c {
- event e(uint indexed a, bytes3 indexed b, bool indexed c, uint indexed d);
- }
- )";
- CHECK_ERROR(text, TypeError, "More than 3 indexed arguments for event.");
-}
-
-BOOST_AUTO_TEST_CASE(anonymous_event_four_indexed)
-{
- char const* text = R"(
- contract c {
- event e(uint indexed a, bytes3 indexed b, bool indexed c, uint indexed d) anonymous;
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(anonymous_event_too_many_indexed)
-{
- char const* text = R"(
- contract c {
- event e(uint indexed a, bytes3 indexed b, bool indexed c, uint indexed d, uint indexed e) anonymous;
- }
- )";
- CHECK_ERROR(text, TypeError, "More than 4 indexed arguments for anonymous event.");
-}
-
-BOOST_AUTO_TEST_CASE(events_with_same_name)
-{
- char const* text = R"(
- contract TestIt {
- event A();
- event A(uint i);
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(events_with_same_name_unnamed_arguments)
-{
- char const* text = R"(
- contract test {
- event A(uint);
- event A(uint, uint);
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(events_with_same_name_different_types)
-{
- char const* text = R"(
- contract test {
- event A(uint);
- event A(bytes);
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(double_event_declaration)
-{
- char const* text = R"(
- contract test {
- event A(uint i);
- event A(uint i);
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Event with same name and arguments defined twice.");
-}
-
-BOOST_AUTO_TEST_CASE(double_event_declaration_ignores_anonymous)
-{
- char const* text = R"(
- contract test {
- event A(uint i);
- event A(uint i) anonymous;
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Event with same name and arguments defined twice.");
-}
-
-BOOST_AUTO_TEST_CASE(double_event_declaration_ignores_indexed)
-{
- char const* text = R"(
- contract test {
- event A(uint i);
- event A(uint indexed i);
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Event with same name and arguments defined twice.");
-}
-
-BOOST_AUTO_TEST_CASE(event_call)
-{
- char const* text = R"(
- contract c {
- event e(uint a, bytes3 indexed s, bool indexed b);
- function f() public { e(2, "abc", true); }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(event_function_inheritance_clash)
-{
- char const* text = R"(
- contract A {
- function dup() public returns (uint) {
- return 1;
- }
- }
- contract B {
- event dup();
- }
- contract C is A, B {
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Identifier already declared.");
-}
-
-BOOST_AUTO_TEST_CASE(function_event_inheritance_clash)
-{
- char const* text = R"(
- contract B {
- event dup();
- }
- contract A {
- function dup() public returns (uint) {
- return 1;
- }
- }
- contract C is B, A {
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Identifier already declared.");
-}
-
-BOOST_AUTO_TEST_CASE(function_event_in_contract_clash)
-{
- char const* text = R"(
- contract A {
- event dup();
- function dup() public returns (uint) {
- return 1;
- }
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Identifier already declared.");
-}
-
-BOOST_AUTO_TEST_CASE(event_inheritance)
-{
- char const* text = R"(
- contract base {
- event e(uint a, bytes3 indexed s, bool indexed b);
- }
- contract c is base {
- function f() public { e(2, "abc", true); }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(multiple_events_argument_clash)
-{
- char const* text = R"(
- contract c {
- event e1(uint a, uint e1, uint e2);
- event e2(uint a, uint e1, uint e2);
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(access_to_default_function_visibility)
-{
- char const* text = R"(
- contract c {
- function f() public {}
- }
- contract d {
- function g() public { c(0).f(); }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(access_to_internal_function)
-{
- char const* text = R"(
- contract c {
- function f() internal {}
- }
- contract d {
- function g() public { c(0).f(); }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"f\" not found or not visible after argument-dependent lookup in contract c");
-}
-
-BOOST_AUTO_TEST_CASE(access_to_default_state_variable_visibility)
-{
- char const* text = R"(
- contract c {
- uint a;
- }
- contract d {
- function g() public { c(0).a(); }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"a\" not found or not visible after argument-dependent lookup in contract c");
-}
-
-BOOST_AUTO_TEST_CASE(access_to_internal_state_variable)
-{
- char const* text = R"(
- contract c {
- uint public a;
- }
- contract d {
- function g() public { c(0).a(); }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(error_count_in_named_args)
-{
- char const* sourceCode = R"(
- contract test {
- function a(uint a, uint b) public returns (uint r) {
- r = a + b;
- }
- function b() public returns (uint r) {
- r = a({a: 1});
- }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Wrong argument count for function call: 1 arguments given but expected 2.");
-}
-
-BOOST_AUTO_TEST_CASE(empty_in_named_args)
-{
- char const* sourceCode = R"(
- contract test {
- function a(uint a, uint b) public returns (uint r) {
- r = a + b;
- }
- function b() public returns (uint r) {
- r = a({});
- }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Wrong argument count for function call: 0 arguments given but expected 2.");
-}
-
-BOOST_AUTO_TEST_CASE(duplicate_parameter_names_in_named_args)
-{
- char const* sourceCode = R"(
- contract test {
- function a(uint a, uint b) public returns (uint r) {
- r = a + b;
- }
- function b() public returns (uint r) {
- r = a({a: 1, a: 2});
- }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Duplicate named argument.");
-}
-
-BOOST_AUTO_TEST_CASE(invalid_parameter_names_in_named_args)
-{
- char const* sourceCode = R"(
- contract test {
- function a(uint a, uint b) public returns (uint r) {
- r = a + b;
- }
- function b() public returns (uint r) {
- r = a({a: 1, c: 2});
- }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Named argument does not match function declaration.");
-}
-
-BOOST_AUTO_TEST_CASE(empty_name_input_parameter)
-{
- char const* text = R"(
- contract test {
- function f(uint) public { }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(constant_input_parameter)
-{
- char const* text = R"(
- contract test {
- function f(uint[] constant a) public { }
- }
- )";
- CHECK_ERROR_ALLOW_MULTI(text, TypeError, (vector<string>{
- "Illegal use of \"constant\" specifier",
- "Constants of non-value type not yet implemented",
- "Uninitialized \"constant\" variable"
- }));
-}
-
-BOOST_AUTO_TEST_CASE(empty_name_return_parameter)
-{
- char const* text = R"(
- contract test {
- function f() public returns (bool) { }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one)
-{
- char const* text = R"(
- contract test {
- function f(uint, uint k) public returns (uint ret_k) {
- return k;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(empty_name_return_parameter_with_named_one)
-{
- char const* text = R"(
- contract test {
- function f() public returns (uint ret_k, uint) {
- return 5;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Different number of arguments in return statement than in returns declaration.");
-}
-
-BOOST_AUTO_TEST_CASE(disallow_declaration_of_void_type)
-{
- char const* sourceCode = R"(
- contract c {
- function f() public { var (x) = f(); }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Not enough components (0) in value to assign all variables (1).");
-}
-
-BOOST_AUTO_TEST_CASE(overflow_caused_by_ether_units)
-{
- char const* sourceCodeFine = R"(
- contract c {
- function c () public {
- a = 115792089237316195423570985008687907853269984665640564039458;
- }
- uint256 a;
- }
- )";
- CHECK_SUCCESS(sourceCodeFine);
- char const* sourceCode = R"(
- contract c {
- function c () public {
- a = 115792089237316195423570985008687907853269984665640564039458 ether;
- }
- uint256 a;
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Type int_const 1157...(70 digits omitted)...0000 is not implicitly convertible to expected type uint256.");
-}
-
-BOOST_AUTO_TEST_CASE(exp_operator_exponent_too_big)
-{
- char const* sourceCode = R"(
- contract test {
- function f() public returns (uint d) { return 2 ** 10000000000; }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Operator ** not compatible with types int_const 2 and int_const 10000000000");
-}
-
-BOOST_AUTO_TEST_CASE(exp_warn_literal_base)
-{
- char const* sourceCode = R"(
- contract test {
- function f() pure public returns(uint) {
- uint8 x = 100;
- return 10**x;
- }
- }
- )";
- CHECK_WARNING(sourceCode, "might overflow");
- sourceCode = R"(
- contract test {
- function f() pure public returns(uint) {
- uint8 x = 100;
- return uint8(10)**x;
- }
- }
- )";
- CHECK_SUCCESS(sourceCode);
- sourceCode = R"(
- contract test {
- function f() pure public returns(uint) {
- return 2**80;
- }
- }
- )";
- CHECK_SUCCESS(sourceCode);
-}
-
-BOOST_AUTO_TEST_CASE(shift_warn_literal_base)
-{
- char const* sourceCode = R"(
- contract test {
- function f() pure public returns(uint) {
- uint8 x = 100;
- return 10 << x;
- }
- }
- )";
- CHECK_WARNING(sourceCode, "might overflow");
- sourceCode = R"(
- contract test {
- function f() pure public returns(uint) {
- uint8 x = 100;
- return uint8(10) << x;
- }
- }
- )";
- CHECK_SUCCESS(sourceCode);
- sourceCode = R"(
- contract test {
- function f() pure public returns(uint) {
- return 2 << 80;
- }
- }
- )";
- CHECK_SUCCESS(sourceCode);
- sourceCode = R"(
- contract test {
- function f() pure public returns(uint) {
- uint8 x = 100;
- return 10 >> x;
- }
- }
- )";
- CHECK_SUCCESS(sourceCode);
-}
-
-BOOST_AUTO_TEST_CASE(warn_var_from_zero)
-{
- char const* sourceCode = R"(
- contract test {
- function f() pure public returns (uint) {
- var i = 1;
- return i;
- }
- }
- )";
- CHECK_WARNING_ALLOW_MULTI(sourceCode, (std::vector<std::string>{
- "uint8, which can hold values between 0 and 255",
- "Use of the \"var\" keyword is deprecated."
- }));
- sourceCode = R"(
- contract test {
- function f() pure public {
- var i = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
- i;
- }
- }
- )";
- CHECK_WARNING_ALLOW_MULTI(sourceCode, (std::vector<std::string>{
- "uint256, which can hold values between 0 and 115792089237316195423570985008687907853269984665640564039457584007913129639935",
- "Use of the \"var\" keyword is deprecated."
- }));
- sourceCode = R"(
- contract test {
- function f() pure public {
- var i = -2;
- i;
- }
- }
- )";
- CHECK_WARNING_ALLOW_MULTI(sourceCode, (std::vector<std::string>{
- "int8, which can hold values between -128 and 127",
- "Use of the \"var\" keyword is deprecated."
- }));
- sourceCode = R"(
- contract test {
- function f() pure public {
- for (var i = 0; i < msg.data.length; i++) { }
- }
- }
- )";
- CHECK_WARNING_ALLOW_MULTI(sourceCode, (std::vector<std::string>{
- "uint8, which can hold",
- "Use of the \"var\" keyword is deprecated."
- }));
-}
-
-BOOST_AUTO_TEST_CASE(enum_member_access)
-{
- char const* text = R"(
- contract test {
- enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
- function test()
- {
- choices = ActionChoices.GoStraight;
- }
- ActionChoices choices;
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(enum_member_access_accross_contracts)
-{
- char const* text = R"(
- contract Interface {
- enum MyEnum { One, Two }
- }
- contract Impl {
- function test() public returns (Interface.MyEnum) {
- return Interface.MyEnum.One;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(enum_invalid_member_access)
-{
- char const* text = R"(
- contract test {
- enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
- function test() public {
- choices = ActionChoices.RunAroundWavingYourHands;
- }
- ActionChoices choices;
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"RunAroundWavingYourHands\" not found or not visible after argument-dependent lookup in type(enum test.ActionChoices)");
-}
-
-BOOST_AUTO_TEST_CASE(enum_invalid_direct_member_access)
-{
- char const* text = R"(
- contract test {
- enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
- function test() public {
- choices = Sit;
- }
- ActionChoices choices;
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Undeclared identifier.");
-}
-
-BOOST_AUTO_TEST_CASE(enum_explicit_conversion_is_okay)
-{
- char const* text = R"(
- contract test {
- enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
- function test() public {
- a = uint256(ActionChoices.GoStraight);
- b = uint64(ActionChoices.Sit);
- }
- uint256 a;
- uint64 b;
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(int_to_enum_explicit_conversion_is_okay)
-{
- char const* text = R"(
- contract test {
- enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
- function test() public {
- a = 2;
- b = ActionChoices(a);
- }
- uint256 a;
- ActionChoices b;
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(enum_implicit_conversion_is_not_okay_256)
-{
- char const* text = R"(
- contract test {
- enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
- function test() public {
- a = ActionChoices.GoStraight;
- }
- uint256 a;
- }
- )";
- CHECK_ERROR(text, TypeError, "Type enum test.ActionChoices is not implicitly convertible to expected type uint256.");
-}
-
-BOOST_AUTO_TEST_CASE(enum_implicit_conversion_is_not_okay_64)
-{
- char const* text = R"(
- contract test {
- enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
- function test() public {
- b = ActionChoices.Sit;
- }
- uint64 b;
- }
- )";
- CHECK_ERROR(text, TypeError, "Type enum test.ActionChoices is not implicitly convertible to expected type uint64.");
-}
-
-BOOST_AUTO_TEST_CASE(enum_to_enum_conversion_is_not_okay)
-{
- char const* text = R"(
- contract test {
- enum Paper { Up, Down, Left, Right }
- enum Ground { North, South, West, East }
- function test() public {
- Ground(Paper.Up);
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Explicit type conversion not allowed from \"enum test.Paper\" to \"enum test.Ground\".");
-}
-
-BOOST_AUTO_TEST_CASE(enum_duplicate_values)
-{
- char const* text = R"(
- contract test {
- enum ActionChoices { GoLeft, GoRight, GoLeft, Sit }
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Identifier already declared.");
-}
-
-BOOST_AUTO_TEST_CASE(enum_name_resolution_under_current_contract_name)
-{
- char const* text = R"(
- contract A {
- enum Foo {
- First,
- Second
- }
-
- function a() public {
- A.Foo;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(private_visibility)
-{
- char const* sourceCode = R"(
- contract base {
- function f() private {}
- }
- contract derived is base {
- function g() public { f(); }
- }
- )";
- CHECK_ERROR(sourceCode, DeclarationError, "Undeclared identifier.");
-}
-
-BOOST_AUTO_TEST_CASE(private_visibility_via_explicit_base_access)
-{
- char const* sourceCode = R"(
- contract base {
- function f() private {}
- }
- contract derived is base {
- function g() public { base.f(); }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Member \"f\" not found or not visible after argument-dependent lookup in type(contract base)");
-}
-
-BOOST_AUTO_TEST_CASE(external_visibility)
-{
- char const* sourceCode = R"(
- contract c {
- function f() external {}
- function g() public { f(); }
- }
- )";
- CHECK_ERROR(sourceCode, DeclarationError, "Undeclared identifier.");
-}
-
-BOOST_AUTO_TEST_CASE(similar_name_suggestions_expected)
-{
- char const* sourceCode = R"(
- contract c {
- function func() {}
- function g() public { fun(); }
- }
- )";
- CHECK_ERROR(sourceCode, DeclarationError, "Undeclared identifier. Did you mean \"func\"?");
-}
-
-BOOST_AUTO_TEST_CASE(no_name_suggestion)
-{
- char const* sourceCode = R"(
- contract c {
- function g() public { fun(); }
- }
- )";
- CHECK_ERROR(sourceCode, DeclarationError, "Undeclared identifier.");
-}
-
-BOOST_AUTO_TEST_CASE(multiple_similar_suggestions)
-{
- char const* sourceCode = R"(
- contract c {
- function g() public {
- uint var1 = 1;
- uint var2 = 1;
- uint var3 = 1;
- uint var4 = 1;
- uint var5 = varx;
- }
- }
- )";
- CHECK_ERROR(sourceCode, DeclarationError, "Undeclared identifier. Did you mean \"var1\", \"var2\", \"var3\", \"var4\" or \"var5\"?");
-}
-
-BOOST_AUTO_TEST_CASE(multiple_scopes_suggestions)
-{
- char const* sourceCode = R"(
- contract c {
- uint log9 = 2;
- function g() public {
- uint log8 = 3;
- uint var1 = lgox;
- }
- }
- )";
- CHECK_ERROR(sourceCode, DeclarationError, "Undeclared identifier. Did you mean \"log8\", \"log9\", \"log0\", \"log1\", \"log2\", \"log3\" or \"log4\"?");
-}
-
-BOOST_AUTO_TEST_CASE(inheritence_suggestions)
-{
- char const* sourceCode = R"(
- contract a { function func() public {} }
- contract c is a {
- function g() public {
- uint var1 = fun();
- }
- }
- )";
- CHECK_ERROR(sourceCode, DeclarationError, "Undeclared identifier. Did you mean \"func\"?");
-}
-
-BOOST_AUTO_TEST_CASE(no_spurious_suggestions)
-{
- char const* sourceCode = R"(
- contract c {
- function g() public {
- uint va = 1;
- uint vb = vaxyz;
- }
- }
- )";
- CHECK_ERROR(sourceCode, DeclarationError, "Undeclared identifier.");
-
- sourceCode = R"(
- contract c {
- function g() public {
- uint va = 1;
- uint vb = x;
- }
- }
- )";
- CHECK_ERROR(sourceCode, DeclarationError, "Undeclared identifier.");
-}
-
-BOOST_AUTO_TEST_CASE(external_base_visibility)
-{
- char const* sourceCode = R"(
- contract base {
- function f() external {}
- }
- contract derived is base {
- function g() public { base.f(); }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Member \"f\" not found or not visible after argument-dependent lookup in type(contract base)");
-}
-
-BOOST_AUTO_TEST_CASE(external_argument_assign)
-{
- char const* sourceCode = R"(
- contract c {
- function f(uint a) external { a = 1; }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Expression has to be an lvalue.");
-}
-
-BOOST_AUTO_TEST_CASE(external_argument_increment)
-{
- char const* sourceCode = R"(
- contract c {
- function f(uint a) external { a++; }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Expression has to be an lvalue.");
-}
-
-BOOST_AUTO_TEST_CASE(external_argument_delete)
-{
- char const* sourceCode = R"(
- contract c {
- function f(uint a) external { delete a; }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Expression has to be an lvalue.");
-}
-
-BOOST_AUTO_TEST_CASE(test_for_bug_override_function_with_bytearray_type)
-{
- char const* sourceCode = R"(
- contract Vehicle {
- function f(bytes) external returns (uint256 r) {r = 1;}
- }
- contract Bike is Vehicle {
- function f(bytes) external returns (uint256 r) {r = 42;}
- }
- )";
- CHECK_SUCCESS(sourceCode);
-}
-
-BOOST_AUTO_TEST_CASE(array_with_nonconstant_length)
-{
- char const* text = R"(
- contract c {
- function f(uint a) public { uint8[a] x; }
- }
- )";
- CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal or constant expression.");
-}
-
-BOOST_AUTO_TEST_CASE(array_with_negative_length)
-{
- char const* text = R"(
- contract c {
- function f(uint a) public { uint8[-1] x; }
- }
- )";
- CHECK_ERROR(text, TypeError, "Array with negative length specified");
-}
-
-BOOST_AUTO_TEST_CASE(array_copy_with_different_types1)
-{
- char const* text = R"(
- contract c {
- bytes a;
- uint[] b;
- function f() public { b = a; }
- }
- )";
- CHECK_ERROR(text, TypeError, "Type bytes storage ref is not implicitly convertible to expected type uint256[] storage ref.");
-}
-
-BOOST_AUTO_TEST_CASE(array_copy_with_different_types2)
-{
- char const* text = R"(
- contract c {
- uint32[] a;
- uint8[] b;
- function f() public { b = a; }
- }
- )";
- CHECK_ERROR(text, TypeError, "Type uint32[] storage ref is not implicitly convertible to expected type uint8[] storage ref.");
-}
-
-BOOST_AUTO_TEST_CASE(array_copy_with_different_types_conversion_possible)
-{
- char const* text = R"(
- contract c {
- uint32[] a;
- uint8[] b;
- function f() public { a = b; }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(array_copy_with_different_types_static_dynamic)
-{
- char const* text = R"(
- contract c {
- uint32[] a;
- uint8[80] b;
- function f() public { a = b; }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(array_copy_with_different_types_dynamic_static)
-{
- char const* text = R"(
- contract c {
- uint[] a;
- uint[80] b;
- function f() public { b = a; }
- }
- )";
- CHECK_ERROR(text, TypeError, "Type uint256[] storage ref is not implicitly convertible to expected type uint256[80] storage ref.");
-}
-
-BOOST_AUTO_TEST_CASE(array_of_undeclared_type)
-{
- char const* text = R"(
- contract c {
- a[] public foo;
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Identifier not found or not unique.");
-}
-
-BOOST_AUTO_TEST_CASE(storage_variable_initialization_with_incorrect_type_int)
-{
- char const* text = R"(
- contract c {
- uint8 a = 1000;
- }
- )";
- CHECK_ERROR(text, TypeError, "Type int_const 1000 is not implicitly convertible to expected type uint8.");
-}
-
-BOOST_AUTO_TEST_CASE(storage_variable_initialization_with_incorrect_type_string)
-{
- char const* text = R"(
- contract c {
- uint a = "abc";
- }
- )";
- CHECK_ERROR(text, TypeError, "Type literal_string \"abc\" is not implicitly convertible to expected type uint256.");
-}
-
-BOOST_AUTO_TEST_CASE(test_fromElementaryTypeName)
-{
-
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::Int, 0, 0)) == *make_shared<IntegerType>(256, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 8, 0)) == *make_shared<IntegerType>(8, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 16, 0)) == *make_shared<IntegerType>(16, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 24, 0)) == *make_shared<IntegerType>(24, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 32, 0)) == *make_shared<IntegerType>(32, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 40, 0)) == *make_shared<IntegerType>(40, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 48, 0)) == *make_shared<IntegerType>(48, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 56, 0)) == *make_shared<IntegerType>(56, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 64, 0)) == *make_shared<IntegerType>(64, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 72, 0)) == *make_shared<IntegerType>(72, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 80, 0)) == *make_shared<IntegerType>(80, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 88, 0)) == *make_shared<IntegerType>(88, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 96, 0)) == *make_shared<IntegerType>(96, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 104, 0)) == *make_shared<IntegerType>(104, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 112, 0)) == *make_shared<IntegerType>(112, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 120, 0)) == *make_shared<IntegerType>(120, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 128, 0)) == *make_shared<IntegerType>(128, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 136, 0)) == *make_shared<IntegerType>(136, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 144, 0)) == *make_shared<IntegerType>(144, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 152, 0)) == *make_shared<IntegerType>(152, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 160, 0)) == *make_shared<IntegerType>(160, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 168, 0)) == *make_shared<IntegerType>(168, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 176, 0)) == *make_shared<IntegerType>(176, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 184, 0)) == *make_shared<IntegerType>(184, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 192, 0)) == *make_shared<IntegerType>(192, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 200, 0)) == *make_shared<IntegerType>(200, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 208, 0)) == *make_shared<IntegerType>(208, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 216, 0)) == *make_shared<IntegerType>(216, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 224, 0)) == *make_shared<IntegerType>(224, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 232, 0)) == *make_shared<IntegerType>(232, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 240, 0)) == *make_shared<IntegerType>(240, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 248, 0)) == *make_shared<IntegerType>(248, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 256, 0)) == *make_shared<IntegerType>(256, IntegerType::Modifier::Signed));
-
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UInt, 0, 0)) == *make_shared<IntegerType>(256, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 8, 0)) == *make_shared<IntegerType>(8, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 16, 0)) == *make_shared<IntegerType>(16, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 24, 0)) == *make_shared<IntegerType>(24, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 32, 0)) == *make_shared<IntegerType>(32, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 40, 0)) == *make_shared<IntegerType>(40, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 48, 0)) == *make_shared<IntegerType>(48, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 56, 0)) == *make_shared<IntegerType>(56, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 64, 0)) == *make_shared<IntegerType>(64, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 72, 0)) == *make_shared<IntegerType>(72, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 80, 0)) == *make_shared<IntegerType>(80, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 88, 0)) == *make_shared<IntegerType>(88, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 96, 0)) == *make_shared<IntegerType>(96, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 104, 0)) == *make_shared<IntegerType>(104, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 112, 0)) == *make_shared<IntegerType>(112, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 120, 0)) == *make_shared<IntegerType>(120, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 128, 0)) == *make_shared<IntegerType>(128, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 136, 0)) == *make_shared<IntegerType>(136, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 144, 0)) == *make_shared<IntegerType>(144, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 152, 0)) == *make_shared<IntegerType>(152, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 160, 0)) == *make_shared<IntegerType>(160, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 168, 0)) == *make_shared<IntegerType>(168, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 176, 0)) == *make_shared<IntegerType>(176, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 184, 0)) == *make_shared<IntegerType>(184, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 192, 0)) == *make_shared<IntegerType>(192, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 200, 0)) == *make_shared<IntegerType>(200, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 208, 0)) == *make_shared<IntegerType>(208, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 216, 0)) == *make_shared<IntegerType>(216, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 224, 0)) == *make_shared<IntegerType>(224, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 232, 0)) == *make_shared<IntegerType>(232, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 240, 0)) == *make_shared<IntegerType>(240, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 248, 0)) == *make_shared<IntegerType>(248, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 256, 0)) == *make_shared<IntegerType>(256, IntegerType::Modifier::Unsigned));
-
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::Byte, 0, 0)) == *make_shared<FixedBytesType>(1));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 1, 0)) == *make_shared<FixedBytesType>(1));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 2, 0)) == *make_shared<FixedBytesType>(2));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 3, 0)) == *make_shared<FixedBytesType>(3));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 4, 0)) == *make_shared<FixedBytesType>(4));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 5, 0)) == *make_shared<FixedBytesType>(5));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 6, 0)) == *make_shared<FixedBytesType>(6));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 7, 0)) == *make_shared<FixedBytesType>(7));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 8, 0)) == *make_shared<FixedBytesType>(8));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 9, 0)) == *make_shared<FixedBytesType>(9));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 10, 0)) == *make_shared<FixedBytesType>(10));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 11, 0)) == *make_shared<FixedBytesType>(11));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 12, 0)) == *make_shared<FixedBytesType>(12));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 13, 0)) == *make_shared<FixedBytesType>(13));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 14, 0)) == *make_shared<FixedBytesType>(14));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 15, 0)) == *make_shared<FixedBytesType>(15));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 16, 0)) == *make_shared<FixedBytesType>(16));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 17, 0)) == *make_shared<FixedBytesType>(17));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 18, 0)) == *make_shared<FixedBytesType>(18));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 19, 0)) == *make_shared<FixedBytesType>(19));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 20, 0)) == *make_shared<FixedBytesType>(20));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 21, 0)) == *make_shared<FixedBytesType>(21));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 22, 0)) == *make_shared<FixedBytesType>(22));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 23, 0)) == *make_shared<FixedBytesType>(23));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 24, 0)) == *make_shared<FixedBytesType>(24));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 25, 0)) == *make_shared<FixedBytesType>(25));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 26, 0)) == *make_shared<FixedBytesType>(26));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 27, 0)) == *make_shared<FixedBytesType>(27));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 28, 0)) == *make_shared<FixedBytesType>(28));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 29, 0)) == *make_shared<FixedBytesType>(29));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 30, 0)) == *make_shared<FixedBytesType>(30));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 31, 0)) == *make_shared<FixedBytesType>(31));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 32, 0)) == *make_shared<FixedBytesType>(32));
-
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::Fixed, 0, 0)) == *make_shared<FixedPointType>(128, 18, FixedPointType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UFixed, 0, 0)) == *make_shared<FixedPointType>(128, 18, FixedPointType::Modifier::Unsigned));
-}
-
-BOOST_AUTO_TEST_CASE(test_byte_is_alias_of_byte1)
-{
- char const* text = R"(
- contract c {
- bytes arr;
- function f() public { byte a = arr[0];}
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(warns_assigning_decimal_to_bytesxx)
-{
- char const* text = R"(
- contract Foo {
- bytes32 a = 7;
- }
- )";
- CHECK_WARNING(text, "Decimal literal assigned to bytesXX variable will be left-aligned.");
-}
-
-BOOST_AUTO_TEST_CASE(does_not_warn_assigning_hex_number_to_bytesxx)
-{
- char const* text = R"(
- contract Foo {
- bytes32 a = 0x1234;
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(explicit_conversion_from_decimal_to_bytesxx)
-{
- char const* text = R"(
- contract Foo {
- bytes32 a = bytes32(7);
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(assigning_value_to_const_variable)
-{
- char const* text = R"(
- contract Foo {
- function changeIt() public { x = 9; }
- uint constant x = 56;
- }
- )";
- CHECK_ERROR(text, TypeError, "Cannot assign to a constant variable.");
-}
-
-BOOST_AUTO_TEST_CASE(assigning_state_to_const_variable_0_4_x)
-{
- char const* text = R"(
- contract C {
- address constant x = msg.sender;
- }
- )";
- CHECK_WARNING(text, "Initial value for constant variable has to be compile-time constant.");
-}
-
-BOOST_AUTO_TEST_CASE(assigning_state_to_const_variable)
-{
- char const* text = R"(
- pragma experimental "v0.5.0";
-
- contract C {
- address constant x = msg.sender;
- }
- )";
- CHECK_ERROR(text, TypeError, "Initial value for constant variable has to be compile-time constant.");
-}
-
-BOOST_AUTO_TEST_CASE(constant_string_literal_disallows_assignment)
-{
- char const* text = R"(
- contract Test {
- string constant x = "abefghijklmnopqabcdefghijklmnopqabcdefghijklmnopqabca";
- function f() public {
- x[0] = "f";
- }
- }
- )";
-
- // Even if this is made possible in the future, we should not allow assignment
- // to elements of constant arrays.
- CHECK_ERROR(text, TypeError, "Index access for string is not possible.");
-}
-
-BOOST_AUTO_TEST_CASE(assignment_to_const_var_involving_conversion)
-{
- char const* text = R"(
- contract C {
- C constant x = C(0x123);
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(assignment_to_const_var_involving_expression)
-{
- char const* text = R"(
- contract C {
- uint constant x = 0x123 + 0x456;
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(assignment_to_const_var_involving_keccak)
-{
- char const* text = R"(
- contract C {
- bytes32 constant x = keccak256("abc");
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(assignment_to_const_array_vars)
-{
- char const* text = R"(
- contract C {
- uint[3] constant x = [uint(1), 2, 3];
- }
- )";
- CHECK_ERROR(text, TypeError, "implemented");
-}
-
-BOOST_AUTO_TEST_CASE(assignment_to_const_string_bytes)
-{
- char const* text = R"(
- contract C {
- bytes constant a = "\x00\x01\x02";
- bytes constant b = hex"000102";
- string constant c = "hello";
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(constant_struct)
-{
- char const* text = R"(
- contract C {
- struct S { uint x; uint[] y; }
- S constant x = S(5, new uint[](4));
- }
- )";
- CHECK_ERROR(text, TypeError, "implemented");
-}
-
-BOOST_AUTO_TEST_CASE(address_is_constant)
-{
- char const* text = R"(
- contract C {
- address constant x = 0x1212121212121212121212121212121212121212;
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(uninitialized_const_variable)
-{
- char const* text = R"(
- contract Foo {
- uint constant y;
- }
- )";
- CHECK_ERROR(text, TypeError, "Uninitialized \"constant\" variable.");
-}
-
-BOOST_AUTO_TEST_CASE(overloaded_function_cannot_resolve)
-{
- char const* sourceCode = R"(
- contract test {
- function f() public returns (uint) { return 1; }
- function f(uint a) public returns (uint) { return a; }
- function g() public returns (uint) { return f(3, 5); }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "No matching declaration found after argument-dependent lookup.");
-}
-
-BOOST_AUTO_TEST_CASE(ambiguous_overloaded_function)
-{
- // literal 1 can be both converted to uint and uint8, so the call is ambiguous.
- char const* sourceCode = R"(
- contract test {
- function f(uint8 a) public returns (uint) { return a; }
- function f(uint a) public returns (uint) { return 2*a; }
- function g() public returns (uint) { return f(1); }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "No unique declaration found after argument-dependent lookup.");
-}
-
-BOOST_AUTO_TEST_CASE(assignment_of_nonoverloaded_function)
-{
- char const* sourceCode = R"(
- contract test {
- function f(uint a) public returns (uint) { return 2 * a; }
- function g() public returns (uint) { var x = f; return x(7); }
- }
- )";
- CHECK_SUCCESS(sourceCode);
-}
-
-BOOST_AUTO_TEST_CASE(assignment_of_overloaded_function)
-{
- char const* sourceCode = R"(
- contract test {
- function f() public returns (uint) { return 1; }
- function f(uint a) public returns (uint) { return 2 * a; }
- function g() public returns (uint) { var x = f; return x(7); }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "No matching declaration found after variable lookup.");
-}
-
-BOOST_AUTO_TEST_CASE(external_types_clash)
-{
- char const* sourceCode = R"(
- contract base {
- enum a { X }
- function f(a) public { }
- }
- contract test is base {
- function f(uint8 a) public { }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Function overload clash during conversion to external types for arguments.");
-}
-
-BOOST_AUTO_TEST_CASE(override_changes_return_types)
-{
- char const* sourceCode = R"(
- contract base {
- function f(uint a) public returns (uint) { }
- }
- contract test is base {
- function f(uint a) public returns (uint8) { }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Overriding function return types differ");
-}
-
-BOOST_AUTO_TEST_CASE(equal_overload)
-{
- char const* sourceCode = R"(
- contract C {
- function test(uint a) public returns (uint b) { }
- function test(uint a) external {}
- }
- )";
- CHECK_ALLOW_MULTI(sourceCode, (vector<pair<Error::Type, string>>{
- {Error::Type::DeclarationError, "Function with same name and arguments defined twice."},
- {Error::Type::TypeError, "Overriding function visibility differs"}
- }));
-}
-
-BOOST_AUTO_TEST_CASE(uninitialized_var)
-{
- char const* sourceCode = R"(
- contract C {
- function f() public returns (uint) { var x; return 2; }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Assignment necessary for type detection.");
-}
-
BOOST_AUTO_TEST_CASE(string)
{
char const* sourceCode = R"(
@@ -2478,350 +346,6 @@ BOOST_AUTO_TEST_CASE(string)
BOOST_CHECK_NO_THROW(parseAndAnalyse(sourceCode));
}
-BOOST_AUTO_TEST_CASE(invalid_utf8_implicit)
-{
- char const* sourceCode = R"(
- contract C {
- string s = "\xa0\x00";
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "invalid UTF-8");
-}
-
-BOOST_AUTO_TEST_CASE(invalid_utf8_explicit)
-{
- char const* sourceCode = R"(
- contract C {
- string s = string("\xa0\x00");
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Explicit type conversion not allowed");
-}
-
-BOOST_AUTO_TEST_CASE(large_utf8_codepoint)
-{
- char const* sourceCode = R"(
- contract C {
- string s = "\xf0\x9f\xa6\x84";
- }
- )";
- CHECK_SUCCESS(sourceCode);
-}
-
-BOOST_AUTO_TEST_CASE(string_index)
-{
- char const* sourceCode = R"(
- contract C {
- string s;
- function f() public { var a = s[2]; }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Index access for string is not possible.");
-}
-
-BOOST_AUTO_TEST_CASE(string_length)
-{
- char const* sourceCode = R"(
- contract C {
- string s;
- function f() public { var a = s.length; }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Member \"length\" not found or not visible after argument-dependent lookup in string storage ref");
-}
-
-BOOST_AUTO_TEST_CASE(negative_integers_to_signed_out_of_bound)
-{
- char const* sourceCode = R"(
- contract test {
- int8 public i = -129;
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Type int_const -129 is not implicitly convertible to expected type int8.");
-}
-
-BOOST_AUTO_TEST_CASE(negative_integers_to_signed_min)
-{
- char const* sourceCode = R"(
- contract test {
- int8 public i = -128;
- }
- )";
- BOOST_CHECK_NO_THROW(parseAndAnalyse(sourceCode));
-}
-
-BOOST_AUTO_TEST_CASE(positive_integers_to_signed_out_of_bound)
-{
- char const* sourceCode = R"(
- contract test {
- int8 public j = 128;
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Type int_const 128 is not implicitly convertible to expected type int8.");
-}
-
-BOOST_AUTO_TEST_CASE(positive_integers_to_signed_out_of_bound_max)
-{
- char const* sourceCode = R"(
- contract test {
- int8 public j = 127;
- }
- )";
- BOOST_CHECK_NO_THROW(parseAndAnalyse(sourceCode));
-}
-
-BOOST_AUTO_TEST_CASE(negative_integers_to_unsigned)
-{
- char const* sourceCode = R"(
- contract test {
- uint8 public x = -1;
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Type int_const -1 is not implicitly convertible to expected type uint8.");
-}
-
-BOOST_AUTO_TEST_CASE(positive_integers_to_unsigned_out_of_bound)
-{
- char const* sourceCode = R"(
- contract test {
- uint8 public x = 700;
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Type int_const 700 is not implicitly convertible to expected type uint8.");
-}
-
-BOOST_AUTO_TEST_CASE(integer_boolean_operators)
-{
- char const* sourceCode1 = R"(
- contract test { function() public { uint x = 1; uint y = 2; x || y; } }
- )";
- CHECK_ERROR(sourceCode1, TypeError, "Operator || not compatible with types uint256 and uint256");
- char const* sourceCode2 = R"(
- contract test { function() public { uint x = 1; uint y = 2; x && y; } }
- )";
- CHECK_ERROR(sourceCode2, TypeError, "Operator && not compatible with types uint256 and uint256");
- char const* sourceCode3 = R"(
- contract test { function() public { uint x = 1; !x; } }
- )";
- CHECK_ERROR(sourceCode3, TypeError, "Unary operator ! cannot be applied to type uint256");
-}
-
-BOOST_AUTO_TEST_CASE(exp_signed_variable)
-{
- char const* sourceCode1 = R"(
- contract test { function() public { uint x = 3; int y = -4; x ** y; } }
- )";
- CHECK_ERROR(sourceCode1, TypeError, "Operator ** not compatible with types uint256 and int256");
- char const* sourceCode2 = R"(
- contract test { function() public { uint x = 3; int y = -4; y ** x; } }
- )";
- CHECK_ERROR(sourceCode2, TypeError, "Operator ** not compatible with types int256 and uint256");
- char const* sourceCode3 = R"(
- contract test { function() public { int x = -3; int y = -4; x ** y; } }
- )";
- CHECK_ERROR(sourceCode3, TypeError, "Operator ** not compatible with types int256 and int256");
-}
-
-BOOST_AUTO_TEST_CASE(reference_compare_operators)
-{
- char const* sourceCode1 = R"(
- contract test { bytes a; bytes b; function() public { a == b; } }
- )";
- CHECK_ERROR(sourceCode1, TypeError, "Operator == not compatible with types bytes storage ref and bytes storage ref");
- char const* sourceCode2 = R"(
- contract test { struct s {uint a;} s x; s y; function() public { x == y; } }
- )";
- CHECK_ERROR(sourceCode2, TypeError, "Operator == not compatible with types struct test.s storage ref and struct test.s storage ref");
-}
-
-BOOST_AUTO_TEST_CASE(overwrite_memory_location_external)
-{
- char const* sourceCode = R"(
- contract C {
- function f(uint[] memory a) external {}
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Location has to be calldata for external functions (remove the \"memory\" or \"storage\" keyword).");
-}
-
-BOOST_AUTO_TEST_CASE(overwrite_storage_location_external)
-{
- char const* sourceCode = R"(
- contract C {
- function f(uint[] storage a) external {}
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Location has to be calldata for external functions (remove the \"memory\" or \"storage\" keyword).");
-}
-
-BOOST_AUTO_TEST_CASE(storage_location_local_variables)
-{
- char const* sourceCode = R"(
- contract C {
- function f() public {
- uint[] storage x;
- uint[] memory y;
- uint[] memory z;
- x;y;z;
- }
- }
- )";
- BOOST_CHECK_NO_THROW(parseAndAnalyse(sourceCode));
-}
-
-BOOST_AUTO_TEST_CASE(no_mappings_in_memory_array)
-{
- char const* sourceCode = R"(
- contract C {
- function f() public {
- mapping(uint=>uint)[] memory x;
- }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Type mapping(uint256 => uint256)[] memory is only valid in storage.");
-}
-
-BOOST_AUTO_TEST_CASE(assignment_mem_to_local_storage_variable)
-{
- char const* sourceCode = R"(
- contract C {
- uint[] data;
- function f(uint[] x) public {
- var dataRef = data;
- dataRef = x;
- }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Type uint256[] memory is not implicitly convertible to expected type uint256[] storage pointer.");
-}
-
-BOOST_AUTO_TEST_CASE(storage_assign_to_different_local_variable)
-{
- char const* sourceCode = R"(
- contract C {
- uint[] data;
- uint8[] otherData;
- function f() public {
- uint8[] storage x = otherData;
- uint[] storage y = data;
- y = x;
- // note that data = otherData works
- }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Type uint8[] storage pointer is not implicitly convertible to expected type uint256[] storage pointer.");
-}
-
-BOOST_AUTO_TEST_CASE(uninitialized_mapping_variable)
-{
- char const* sourceCode = R"(
- contract C {
- function f() public {
- mapping(uint => uint) x;
- x;
- }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Uninitialized mapping. Mappings cannot be created dynamically, you have to assign them from a state variable");
-}
-
-BOOST_AUTO_TEST_CASE(uninitialized_mapping_array_variable)
-{
- char const* sourceCode = R"(
- contract C {
- function f() pure public {
- mapping(uint => uint)[] storage x;
- x;
- }
- }
- )";
- CHECK_WARNING(sourceCode, "Uninitialized storage pointer");
-}
-
-BOOST_AUTO_TEST_CASE(uninitialized_mapping_array_variable_050)
-{
- char const* sourceCode = R"(
- pragma experimental "v0.5.0";
- contract C {
- function f() pure public {
- mapping(uint => uint)[] storage x;
- x;
- }
- }
- )";
- CHECK_ERROR(sourceCode, DeclarationError, "Uninitialized storage pointer");
-}
-
-BOOST_AUTO_TEST_CASE(no_delete_on_storage_pointers)
-{
- char const* sourceCode = R"(
- contract C {
- uint[] data;
- function f() public {
- var x = data;
- delete x;
- }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Unary operator delete cannot be applied to type uint256[] storage pointer");
-}
-
-BOOST_AUTO_TEST_CASE(assignment_mem_storage_variable_directly)
-{
- char const* sourceCode = R"(
- contract C {
- uint[] data;
- function f(uint[] x) public {
- data = x;
- }
- }
- )";
- BOOST_CHECK_NO_THROW(parseAndAnalyse(sourceCode));
-}
-
-BOOST_AUTO_TEST_CASE(function_argument_mem_to_storage)
-{
- char const* sourceCode = R"(
- contract C {
- function f(uint[] storage x) private {
- }
- function g(uint[] x) public {
- f(x);
- }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Invalid type for argument in function call. Invalid implicit conversion from uint256[] memory to uint256[] storage pointer requested.");
-}
-
-BOOST_AUTO_TEST_CASE(function_argument_storage_to_mem)
-{
- char const* sourceCode = R"(
- contract C {
- function f(uint[] storage x) private {
- g(x);
- }
- function g(uint[] x) public {
- }
- }
- )";
- BOOST_CHECK_NO_THROW(parseAndAnalyse(sourceCode));
-}
-
-BOOST_AUTO_TEST_CASE(mem_array_assignment_changes_base_type)
-{
- // Such an assignment is possible in storage, but not in memory
- // (because it would incur an otherwise unnecessary copy).
- // This requirement might be lifted, though.
- char const* sourceCode = R"(
- contract C {
- function f(uint8[] memory x) private {
- uint[] memory y = x;
- }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Type uint8[] memory is not implicitly convertible to expected type uint256[] memory.");
-}
-
BOOST_AUTO_TEST_CASE(dynamic_return_types_not_possible)
{
char const* sourceCode = R"(
@@ -2840,1994 +364,11 @@ BOOST_AUTO_TEST_CASE(dynamic_return_types_not_possible)
CHECK_WARNING(sourceCode, "Use of the \"var\" keyword is deprecated");
}
-BOOST_AUTO_TEST_CASE(memory_arrays_not_resizeable)
-{
- char const* sourceCode = R"(
- contract C {
- function f() public {
- uint[] memory x;
- x.length = 2;
- }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Expression has to be an lvalue.");
-}
-
-BOOST_AUTO_TEST_CASE(struct_constructor)
-{
- char const* sourceCode = R"(
- contract C {
- struct S { uint a; bool x; }
- function f() public {
- S memory s = S(1, true);
- }
- }
- )";
- BOOST_CHECK_NO_THROW(parseAndAnalyse(sourceCode));
-}
-
-BOOST_AUTO_TEST_CASE(struct_constructor_nested)
-{
- char const* sourceCode = R"(
- contract C {
- struct X { uint x1; uint x2; }
- struct S { uint s1; uint[3] s2; X s3; }
- function f() public {
- uint[3] memory s2;
- S memory s = S(1, s2, X(4, 5));
- }
- }
- )";
- BOOST_CHECK_NO_THROW(parseAndAnalyse(sourceCode));
-}
-
-BOOST_AUTO_TEST_CASE(struct_named_constructor)
-{
- char const* sourceCode = R"(
- contract C {
- struct S { uint a; bool x; }
- function f() public {
- S memory s = S({a: 1, x: true});
- }
- }
- )";
- BOOST_CHECK_NO_THROW(parseAndAnalyse(sourceCode));
-}
-
-BOOST_AUTO_TEST_CASE(literal_strings)
-{
- char const* text = R"(
- contract Foo {
- function f() public {
- string memory long = "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
- string memory short = "123";
- long; short;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(string_bytes_conversion)
-{
- char const* text = R"(
- contract Test {
- string s;
- bytes b;
- function h(string _s) external { bytes(_s).length; }
- function i(string _s) internal { bytes(_s).length; }
- function j() internal { bytes(s).length; }
- function k(bytes _b) external { string(_b); }
- function l(bytes _b) internal { string(_b); }
- function m() internal { string(b); }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(inheriting_from_library)
-{
- char const* text = R"(
- library Lib {}
- contract Test is Lib {}
- )";
- CHECK_ERROR(text, TypeError, "Libraries cannot be inherited from.");
-}
-
-BOOST_AUTO_TEST_CASE(inheriting_library)
-{
- char const* text = R"(
- contract Test {}
- library Lib is Test {}
- )";
- CHECK_ERROR(text, TypeError, "Library is not allowed to inherit.");
-}
-
-BOOST_AUTO_TEST_CASE(library_having_variables)
-{
- char const* text = R"(
- library Lib { uint x; }
- )";
- CHECK_ERROR(text, TypeError, "Library cannot have non-constant state variables");
-}
-
-BOOST_AUTO_TEST_CASE(valid_library)
-{
- char const* text = R"(
- library Lib { uint constant x = 9; }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(call_to_library_function)
-{
- char const* text = R"(
- library Lib {
- function min(uint, uint) public returns (uint);
- }
- contract Test {
- function f() public {
- uint t = Lib.min(12, 7);
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(creating_contract_within_the_contract)
-{
- char const* sourceCode = R"(
- contract Test {
- function f() public { var x = new Test(); }
- }
- )";
- CHECK_ERROR(sourceCode, TypeError, "Circular reference for contract creation (cannot create instance of derived or same contract).");
-}
-
-BOOST_AUTO_TEST_CASE(array_out_of_bound_access)
-{
- char const* text = R"(
- contract c {
- uint[2] dataArray;
- function set5th() public returns (bool) {
- dataArray[5] = 2;
- return true;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Out of bounds array access.");
-}
-
-BOOST_AUTO_TEST_CASE(literal_string_to_storage_pointer)
-{
- char const* text = R"(
- contract C {
- function f() public { string x = "abc"; }
- }
- )";
- CHECK_ERROR(text, TypeError, "Type literal_string \"abc\" is not implicitly convertible to expected type string storage pointer.");
-}
-
-BOOST_AUTO_TEST_CASE(non_initialized_references)
-{
- char const* text = R"(
- contract c
- {
- struct s {
- uint a;
- }
- function f() public {
- s storage x;
- x.a = 2;
- }
- }
- )";
-
- CHECK_WARNING(text, "Uninitialized storage pointer");
-}
-
-BOOST_AUTO_TEST_CASE(non_initialized_references_050)
-{
- char const* text = R"(
- pragma experimental "v0.5.0";
- contract c
- {
- struct s {
- uint a;
- }
- function f() public {
- s storage x;
- }
- }
- )";
-
- CHECK_ERROR(text, DeclarationError, "Uninitialized storage pointer");
-}
-
-BOOST_AUTO_TEST_CASE(keccak256_with_large_integer_constant)
-{
- char const* text = R"(
- contract c
- {
- function f() public { keccak256(2**500); }
- }
- )";
- CHECK_ERROR(text, TypeError, "Invalid rational number (too large or division by zero).");
-}
-
-BOOST_AUTO_TEST_CASE(cyclic_binary_dependency)
-{
- char const* text = R"(
- contract A { function f() public { new B(); } }
- contract B { function f() public { new C(); } }
- contract C { function f() public { new A(); } }
- )";
- CHECK_ERROR(text, TypeError, "Circular reference for contract creation (cannot create instance of derived or same contract).");
-}
-
-BOOST_AUTO_TEST_CASE(cyclic_binary_dependency_via_inheritance)
-{
- char const* text = R"(
- contract A is B { }
- contract B { function f() public { new C(); } }
- contract C { function f() public { new A(); } }
- )";
- CHECK_ERROR(text, TypeError, "Definition of base has to precede definition of derived contract");
-}
-
-BOOST_AUTO_TEST_CASE(multi_variable_declaration_fail)
-{
- char const* text = R"(
- contract C { function f() public { var (x,y); x = 1; y = 1;} }
- )";
- CHECK_ERROR(text, TypeError, "Assignment necessary for type detection.");
-}
-
-BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fine)
-{
- char const* text = R"(
- contract C {
- function three() public returns (uint, uint, uint);
- function two() public returns (uint, uint);
- function none();
- function f() public {
- var (a,) = three();
- var (b,c,) = two();
- var (,d) = three();
- var (,e,g) = two();
- var (,,) = three();
- var () = none();
- a;b;c;d;e;g;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_1)
-{
- char const* text = R"(
- contract C {
- function one() public returns (uint);
- function f() public { var (a, b, ) = one(); }
- }
- )";
- CHECK_ERROR(text, TypeError, "Not enough components (1) in value to assign all variables (2).");
-}
-BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_2)
-{
- char const* text = R"(
- contract C {
- function one() public returns (uint);
- function f() public { var (a, , ) = one(); }
- }
- )";
- CHECK_ERROR(text, TypeError, "Not enough components (1) in value to assign all variables (2).");
-}
-
-BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_3)
-{
- char const* text = R"(
- contract C {
- function one() public returns (uint);
- function f() public { var (, , a) = one(); }
- }
- )";
- CHECK_ERROR(text, TypeError, "Not enough components (1) in value to assign all variables (2).");
-}
-
-BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_4)
-{
- char const* text = R"(
- contract C {
- function one() public returns (uint);
- function f() public { var (, a, b) = one(); }
- }
- )";
- CHECK_ERROR(text, TypeError, "Not enough components (1) in value to assign all variables (2).");
-}
-
-BOOST_AUTO_TEST_CASE(tuples)
-{
- char const* text = R"(
- contract C {
- function f() public {
- uint a = (1);
- var (b,) = (uint8(1),);
- var (c,d) = (uint32(1), 2 + a);
- var (e,) = (uint64(1), 2, b);
- a;b;c;d;e;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(tuples_empty_components)
-{
- char const* text = R"(
- contract C {
- function f() public {
- (1,,2);
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Tuple component cannot be empty.");
-}
-
-BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_5)
-{
- char const* text = R"(
- contract C {
- function one() public returns (uint);
- function f() public { var (,) = one(); }
- }
- )";
- CHECK_ERROR(text, TypeError, "Wildcard both at beginning and end of variable declaration list is only allowed if the number of components is equal.");
-}
-
-BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_6)
-{
- char const* text = R"(
- contract C {
- function two() public returns (uint, uint);
- function f() public { var (a, b, c) = two(); }
- }
- )";
- CHECK_ERROR(text, TypeError, "Not enough components (2) in value to assign all variables (3)");
-}
-
-BOOST_AUTO_TEST_CASE(tuple_assignment_from_void_function)
-{
- char const* text = R"(
- contract C {
- function f() public { }
- function g() public {
- var (x,) = (f(), f());
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Cannot declare variable with void (empty tuple) type.");
-}
-
-BOOST_AUTO_TEST_CASE(tuple_compound_assignment)
-{
- char const* text = R"(
- contract C {
- function f() public returns (uint a, uint b) {
- (a, b) += (1, 1);
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Compound assignment is not allowed for tuple types.");
-}
-
-BOOST_AUTO_TEST_CASE(member_access_parser_ambiguity)
-{
- char const* text = R"(
- contract C {
- struct R { uint[10][10] y; }
- struct S { uint a; uint b; uint[20][20][20] c; R d; }
- S data;
- function f() public {
- C.S x = data;
- C.S memory y;
- C.S[10] memory z;
- C.S[10];
- y.a = 2;
- x.c[1][2][3] = 9;
- x.d.y[2][2] = 3;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(using_for_library)
-{
- char const* text = R"(
- library D { }
- contract C {
- using D for uint;
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(using_for_not_library)
-{
- char const* text = R"(
- contract D { }
- contract C {
- using D for uint;
- }
- )";
- CHECK_ERROR(text, TypeError, "Library name expected.");
-}
-
-BOOST_AUTO_TEST_CASE(using_for_function_exists)
-{
- char const* text = R"(
- library D { function double(uint self) public returns (uint) { return 2*self; } }
- contract C {
- using D for uint;
- function f(uint a) public {
- a.double;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(using_for_function_on_int)
-{
- char const* text = R"(
- library D { function double(uint self) public returns (uint) { return 2*self; } }
- contract C {
- using D for uint;
- function f(uint a) public returns (uint) {
- return a.double();
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(using_for_function_on_struct)
-{
- char const* text = R"(
- library D { struct s { uint a; } function mul(s storage self, uint x) public returns (uint) { return self.a *= x; } }
- contract C {
- using D for D.s;
- D.s x;
- function f(uint a) public returns (uint) {
- return x.mul(a);
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(using_for_overload)
-{
- char const* text = R"(
- library D {
- struct s { uint a; }
- function mul(s storage self, uint x) public returns (uint) { return self.a *= x; }
- function mul(s storage, bytes32) public returns (bytes32) { }
- }
- contract C {
- using D for D.s;
- D.s x;
- function f(uint a) public returns (uint) {
- return x.mul(a);
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(using_for_by_name)
-{
- char const* text = R"(
- library D { struct s { uint a; } function mul(s storage self, uint x) public returns (uint) { return self.a *= x; } }
- contract C {
- using D for D.s;
- D.s x;
- function f(uint a) public returns (uint) {
- return x.mul({x: a});
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(using_for_mismatch)
-{
- char const* text = R"(
- library D { function double(bytes32 self) public returns (uint) { return 2; } }
- contract C {
- using D for uint;
- function f(uint a) public returns (uint) {
- return a.double();
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"double\" not found or not visible after argument-dependent lookup in uint256");
-}
-
-BOOST_AUTO_TEST_CASE(using_for_not_used)
-{
- // This is an error because the function is only bound to uint.
- // Had it been bound to *, it would have worked.
- char const* text = R"(
- library D { function double(uint self) public returns (uint) { return 2; } }
- contract C {
- using D for uint;
- function f(uint16 a) public returns (uint) {
- return a.double();
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"double\" not found or not visible after argument-dependent lookup in uint16");
-}
-
-BOOST_AUTO_TEST_CASE(library_memory_struct)
-{
- char const* text = R"(
- pragma experimental ABIEncoderV2;
- library c {
- struct S { uint x; }
- function f() public returns (S ) {}
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(using_for_arbitrary_mismatch)
-{
- // Bound to a, but self type does not match.
- char const* text = R"(
- library D { function double(bytes32 self) public returns (uint) { return 2; } }
- contract C {
- using D for *;
- function f(uint a) public returns (uint) {
- return a.double();
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"double\" not found or not visible after argument-dependent lookup in uint256");
-}
-
-BOOST_AUTO_TEST_CASE(bound_function_in_var)
-{
- char const* text = R"(
- library D { struct s { uint a; } function mul(s storage self, uint x) public returns (uint) { return self.a *= x; } }
- contract C {
- using D for D.s;
- D.s x;
- function f(uint a) public returns (uint) {
- var g = x.mul;
- return g({x: a});
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(create_memory_arrays)
-{
- char const* text = R"(
- library L {
- struct R { uint[10][10] y; }
- struct S { uint a; uint b; uint[20][20][20] c; R d; }
- }
- contract C {
- function f(uint size) public {
- L.S[][] memory x = new L.S[][](10);
- var y = new uint[](20);
- var z = new bytes(size);
- x;y;z;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(mapping_in_memory_array)
-{
- char const* text = R"(
- contract C {
- function f(uint size) public {
- var x = new mapping(uint => uint)[](4);
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Type cannot live outside storage.");
-}
-
-BOOST_AUTO_TEST_CASE(new_for_non_array)
-{
- char const* text = R"(
- contract C {
- function f(uint size) public {
- var x = new uint(7);
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Contract or array type expected.");
-}
-
-BOOST_AUTO_TEST_CASE(invalid_args_creating_memory_array)
-{
- char const* text = R"(
- contract C {
- function f(uint size) public {
- var x = new uint[]();
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Wrong argument count for function call: 0 arguments given but expected 1.");
-}
-
-BOOST_AUTO_TEST_CASE(invalid_args_creating_struct)
-{
- char const* text = R"(
- contract C {
- struct S { uint a; uint b; }
-
- function f() public {
- var s = S({a: 1});
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Wrong argument count for struct constructor: 1 arguments given but expected 2.");
-}
-
-BOOST_AUTO_TEST_CASE(function_overload_array_type)
-{
- char const* text = R"(
- contract M {
- function f(uint[]);
- function f(int[]);
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(inline_array_declaration_and_passing_implicit_conversion)
-{
- char const* text = R"(
- contract C {
- function f() public returns (uint) {
- uint8 x = 7;
- uint16 y = 8;
- uint32 z = 9;
- uint32[3] memory ending = [x, y, z];
- return (ending[1]);
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(inline_array_declaration_and_passing_implicit_conversion_strings)
-{
- char const* text = R"(
- contract C {
- function f() public returns (string) {
- string memory x = "Hello";
- string memory y = "World";
- string[2] memory z = [x, y];
- return (z[0]);
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(inline_array_declaration_const_int_conversion)
-{
- char const* text = R"(
- contract C {
- function f() public returns (uint) {
- uint8[4] memory z = [1,2,3,5];
- return (z[0]);
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(inline_array_declaration_const_string_conversion)
-{
- char const* text = R"(
- contract C {
- function f() public returns (string) {
- string[2] memory z = ["Hello", "World"];
- return (z[0]);
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(inline_array_declaration_no_type)
-{
- char const* text = R"(
- contract C {
- function f() public returns (uint) {
- return ([4,5,6][1]);
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(inline_array_declaration_no_type_strings)
-{
- char const* text = R"(
- contract C {
- function f() public returns (string) {
- return (["foo", "man", "choo"][1]);
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(inline_struct_declaration_arrays)
-{
- char const* text = R"(
- contract C {
- struct S {
- uint a;
- string b;
- }
- function f() {
- S[2] memory x = [S({a: 1, b: "fish"}), S({a: 2, b: "fish"})];
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(invalid_types_in_inline_array)
-{
- char const* text = R"(
- contract C {
- function f() public {
- uint[3] x = [45, 'foo', true];
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Unable to deduce common type for array elements.");
-}
-
-BOOST_AUTO_TEST_CASE(dynamic_inline_array)
-{
- char const* text = R"(
- contract C {
- function f() public {
- uint8[4][4] memory dyn = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]];
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(lvalues_as_inline_array)
-{
- char const* text = R"(
- contract C {
- function f() public {
- [1, 2, 3]++;
- [1, 2, 3] = [4, 5, 6];
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Inline array type cannot be declared as LValue.");
-}
-
-BOOST_AUTO_TEST_CASE(break_not_in_loop)
-{
- char const* text = R"(
- contract C {
- function f() public {
- if (true)
- break;
- }
- }
- )";
- CHECK_ERROR(text, SyntaxError, "\"break\" has to be in a \"for\" or \"while\" loop.");
-}
-
-BOOST_AUTO_TEST_CASE(continue_not_in_loop)
-{
- char const* text = R"(
- contract C {
- function f() public {
- if (true)
- continue;
- }
- }
- )";
- CHECK_ERROR(text, SyntaxError, "\"continue\" has to be in a \"for\" or \"while\" loop.");
-}
-
-BOOST_AUTO_TEST_CASE(continue_not_in_loop_2)
-{
- char const* text = R"(
- contract C {
- function f() public {
- while (true)
- {
- }
- continue;
- }
- }
- )";
- CHECK_ERROR(text, SyntaxError, "\"continue\" has to be in a \"for\" or \"while\" loop.");
-}
-
-BOOST_AUTO_TEST_CASE(invalid_different_types_for_conditional_expression)
-{
- char const* text = R"(
- contract C {
- function f() public {
- true ? true : 2;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "True expression's type bool doesn't match false expression's type uint8.");
-}
-
-BOOST_AUTO_TEST_CASE(left_value_in_conditional_expression_not_supported_yet)
-{
- char const* text = R"(
- contract C {
- function f() public {
- uint x;
- uint y;
- (true ? x : y) = 1;
- }
- }
- )";
- CHECK_ERROR_ALLOW_MULTI(text, TypeError, (std::vector<std::string>{
- "Conditional expression as left value is not supported yet.",
- "Expression has to be an lvalue"
- }));
-}
-
-BOOST_AUTO_TEST_CASE(conditional_expression_with_different_struct)
-{
- char const* text = R"(
- contract C {
- struct s1 {
- uint x;
- }
- struct s2 {
- uint x;
- }
- function f() public {
- s1 memory x;
- s2 memory y;
- true ? x : y;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "True expression's type struct C.s1 memory doesn't match false expression's type struct C.s2 memory.");
-}
-
-BOOST_AUTO_TEST_CASE(conditional_expression_with_different_function_type)
-{
- char const* text = R"(
- contract C {
- function x(bool) public {}
- function y() public {}
-
- function f() public {
- true ? x : y;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "True expression's type function (bool) doesn't match false expression's type function ().");
-}
-
-BOOST_AUTO_TEST_CASE(conditional_expression_with_different_enum)
-{
- char const* text = R"(
- contract C {
- enum small { A, B, C, D }
- enum big { A, B, C, D }
-
- function f() public {
- small x;
- big y;
-
- true ? x : y;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "True expression's type enum C.small doesn't match false expression's type enum C.big.");
-}
-
-BOOST_AUTO_TEST_CASE(conditional_expression_with_different_mapping)
-{
- char const* text = R"(
- contract C {
- mapping(uint8 => uint8) table1;
- mapping(uint32 => uint8) table2;
-
- function f() public {
- true ? table1 : table2;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "True expression's type mapping(uint8 => uint8) doesn't match false expression's type mapping(uint32 => uint8).");
-}
-
-BOOST_AUTO_TEST_CASE(conditional_with_all_types)
-{
- char const* text = R"(
- contract C {
- struct s1 {
- uint x;
- }
- s1 struct_x;
- s1 struct_y;
-
- function fun_x() public {}
- function fun_y() public {}
-
- enum small { A, B, C, D }
-
- mapping(uint8 => uint8) table1;
- mapping(uint8 => uint8) table2;
-
- function f() public {
- // integers
- uint x;
- uint y;
- uint g = true ? x : y;
- g += 1; // Avoid unused var warning
-
- // integer constants
- uint h = true ? 1 : 3;
- h += 1; // Avoid unused var warning
-
- // string literal
- var i = true ? "hello" : "world";
- i = "used"; //Avoid unused var warning
- }
- function f2() public {
- // bool
- bool j = true ? true : false;
- j = j && true; // Avoid unused var warning
-
- // real is not there yet.
-
- // array
- byte[2] memory a;
- byte[2] memory b;
- var k = true ? a : b;
- k[0] = byte(0); //Avoid unused var warning
-
- bytes memory e;
- bytes memory f;
- var l = true ? e : f;
- l[0] = byte(0); // Avoid unused var warning
-
- // fixed bytes
- bytes2 c;
- bytes2 d;
- var m = true ? c : d;
- m &= m;
-
- }
- function f3() public {
- // contract doesn't fit in here
-
- // struct
- struct_x = true ? struct_x : struct_y;
-
- // function
- var r = true ? fun_x : fun_y;
- r(); // Avoid unused var warning
- // enum
- small enum_x;
- small enum_y;
- enum_x = true ? enum_x : enum_y;
-
- // tuple
- var (n, o) = true ? (1, 2) : (3, 4);
- (n, o) = (o, n); // Avoid unused var warning
- // mapping
- var p = true ? table1 : table2;
- p[0] = 0; // Avoid unused var warning
- // typetype
- var q = true ? uint32(1) : uint32(2);
- q += 1; // Avoid unused var warning
- // modifier doesn't fit in here
-
- // magic doesn't fit in here
-
- // module doesn't fit in here
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(index_access_for_bytes)
-{
- char const* text = R"(
- contract C {
- bytes20 x;
- function f(bytes16 b) public {
- b[uint(x[2])];
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(uint7_and_uintM_as_identifier)
-{
- char const* text = R"(
- contract test {
- string uintM = "Hello 4 you";
- function f() public {
- uint8 uint7 = 3;
- uint7 = 5;
- string memory intM;
- uint bytesM = 21;
- intM; bytesM;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(varM_disqualified_as_keyword)
-{
- char const* text = R"(
- contract test {
- function f() public {
- uintM something = 3;
- intM should = 4;
- bytesM fail = "now";
- }
- }
- )";
- CHECK_ERROR_ALLOW_MULTI(text, DeclarationError, (std::vector<std::string>{
- "Identifier not found or not unique.",
- "Identifier not found or not unique.",
- "Identifier not found or not unique."
- }));
-}
-
-BOOST_AUTO_TEST_CASE(modifier_is_not_a_valid_typename)
-{
- char const* text = R"(
- contract test {
- modifier mod() { _; }
-
- function f() public {
- mod g;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Name has to refer to a struct, enum or contract.");
-}
-
-BOOST_AUTO_TEST_CASE(modifier_is_not_a_valid_typename_is_not_fatal)
-{
- char const* text = R"(
- contract test {
- modifier mod() { _; }
-
- function f() public {
- mod g;
- g = f;
- }
- }
- )";
- CHECK_ERROR_ALLOW_MULTI(text, TypeError, (std::vector<std::string>{"Name has to refer to a struct, enum or contract."}));
-}
-
-BOOST_AUTO_TEST_CASE(function_is_not_a_valid_typename)
-{
- char const* text = R"(
- contract test {
- function foo() public {
- }
-
- function f() public {
- foo g;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Name has to refer to a struct, enum or contract.");
-}
-
-BOOST_AUTO_TEST_CASE(long_uint_variable_fails)
-{
- char const* text = R"(
- contract test {
- function f() public {
- uint99999999999999999999999999 something = 3;
- }
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Identifier not found or not unique.");
-}
-
-BOOST_AUTO_TEST_CASE(bytes10abc_is_identifier)
-{
- char const* text = R"(
- contract test {
- function f() public {
- bytes32 bytes10abc = "abc";
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(int10abc_is_identifier)
-{
- char const* text = R"(
- contract test {
- function f() public {
- uint uint10abc = 3;
- int int10abc = 4;
- uint10abc; int10abc;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(library_functions_do_not_have_value)
-{
- char const* text = R"(
- library L { function l() public {} }
- contract test {
- function f() public {
- L.l.value;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"value\" not found or not visible after argument-dependent lookup in function ()");
-}
-
-BOOST_AUTO_TEST_CASE(invalid_fixed_types_0x7_mxn)
-{
- char const* text = R"(
- contract test {
- fixed0x7 a = .3;
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Identifier not found");
-}
-
-BOOST_AUTO_TEST_CASE(invalid_fixed_types_long_invalid_identifier)
-{
- char const* text = R"(
- contract test {
- fixed99999999999999999999999999999999999999x7 b = 9.5;
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Identifier not found");
-}
-
-BOOST_AUTO_TEST_CASE(invalid_fixed_types_7x8_mxn)
-{
- char const* text = R"(
- contract test {
- fixed7x8 c = 3.12345678;
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Identifier not found");
-}
-
-BOOST_AUTO_TEST_CASE(library_instances_cannot_be_used)
-{
- char const* text = R"(
- library L { function l() public {} }
- contract test {
- function f() public {
- L x;
- x.l();
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"l\" not found or not visible after argument-dependent lookup in library L");
-}
-
-BOOST_AUTO_TEST_CASE(invalid_fixed_type_long)
-{
- char const* text = R"(
- contract test {
- function f() public {
- fixed8x888888888888888888888888888888888888888888888888888 b;
- }
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Identifier not found");
-}
-
-BOOST_AUTO_TEST_CASE(fixed_type_int_conversion)
-{
- char const* text = R"(
- contract test {
- function f() public {
- uint64 a = 3;
- int64 b = 4;
- fixed c = b;
- ufixed d = a;
- c; d;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(fixed_type_rational_int_conversion)
-{
- char const* text = R"(
- contract test {
- function f() public {
- fixed c = 3;
- ufixed d = 4;
- c; d;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(fixed_type_rational_fraction_conversion)
-{
- char const* text = R"(
- contract test {
- function f() public {
- fixed a = 4.5;
- ufixed d = 2.5;
- a; d;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(invalid_int_implicit_conversion_from_fixed)
-{
- char const* text = R"(
- contract test {
- function f() public {
- fixed a = 4.5;
- int b = a;
- a; b;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Type fixed128x18 is not implicitly convertible to expected type int256");
-}
-
-BOOST_AUTO_TEST_CASE(rational_unary_operation)
-{
- char const* text = R"(
- contract test {
- function f() pure public {
- ufixed16x2 a = 3.25;
- fixed16x2 b = -3.25;
- a; b;
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-
- // Test deprecation warning under < 0.5.0
- text = R"(
- contract test {
- function f() pure public {
- ufixed16x2 a = +3.25;
- fixed16x2 b = -3.25;
- a; b;
- }
- }
- )";
- CHECK_WARNING(text, "Use of unary + is deprecated");
- text = R"(
- contract test {
- function f(uint x) pure public {
- uint y = +x;
- y;
- }
- }
- )";
- CHECK_WARNING(text,"Use of unary + is deprecated");
-
- // Test syntax error under 0.5.0
- text = R"(
- pragma experimental "v0.5.0";
- contract test {
- function f() pure public {
- ufixed16x2 a = +3.25;
- fixed16x2 b = -3.25;
- a; b;
- }
- }
- )";
- CHECK_ERROR(text, SyntaxError, "Use of unary + is deprecated");
- text = R"(
- pragma experimental "v0.5.0";
- contract test {
- function f(uint x) pure public {
- uint y = +x;
- y;
- }
- }
- )";
- CHECK_ERROR(text, SyntaxError, "Use of unary + is deprecated");
-}
-
-BOOST_AUTO_TEST_CASE(leading_zero_rationals_convert)
-{
- char const* text = R"(
- contract A {
- function f() pure public {
- ufixed16x2 a = 0.5;
- ufixed256x52 b = 0.0000000000000006661338147750939242541790008544921875;
- fixed16x2 c = -0.5;
- fixed256x52 d = -0.0000000000000006661338147750939242541790008544921875;
- a; b; c; d;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(size_capabilities_of_fixed_point_types)
-{
- char const* text = R"(
- contract test {
- function f() public {
- ufixed256x1 a = 123456781234567979695948382928485849359686494864095409282048094275023098123.5;
- ufixed256x77 b = 0.920890746623327805482905058466021565416131529487595827354393978494366605267637;
- ufixed224x78 c = 0.000000000001519884736399797998492268541131529487595827354393978494366605267646;
- fixed256x1 d = -123456781234567979695948382928485849359686494864095409282048094275023098123.5;
- fixed256x76 e = -0.93322335481643744342575580035176794825198893968114429702091846411734101080123;
- fixed256x79 g = -0.0001178860664374434257558003517679482519889396811442970209184641173410108012309;
- a; b; c; d; e; g;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(zero_handling)
-{
- char const* text = R"(
- contract test {
- function f() public {
- fixed16x2 a = 0; a;
- ufixed32x1 b = 0; b;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(fixed_type_invalid_implicit_conversion_size)
-{
- char const* text = R"(
- contract test {
- function f() public {
- ufixed a = 11/4;
- ufixed248x8 b = a; b;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Type ufixed128x18 is not implicitly convertible to expected type ufixed248x8");
-}
-
-BOOST_AUTO_TEST_CASE(fixed_type_invalid_implicit_conversion_lost_data)
-{
- char const* text = R"(
- contract test {
- function f() public {
- ufixed256x1 a = 1/3; a;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "is not implicitly convertible to expected type ufixed256x1");
-}
-
-BOOST_AUTO_TEST_CASE(fixed_type_valid_explicit_conversions)
-{
- char const* text = R"(
- contract test {
- function f() public {
- ufixed256x80 a = ufixed256x80(1/3); a;
- ufixed248x80 b = ufixed248x80(1/3); b;
- ufixed8x1 c = ufixed8x1(1/3); c;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(invalid_array_declaration_with_rational)
-{
- char const* text = R"(
- contract test {
- function f() public {
- uint[3.5] a; a;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Array with fractional length specified.");
-}
-
-BOOST_AUTO_TEST_CASE(invalid_array_declaration_with_signed_fixed_type)
-{
- char const* text = R"(
- contract test {
- function f() public {
- uint[fixed(3.5)] a; a;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal or constant expression.");
-}
-
-BOOST_AUTO_TEST_CASE(invalid_array_declaration_with_unsigned_fixed_type)
-{
- char const* text = R"(
- contract test {
- function f() public {
- uint[ufixed(3.5)] a; a;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal or constant expression.");
-}
-
-BOOST_AUTO_TEST_CASE(rational_to_bytes_implicit_conversion)
-{
- char const* text = R"(
- contract test {
- function f() public {
- bytes32 c = 3.2; c;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "is not implicitly convertible to expected type bytes32");
-}
-
-BOOST_AUTO_TEST_CASE(fixed_to_bytes_implicit_conversion)
-{
- char const* text = R"(
- contract test {
- function f() public {
- fixed a = 3.25;
- bytes32 c = a; c;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "fixed128x18 is not implicitly convertible to expected type bytes32");
-}
-
-BOOST_AUTO_TEST_CASE(mapping_with_fixed_literal)
-{
- char const* text = R"(
- contract test {
- mapping(ufixed8x1 => string) fixedString;
- function f() public {
- fixedString[0.5] = "Half";
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(fixed_points_inside_structs)
-{
- char const* text = R"(
- contract test {
- struct myStruct {
- ufixed a;
- int b;
- }
- myStruct a = myStruct(3.125, 3);
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(inline_array_fixed_types)
-{
- char const* text = R"(
- contract test {
- function f() public {
- fixed[3] memory a = [fixed(3.5), fixed(-4.25), fixed(967.125)];
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(inline_array_rationals)
-{
- char const* text = R"(
- contract test {
- function f() public {
- ufixed128x3[4] memory a = [ufixed128x3(3.5), 4.125, 2.5, 4.0];
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(rational_index_access)
-{
- char const* text = R"(
- contract test {
- function f() public {
- uint[] memory a;
- a[.5];
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "rational_const 1 / 2 is not implicitly convertible to expected type uint256");
-}
-
-BOOST_AUTO_TEST_CASE(rational_to_fixed_literal_expression)
-{
- char const* text = R"(
- contract test {
- function f() public {
- ufixed64x8 a = 3.5 * 3;
- ufixed64x8 b = 4 - 2.5;
- ufixed64x8 c = 11 / 4;
- ufixed240x5 d = 599 + 0.21875;
- ufixed256x80 e = ufixed256x80(35.245 % 12.9);
- ufixed256x80 f = ufixed256x80(1.2 % 2);
- fixed g = 2 ** -2;
- a; b; c; d; e; f; g;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(rational_as_exponent_value_signed)
-{
- char const* text = R"(
- contract test {
- function f() public {
- fixed g = 2 ** -2.2;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "not compatible with types");
-}
-
-BOOST_AUTO_TEST_CASE(rational_as_exponent_value_unsigned)
-{
- char const* text = R"(
- contract test {
- function f() public {
- ufixed b = 3 ** 2.5;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "not compatible with types");
-}
-
-BOOST_AUTO_TEST_CASE(rational_as_exponent_half)
-{
- char const* text = R"(
- contract test {
- function f() public {
- 2 ** (1/2);
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "not compatible with types");
-}
-
-BOOST_AUTO_TEST_CASE(rational_as_exponent_value_neg_quarter)
-{
- char const* text = R"(
- contract test {
- function f() public {
- 42 ** (-1/4);
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "not compatible with types");
-}
-
-BOOST_AUTO_TEST_CASE(fixed_point_casting_exponents_15)
-{
- char const* text = R"(
- contract test {
- function f() public {
- var a = 3 ** ufixed(1.5);
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "not compatible with types");
-}
-
-BOOST_AUTO_TEST_CASE(fixed_point_casting_exponents_neg)
-{
- char const* text = R"(
- contract test {
- function f() public {
- var c = 42 ** fixed(-1/4);
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "not compatible with types");
-}
-
-BOOST_AUTO_TEST_CASE(var_capable_of_holding_constant_rationals)
-{
- char const* text = R"(
- contract test {
- function f() public {
- var a = 0.12345678;
- var b = 12345678.352;
- var c = 0.00000009;
- a; b; c;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(var_and_rational_with_tuple)
-{
- char const* text = R"(
- contract test {
- function f() public {
- var (a, b) = (.5, 1/3);
- a; b;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(var_handle_divided_integers)
-{
- char const* text = R"(
- contract test {
- function f() public {
- var x = 1/3;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(rational_bitnot_unary_operation)
-{
- char const* text = R"(
- contract test {
- function f() public {
- ~fixed(3.5);
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "cannot be applied");
-}
-
-BOOST_AUTO_TEST_CASE(rational_bitor_binary_operation)
-{
- char const* text = R"(
- contract test {
- function f() public {
- fixed(1.5) | 3;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "not compatible with types");
-}
-
-BOOST_AUTO_TEST_CASE(rational_bitxor_binary_operation)
-{
- char const* text = R"(
- contract test {
- function f() public {
- fixed(1.75) ^ 3;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "not compatible with types");
-}
-
-BOOST_AUTO_TEST_CASE(rational_bitand_binary_operation)
-{
- char const* text = R"(
- contract test {
- function f() public {
- fixed(1.75) & 3;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "not compatible with types");
-}
-
-BOOST_AUTO_TEST_CASE(missing_bool_conversion)
-{
- char const* text = R"(
- contract test {
- function b(uint a) public {
- bool(a == 1);
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(integer_and_fixed_interaction)
-{
- char const* text = R"(
- contract test {
- function f() public {
- ufixed a = uint64(1) + ufixed(2);
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(one_divided_by_three_integer_conversion)
-{
- char const* text = R"(
- contract test {
- function f() public {
- uint a = 1/3;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "is not implicitly convertible to expected type uint256. Try converting to type ufixed256x77");
-}
-
-BOOST_AUTO_TEST_CASE(unused_return_value)
-{
- char const* text = R"(
- contract test {
- function g() public returns (uint) {}
- function f() public {
- g();
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(unused_return_value_send)
-{
- char const* text = R"(
- contract test {
- function f() public {
- address(0x12).send(1);
- }
- }
- )";
- CHECK_WARNING(text, "Failure condition of 'send' ignored. Consider using 'transfer' instead.");
-}
-
-BOOST_AUTO_TEST_CASE(unused_return_value_call)
-{
- char const* text = R"(
- contract test {
- function f() public {
- address(0x12).call("abc");
- }
- }
- )";
- CHECK_WARNING(text, "Return value of low-level calls not used");
-}
-
-BOOST_AUTO_TEST_CASE(unused_return_value_call_value)
-{
- char const* text = R"(
- contract test {
- function f() public {
- address(0x12).call.value(2)("abc");
- }
- }
- )";
- CHECK_WARNING(text, "Return value of low-level calls not used");
-}
-
-BOOST_AUTO_TEST_CASE(unused_return_value_callcode)
-{
- char const* text = R"(
- contract test {
- function f() public {
- address(0x12).callcode("abc");
- }
- }
- )";
- CHECK_WARNING_ALLOW_MULTI(text, (std::vector<std::string>{
- "Return value of low-level calls not used",
- "\"callcode\" has been deprecated"
- }));
-}
-
-BOOST_AUTO_TEST_CASE(unused_return_value_delegatecall)
-{
- char const* text = R"(
- contract test {
- function f() public {
- address(0x12).delegatecall("abc");
- }
- }
- )";
- CHECK_WARNING(text, "Return value of low-level calls not used");
-}
-
-BOOST_AUTO_TEST_CASE(warn_about_callcode)
-{
- char const* text = R"(
- contract test {
- function f() pure public {
- address(0x12).callcode;
- }
- }
- )";
- CHECK_WARNING(text, "\"callcode\" has been deprecated in favour of \"delegatecall\"");
- text = R"(
- pragma experimental "v0.5.0";
- contract test {
- function f() pure public {
- address(0x12).callcode;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "\"callcode\" has been deprecated in favour of \"delegatecall\"");
-}
-
-BOOST_AUTO_TEST_CASE(no_warn_about_callcode_as_function)
-{
- char const* text = R"(
- contract test {
- function callcode() pure public {
- test.callcode();
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(payable_in_library)
-{
- char const* text = R"(
- library test {
- function f() payable public {}
- }
- )";
- CHECK_ERROR(text, TypeError, "Library functions cannot be payable.");
-}
-
-BOOST_AUTO_TEST_CASE(payable_external)
-{
- char const* text = R"(
- contract test {
- function f() payable external {}
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(payable_internal)
-{
- char const* text = R"(
- contract test {
- function f() payable internal {}
- }
- )";
- CHECK_ERROR(text, TypeError, "Internal functions cannot be payable.");
-}
-
-BOOST_AUTO_TEST_CASE(payable_private)
-{
- char const* text = R"(
- contract test {
- function f() payable private {}
- }
- )";
- CHECK_ERROR(text, TypeError, "Internal functions cannot be payable.");
-}
-
-BOOST_AUTO_TEST_CASE(illegal_override_payable)
-{
- char const* text = R"(
- contract B { function f() payable public {} }
- contract C is B { function f() public {} }
- )";
- CHECK_ERROR(text, TypeError, "Overriding function changes state mutability from \"payable\" to \"nonpayable\".");
-}
-
-BOOST_AUTO_TEST_CASE(illegal_override_payable_nonpayable)
-{
- char const* text = R"(
- contract B { function f() public {} }
- contract C is B { function f() payable public {} }
- )";
- CHECK_ERROR(text, TypeError, "Overriding function changes state mutability from \"nonpayable\" to \"payable\".");
-}
-
-BOOST_AUTO_TEST_CASE(function_variable_mixin)
-{
- // bug #1798 (cpp-ethereum), related to #1286 (solidity)
- char const* text = R"(
- contract attribute {
- bool ok = false;
- }
- contract func {
- function ok() public returns (bool) { return true; }
- }
-
- contract attr_func is attribute, func {
- function checkOk() public returns (bool) { return ok(); }
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Identifier already declared.");
-}
-
-BOOST_AUTO_TEST_CASE(calling_payable)
-{
- char const* text = R"(
- contract receiver { function pay() payable public {} }
- contract test {
- function f() public { (new receiver()).pay.value(10)(); }
- receiver r = new receiver();
- function g() public { r.pay.value(10)(); }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(calling_nonpayable)
-{
- char const* text = R"(
- contract receiver { function nopay() public {} }
- contract test {
- function f() public { (new receiver()).nopay.value(10)(); }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"value\" not found or not visible after argument-dependent lookup in function () external - did you forget the \"payable\" modifier?");
-}
-
-BOOST_AUTO_TEST_CASE(non_payable_constructor)
+BOOST_AUTO_TEST_CASE(warn_nonpresent_pragma)
{
char const* text = R"(
- contract C {
- function C() { }
- }
- contract D {
- function f() public returns (uint) {
- (new C).value(2)();
- return 2;
- }
- }
+ contract C {}
)";
- CHECK_ERROR(text, TypeError, "Member \"value\" not found or not visible after argument-dependent lookup in function () returns (contract C) - did you forget the \"payable\" modifier?");
-}
-
-BOOST_AUTO_TEST_CASE(warn_nonpresent_pragma)
-{
- char const* text = "contract C {}";
auto sourceAndError = parseAnalyseAndReturnError(text, true, false);
BOOST_REQUIRE(!sourceAndError.second.empty());
BOOST_REQUIRE(!!sourceAndError.first);
@@ -4846,1322 +387,6 @@ BOOST_AUTO_TEST_CASE(unsatisfied_version)
BOOST_CHECK(searchErrorMessage(*sourceAndError.second.front(), "Source file requires different compiler version"));
}
-BOOST_AUTO_TEST_CASE(invalid_array_as_statement)
-{
- char const* text = R"(
- contract test {
- struct S { uint x; }
- function test(uint k) public { S[k]; }
- }
- )";
- CHECK_ERROR(text, TypeError, "Integer constant expected.");
-}
-
-BOOST_AUTO_TEST_CASE(using_directive_for_missing_selftype)
-{
- char const* text = R"(
- library B {
- function b() public {}
- }
-
- contract A {
- using B for bytes;
-
- function a() public {
- bytes memory x;
- x.b();
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"b\" not found or not visible after argument-dependent lookup in bytes memory");
-}
-
-BOOST_AUTO_TEST_CASE(shift_constant_left_negative_rvalue)
-{
- char const* text = R"(
- contract C {
- uint public a = 0x42 << -8;
- }
- )";
- CHECK_ERROR(text, TypeError, "Operator << not compatible with types int_const 66 and int_const -8");
-}
-
-BOOST_AUTO_TEST_CASE(shift_constant_right_negative_rvalue)
-{
- char const* text = R"(
- contract C {
- uint public a = 0x42 >> -8;
- }
- )";
- CHECK_ERROR(text, TypeError, "Operator >> not compatible with types int_const 66 and int_const -8");
-}
-
-BOOST_AUTO_TEST_CASE(shift_constant_left_excessive_rvalue)
-{
- char const* text = R"(
- contract C {
- uint public a = 0x42 << 0x100000000;
- }
- )";
- CHECK_ERROR(text, TypeError, "Operator << not compatible with types int_const 66 and int_const 4294967296");
-}
-
-BOOST_AUTO_TEST_CASE(shift_constant_right_excessive_rvalue)
-{
- char const* text = R"(
- contract C {
- uint public a = 0x42 >> 0x100000000;
- }
- )";
- CHECK_ERROR(text, TypeError, "Operator >> not compatible with types int_const 66 and int_const 4294967296");
-}
-
-BOOST_AUTO_TEST_CASE(shift_constant_right_fractional)
-{
- char const* text = R"(
- contract C {
- uint public a = 0x42 >> (1 / 2);
- }
- )";
- CHECK_ERROR(text, TypeError, "Operator >> not compatible with types int_const 66 and rational_const 1 / 2");
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_unbalanced_positive_stack)
-{
- char const* text = R"(
- contract test {
- function f() public {
- assembly {
- 1
- }
- }
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Unbalanced stack at the end of a block: 1 surplus item(s).");
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_unbalanced_negative_stack)
-{
- char const* text = R"(
- contract test {
- function f() public {
- assembly {
- pop
- }
- }
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Unbalanced stack at the end of a block: 1 missing item(s).");
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_unbalanced_two_stack_load)
-{
- char const* text = R"(
- pragma experimental "v0.5.0";
- contract c {
- uint8 x;
- function f() public {
- assembly { pop(x) }
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Only local variables are supported. To access storage variables,");
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_in_modifier)
-{
- char const* text = R"(
- pragma experimental "v0.5.0";
- contract test {
- modifier m {
- uint a = 1;
- assembly {
- a := 2
- }
- _;
- }
- function f() public m {
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_storage)
-{
- char const* text = R"(
- pragma experimental "v0.5.0";
- contract test {
- uint x = 1;
- function f() public {
- assembly {
- x := 2
- }
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Only local variables are supported. To access storage variables,");
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_storage_in_modifiers)
-{
- char const* text = R"(
- pragma experimental "v0.5.0";
- contract test {
- uint x = 1;
- modifier m {
- assembly {
- x := 2
- }
- _;
- }
- function f() public m {
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Only local variables are supported. To access storage variables,");
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_constant_assign)
-{
- char const* text = R"(
- pragma experimental "v0.5.0";
- contract test {
- uint constant x = 1;
- function f() public {
- assembly {
- x := 2
- }
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Constant variables not supported by inline assembly");
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_constant_access)
-{
- char const* text = R"(
- pragma experimental "v0.5.0";
- contract test {
- uint constant x = 1;
- function f() public {
- assembly {
- let y := x
- }
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Constant variables not supported by inline assembly");
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_local_variable_access_out_of_functions)
-{
- char const* text = R"(
- pragma experimental "v0.5.0";
- contract test {
- function f() public {
- uint a;
- assembly {
- function g() -> x { x := a }
- }
- }
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Cannot access local Solidity variables from inside an inline assembly function.");
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_local_variable_access_out_of_functions_storage_ptr)
-{
- char const* text = R"(
- pragma experimental "v0.5.0";
- contract test {
- uint[] r;
- function f() public {
- uint[] storage a = r;
- assembly {
- function g() -> x { x := a_offset }
- }
- }
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Cannot access local Solidity variables from inside an inline assembly function.");
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_storage_variable_access_out_of_functions)
-{
- char const* text = R"(
- pragma experimental "v0.5.0";
- contract test {
- uint a;
- function f() pure public {
- assembly {
- function g() -> x { x := a_slot }
- }
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_constant_variable_via_offset)
-{
- char const* text = R"(
- contract test {
- uint constant x = 2;
- function f() pure public {
- assembly {
- let r := x_offset
- }
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Constant variables not supported by inline assembly.");
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_calldata_variables)
-{
- char const* text = R"(
- pragma experimental "v0.5.0";
- contract C {
- function f(bytes bytesAsCalldata) external {
- assembly {
- let x := bytesAsCalldata
- }
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Call data elements cannot be accessed directly.");
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_050_literals_on_stack)
-{
- char const* text = R"(
- pragma experimental "v0.5.0";
- contract C {
- function f() pure public {
- assembly {
- 1
- }
- }
- }
- )";
- CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{
- {Error::Type::SyntaxError, "are not supposed to return"},
- {Error::Type::DeclarationError, "Unbalanced stack"},
- }));
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_literals_on_stack)
-{
- char const* text = R"(
- contract C {
- function f() pure public {
- assembly {
- 1
- }
- }
- }
- )";
- CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{
- {Error::Type::Warning, "are not supposed to return"},
- {Error::Type::DeclarationError, "Unbalanced stack"},
- }));
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_050_bare_instructions)
-{
- char const* text = R"(
- pragma experimental "v0.5.0";
- contract C {
- function f() view public {
- assembly {
- address
- pop
- }
- }
- }
- )";
- CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{
- {Error::Type::SyntaxError, "The use of non-functional"},
- {Error::Type::SyntaxError, "The use of non-functional"}
- }));
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_bare_instructions)
-{
- char const* text = R"(
- contract C {
- function f() view public {
- assembly {
- address
- pop
- }
- }
- }
- )";
- CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{
- {Error::Type::Warning, "The use of non-functional"},
- {Error::Type::Warning, "The use of non-functional"}
- }));
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_050_labels)
-{
- char const* text = R"(
- pragma experimental "v0.5.0";
- contract C {
- function f() pure public {
- assembly {
- label:
- }
- }
- }
- )";
- CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{
- {Error::Type::SyntaxError, "Jump instructions and labels are low-level"},
- {Error::Type::SyntaxError, "The use of labels is deprecated"}
- }));
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_labels)
-{
- char const* text = R"(
- contract C {
- function f() pure public {
- assembly {
- label:
- }
- }
- }
- )";
- CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{
- {Error::Type::Warning, "Jump instructions and labels are low-level"},
- {Error::Type::Warning, "The use of labels is deprecated"}
- }));
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_050_jump)
-{
- char const* text = R"(
- pragma experimental "v0.5.0";
- contract C {
- function f() pure public {
- assembly {
- jump(2)
- }
- }
- }
- )";
- CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{
- {Error::Type::SyntaxError, "Jump instructions and labels are low-level"}
- }));
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_jump)
-{
- char const* text = R"(
- contract C {
- function f() pure public {
- assembly {
- jump(2)
- }
- }
- }
- )";
- CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{
- {Error::Type::TypeError, "Function declared as pure"},
- {Error::Type::Warning, "Jump instructions and labels are low-level"}
- }));
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_050_leave_items_on_stack)
-{
- char const* text = R"(
- pragma experimental "v0.5.0";
- contract C {
- function f() pure public {
- assembly {
- mload(0)
- }
- }
- }
- )";
- CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{
- {Error::Type::SyntaxError, "are not supposed to return"},
- {Error::Type::DeclarationError, "Unbalanced stack"},
- }));
-}
-
-BOOST_AUTO_TEST_CASE(inline_assembly_leave_items_on_stack)
-{
- char const* text = R"(
- contract C {
- function f() pure public {
- assembly {
- mload(0)
- }
- }
- }
- )";
- CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{
- {Error::Type::Warning, "are not supposed to return"},
- {Error::Type::DeclarationError, "Unbalanced stack"},
- }));
-}
-
-BOOST_AUTO_TEST_CASE(invalid_mobile_type)
-{
- char const* text = R"(
- contract C {
- function f() public {
- // Invalid number
- [1, 78901234567890123456789012345678901234567890123456789345678901234567890012345678012345678901234567];
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Invalid rational number.");
-}
-
-BOOST_AUTO_TEST_CASE(warns_msg_value_in_non_payable_public_function)
-{
- char const* text = R"(
- contract C {
- function f() view public {
- msg.value;
- }
- }
- )";
- CHECK_WARNING(text, "\"msg.value\" used in non-payable function. Do you want to add the \"payable\" modifier to this function?");
-}
-
-BOOST_AUTO_TEST_CASE(does_not_warn_msg_value_in_payable_function)
-{
- char const* text = R"(
- contract C {
- function f() payable public {
- msg.value;
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(does_not_warn_msg_value_in_internal_function)
-{
- char const* text = R"(
- contract C {
- function f() view internal {
- msg.value;
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(does_not_warn_msg_value_in_library)
-{
- char const* text = R"(
- library C {
- function f() view public {
- msg.value;
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(does_not_warn_msg_value_in_modifier_following_non_payable_public_function)
-{
- char const* text = R"(
- contract c {
- function f() pure public { }
- modifier m() { msg.value; _; }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(assignment_to_constant)
-{
- char const* text = R"(
- contract c {
- uint constant a = 1;
- function f() public { a = 2; }
- }
- )";
- CHECK_ERROR(text, TypeError, "Cannot assign to a constant variable.");
-}
-
-BOOST_AUTO_TEST_CASE(return_structs)
-{
- char const* text = R"(
- pragma experimental ABIEncoderV2;
- contract C {
- struct S { uint a; T[] sub; }
- struct T { uint[] x; }
- function f() returns (uint, S) {
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(read_returned_struct)
-{
- char const* text = R"(
- pragma experimental ABIEncoderV2;
- contract A {
- struct T {
- int x;
- int y;
- }
- function g() public returns (T) {
- return this.g();
- }
- }
- )";
- CHECK_WARNING(text, "Experimental features");
-}
-BOOST_AUTO_TEST_CASE(address_checksum_type_deduction)
-{
- char const* text = R"(
- contract C {
- function f() public {
- var x = 0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E;
- x.send(2);
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(invalid_address_checksum)
-{
- char const* text = R"(
- contract C {
- function f() pure public {
- address x = 0xFA0bFc97E48458494Ccd857e1A85DC91F7F0046E;
- x;
- }
- }
- )";
- CHECK_WARNING(text, "This looks like an address but has an invalid checksum.");
-}
-
-BOOST_AUTO_TEST_CASE(invalid_address_no_checksum)
-{
- char const* text = R"(
- contract C {
- function f() pure public {
- address x = 0xfa0bfc97e48458494ccd857e1a85dc91f7f0046e;
- x;
- }
- }
- )";
- CHECK_WARNING(text, "This looks like an address but has an invalid checksum.");
-}
-
-BOOST_AUTO_TEST_CASE(invalid_address_length_short)
-{
- char const* text = R"(
- contract C {
- function f() pure public {
- address x = 0xA0bFc97E48458494Ccd857e1A85DC91F7F0046E;
- x;
- }
- }
- )";
- CHECK_WARNING(text, "This looks like an address but has an invalid checksum.");
-}
-
-BOOST_AUTO_TEST_CASE(invalid_address_length_long)
-{
- char const* text = R"(
- contract C {
- function f() pure public {
- address x = 0xFA0bFc97E48458494Ccd857e1A85DC91F7F0046E0;
- x;
- }
- }
- )";
- CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{
- {Error::Type::Warning, "This looks like an address but has an invalid checksum."},
- {Error::Type::TypeError, "not implicitly convertible"}
- }));
-}
-
-BOOST_AUTO_TEST_CASE(address_test_for_bug_in_implementation)
-{
- // A previous implementation claimed the string would be an address
- char const* text = R"(
- contract AddrString {
- address public test = "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c";
- }
- )";
- CHECK_ERROR(text, TypeError, "is not implicitly convertible to expected type address");
- text = R"(
- contract AddrString {
- function f() public returns (address) {
- return "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c";
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "is not implicitly convertible to expected type");
-}
-
-BOOST_AUTO_TEST_CASE(early_exit_on_fatal_errors)
-{
- // This tests a crash that occured because we did not stop for fatal errors.
- char const* text = R"(
- contract C {
- struct S {
- ftring a;
- }
- S public s;
- function s() s {
- }
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Identifier not found or not unique");
-}
-
-BOOST_AUTO_TEST_CASE(address_methods)
-{
- char const* text = R"(
- contract C {
- function f() public {
- address addr;
- uint balance = addr.balance;
- bool callRet = addr.call();
- bool callcodeRet = addr.callcode();
- bool delegatecallRet = addr.delegatecall();
- bool sendRet = addr.send(1);
- addr.transfer(1);
- callRet; callcodeRet; delegatecallRet; sendRet;
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(interface)
-{
- char const* text = R"(
- interface I {
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(interface_functions)
-{
- char const* text = R"(
- interface I {
- function();
- function f();
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(interface_function_bodies)
-{
- char const* text = R"(
- interface I {
- function f() public {
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Functions in interfaces cannot have an implementation");
-}
-
-BOOST_AUTO_TEST_CASE(interface_events)
-{
- char const* text = R"(
- interface I {
- event E();
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(interface_inheritance)
-{
- char const* text = R"(
- interface A {
- }
- interface I is A {
- }
- )";
- CHECK_ERROR(text, TypeError, "Interfaces cannot inherit");
-}
-
-
-BOOST_AUTO_TEST_CASE(interface_structs)
-{
- char const* text = R"(
- interface I {
- struct A {
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Structs cannot be defined in interfaces");
-}
-
-BOOST_AUTO_TEST_CASE(interface_variables)
-{
- char const* text = R"(
- interface I {
- uint a;
- }
- )";
- CHECK_ERROR(text, TypeError, "Variables cannot be declared in interfaces");
-}
-
-BOOST_AUTO_TEST_CASE(interface_function_parameters)
-{
- char const* text = R"(
- interface I {
- function f(uint a) public returns (bool);
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(interface_enums)
-{
- char const* text = R"(
- interface I {
- enum A { B, C }
- }
- )";
- CHECK_ERROR(text, TypeError, "Enumerable cannot be declared in interfaces");
-}
-
-BOOST_AUTO_TEST_CASE(using_interface)
-{
- char const* text = R"(
- interface I {
- function f();
- }
- contract C is I {
- function f() public {
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(using_interface_complex)
-{
- char const* text = R"(
- interface I {
- event A();
- function f();
- function g();
- function();
- }
- contract C is I {
- function f() public {
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(interface_implement_public_contract)
-{
- char const* text = R"(
- interface I {
- function f() external;
- }
- contract C is I {
- function f() public {
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(warn_about_throw)
-{
- char const* text = R"(
- contract C {
- function f() pure public {
- throw;
- }
- }
- )";
- CHECK_WARNING(text, "\"throw\" is deprecated in favour of \"revert()\", \"require()\" and \"assert()\"");
- text = R"(
- pragma experimental "v0.5.0";
- contract C {
- function f() pure public {
- throw;
- }
- }
- )";
- CHECK_ERROR(text, SyntaxError, "\"throw\" is deprecated in favour of \"revert()\", \"require()\" and \"assert()\"");
-}
-
-BOOST_AUTO_TEST_CASE(bare_revert)
-{
- char const* text = R"(
- contract C {
- function f(uint x) pure public {
- if (x > 7)
- revert;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "No matching declaration found");
-}
-
-BOOST_AUTO_TEST_CASE(revert_with_reason)
-{
- char const* text = R"(
- contract C {
- function f(uint x) pure public {
- if (x > 7)
- revert("abc");
- else
- revert();
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(bare_others)
-{
- CHECK_WARNING("contract C { function f() pure public { selfdestruct; } }", "Statement has no effect.");
- CHECK_WARNING("contract C { function f() pure public { assert; } }", "Statement has no effect.");
- // This is different because it does have overloads.
- CHECK_ERROR("contract C { function f() pure public { require; } }", TypeError, "No matching declaration found after variable lookup.");
- CHECK_WARNING("contract C { function f() pure public { selfdestruct; } }", "Statement has no effect.");
-}
-
-BOOST_AUTO_TEST_CASE(pure_statement_in_for_loop)
-{
- char const* text = R"(
- contract C {
- function f() pure public {
- for (uint x = 0; x < 10; true)
- x++;
- }
- }
- )";
- CHECK_WARNING(text, "Statement has no effect.");
-}
-
-BOOST_AUTO_TEST_CASE(pure_statement_check_for_regular_for_loop)
-{
- char const* text = R"(
- contract C {
- function f() pure public {
- for (uint x = 0; true; x++)
- {}
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(warn_unused_local)
-{
- char const* text = R"(
- contract C {
- function f() pure public {
- uint a;
- }
- }
- )";
- CHECK_WARNING(text, "Unused local variable.");
-}
-
-BOOST_AUTO_TEST_CASE(warn_unused_local_assigned)
-{
- char const* text = R"(
- contract C {
- function f() pure public {
- uint a = 1;
- }
- }
- )";
- CHECK_WARNING(text, "Unused local variable.");
-}
-
-BOOST_AUTO_TEST_CASE(warn_unused_function_parameter)
-{
- char const* text = R"(
- contract C {
- function f(uint a) pure public {
- }
- }
- )";
- CHECK_WARNING(text, "Unused function parameter. Remove or comment out the variable name to silence this warning.");
- text = R"(
- contract C {
- function f(uint a) pure public {
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(warn_unused_return_parameter)
-{
- char const* text = R"(
- contract C {
- function f() pure public returns (uint a) {
- }
- }
- )";
- CHECK_WARNING(text, "Unused function parameter. Remove or comment out the variable name to silence this warning.");
- text = R"(
- contract C {
- function f() pure public returns (uint a) {
- return;
- }
- }
- )";
- CHECK_WARNING(text, "Unused function parameter. Remove or comment out the variable name to silence this warning.");
- text = R"(
- contract C {
- function f() pure public returns (uint) {
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
- text = R"(
- contract C {
- function f() pure public returns (uint a) {
- a = 1;
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
- text = R"(
- contract C {
- function f() pure public returns (uint a) {
- return 1;
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(no_unused_warning_interface_arguments)
-{
- char const* text = R"(
- interface I {
- function f(uint a) pure external returns (uint b);
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(no_unused_warning_abstract_arguments)
-{
- char const* text = R"(
- contract C {
- function f(uint a) pure public returns (uint b);
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(no_unused_warnings)
-{
- char const* text = R"(
- contract C {
- function f(uint a) pure public returns (uint b) {
- uint c = 1;
- b = a + c;
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(no_unused_dec_after_use)
-{
- char const* text = R"(
- contract C {
- function f() pure public {
- a = 7;
- uint a;
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(no_unused_inline_asm)
-{
- char const* text = R"(
- contract C {
- function f() pure public {
- uint a;
- assembly {
- a := 1
- }
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(shadowing_builtins_with_functions)
-{
- char const* text = R"(
- contract C {
- function keccak256() pure public {}
- }
- )";
- CHECK_WARNING(text, "shadows a builtin symbol");
-}
-
-BOOST_AUTO_TEST_CASE(shadowing_builtins_with_variables)
-{
- char const* text = R"(
- contract C {
- function f() pure public {
- uint msg;
- msg;
- }
- }
- )";
- CHECK_WARNING(text, "shadows a builtin symbol");
-}
-
-BOOST_AUTO_TEST_CASE(shadowing_builtins_with_storage_variables)
-{
- char const* text = R"(
- contract C {
- uint msg;
- }
- )";
- CHECK_WARNING(text, "shadows a builtin symbol");
-}
-
-BOOST_AUTO_TEST_CASE(shadowing_builtin_at_global_scope)
-{
- char const* text = R"(
- contract msg {
- }
- )";
- CHECK_WARNING(text, "shadows a builtin symbol");
-}
-
-BOOST_AUTO_TEST_CASE(shadowing_builtins_with_parameters)
-{
- char const* text = R"(
- contract C {
- function f(uint require) pure public {
- require = 2;
- }
- }
- )";
- CHECK_WARNING(text, "shadows a builtin symbol");
-}
-
-BOOST_AUTO_TEST_CASE(shadowing_builtins_with_return_parameters)
-{
- char const* text = R"(
- contract C {
- function f() pure public returns (uint require) {
- require = 2;
- }
- }
- )";
- CHECK_WARNING(text, "shadows a builtin symbol");
-}
-
-BOOST_AUTO_TEST_CASE(shadowing_builtins_with_events)
-{
- char const* text = R"(
- contract C {
- event keccak256();
- }
- )";
- CHECK_WARNING(text, "shadows a builtin symbol");
-}
-
-BOOST_AUTO_TEST_CASE(shadowing_builtins_ignores_struct)
-{
- char const* text = R"(
- contract C {
- struct a {
- uint msg;
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(shadowing_builtins_ignores_constructor)
-{
- char const* text = R"(
- contract C {
- constructor() public {}
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(function_overload_is_not_shadowing)
-{
- char const* text = R"(
- contract C {
- function f() pure public {}
- function f(uint) pure public {}
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(function_override_is_not_shadowing)
-{
- char const* text = R"(
- contract D { function f() pure public {} }
- contract C is D {
- function f(uint) pure public {}
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(event_parameter_cannot_shadow_state_variable)
-{
- char const* text = R"(
- contract C {
- address a;
- event E(address a);
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(callable_crash)
-{
- char const* text = R"(
- contract C {
- struct S { uint a; bool x; }
- S public s;
- function C() public {
- 3({a: 1, x: true});
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Type is not callable");
-}
-
-BOOST_AUTO_TEST_CASE(error_transfer_non_payable_fallback)
-{
- // This used to be a test for a.transfer to generate a warning
- // because A's fallback function is not payable.
- char const* text = R"(
- contract A {
- function() public {}
- }
-
- contract B {
- A a;
-
- function() public {
- a.transfer(100);
- }
- }
- )";
- CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{
- {Error::Type::Warning, "Using contract member \"transfer\" inherited from the address type is deprecated"},
- {Error::Type::TypeError, "Value transfer to a contract without a payable fallback function"}
- }));
-}
-
-BOOST_AUTO_TEST_CASE(error_transfer_no_fallback)
-{
- // This used to be a test for a.transfer to generate a warning
- // because A does not have a payable fallback function.
- std::string text = R"(
- contract A {}
-
- contract B {
- A a;
-
- function() public {
- a.transfer(100);
- }
- }
- )";
- CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{
- {Error::Type::Warning, "Using contract member \"transfer\" inherited from the address type is deprecated"},
- {Error::Type::TypeError, "Value transfer to a contract without a payable fallback function"}
- }));
-}
-
-BOOST_AUTO_TEST_CASE(error_send_non_payable_fallback)
-{
- // This used to be a test for a.send to generate a warning
- // because A does not have a payable fallback function.
- std::string text = R"(
- contract A {
- function() public {}
- }
-
- contract B {
- A a;
-
- function() public {
- require(a.send(100));
- }
- }
- )";
- CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{
- {Error::Type::Warning, "Using contract member \"send\" inherited from the address type is deprecated"},
- {Error::Type::TypeError, "Value transfer to a contract without a payable fallback function"}
- }));
-}
-
-BOOST_AUTO_TEST_CASE(does_not_error_transfer_payable_fallback)
-{
- // This used to be a test for a.transfer to generate a warning
- // because A does not have a payable fallback function.
- char const* text = R"(
- contract A {
- function() payable public {}
- }
-
- contract B {
- A a;
-
- function() public {
- a.transfer(100);
- }
- }
- )";
- CHECK_WARNING(text, "Using contract member \"transfer\" inherited from the address type is deprecated.");
-}
-
-BOOST_AUTO_TEST_CASE(does_not_error_transfer_regular_function)
-{
- char const* text = R"(
- contract A {
- function transfer() pure public {}
- }
-
- contract B {
- A a;
-
- function() public {
- a.transfer();
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
BOOST_AUTO_TEST_CASE(returndatasize_as_variable)
{
char const* text = R"(
@@ -6182,6 +407,8 @@ BOOST_AUTO_TEST_CASE(create2_as_variable)
char const* text = R"(
contract c { function f() public { uint create2; assembly { 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"},
@@ -6190,928 +417,6 @@ BOOST_AUTO_TEST_CASE(create2_as_variable)
}));
}
-BOOST_AUTO_TEST_CASE(warn_unspecified_storage)
-{
- char const* text = R"(
- contract C {
- struct S { uint a; string b; }
- S x;
- function f() view public {
- S storage y = x;
- y;
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
- text = R"(
- contract C {
- struct S { uint a; }
- S x;
- function f() view public {
- S y = x;
- y;
- }
- }
- )";
- CHECK_WARNING(text, "Variable is declared as a storage pointer. Use an explicit \"storage\" keyword to silence this warning");
- text = R"(
- pragma experimental "v0.5.0";
- contract C {
- struct S { uint a; }
- S x;
- function f() view public {
- S y = x;
- y;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Storage location must be specified as either \"memory\" or \"storage\".");
-}
-
-BOOST_AUTO_TEST_CASE(storage_location_non_array_or_struct_disallowed)
-{
- char const* text = R"(
- contract C {
- function f(uint storage a) public { }
- }
- )";
- CHECK_ERROR(text, TypeError, "Storage location can only be given for array or struct types.");
-}
-
-BOOST_AUTO_TEST_CASE(storage_location_non_array_or_struct_disallowed_is_not_fatal)
-{
- char const* text = R"(
- contract C {
- function f(uint storage a) public {
- a = f;
- }
- }
- )";
- CHECK_ERROR_ALLOW_MULTI(text, TypeError, (std::vector<std::string>{"Storage location can only be given for array or struct types."}));
-}
-
-BOOST_AUTO_TEST_CASE(implicit_conversion_disallowed)
-{
- char const* text = R"(
- contract C {
- function f() public returns (bytes4) {
- uint32 tmp = 1;
- return tmp;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Return argument type uint32 is not implicitly convertible to expected type (type of first return variable) bytes4.");
-}
-
-BOOST_AUTO_TEST_CASE(too_large_arrays_for_calldata)
-{
- char const* text = R"(
- contract C {
- function f(uint[85678901234] a) pure external {
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Array is too large to be encoded.");
- text = R"(
- contract C {
- function f(uint[85678901234] a) pure internal {
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Array is too large to be encoded.");
- text = R"(
- contract C {
- function f(uint[85678901234] a) pure public {
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Array is too large to be encoded.");
-}
-
-BOOST_AUTO_TEST_CASE(explicit_literal_to_storage_string)
-{
- char const* text = R"(
- contract C {
- function f() pure public {
- string memory x = "abc";
- x;
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
- text = R"(
- contract C {
- function f() pure public {
- string storage x = "abc";
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Type literal_string \"abc\" is not implicitly convertible to expected type string storage pointer.");
- text = R"(
- contract C {
- function f() pure public {
- string x = "abc";
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Type literal_string \"abc\" is not implicitly convertible to expected type string storage pointer.");
- text = R"(
- contract C {
- function f() pure public {
- string("abc");
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Explicit type conversion not allowed from \"literal_string \"abc\"\" to \"string storage pointer\"");
-}
-
-BOOST_AUTO_TEST_CASE(modifiers_access_storage_pointer)
-{
- char const* text = R"(
- contract C {
- struct S { uint a; }
- modifier m(S storage x) {
- x;
- _;
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(function_types_sig)
-{
- char const* text = R"(
- contract C {
- function f() view returns (bytes4) {
- return f.selector;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"selector\" not found");
- text = R"(
- contract C {
- function g() pure internal {
- }
- function f() view returns (bytes4) {
- return g.selector;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"selector\" not found");
- text = R"(
- contract C {
- function f() view returns (bytes4) {
- function () g;
- return g.selector;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"selector\" not found");
- text = R"(
- contract C {
- function f() pure external returns (bytes4) {
- return this.f.selector;
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
- text = R"(
- contract C {
- function h() pure external {
- }
- function f() view external returns (bytes4) {
- var g = this.h;
- return g.selector;
- }
- }
- )";
- CHECK_WARNING(text, "Use of the \"var\" keyword is deprecated.");
- text = R"(
- contract C {
- function h() pure external {
- }
- function f() view external returns (bytes4) {
- function () pure external g = this.h;
- return g.selector;
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
- text = R"(
- contract C {
- function h() pure external {
- }
- function f() view external returns (bytes4) {
- function () pure external g = this.h;
- var i = g;
- return i.selector;
- }
- }
- )";
- CHECK_WARNING(text, "Use of the \"var\" keyword is deprecated.");
-}
-
-BOOST_AUTO_TEST_CASE(using_this_in_constructor)
-{
- char const* text = R"(
- contract C {
- constructor() public {
- this.f();
- }
- function f() pure public {
- }
- }
- )";
- CHECK_WARNING(text, "\"this\" used in constructor");
-}
-
-BOOST_AUTO_TEST_CASE(do_not_crash_on_not_lvalue)
-{
- // This checks for a bug that caused a crash because of continued analysis.
- char const* text = R"(
- contract C {
- mapping (uint => uint) m;
- function f() public {
- m(1) = 2;
- }
- }
- )";
- CHECK_ERROR_ALLOW_MULTI(text, TypeError, (std::vector<std::string>{
- "is not callable",
- "Expression has to be an lvalue",
- "Type int_const 2 is not implicitly"
- }));
-}
-
-BOOST_AUTO_TEST_CASE(builtin_reject_gas)
-{
- char const* text = R"(
- contract C {
- function f() public {
- keccak256.gas();
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"gas\" not found or not visible after argument-dependent lookup");
- text = R"(
- contract C {
- function f() public {
- sha256.gas();
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"gas\" not found or not visible after argument-dependent lookup");
- text = R"(
- contract C {
- function f() public {
- ripemd160.gas();
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"gas\" not found or not visible after argument-dependent lookup");
- text = R"(
- contract C {
- function f() public {
- ecrecover.gas();
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"gas\" not found or not visible after argument-dependent lookup");
-}
-
-BOOST_AUTO_TEST_CASE(gasleft)
-{
- char const* text = R"(
- contract C {
- function f() public view returns (uint256 val) { return msg.gas; }
- }
- )";
- CHECK_WARNING(text, "\"msg.gas\" has been deprecated in favor of \"gasleft()\"");
-
- text = R"(
- contract C {
- function f() public view returns (uint256 val) { return gasleft(); }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-
- text = R"(
- pragma experimental "v0.5.0";
- contract C {
- function f() public returns (uint256 val) { return msg.gas; }
- }
- )";
- CHECK_ERROR(text, TypeError, "\"msg.gas\" has been deprecated in favor of \"gasleft()\"");
-}
-
-BOOST_AUTO_TEST_CASE(gasleft_shadowing)
-{
- char const* text = R"(
- contract C {
- function gasleft() public pure returns (bytes32 val) { return "abc"; }
- function f() public pure returns (bytes32 val) { return gasleft(); }
- }
- )";
- CHECK_WARNING(text, "This declaration shadows a builtin symbol.");
-
- text = R"(
- contract C {
- uint gasleft;
- function f() public { gasleft = 42; }
- }
- )";
- CHECK_WARNING(text, "This declaration shadows a builtin symbol.");
-}
-
-BOOST_AUTO_TEST_CASE(builtin_reject_value)
-{
- char const* text = R"(
- contract C {
- function f() public {
- keccak256.value();
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"value\" not found or not visible after argument-dependent lookup");
- text = R"(
- contract C {
- function f() public {
- sha256.value();
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"value\" not found or not visible after argument-dependent lookup");
- text = R"(
- contract C {
- function f() public {
- ripemd160.value();
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"value\" not found or not visible after argument-dependent lookup");
- text = R"(
- contract C {
- function f() public {
- ecrecover.value();
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"value\" not found or not visible after argument-dependent lookup");
-}
-
-BOOST_AUTO_TEST_CASE(large_storage_array_fine)
-{
- char const* text = R"(
- contract C {
- uint[2**64 - 1] x;
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(large_storage_array_simple)
-{
- char const* text = R"(
- contract C {
- uint[2**64] x;
- }
- )";
- CHECK_WARNING(text, "covers a large part of storage and thus makes collisions likely");
-}
-
-BOOST_AUTO_TEST_CASE(large_storage_arrays_combined)
-{
- char const* text = R"(
- contract C {
- uint[200][200][2**30][][2**30] x;
- }
- )";
- CHECK_WARNING(text, "covers a large part of storage and thus makes collisions likely");
-}
-
-BOOST_AUTO_TEST_CASE(large_storage_arrays_struct)
-{
- char const* text = R"(
- contract C {
- struct S { uint[2**30] x; uint[2**50] y; }
- S[2**20] x;
- }
- )";
- CHECK_WARNING(text, "covers a large part of storage and thus makes collisions likely");
-}
-
-BOOST_AUTO_TEST_CASE(large_storage_array_mapping)
-{
- char const* text = R"(
- contract C {
- mapping(uint => uint[2**100]) x;
- }
- )";
- CHECK_WARNING(text, "covers a large part of storage and thus makes collisions likely");
-}
-
-BOOST_AUTO_TEST_CASE(library_function_without_implementation)
-{
- char const* text = R"(
- library L {
- function f() public;
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
- text = R"(
- library L {
- function f() internal;
- }
- )";
- CHECK_ERROR(text, TypeError, "Internal library function must be implemented if declared.");
- text = R"(
- library L {
- function f() private;
- }
- )";
- CHECK_ERROR(text, TypeError, "Internal library function must be implemented if declared.");
-}
-
-BOOST_AUTO_TEST_CASE(using_for_with_non_library)
-{
- // This tests a crash that was resolved by making the first error fatal.
- char const* text = R"(
- library L {
- struct S { uint d; }
- using S for S;
- function f(S _s) internal {
- _s.d = 1;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Library name expected.");
-}
-
-BOOST_AUTO_TEST_CASE(experimental_pragma)
-{
- char const* text = R"(
- pragma experimental;
- )";
- CHECK_ERROR(text, SyntaxError, "Experimental feature name is missing.");
- text = R"(
- pragma experimental 123;
- )";
- CHECK_ERROR(text, SyntaxError, "Unsupported experimental feature name.");
- text = R"(
- pragma experimental unsupportedName;
- )";
- CHECK_ERROR(text, SyntaxError, "Unsupported experimental feature name.");
- text = R"(
- pragma experimental "unsupportedName";
- )";
- CHECK_ERROR(text, SyntaxError, "Unsupported experimental feature name.");
- text = R"(
- pragma experimental "";
- )";
- CHECK_ERROR(text, SyntaxError, "Empty experimental feature name is invalid.");
- text = R"(
- pragma experimental unsupportedName unsupportedName;
- )";
- CHECK_ERROR(text, SyntaxError, "Stray arguments.");
- text = R"(
- pragma experimental __test;
- )";
- CHECK_WARNING(text, "Experimental features are turned on. Do not use experimental features on live deployments.");
- text = R"(
- pragma experimental __test;
- pragma experimental __test;
- )";
- CHECK_ERROR_ALLOW_MULTI(text, SyntaxError, (std::vector<std::string>{"Duplicate experimental feature name."}));
-}
-
-BOOST_AUTO_TEST_CASE(reject_interface_creation)
-{
- char const* text = R"(
- interface I {}
- contract C {
- function f() public {
- new I();
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Cannot instantiate an interface.");
-}
-
-BOOST_AUTO_TEST_CASE(accept_library_creation)
-{
- char const* text = R"(
- library L {}
- contract C {
- function f() public {
- new L();
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(reject_interface_constructors)
-{
- char const* text = R"(
- interface I {}
- contract C is I(2) {}
- )";
- CHECK_ERROR(text, TypeError, "Wrong argument count for constructor call: 1 arguments given but expected 0.");
-}
-
-BOOST_AUTO_TEST_CASE(non_external_fallback)
-{
- char const* text = R"(
- pragma experimental "v0.5.0";
- contract C {
- function () external { }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
- text = R"(
- pragma experimental "v0.5.0";
- contract C {
- function () internal { }
- }
- )";
- CHECK_ERROR(text, TypeError, "Fallback function must be defined as \"external\".");
- text = R"(
- pragma experimental "v0.5.0";
- contract C {
- function () private { }
- }
- )";
- CHECK_ERROR(text, TypeError, "Fallback function must be defined as \"external\".");
- text = R"(
- pragma experimental "v0.5.0";
- contract C {
- function () public { }
- }
- )";
- CHECK_ERROR(text, TypeError, "Fallback function must be defined as \"external\".");
-}
-
-BOOST_AUTO_TEST_CASE(invalid_literal_in_tuple)
-{
- char const* text = R"(
- contract C {
- function f() pure public {
- uint x;
- (x, ) = (1E111);
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "is not implicitly convertible to expected type");
- text = R"(
- contract C {
- function f() pure public {
- uint x;
- (x, ) = (1, 1E111);
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Invalid rational number.");
- text = R"(
- contract C {
- function f() pure public {
- uint x;
- (x, ) = (1E111, 1);
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Invalid rational number.");
- text = R"(
- contract C {
- function f() pure public {
- (2**270, 1);
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Invalid rational number.");
- text = R"(
- contract C {
- function f() pure public {
- ((2**270) / 2**100, 1);
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(address_overload_resolution)
-{
- char const* text = R"(
- contract C {
- function balance() returns (uint) {
- this.balance; // to avoid pureness warning
- return 1;
- }
- function transfer(uint amount) {
- address(this).transfer(amount); // to avoid pureness warning
- }
- }
- contract D {
- function f() {
- var x = (new C()).balance();
- x;
- (new C()).transfer(5);
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
-BOOST_AUTO_TEST_CASE(array_length_invalid_expression)
-{
- char const* text = R"(
- contract C {
- uint[-true] ids;
- }
- )";
- CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal or constant expression.");
- text = R"(
- contract C {
- uint[true/1] ids;
- }
- )";
- CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal or constant expression.");
- text = R"(
- contract C {
- uint[1/true] ids;
- }
- )";
- CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal or constant expression.");
- text = R"(
- contract C {
- uint[1.111111E1111111111111] ids;
- }
- )";
- CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal or constant expression.");
- text = R"(
- contract C {
- uint[3/0] ids;
- }
- )";
- CHECK_ERROR(text, TypeError, "Operator / not compatible with types int_const 3 and int_const 0");
-}
-
-BOOST_AUTO_TEST_CASE(warn_about_address_members_on_contract)
-{
- std::string text = R"(
- contract C {
- function f() view public {
- this.balance;
- }
- }
- )";
- CHECK_WARNING(text, "Using contract member \"balance\" inherited from the address type is deprecated.");
- text = R"(
- contract C {
- function f() view public {
- this.transfer;
- }
- }
- )";
- CHECK_ALLOW_MULTI(text, (vector<pair<Error::Type, std::string>>{
- {Error::Type::Warning, "Using contract member \"transfer\" inherited from the address type is deprecated"},
- {Error::Type::TypeError, "Value transfer to a contract without a payable fallback function"}
- }));
- text = R"(
- contract C {
- function f() view public {
- this.send;
- }
- }
- )";
- CHECK_ALLOW_MULTI(text, (vector<pair<Error::Type, std::string>>{
- {Error::Type::Warning, "Using contract member \"send\" inherited from the address type is deprecated"},
- {Error::Type::TypeError, "Value transfer to a contract without a payable fallback function"}
- }));
- text = R"(
- contract C {
- function f() view public {
- this.call;
- }
- }
- )";
- CHECK_WARNING(text, "Using contract member \"call\" inherited from the address type is deprecated.");
- text = R"(
- contract C {
- function f() view public {
- this.callcode;
- }
- }
- )";
- CHECK_ALLOW_MULTI(text, (vector<pair<Error::Type, std::string>>{
- {Error::Type::Warning, "Using contract member \"callcode\" inherited from the address type is deprecated"},
- {Error::Type::Warning, "\"callcode\" has been deprecated in favour of \"delegatecall\""}
- }));
- text = R"(
- contract C {
- function f() view public {
- this.delegatecall;
- }
- }
- )";
- CHECK_WARNING(text, "Using contract member \"delegatecall\" inherited from the address type is deprecated.");
-}
-
-BOOST_AUTO_TEST_CASE(warn_about_address_members_on_non_this_contract)
-{
- std::string text = R"(
- contract C {
- function f() view public {
- C c;
- c.balance;
- }
- }
- )";
- CHECK_WARNING(text, "Using contract member \"balance\" inherited from the address type is deprecated");
- text = R"(
- contract C {
- function f() view public {
- C c;
- c.transfer;
- }
- }
- )";
- CHECK_ALLOW_MULTI(text, (vector<pair<Error::Type, std::string>>{
- {Error::Type::Warning, "Using contract member \"transfer\" inherited from the address type is deprecated"},
- {Error::Type::TypeError, "Value transfer to a contract without a payable fallback function"}
- }));
- text = R"(
- contract C {
- function f() view public {
- C c;
- c.send;
- }
- }
- )";
- CHECK_ALLOW_MULTI(text, (vector<pair<Error::Type, std::string>>{
- {Error::Type::Warning, "Using contract member \"send\" inherited from the address type is deprecated"},
- {Error::Type::TypeError, "Value transfer to a contract without a payable fallback function"}
- }));
- text = R"(
- contract C {
- function f() pure public {
- C c;
- c.call;
- }
- }
- )";
- CHECK_WARNING(text, "Using contract member \"call\" inherited from the address type is deprecated");
- text = R"(
- contract C {
- function f() pure public {
- C c;
- c.callcode;
- }
- }
- )";
- CHECK_WARNING_ALLOW_MULTI(text, (std::vector<std::string>{
- "Using contract member \"callcode\" inherited from the address type is deprecated",
- "\"callcode\" has been deprecated in favour of \"delegatecall\""
- }));
- text = R"(
- contract C {
- function f() pure public {
- C c;
- c.delegatecall;
- }
- }
- )";
- CHECK_WARNING(text, "Using contract member \"delegatecall\" inherited from the address type is deprecated");
-}
-
-BOOST_AUTO_TEST_CASE(no_address_members_on_contract)
-{
- char const* text = R"(
- pragma experimental "v0.5.0";
- contract C {
- function f() public {
- this.balance;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"balance\" not found or not visible after argument-dependent lookup in contract");
- text = R"(
- pragma experimental "v0.5.0";
- contract C {
- function f() public {
- this.transfer;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"transfer\" not found or not visible after argument-dependent lookup in contract");
- text = R"(
- pragma experimental "v0.5.0";
- contract C {
- function f() public {
- this.send;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"send\" not found or not visible after argument-dependent lookup in contract");
- text = R"(
- pragma experimental "v0.5.0";
- contract C {
- function f() public {
- this.call;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"call\" not found or not visible after argument-dependent lookup in contract");
- text = R"(
- pragma experimental "v0.5.0";
- contract C {
- function f() public {
- this.callcode;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"callcode\" not found or not visible after argument-dependent lookup in contract");
- text = R"(
- pragma experimental "v0.5.0";
- contract C {
- function f() public {
- this.delegatecall;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "Member \"delegatecall\" not found or not visible after argument-dependent lookup in contract");
-}
-
-BOOST_AUTO_TEST_CASE(no_warning_for_using_members_that_look_like_address_members)
-{
- char const* text = R"(
- pragma experimental "v0.5.0";
- contract C {
- function transfer(uint) public;
- function f() public {
- this.transfer(10);
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(emit_events)
-{
- char const* text = R"(
- contract C {
- event e();
- function f() public {
- emit e();
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
- text = R"(
- contract C {
- event e(uint a, string b);
- function f() public {
- emit e(2, "abc");
- emit e({b: "abc", a: 8});
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
- text = R"(
- contract A { event e(uint a, string b); }
- contract C is A {
- function f() public {
- emit A.e(2, "abc");
- emit A.e({b: "abc", a: 8});
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(old_style_events_050)
-{
- char const* text = R"(
- contract C {
- event e();
- function f() public {
- e();
- }
- }
- )";
- CHECK_WARNING(text, "without \"emit\" prefix");
- text = R"(
- pragma experimental "v0.5.0";
- contract C {
- event e();
- function f() public {
- e();
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "have to be prefixed");
-}
-
BOOST_AUTO_TEST_CASE(getter_is_memory_type)
{
char const* text = R"(
@@ -7132,50 +437,6 @@ BOOST_AUTO_TEST_CASE(getter_is_memory_type)
}
}
-BOOST_AUTO_TEST_CASE(require_visibility_specifiers)
-{
- char const* text = R"(
- contract C {
- function f() pure { }
- }
- )";
- CHECK_WARNING(text, "No visibility specified. Defaulting to");
- text = R"(
- pragma experimental "v0.5.0";
- contract C {
- function f() pure { }
- }
- )";
- CHECK_ERROR(text, SyntaxError, "No visibility specified.");
-}
-
-BOOST_AUTO_TEST_CASE(blockhash)
-{
- char const* code = R"(
- contract C {
- function f() public view returns (bytes32) {
- return block.blockhash(3);
- }
- }
- )";
- CHECK_WARNING(code, "\"block.blockhash()\" has been deprecated in favor of \"blockhash()\"");
-
- code = R"(
- contract C {
- function f() public view returns (bytes32) { return blockhash(3); }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(code);
-
- code = R"(
- pragma experimental "v0.5.0";
- contract C {
- function f() public returns (bytes32) { return block.blockhash(3); }
- }
- )";
- CHECK_ERROR(code, TypeError, "\"block.blockhash()\" has been deprecated in favor of \"blockhash()\"");
-}
-
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp
index 5326feaf..3a8585f7 100644
--- a/test/libsolidity/SolidityOptimizer.cpp
+++ b/test/libsolidity/SolidityOptimizer.cpp
@@ -139,7 +139,8 @@ BOOST_AUTO_TEST_CASE(smoke_test)
function f(uint a) returns (uint b) {
return a;
}
- })";
+ }
+ )";
compileBothVersions(sourceCode);
compareVersions("f(uint256)", u256(7));
}
@@ -151,7 +152,8 @@ BOOST_AUTO_TEST_CASE(identities)
function f(int a) returns (int b) {
return int(0) | (int(1) * (int(0) ^ (0 + a)));
}
- })";
+ }
+ )";
compileBothVersions(sourceCode);
compareVersions("f(int256)", u256(0x12334664));
}
@@ -165,7 +167,8 @@ BOOST_AUTO_TEST_CASE(unused_expressions)
10 + 20;
data;
}
- })";
+ }
+ )";
compileBothVersions(sourceCode);
compareVersions("f()");
}
@@ -180,7 +183,8 @@ BOOST_AUTO_TEST_CASE(constant_folding_both_sides)
function f(uint x) returns (uint y) {
return 98 ^ (7 * ((1 | (x | 1000)) * 40) ^ 102);
}
- })";
+ }
+ )";
compileBothVersions(sourceCode);
compareVersions("f(uint256)", 7);
}
@@ -212,7 +216,7 @@ BOOST_AUTO_TEST_CASE(array_copy)
data1[i] = msg.data[i];
data2 = data1;
l = data2.length;
- y = uint(data2[x]);
+ y = uint(uint40(data2[x]));
}
}
)";
diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp
index 0c801cf6..1ffbd771 100644
--- a/test/libsolidity/SolidityParser.cpp
+++ b/test/libsolidity/SolidityParser.cpp
@@ -112,52 +112,6 @@ while(0)
BOOST_AUTO_TEST_SUITE(SolidityParser)
-BOOST_AUTO_TEST_CASE(multiple_return_param_trailing_comma)
-{
- char const* text = R"(
- contract test {
- function() returns (uint a, uint b,) {}
- }
- )";
- CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list.");
-}
-
-BOOST_AUTO_TEST_CASE(multiple_modifier_arg_trailing_comma)
-{
- char const* text = R"(
- contract test {
- modifier modTest(uint a, uint b,) { _; }
- function(uint a) {}
- }
- )";
- CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list.");
-}
-
-BOOST_AUTO_TEST_CASE(multiple_event_arg_trailing_comma)
-{
- char const* text = R"(
- contract test {
- event Test(uint a, uint b,);
- function(uint a) {}
- }
- )";
- CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list.");
-}
-
-BOOST_AUTO_TEST_CASE(two_exact_functions)
-{
- char const* text = R"(
- contract test {
- function fun(uint a) returns(uint r) { return a; }
- function fun(uint a) returns(uint r) { return a; }
- }
- )";
- // with support of overloaded functions, during parsing,
- // we can't determine whether they match exactly, however
- // it will throw DeclarationError in following stage.
- BOOST_CHECK(successParse(text));
-}
-
BOOST_AUTO_TEST_CASE(function_natspec_documentation)
{
char const* text = R"(
@@ -334,57 +288,6 @@ BOOST_AUTO_TEST_CASE(natspec_docstring_after_signature)
"Shouldn't get natspec docstring for this function");
}
-BOOST_AUTO_TEST_CASE(struct_definition)
-{
- char const* text = R"(
- contract test {
- uint256 stateVar;
- struct MyStructName {
- address addr;
- uint256 count;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(mapping)
-{
- char const* text = R"(
- contract test {
- mapping(address => bytes32) names;
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(mapping_in_struct)
-{
- char const* text = R"(
- contract test {
- struct test_struct {
- address addr;
- uint256 count;
- mapping(bytes32 => test_struct) self_reference;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(mapping_to_mapping_in_struct)
-{
- char const* text = R"(
- contract test {
- struct test_struct {
- address addr;
- mapping (uint64 => mapping (bytes32 => uint)) complex_mapping;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
BOOST_AUTO_TEST_CASE(variable_definition)
{
char const* text = R"(
@@ -440,112 +343,6 @@ BOOST_AUTO_TEST_CASE(complex_expression)
BOOST_CHECK(successParse(text));
}
-BOOST_AUTO_TEST_CASE(exp_expression)
-{
- char const* text = R"(
- contract test {
- function fun(uint256 a) {
- uint256 x = 3 ** a;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(while_loop)
-{
- char const* text = R"(
- contract test {
- function fun(uint256 a) {
- while (true) { uint256 x = 1; break; continue; } x = 9;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(for_loop_vardef_initexpr)
-{
- char const* text = R"(
- contract test {
- function fun(uint256 a) {
- for (uint256 i = 0; i < 10; i++) {
- uint256 x = i; break; continue;
- }
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(for_loop_simple_initexpr)
-{
- char const* text = R"(
- contract test {
- function fun(uint256 a) {
- uint256 i =0;
- for (i = 0; i < 10; i++) {
- uint256 x = i; break; continue;
- }
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(for_loop_simple_noexpr)
-{
- char const* text = R"(
- contract test {
- function fun(uint256 a) {
- uint256 i =0;
- for (;;) {
- uint256 x = i; break; continue;
- }
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(for_loop_single_stmt_body)
-{
- char const* text = R"(
- contract test {
- function fun(uint256 a) {
- uint256 i = 0;
- for (i = 0; i < 10; i++)
- continue;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(if_statement)
-{
- char const* text = R"(
- contract test {
- function fun(uint256 a) {
- if (a >= 8) { return 2; } else { var b = 7; }
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(else_if_statement)
-{
- char const* text = R"(
- contract test {
- function fun(uint256 a) returns (address b) {
- if (a < 0) b = 0x67; else if (a == 0) b = 0x12; else b = 0x78;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
BOOST_AUTO_TEST_CASE(statement_starting_with_type_conversion)
{
char const* text = R"(
@@ -673,275 +470,70 @@ BOOST_AUTO_TEST_CASE(contract_multiple_inheritance_with_arguments)
BOOST_CHECK(successParse(text));
}
-BOOST_AUTO_TEST_CASE(placeholder_in_function_context)
-{
- char const* text = R"(
- contract c {
- function fun() returns (uint r) {
- var _ = 8;
- return _ + 1;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(modifier)
-{
- char const* text = R"(
- contract c {
- modifier mod { if (msg.sender == 0) _; }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(modifier_arguments)
-{
- char const* text = R"(
- contract c {
- modifier mod(address a) { if (msg.sender == a) _; }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(modifier_invocation)
-{
- char const* text = R"(
- contract c {
- modifier mod1(uint a) { if (msg.sender == a) _; }
- modifier mod2 { if (msg.sender == 2) _; }
- function f() mod1(7) mod2 { }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(fallback_function)
-{
- char const* text = R"(
- contract c {
- function() { }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(event)
-{
- char const* text = R"(
- contract c {
- event e();
- })";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(event_arguments)
-{
- char const* text = R"(
- contract c {
- event e(uint a, bytes32 s);
- })";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(event_arguments_indexed)
-{
- char const* text = R"(
- contract c {
- event e(uint a, bytes32 indexed s, bool indexed b);
- })";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(visibility_specifiers)
-{
- char const* text = R"(
- contract c {
- uint private a;
- uint internal b;
- uint public c;
- uint d;
- function f() {}
- function f_priv() private {}
- function f_public() public {}
- function f_internal() internal {}
- })";
- BOOST_CHECK(successParse(text));
-}
-
BOOST_AUTO_TEST_CASE(multiple_visibility_specifiers)
{
char const* text = R"(
contract c {
uint private internal a;
- })";
+ }
+ )";
CHECK_PARSE_ERROR(text, "Visibility already specified as \"private\".");
text = R"(
contract c {
function f() private external {}
- })";
+ }
+ )";
CHECK_PARSE_ERROR(text, "Visibility already specified as \"private\".");
}
-BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations)
-{
- char const* text = R"(
- contract c {
- function c ()
- {
- a = 1 wei;
- b = 2 szabo;
- c = 3 finney;
- b = 4 ether;
- }
- uint256 a;
- uint256 b;
- uint256 c;
- uint256 d;
- })";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations_in_expressions)
-{
- char const* text = R"(
- contract c {
- function c ()
- {
- a = 1 wei * 100 wei + 7 szabo - 3;
- }
- uint256 a;
- })";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(enum_valid_declaration)
-{
- char const* text = R"(
- contract c {
- enum validEnum { Value1, Value2, Value3, Value4 }
- function c ()
- {
- a = foo.Value3;
- }
- uint256 a;
- })";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(external_function)
-{
- char const* text = R"(
- contract c {
- function x() external {}
- })";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(arrays_in_storage)
-{
- char const* text = R"(
- contract c {
- uint[10] a;
- uint[] a2;
- struct x { uint[2**20] b; y[0] c; }
- struct y { uint d; mapping(uint=>x)[] e; }
- })";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(arrays_in_events)
-{
- char const* text = R"(
- contract c {
- event e(uint[10] a, bytes7[8] indexed b, c[3] x);
- })";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(arrays_in_expressions)
-{
- char const* text = R"(
- contract c {
- function f() { c[10] a = 7; uint8[10 * 2] x; }
- })";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(multi_arrays)
-{
- char const* text = R"(
- contract c {
- mapping(uint => mapping(uint => int8)[8][][9])[] x;
- })";
- BOOST_CHECK(successParse(text));
-}
-
BOOST_AUTO_TEST_CASE(keyword_is_reserved)
{
auto keywords = {
"abstract",
"after",
+ "alias",
+ "apply",
+ "auto",
"case",
"catch",
+ "copyof",
"default",
+ "define",
"final",
+ "immutable",
+ "implements",
"in",
"inline",
"let",
+ "macro",
"match",
+ "mutable",
"null",
"of",
+ "override",
+ "partial",
+ "promise",
+ "reference",
"relocatable",
+ "sealed",
+ "sizeof",
"static",
+ "supports",
"switch",
"try",
"type",
- "typeof"
+ "typedef",
+ "typeof",
+ "unchecked"
};
for (const auto& keyword: keywords)
{
auto text = std::string("contract ") + keyword + " {}";
- CHECK_PARSE_ERROR(text.c_str(), "Expected identifier but got reserved keyword");
+ CHECK_PARSE_ERROR(text.c_str(), string("Expected identifier but got reserved keyword '") + keyword + "'");
}
}
-BOOST_AUTO_TEST_CASE(location_specifiers_for_params)
-{
- char const* text = R"(
- contract Foo {
- function f(uint[] storage constant x, uint[] memory y) { }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(location_specifiers_for_locals)
-{
- char const* text = R"(
- contract Foo {
- function f() {
- uint[] storage x;
- uint[] memory y;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(library_simple)
-{
- char const* text = R"(
- library Lib {
- function f() { }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
BOOST_AUTO_TEST_CASE(member_access_parser_ambiguity)
{
char const* text = R"(
@@ -986,97 +578,6 @@ BOOST_AUTO_TEST_CASE(complex_import)
BOOST_CHECK(successParse(text));
}
-BOOST_AUTO_TEST_CASE(from_is_not_keyword)
-{
- // "from" is not a keyword although it is used as a keyword in import directives.
- char const* text = R"(
- contract from {
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(inline_array_declaration)
-{
- char const* text = R"(
- contract c {
- uint[] a;
- function f() returns (uint, uint) {
- a = [1,2,3];
- return (a[3], [2,3,4][0]);
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(conditional_true_false_literal)
-{
- char const* text = R"(
- contract A {
- function f() {
- uint x = true ? 1 : 0;
- uint y = false ? 0 : 1;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(conditional_with_constants)
-{
- char const* text = R"(
- contract A {
- function f() {
- uint x = 3 > 0 ? 3 : 0;
- uint y = (3 > 0) ? 3 : 0;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(conditional_with_variables)
-{
- char const* text = R"(
- contract A {
- function f() {
- uint x = 3;
- uint y = 1;
- uint z = (x > y) ? x : y;
- uint w = x > y ? x : y;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(conditional_multiple)
-{
- char const* text = R"(
- contract A {
- function f() {
- uint x = 3 < 0 ? 2 > 1 ? 2 : 1 : 7 > 2 ? 7 : 6;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(conditional_with_assignment)
-{
- char const* text = R"(
- contract A {
- function f() {
- uint y = 1;
- uint x = 3 < 0 ? x = 3 : 6;
- true ? x = 3 : 4;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
BOOST_AUTO_TEST_CASE(recursion_depth1)
{
string text("contract C { bytes");
@@ -1113,117 +614,6 @@ BOOST_AUTO_TEST_CASE(recursion_depth4)
CHECK_PARSE_ERROR(text, "Maximum recursion depth reached during parsing");
}
-BOOST_AUTO_TEST_CASE(declaring_fixed_and_ufixed_variables)
-{
- char const* text = R"(
- contract A {
- fixed40x40 storeMe;
- function f(ufixed x, fixed32x32 y) {
- ufixed8x8 a;
- fixed b;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(declaring_fixed_literal_variables)
-{
- char const* text = R"(
- contract A {
- fixed40x40 pi = 3.14;
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(function_type_in_expression)
-{
- char const* text = R"(
- contract test {
- function f(uint x, uint y) returns (uint a) {}
- function g() {
- function (uint, uint) internal returns (uint) f1 = f;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(function_type_as_storage_variable)
-{
- char const* text = R"(
- contract test {
- function (uint, uint) internal returns (uint) f1;
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(function_type_as_storage_variable_with_assignment)
-{
- char const* text = R"(
- contract test {
- function f(uint x, uint y) returns (uint a) {}
- function (uint, uint) internal returns (uint) f1 = f;
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(function_type_in_struct)
-{
- char const* text = R"(
- contract test {
- struct S {
- function (uint x, uint y) internal returns (uint a) f;
- function (uint, uint) external returns (uint) g;
- uint d;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(function_type_as_parameter)
-{
- char const* text = R"(
- contract test {
- function f(function(uint) external returns (uint) g) internal returns (uint a) {
- return g(1);
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(calling_function)
-{
- char const* text = R"(
- contract test {
- function f() {
- function() returns(function() returns(function() returns(function() returns(uint)))) x;
- uint y;
- y = x()()()();
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(mapping_and_array_of_functions)
-{
- char const* text = R"(
- contract test {
- mapping (address => function() internal returns (uint)) a;
- mapping (address => function() external) b;
- mapping (address => function() external[]) c;
- function() external[] d;
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/test/libsolidity/SolidityScanner.cpp b/test/libsolidity/SolidityScanner.cpp
index 020bce7f..f455c5eb 100644
--- a/test/libsolidity/SolidityScanner.cpp
+++ b/test/libsolidity/SolidityScanner.cpp
@@ -127,6 +127,26 @@ BOOST_AUTO_TEST_CASE(scientific_notation)
BOOST_CHECK_EQUAL(scanner.next(), Token::EOS);
}
+BOOST_AUTO_TEST_CASE(trailing_dot)
+{
+ Scanner scanner(CharStream("2.5"));
+ BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::EOS);
+ scanner.reset(CharStream("2.5e10"), "");
+ BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::EOS);
+ scanner.reset(CharStream(".5"), "");
+ BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::EOS);
+ scanner.reset(CharStream(".5e10"), "");
+ BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::EOS);
+ scanner.reset(CharStream("2."), "");
+ BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::Period);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::EOS);
+}
+
BOOST_AUTO_TEST_CASE(negative_numbers)
{
Scanner scanner(CharStream("var x = -.2 + -0x78 + -7.3 + 8.9 + 2e-2;"));
diff --git a/test/libsolidity/SolidityTypes.cpp b/test/libsolidity/SolidityTypes.cpp
index 738b24bc..ba0e9d4f 100644
--- a/test/libsolidity/SolidityTypes.cpp
+++ b/test/libsolidity/SolidityTypes.cpp
@@ -36,6 +36,33 @@ namespace test
BOOST_AUTO_TEST_SUITE(SolidityTypes)
+BOOST_AUTO_TEST_CASE(int_types)
+{
+ BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::Int, 0, 0)) == *make_shared<IntegerType>(256, IntegerType::Modifier::Signed));
+ for (unsigned i = 8; i <= 256; i += 8)
+ BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, i, 0)) == *make_shared<IntegerType>(i, IntegerType::Modifier::Signed));
+}
+
+BOOST_AUTO_TEST_CASE(uint_types)
+{
+ BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UInt, 0, 0)) == *make_shared<IntegerType>(256, IntegerType::Modifier::Unsigned));
+ for (unsigned i = 8; i <= 256; i += 8)
+ BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, i, 0)) == *make_shared<IntegerType>(i, IntegerType::Modifier::Unsigned));
+}
+
+BOOST_AUTO_TEST_CASE(byte_types)
+{
+ BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::Byte, 0, 0)) == *make_shared<FixedBytesType>(1));
+ for (unsigned i = 1; i <= 32; i++)
+ BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, i, 0)) == *make_shared<FixedBytesType>(i));
+}
+
+BOOST_AUTO_TEST_CASE(fixed_types)
+{
+ BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::Fixed, 0, 0)) == *make_shared<FixedPointType>(128, 18, FixedPointType::Modifier::Signed));
+ BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UFixed, 0, 0)) == *make_shared<FixedPointType>(128, 18, FixedPointType::Modifier::Unsigned));
+}
+
BOOST_AUTO_TEST_CASE(storage_layout_simple)
{
MemberList members(MemberList::MemberMap({
@@ -124,7 +151,12 @@ BOOST_AUTO_TEST_CASE(type_identifiers)
BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("bool")->identifier(), "t_bool");
BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("bytes")->identifier(), "t_bytes_storage_ptr");
BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("bytes memory")->identifier(), "t_bytes_memory_ptr");
+ BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("bytes storage")->identifier(), "t_bytes_storage_ptr");
+ BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("bytes calldata")->identifier(), "t_bytes_calldata_ptr");
BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("string")->identifier(), "t_string_storage_ptr");
+ BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("string memory")->identifier(), "t_string_memory_ptr");
+ BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("string storage")->identifier(), "t_string_storage_ptr");
+ BOOST_CHECK_EQUAL(Type::fromElementaryTypeName("string calldata")->identifier(), "t_string_calldata_ptr");
ArrayType largeintArray(DataLocation::Memory, Type::fromElementaryTypeName("int128"), u256("2535301200456458802993406410752"));
BOOST_CHECK_EQUAL(largeintArray.identifier(), "t_array$_t_int128_$2535301200456458802993406410752_memory_ptr");
TypePointer stringArray = make_shared<ArrayType>(DataLocation::Storage, Type::fromElementaryTypeName("string"), u256("20"));
diff --git a/test/libsolidity/SyntaxTest.cpp b/test/libsolidity/SyntaxTest.cpp
index 1c2355d5..1de42300 100644
--- a/test/libsolidity/SyntaxTest.cpp
+++ b/test/libsolidity/SyntaxTest.cpp
@@ -33,28 +33,10 @@ using namespace std;
namespace fs = boost::filesystem;
using namespace boost::unit_test;
-template<typename IteratorType>
-void skipWhitespace(IteratorType& _it, IteratorType _end)
+namespace
{
- while (_it != _end && isspace(*_it))
- ++_it;
-}
-template<typename IteratorType>
-void skipSlashes(IteratorType& _it, IteratorType _end)
-{
- while (_it != _end && *_it == '/')
- ++_it;
-}
-
-void expect(string::iterator& _it, string::iterator _end, string::value_type _c)
-{
- if (_it == _end || *_it != _c)
- throw runtime_error(string("Invalid test expectation. Expected: \"") + _c + "\".");
- ++_it;
-}
-
-int parseUnsignedInteger(string::iterator &_it, string::iterator _end)
+int parseUnsignedInteger(string::iterator& _it, string::iterator _end)
{
if (_it == _end || !isdigit(*_it))
throw runtime_error("Invalid test expectation. Source location expected.");
@@ -68,6 +50,8 @@ int parseUnsignedInteger(string::iterator &_it, string::iterator _end)
return result;
}
+}
+
SyntaxTest::SyntaxTest(string const& _filename)
{
ifstream file(_filename);
@@ -120,6 +104,55 @@ bool SyntaxTest::run(ostream& _stream, string const& _linePrefix, bool const _fo
return true;
}
+void SyntaxTest::printSource(ostream& _stream, string const& _linePrefix, bool const _formatted) const
+{
+ if (_formatted)
+ {
+ if (m_source.empty())
+ return;
+
+ vector<char const*> sourceFormatting(m_source.length(), formatting::RESET);
+ for (auto const& error: m_errorList)
+ if (error.locationStart >= 0 && error.locationEnd >= 0)
+ {
+ assert(static_cast<size_t>(error.locationStart) <= m_source.length());
+ assert(static_cast<size_t>(error.locationEnd) <= m_source.length());
+ bool isWarning = error.type == "Warning";
+ for (int i = error.locationStart; i < error.locationEnd; i++)
+ if (isWarning)
+ {
+ if (sourceFormatting[i] == formatting::RESET)
+ sourceFormatting[i] = formatting::ORANGE_BACKGROUND;
+ }
+ else
+ sourceFormatting[i] = formatting::RED_BACKGROUND;
+ }
+
+ _stream << _linePrefix << sourceFormatting.front() << m_source.front();
+ for (size_t i = 1; i < m_source.length(); i++)
+ {
+ if (sourceFormatting[i] != sourceFormatting[i - 1])
+ _stream << sourceFormatting[i];
+ if (m_source[i] != '\n')
+ _stream << m_source[i];
+ else
+ {
+ _stream << formatting::RESET << endl;
+ if (i + 1 < m_source.length())
+ _stream << _linePrefix << sourceFormatting[i];
+ }
+ }
+ _stream << formatting::RESET;
+ }
+ else
+ {
+ stringstream stream(m_source);
+ string line;
+ while (getline(stream, line))
+ _stream << _linePrefix << line << endl;
+ }
+}
+
void SyntaxTest::printErrorList(
ostream& _stream,
vector<SyntaxTestError> const& _errorList,
@@ -159,19 +192,6 @@ string SyntaxTest::errorMessage(Exception const& _e)
return "NONE";
}
-string SyntaxTest::parseSource(istream& _stream)
-{
- string source;
- string line;
- string const delimiter("// ----");
- while (getline(_stream, line))
- if (boost::algorithm::starts_with(line, delimiter))
- break;
- else
- source += line + "\n";
- return source;
-}
-
vector<SyntaxTestError> SyntaxTest::parseExpectations(istream& _stream)
{
vector<SyntaxTestError> expectations;
@@ -220,64 +240,3 @@ vector<SyntaxTestError> SyntaxTest::parseExpectations(istream& _stream)
}
return expectations;
}
-
-#if BOOST_VERSION < 105900
-test_case *make_test_case(
- function<void()> const& _fn,
- string const& _name,
- string const& /* _filename */,
- size_t /* _line */
-)
-{
- return make_test_case(_fn, _name);
-}
-#endif
-
-bool SyntaxTest::isTestFilename(boost::filesystem::path const& _filename)
-{
- return _filename.extension().string() == ".sol" &&
- !boost::starts_with(_filename.string(), "~") &&
- !boost::starts_with(_filename.string(), ".");
-}
-
-int SyntaxTest::registerTests(
- boost::unit_test::test_suite& _suite,
- boost::filesystem::path const& _basepath,
- boost::filesystem::path const& _path
-)
-{
- int numTestsAdded = 0;
- fs::path fullpath = _basepath / _path;
- if (fs::is_directory(fullpath))
- {
- test_suite* sub_suite = BOOST_TEST_SUITE(_path.filename().string());
- for (auto const& entry: boost::iterator_range<fs::directory_iterator>(
- fs::directory_iterator(fullpath),
- fs::directory_iterator()
- ))
- if (fs::is_directory(entry.path()) || isTestFilename(entry.path().filename()))
- numTestsAdded += registerTests(*sub_suite, _basepath, _path / entry.path().filename());
- _suite.add(sub_suite);
- }
- else
- {
- static vector<unique_ptr<string>> filenames;
-
- filenames.emplace_back(new string(_path.string()));
- _suite.add(make_test_case(
- [fullpath]
- {
- BOOST_REQUIRE_NO_THROW({
- stringstream errorStream;
- if (!SyntaxTest(fullpath.string()).run(errorStream))
- BOOST_ERROR("Test expectation mismatch.\n" + errorStream.str());
- });
- },
- _path.stem().string(),
- *filenames.back(),
- 0
- ));
- numTestsAdded = 1;
- }
- return numTestsAdded;
-}
diff --git a/test/libsolidity/SyntaxTest.h b/test/libsolidity/SyntaxTest.h
index 6159e789..e9e36aa6 100644
--- a/test/libsolidity/SyntaxTest.h
+++ b/test/libsolidity/SyntaxTest.h
@@ -19,11 +19,9 @@
#include <test/libsolidity/AnalysisFramework.h>
#include <test/libsolidity/FormattedScope.h>
+#include <test/libsolidity/TestCase.h>
#include <libsolidity/interface/Exceptions.h>
-#include <boost/noncopyable.hpp>
-#include <boost/test/unit_test.hpp>
-
#include <iosfwd>
#include <string>
#include <vector>
@@ -52,17 +50,24 @@ struct SyntaxTestError
};
-class SyntaxTest: AnalysisFramework
+class SyntaxTest: AnalysisFramework, public TestCase
{
public:
+ static std::unique_ptr<TestCase> create(std::string const& _filename)
+ { return std::unique_ptr<TestCase>(new SyntaxTest(_filename)); }
SyntaxTest(std::string const& _filename);
- bool run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false);
+ virtual bool run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) override;
- std::vector<SyntaxTestError> const& expectations() const { return m_expectations; }
- std::string const& source() const { return m_source; }
- std::vector<SyntaxTestError> const& errorList() const { return m_errorList; }
+ 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
+ {
+ if (!m_errorList.empty())
+ printErrorList(_stream, m_errorList, _linePrefix, false);
+ }
+ static std::string errorMessage(Exception const& _e);
+private:
static void printErrorList(
std::ostream& _stream,
std::vector<SyntaxTestError> const& _errors,
@@ -70,15 +75,6 @@ public:
bool const _formatted = false
);
- static int registerTests(
- boost::unit_test::test_suite& _suite,
- boost::filesystem::path const& _basepath,
- boost::filesystem::path const& _path
- );
- static bool isTestFilename(boost::filesystem::path const& _filename);
- static std::string errorMessage(Exception const& _e);
-private:
- static std::string parseSource(std::istream& _stream);
static std::vector<SyntaxTestError> parseExpectations(std::istream& _stream);
std::string m_source;
diff --git a/test/libsolidity/TestCase.cpp b/test/libsolidity/TestCase.cpp
new file mode 100644
index 00000000..6c4e0aea
--- /dev/null
+++ b/test/libsolidity/TestCase.cpp
@@ -0,0 +1,55 @@
+/*
+ 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/TestCase.h>
+
+#include <boost/algorithm/string.hpp>
+#include <boost/algorithm/string/predicate.hpp>
+
+#include <stdexcept>
+
+using namespace dev;
+using namespace solidity;
+using namespace dev::solidity::test;
+using namespace std;
+
+bool TestCase::isTestFilename(boost::filesystem::path const& _filename)
+{
+ return _filename.extension().string() == ".sol" &&
+ !boost::starts_with(_filename.string(), "~") &&
+ !boost::starts_with(_filename.string(), ".");
+}
+
+string TestCase::parseSource(istream& _stream)
+{
+ string source;
+ string line;
+ string const delimiter("// ----");
+ while (getline(_stream, line))
+ if (boost::algorithm::starts_with(line, delimiter))
+ break;
+ else
+ source += line + "\n";
+ return source;
+}
+
+void TestCase::expect(string::iterator& _it, string::iterator _end, string::value_type _c)
+{
+ if (_it == _end || *_it != _c)
+ throw runtime_error(string("Invalid test expectation. Expected: \"") + _c + "\".");
+ ++_it;
+}
diff --git a/test/libsolidity/TestCase.h b/test/libsolidity/TestCase.h
new file mode 100644
index 00000000..3c05ae4e
--- /dev/null
+++ b/test/libsolidity/TestCase.h
@@ -0,0 +1,80 @@
+/*
+ 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 <boost/filesystem.hpp>
+
+#include <iosfwd>
+#include <memory>
+#include <string>
+
+namespace dev
+{
+namespace solidity
+{
+namespace test
+{
+
+/** Common superclass of SyntaxTest and SemanticsTest. */
+class TestCase
+{
+public:
+ using TestCaseCreator = std::unique_ptr<TestCase>(*)(std::string const&);
+
+ virtual ~TestCase() {}
+
+ /// Runs the test case.
+ /// Outputs error messages to @arg _stream. Each line of output is prefixed with @arg _linePrefix.
+ /// Optionally, color-coding can be enabled (if @arg _formatted is set to true).
+ /// @returns true, if the test case succeeds, false otherwise
+ virtual bool run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) = 0;
+
+ /// Outputs the test contract to @arg _stream.
+ /// Each line of output is prefixed with @arg _linePrefix.
+ /// If @arg _formatted is true, color-coding may be used to indicate
+ /// error locations in the contract, if applicable.
+ virtual void printSource(std::ostream &_stream, std::string const &_linePrefix = "", bool const _formatted = false) const = 0;
+ /// Outputs test expectations to @arg _stream that match the actual results of the test.
+ /// Each line of output is prefixed with @arg _linePrefix.
+ virtual void printUpdatedExpectations(std::ostream& _stream, std::string const& _linePrefix) const = 0;
+
+ static bool isTestFilename(boost::filesystem::path const& _filename);
+
+protected:
+ static std::string parseSource(std::istream& _file);
+ static void expect(std::string::iterator& _it, std::string::iterator _end, std::string::value_type _c);
+
+ template<typename IteratorType>
+ static void skipWhitespace(IteratorType& _it, IteratorType _end)
+ {
+ while (_it != _end && isspace(*_it))
+ ++_it;
+ }
+
+ template<typename IteratorType>
+ static void skipSlashes(IteratorType& _it, IteratorType _end)
+ {
+ while (_it != _end && *_it == '/')
+ ++_it;
+ }
+
+};
+
+}
+}
+}
diff --git a/test/libsolidity/ViewPureChecker.cpp b/test/libsolidity/ViewPureChecker.cpp
index cd0a0b01..53761ff2 100644
--- a/test/libsolidity/ViewPureChecker.cpp
+++ b/test/libsolidity/ViewPureChecker.cpp
@@ -38,71 +38,6 @@ namespace test
BOOST_FIXTURE_TEST_SUITE(ViewPureChecker, AnalysisFramework)
-BOOST_AUTO_TEST_CASE(smoke_test)
-{
- char const* text = R"(
- contract C {
- uint x;
- function g() pure public {}
- function f() view public returns (uint) { return now; }
- function h() public { x = 2; }
- function i() payable public { x = 2; }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(call_internal_functions_success)
-{
- char const* text = R"(
- contract C {
- function g() pure public { g(); }
- function f() view public returns (uint) { f(); g(); }
- function h() public { h(); g(); f(); }
- function i() payable public { i(); h(); g(); f(); }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(suggest_pure)
-{
- char const* text = R"(
- contract C {
- function g() view public { }
- }
- )";
- CHECK_WARNING(text, "can be restricted to pure");
-}
-
-BOOST_AUTO_TEST_CASE(suggest_view)
-{
- char const* text = R"(
- contract C {
- uint x;
- function g() public returns (uint) { return x; }
- }
- )";
- CHECK_WARNING(text, "can be restricted to view");
-}
-
-BOOST_AUTO_TEST_CASE(call_internal_functions_fail)
-{
- CHECK_ERROR(
- "contract C{ function f() pure public { g(); } function g() view public {} }",
- TypeError,
- "Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires \"view\""
- );
-}
-
-BOOST_AUTO_TEST_CASE(write_storage_fail)
-{
- CHECK_WARNING(
- "contract C{ uint x; function f() view public { x = 2; } }",
- "Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable."
- );
-}
-
BOOST_AUTO_TEST_CASE(environment_access)
{
vector<string> view{
@@ -163,275 +98,6 @@ BOOST_AUTO_TEST_CASE(environment_access)
}));
}
-BOOST_AUTO_TEST_CASE(view_error_for_050)
-{
- CHECK_ERROR(
- "pragma experimental \"v0.5.0\"; contract C { uint x; function f() view public { x = 2; } }",
- TypeError,
- "Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable."
- );
-
-}
-
-BOOST_AUTO_TEST_CASE(modifiers)
-{
- string text = R"(
- contract D {
- uint x;
- modifier purem(uint) { _; }
- modifier viewm(uint) { uint a = x; _; a; }
- modifier nonpayablem(uint) { x = 2; _; }
- }
- contract C is D {
- function f() purem(0) pure public {}
- function g() viewm(0) view public {}
- function h() nonpayablem(0) public {}
- function i() purem(x) view public {}
- function j() viewm(x) view public {}
- function k() nonpayablem(x) public {}
- function l() purem(x = 2) public {}
- function m() viewm(x = 2) public {}
- function n() nonpayablem(x = 2) public {}
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(interface)
-{
- string text = R"(
- interface D {
- function f() view external;
- }
- contract C is D {
- function f() view external {}
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(overriding)
-{
- string text = R"(
- contract D {
- uint x;
- function f() public { x = 2; }
- }
- contract C is D {
- function f() public {}
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(returning_structs)
-{
- string text = R"(
- contract C {
- struct S { uint x; }
- S s;
- function f() view internal returns (S storage) {
- return s;
- }
- function g() public {
- f().x = 2;
- }
- function h() view public {
- f();
- f().x;
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(mappings)
-{
- string text = R"(
- contract C {
- mapping(uint => uint) a;
- function f() view public {
- a;
- }
- function g() view public {
- a[2];
- }
- function h() public {
- a[2] = 3;
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(local_storage_variables)
-{
- string text = R"(
- contract C {
- struct S { uint a; }
- S s;
- function f() view public {
- S storage x = s;
- x;
- }
- function g() view public {
- S storage x = s;
- x = s;
- }
- function i() public {
- s.a = 2;
- }
- function h() public {
- S storage x = s;
- x.a = 2;
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(builtin_functions)
-{
- string text = R"(
- contract C {
- function f() public {
- address(this).transfer(1);
- require(address(this).send(2));
- selfdestruct(address(this));
- require(address(this).delegatecall());
- require(address(this).call());
- }
- function g() pure public {
- bytes32 x = keccak256("abc");
- bytes32 y = sha256("abc");
- address z = ecrecover(1, 2, 3, 4);
- require(true);
- assert(true);
- x; y; z;
- }
- function() payable public {}
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(function_types)
-{
- string text = R"(
- contract C {
- function f() pure public {
- function () external nonpayFun;
- function () external view viewFun;
- function () external pure pureFun;
-
- nonpayFun;
- viewFun;
- pureFun;
- pureFun();
- }
- function g() view public {
- function () external view viewFun;
-
- viewFun();
- }
- function h() public {
- function () external nonpayFun;
-
- nonpayFun();
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(selector)
-{
- string text = R"(
- contract C {
- uint public x;
- function f() payable public {
- }
- function g() pure public returns (bytes4) {
- return this.f.selector ^ this.x.selector;
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(selector_complex)
-{
- string text = R"(
- contract C {
- function f(C c) pure public returns (C) {
- return c;
- }
- function g() pure public returns (bytes4) {
- // By passing `this`, we read from the state, even if f itself is pure.
- return f(this).f.selector;
- }
- }
- )";
- CHECK_ERROR(text, TypeError, "reads from the environment or state and thus requires \"view\"");
-}
-
-BOOST_AUTO_TEST_CASE(selector_complex2)
-{
- string text = R"(
- contract C {
- function f() payable public returns (C) {
- return this;
- }
- function g() pure public returns (bytes4) {
- C x = C(0x123);
- return x.f.selector;
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(creation)
-{
- string text = R"(
- contract D {}
- contract C {
- function f() public { new D(); }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(assembly)
-{
- string text = R"(
- contract C {
- struct S { uint x; }
- S s;
- function e() pure public {
- assembly { mstore(keccak256(0, 20), mul(s_slot, 2)) }
- }
- function f() pure public {
- uint x;
- assembly { x := 7 }
- }
- function g() view public {
- assembly { for {} 1 { pop(sload(0)) } { } pop(gas) }
- }
- function h() view public {
- assembly { function g() { pop(blockhash(20)) } }
- }
- function j() public {
- assembly { pop(call(0, 1, 2, 3, 4, 5, 6)) }
- }
- function k() public {
- assembly { pop(call(gas, 1, 2, 3, 4, 5, 6)) }
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
BOOST_AUTO_TEST_CASE(assembly_staticcall)
{
string text = R"(
@@ -447,31 +113,6 @@ BOOST_AUTO_TEST_CASE(assembly_staticcall)
CHECK_SUCCESS_NO_WARNINGS(text);
}
-BOOST_AUTO_TEST_CASE(assembly_jump)
-{
- string text = R"(
- contract C {
- function k() public {
- assembly { jump(2) }
- }
- }
- )";
- CHECK_WARNING(text, "low-level EVM features");
-}
-
-BOOST_AUTO_TEST_CASE(constant)
-{
- string text = R"(
- contract C {
- uint constant x = 2;
- function k() pure public returns (uint) {
- return x;
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/test/libsolidity/syntaxTests/array/array_pop.sol b/test/libsolidity/syntaxTests/array/array_pop.sol
new file mode 100644
index 00000000..3804f911
--- /dev/null
+++ b/test/libsolidity/syntaxTests/array/array_pop.sol
@@ -0,0 +1,7 @@
+contract C {
+ uint[] data;
+ function test() public {
+ data.pop();
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/array/array_pop_arg.sol b/test/libsolidity/syntaxTests/array/array_pop_arg.sol
new file mode 100644
index 00000000..bb7803e2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/array/array_pop_arg.sol
@@ -0,0 +1,8 @@
+contract C {
+ uint[] data;
+ function test() public {
+ data.pop(5);
+ }
+}
+// ----
+// TypeError: (65-76): Wrong argument count for function call: 1 arguments given but expected 0.
diff --git a/test/libsolidity/syntaxTests/array/bytes_pop.sol b/test/libsolidity/syntaxTests/array/bytes_pop.sol
new file mode 100644
index 00000000..cd5aa0eb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/array/bytes_pop.sol
@@ -0,0 +1,7 @@
+contract C {
+ bytes data;
+ function test() public {
+ data.pop();
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/array/dynamic_memory_array_pop.sol b/test/libsolidity/syntaxTests/array/dynamic_memory_array_pop.sol
new file mode 100644
index 00000000..5a79afc9
--- /dev/null
+++ b/test/libsolidity/syntaxTests/array/dynamic_memory_array_pop.sol
@@ -0,0 +1,8 @@
+contract C {
+ function test() public {
+ uint[] memory data;
+ data.pop();
+ }
+}
+// ----
+// TypeError: (74-82): Member "pop" is not available in uint256[] memory outside of storage.
diff --git a/test/libsolidity/syntaxTests/arrayLength/array_length_cannot_be_constant_function_parameter.sol b/test/libsolidity/syntaxTests/array/length/array_length_cannot_be_constant_function_parameter.sol
index 11d40f26..11d40f26 100644
--- a/test/libsolidity/syntaxTests/arrayLength/array_length_cannot_be_constant_function_parameter.sol
+++ b/test/libsolidity/syntaxTests/array/length/array_length_cannot_be_constant_function_parameter.sol
diff --git a/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_function.sol b/test/libsolidity/syntaxTests/array/length/can_be_constant_in_function.sol
index 92536dd5..92536dd5 100644
--- a/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_function.sol
+++ b/test/libsolidity/syntaxTests/array/length/can_be_constant_in_function.sol
diff --git a/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_struct.sol b/test/libsolidity/syntaxTests/array/length/can_be_constant_in_struct.sol
index 89e174f2..89e174f2 100644
--- a/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_struct.sol
+++ b/test/libsolidity/syntaxTests/array/length/can_be_constant_in_struct.sol
diff --git a/test/libsolidity/syntaxTests/arrayLength/can_be_recursive_constant.sol b/test/libsolidity/syntaxTests/array/length/can_be_recursive_constant.sol
index 6810a9d6..6810a9d6 100644
--- a/test/libsolidity/syntaxTests/arrayLength/can_be_recursive_constant.sol
+++ b/test/libsolidity/syntaxTests/array/length/can_be_recursive_constant.sol
diff --git a/test/libsolidity/syntaxTests/arrayLength/cannot_be_function.sol b/test/libsolidity/syntaxTests/array/length/cannot_be_function.sol
index ac3abc4c..ac3abc4c 100644
--- a/test/libsolidity/syntaxTests/arrayLength/cannot_be_function.sol
+++ b/test/libsolidity/syntaxTests/array/length/cannot_be_function.sol
diff --git a/test/libsolidity/syntaxTests/arrayLength/cannot_be_function_call.sol b/test/libsolidity/syntaxTests/array/length/cannot_be_function_call.sol
index a6863955..a6863955 100644
--- a/test/libsolidity/syntaxTests/arrayLength/cannot_be_function_call.sol
+++ b/test/libsolidity/syntaxTests/array/length/cannot_be_function_call.sol
diff --git a/test/libsolidity/syntaxTests/arrayLength/complex_cyclic_constant.sol b/test/libsolidity/syntaxTests/array/length/complex_cyclic_constant.sol
index 254f9f02..254f9f02 100644
--- a/test/libsolidity/syntaxTests/arrayLength/complex_cyclic_constant.sol
+++ b/test/libsolidity/syntaxTests/array/length/complex_cyclic_constant.sol
diff --git a/test/libsolidity/syntaxTests/arrayLength/const_cannot_be_fractional.sol b/test/libsolidity/syntaxTests/array/length/const_cannot_be_fractional.sol
index 397bbbcd..397bbbcd 100644
--- a/test/libsolidity/syntaxTests/arrayLength/const_cannot_be_fractional.sol
+++ b/test/libsolidity/syntaxTests/array/length/const_cannot_be_fractional.sol
diff --git a/test/libsolidity/syntaxTests/arrayLength/constant_var.sol b/test/libsolidity/syntaxTests/array/length/constant_var.sol
index 41750250..41750250 100644
--- a/test/libsolidity/syntaxTests/arrayLength/constant_var.sol
+++ b/test/libsolidity/syntaxTests/array/length/constant_var.sol
diff --git a/test/libsolidity/syntaxTests/arrayLength/cyclic_constant.sol b/test/libsolidity/syntaxTests/array/length/cyclic_constant.sol
index 91ba9045..91ba9045 100644
--- a/test/libsolidity/syntaxTests/arrayLength/cyclic_constant.sol
+++ b/test/libsolidity/syntaxTests/array/length/cyclic_constant.sol
diff --git a/test/libsolidity/syntaxTests/arrayLength/inline_array.sol b/test/libsolidity/syntaxTests/array/length/inline_array.sol
index a30745d3..a30745d3 100644
--- a/test/libsolidity/syntaxTests/arrayLength/inline_array.sol
+++ b/test/libsolidity/syntaxTests/array/length/inline_array.sol
diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_1.sol b/test/libsolidity/syntaxTests/array/length/invalid_expression_1.sol
index c92861eb..c92861eb 100644
--- a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_1.sol
+++ b/test/libsolidity/syntaxTests/array/length/invalid_expression_1.sol
diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_2.sol b/test/libsolidity/syntaxTests/array/length/invalid_expression_2.sol
index 92e3c3cf..92e3c3cf 100644
--- a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_2.sol
+++ b/test/libsolidity/syntaxTests/array/length/invalid_expression_2.sol
diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_3.sol b/test/libsolidity/syntaxTests/array/length/invalid_expression_3.sol
index 26add45c..26add45c 100644
--- a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_3.sol
+++ b/test/libsolidity/syntaxTests/array/length/invalid_expression_3.sol
diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_4.sol b/test/libsolidity/syntaxTests/array/length/invalid_expression_4.sol
index a0d58f4a..a0d58f4a 100644
--- a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_4.sol
+++ b/test/libsolidity/syntaxTests/array/length/invalid_expression_4.sol
diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_5.sol b/test/libsolidity/syntaxTests/array/length/invalid_expression_5.sol
index 38a80867..38a80867 100644
--- a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_5.sol
+++ b/test/libsolidity/syntaxTests/array/length/invalid_expression_5.sol
diff --git a/test/libsolidity/syntaxTests/arrayLength/non_integer_constant_var.sol b/test/libsolidity/syntaxTests/array/length/non_integer_constant_var.sol
index 7a853a34..7a853a34 100644
--- a/test/libsolidity/syntaxTests/arrayLength/non_integer_constant_var.sol
+++ b/test/libsolidity/syntaxTests/array/length/non_integer_constant_var.sol
diff --git a/test/libsolidity/syntaxTests/arrayLength/not_convertible_to_integer.sol b/test/libsolidity/syntaxTests/array/length/not_convertible_to_integer.sol
index b44ccfe9..b44ccfe9 100644
--- a/test/libsolidity/syntaxTests/arrayLength/not_convertible_to_integer.sol
+++ b/test/libsolidity/syntaxTests/array/length/not_convertible_to_integer.sol
diff --git a/test/libsolidity/syntaxTests/arrayLength/parentheses.sol b/test/libsolidity/syntaxTests/array/length/parentheses.sol
index 40f55ad6..40f55ad6 100644
--- a/test/libsolidity/syntaxTests/arrayLength/parentheses.sol
+++ b/test/libsolidity/syntaxTests/array/length/parentheses.sol
diff --git a/test/libsolidity/syntaxTests/arrayLength/pure_functions.sol b/test/libsolidity/syntaxTests/array/length/pure_functions.sol
index b620db76..b620db76 100644
--- a/test/libsolidity/syntaxTests/arrayLength/pure_functions.sol
+++ b/test/libsolidity/syntaxTests/array/length/pure_functions.sol
diff --git a/test/libsolidity/syntaxTests/arrayLength/too_large.sol b/test/libsolidity/syntaxTests/array/length/too_large.sol
index c90a7494..c90a7494 100644
--- a/test/libsolidity/syntaxTests/arrayLength/too_large.sol
+++ b/test/libsolidity/syntaxTests/array/length/too_large.sol
diff --git a/test/libsolidity/syntaxTests/arrayLength/tuples.sol b/test/libsolidity/syntaxTests/array/length/tuples.sol
index bc10b3b5..bc10b3b5 100644
--- a/test/libsolidity/syntaxTests/arrayLength/tuples.sol
+++ b/test/libsolidity/syntaxTests/array/length/tuples.sol
diff --git a/test/libsolidity/syntaxTests/array/no_array_pop.sol b/test/libsolidity/syntaxTests/array/no_array_pop.sol
new file mode 100644
index 00000000..44e54ad2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/array/no_array_pop.sol
@@ -0,0 +1,8 @@
+contract C {
+ uint data;
+ function test() public {
+ data.pop();
+ }
+}
+// ----
+// TypeError: (63-71): Member "pop" not found or not visible after argument-dependent lookup in uint256
diff --git a/test/libsolidity/syntaxTests/array/static_storage_array_pop.sol b/test/libsolidity/syntaxTests/array/static_storage_array_pop.sol
new file mode 100644
index 00000000..0af171ad
--- /dev/null
+++ b/test/libsolidity/syntaxTests/array/static_storage_array_pop.sol
@@ -0,0 +1,8 @@
+contract C {
+ uint[3] data;
+ function test() public {
+ data.pop();
+ }
+}
+// ----
+// TypeError: (66-74): Member "pop" not found or not visible after argument-dependent lookup in uint256[3] storage ref
diff --git a/test/libsolidity/syntaxTests/array/string_pop.sol b/test/libsolidity/syntaxTests/array/string_pop.sol
new file mode 100644
index 00000000..2a46d0c3
--- /dev/null
+++ b/test/libsolidity/syntaxTests/array/string_pop.sol
@@ -0,0 +1,8 @@
+contract C {
+ string data;
+ function test() public {
+ data.pop();
+ }
+}
+// ----
+// TypeError: (65-73): Member "pop" not found or not visible after argument-dependent lookup in string storage ref
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_fine.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_fine.sol
index 6520672c..55c5edd3 100644
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_fine.sol
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_fine.sol
@@ -23,13 +23,8 @@ contract C {
}
function k() internal view returns (S storage c) {
do {
- if (s.f) {
- continue;
- break;
- }
- else {
- c = s;
- }
+ c = s;
+ continue;
} while(false);
}
}
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol
index f1a92e9c..7d001c19 100644
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol
@@ -21,6 +21,15 @@ contract 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 {
@@ -28,8 +37,16 @@ contract C {
}
} 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/dataLocations/externalFunction/function_argument_location_specifier_test_external_calldata.sol b/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_calldata.sol
new file mode 100644
index 00000000..781c645a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_calldata.sol
@@ -0,0 +1,4 @@
+contract test {
+ function f(bytes calldata) external;
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_memory.sol b/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_memory.sol
new file mode 100644
index 00000000..807cc064
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_memory.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f(bytes memory) external;
+}
+// ----
+// TypeError: (31-36): Location has to be calldata for external functions (remove the "memory" or "storage" keyword).
diff --git a/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_storage.sol b/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_storage.sol
new file mode 100644
index 00000000..2664dbab
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_storage.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f(bytes storage) external;
+}
+// ----
+// TypeError: (31-36): Location has to be calldata for external functions (remove the "memory" or "storage" keyword).
diff --git a/test/libsolidity/syntaxTests/dataLocations/function_argument_location_specifier_test_library.sol b/test/libsolidity/syntaxTests/dataLocations/function_argument_location_specifier_test_library.sol
new file mode 100644
index 00000000..4348482a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/function_argument_location_specifier_test_library.sol
@@ -0,0 +1,5 @@
+library test {
+ function f(bytes calldata) public;
+}
+// ----
+// TypeError: (30-35): Location cannot be calldata for non-external functions (remove the "calldata" keyword).
diff --git a/test/libsolidity/syntaxTests/dataLocations/function_argument_location_specifier_test_non_reference_type.sol b/test/libsolidity/syntaxTests/dataLocations/function_argument_location_specifier_test_non_reference_type.sol
new file mode 100644
index 00000000..70f6c5eb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/function_argument_location_specifier_test_non_reference_type.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f(bytes4 memory) public;
+}
+// ----
+// TypeError: (31-37): Data location can only be given for array or struct types.
diff --git a/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_calldata.sol b/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_calldata.sol
new file mode 100644
index 00000000..f2740946
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_calldata.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f(bytes calldata) internal;
+}
+// ----
+// TypeError: (31-36): Variable cannot be declared as "calldata" (remove the "calldata" keyword).
diff --git a/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_memory.sol b/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_memory.sol
new file mode 100644
index 00000000..1e5971c4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_memory.sol
@@ -0,0 +1,4 @@
+contract test {
+ function f(bytes memory) internal;
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_storage.sol b/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_storage.sol
new file mode 100644
index 00000000..56f0fe99
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_storage.sol
@@ -0,0 +1,4 @@
+contract test {
+ function f(bytes storage) internal;
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_calldata.sol b/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_calldata.sol
new file mode 100644
index 00000000..cb00199f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_calldata.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f(bytes calldata) public;
+}
+// ----
+// TypeError: (31-36): Location has to be memory for publicly visible functions (remove the "storage" or "calldata" keyword).
diff --git a/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_memory.sol b/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_memory.sol
new file mode 100644
index 00000000..4eebf016
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_memory.sol
@@ -0,0 +1,4 @@
+contract test {
+ function f(bytes memory) public;
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_storage.sol b/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_storage.sol
new file mode 100644
index 00000000..9380d9df
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_storage.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f(bytes storage) public;
+}
+// ----
+// TypeError: (31-36): Location has to be memory for publicly visible functions (remove the "storage" or "calldata" keyword).
diff --git a/test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_non_reference_type.sol b/test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_non_reference_type.sol
new file mode 100644
index 00000000..876d6fd6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_non_reference_type.sol
@@ -0,0 +1,13 @@
+contract test {
+ function f() {
+ uint storage a1;
+ bytes16 storage b1;
+ uint memory a2;
+ bytes16 memory b2;
+ }
+}
+// ----
+// TypeError: (41-56): Data location can only be given for array or struct types.
+// TypeError: (64-82): Data location can only be given for array or struct types.
+// TypeError: (90-104): Data location can only be given for array or struct types.
+// TypeError: (112-129): Data location can only be given for array or struct types.
diff --git a/test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_reference_type.sol b/test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_reference_type.sol
new file mode 100644
index 00000000..bd011f2d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_reference_type.sol
@@ -0,0 +1,14 @@
+contract test {
+ uint[] a;
+ uint[] b;
+ function f() public {
+ uint[] storage s1 = a;
+ uint[] memory s2 = new uint[](42);
+ uint[] s3 = b;
+ s1.push(42);
+ s2[3] = 12;
+ s3.push(42);
+ }
+}
+// ----
+// Warning: (147-156): Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning.
diff --git a/test/libsolidity/syntaxTests/denominations/denominations.sol b/test/libsolidity/syntaxTests/denominations/denominations.sol
index 6d1aa2f3..43049a14 100644
--- a/test/libsolidity/syntaxTests/denominations/denominations.sol
+++ b/test/libsolidity/syntaxTests/denominations/denominations.sol
@@ -1,7 +1,6 @@
contract C {
uint constant a = 1 wei + 2 szabo + 3 finney + 4 ether;
- uint constant b = 1 seconds + 2 minutes + 3 hours + 4 days + 5 weeks + 6 years;
+ uint constant b = 1 seconds + 2 minutes + 3 hours + 4 days + 5 weeks;
uint constant c = 2 szabo / 1 seconds + 3 finney * 3 hours;
}
// ----
-// Warning: (142-149): Using "years" as a unit denomination is deprecated.
diff --git a/test/libsolidity/syntaxTests/denominations/deprecated_year.sol b/test/libsolidity/syntaxTests/denominations/deprecated_year.sol
index 30e86535..691c0cb0 100644
--- a/test/libsolidity/syntaxTests/denominations/deprecated_year.sol
+++ b/test/libsolidity/syntaxTests/denominations/deprecated_year.sol
@@ -2,4 +2,4 @@ contract C {
uint constant a = 3 years;
}
// ----
-// Warning: (32-39): Using "years" as a unit denomination is deprecated.
+// TypeError: (32-39): Using "years" as a unit denomination is deprecated.
diff --git a/test/libsolidity/syntaxTests/denominations/deprecated_year_050.sol b/test/libsolidity/syntaxTests/denominations/deprecated_year_050.sol
deleted file mode 100644
index 4baaeaa3..00000000
--- a/test/libsolidity/syntaxTests/denominations/deprecated_year_050.sol
+++ /dev/null
@@ -1,6 +0,0 @@
-pragma experimental "v0.5.0";
-contract C {
- uint constant a = 3 years;
-}
-// ----
-// TypeError: (62-69): Using "years" as a unit denomination is deprecated.
diff --git a/test/libsolidity/syntaxTests/deprecated_functions.sol b/test/libsolidity/syntaxTests/deprecated_functions.sol
index 9df2b43c..99ca4542 100644
--- a/test/libsolidity/syntaxTests/deprecated_functions.sol
+++ b/test/libsolidity/syntaxTests/deprecated_functions.sol
@@ -4,9 +4,9 @@ contract test {
x;
}
function g() public {
- suicide(1);
+ suicide(0x0000000000000000000000000000000000000001);
}
}
// ----
-// Warning: (58-64): "sha3" has been deprecated in favour of "keccak256"
-// Warning: (99-109): "suicide" has been deprecated in favour of "selfdestruct"
+// TypeError: (58-64): "sha3" has been deprecated in favour of "keccak256"
+// TypeError: (99-150): "suicide" has been deprecated in favour of "selfdestruct"
diff --git a/test/libsolidity/syntaxTests/deprecated_functions_050.sol b/test/libsolidity/syntaxTests/deprecated_functions_050.sol
deleted file mode 100644
index b28e5abb..00000000
--- a/test/libsolidity/syntaxTests/deprecated_functions_050.sol
+++ /dev/null
@@ -1,15 +0,0 @@
-pragma experimental "v0.5.0";
-contract test {
- function f() pure public {
- bytes32 x = sha3(uint8(1));
- x;
- }
- function g() public {
- suicide(1);
- }
-}
-// ----
-// TypeError: (88-102): "sha3" has been deprecated in favour of "keccak256"
-// TypeError: (88-102): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
-// TypeError: (88-102): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory.
-// TypeError: (137-147): "suicide" has been deprecated in favour of "selfdestruct"
diff --git a/test/libsolidity/syntaxTests/double_variable_declaration.sol b/test/libsolidity/syntaxTests/double_variable_declaration.sol
index 9ab87959..53c5c9be 100644
--- a/test/libsolidity/syntaxTests/double_variable_declaration.sol
+++ b/test/libsolidity/syntaxTests/double_variable_declaration.sol
@@ -1,8 +1,9 @@
contract test {
function f() pure public {
uint256 x;
- if (true) { uint256 x; }
+ x = 1;
+ if (true) { uint256 x; x = 2; }
}
}
// ----
-// DeclarationError: (71-80): Identifier already declared.
+// Warning: (80-89): This declaration shadows an existing declaration.
diff --git a/test/libsolidity/syntaxTests/double_variable_declaration_050.sol b/test/libsolidity/syntaxTests/double_variable_declaration_050.sol
deleted file mode 100644
index 2f47e6dc..00000000
--- a/test/libsolidity/syntaxTests/double_variable_declaration_050.sol
+++ /dev/null
@@ -1,11 +0,0 @@
-pragma experimental "v0.5.0";
-contract test {
- function f() pure public {
- uint256 x;
- if (true) { uint256 x; }
- }
-}
-// ----
-// Warning: (101-110): This declaration shadows an existing declaration.
-// Warning: (76-85): Unused local variable.
-// Warning: (101-110): Unused local variable.
diff --git a/test/libsolidity/syntaxTests/empty_string_var.sol b/test/libsolidity/syntaxTests/empty_string_var.sol
deleted file mode 100644
index e9837590..00000000
--- a/test/libsolidity/syntaxTests/empty_string_var.sol
+++ /dev/null
@@ -1,11 +0,0 @@
-contract C {
- function f() {
- var a = "";
- bytes1 b = bytes1(a);
- bytes memory c = bytes(a);
- string memory d = string(a);
- }
-}
-// ----
-// Warning: (34-39): Use of the "var" keyword is deprecated.
-// TypeError: (61-70): Explicit type conversion not allowed from "string memory" to "bytes1".
diff --git a/test/libsolidity/syntaxTests/empty_struct.sol b/test/libsolidity/syntaxTests/empty_struct.sol
index 12655309..0a52fb72 100644
--- a/test/libsolidity/syntaxTests/empty_struct.sol
+++ b/test/libsolidity/syntaxTests/empty_struct.sol
@@ -2,4 +2,4 @@ contract test {
struct A {}
}
// ----
-// Warning: (17-28): Defining empty structs is deprecated.
+// SyntaxError: (17-28): Defining empty structs is disallowed.
diff --git a/test/libsolidity/syntaxTests/empty_struct_050.sol b/test/libsolidity/syntaxTests/empty_struct_050.sol
deleted file mode 100644
index 886f1f83..00000000
--- a/test/libsolidity/syntaxTests/empty_struct_050.sol
+++ /dev/null
@@ -1,6 +0,0 @@
-pragma experimental "v0.5.0";
-contract test {
- struct A {}
-}
-// ----
-// SyntaxError: (47-58): Defining empty structs is disallowed.
diff --git a/test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol b/test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol
index a6fe6c22..2481c455 100644
--- a/test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol
+++ b/test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol
@@ -3,15 +3,13 @@ contract C {
function(uint) internal returns (uint) y;
function f() public {
delete x;
- var a = y;
+ function(uint) internal returns (uint) a = y;
delete a;
delete y;
- var c = f;
+ function() internal c = f;
delete c;
function(uint) internal returns (uint) g;
delete g;
}
}
// ----
-// Warning: (157-162): Use of the "var" keyword is deprecated.
-// Warning: (212-217): Use of the "var" keyword is deprecated.
diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_return_parameters_with_names.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_return_parameters_with_names.sol
new file mode 100644
index 00000000..12191530
--- /dev/null
+++ b/test/libsolidity/syntaxTests/functionTypes/function_type_return_parameters_with_names.sol
@@ -0,0 +1,5 @@
+contract C {
+ function(uint) returns (bool ret) f;
+}
+// ----
+// SyntaxError: (41-49): Return parameters in function types may not be named.
diff --git a/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables.sol b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables.sol
index 00031924..76bb6fc0 100644
--- a/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables.sol
+++ b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables.sol
@@ -2,3 +2,5 @@ contract B {
function f() mod(x) pure public { uint x = 7; }
modifier mod(uint a) { if (a > 0) _; }
}
+// ----
+// DeclarationError: (34-35): Undeclared identifier.
diff --git a/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables050.sol b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables050.sol
deleted file mode 100644
index c19ccf2c..00000000
--- a/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables050.sol
+++ /dev/null
@@ -1,7 +0,0 @@
-pragma experimental "v0.5.0";
-contract B {
- function f() mod(x) pure public { uint x = 7; }
- modifier mod(uint a) { if (a > 0) _; }
-}
-// ----
-// DeclarationError: (64-65): Undeclared identifier.
diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalid.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalid.sol
deleted file mode 100644
index c8686ae8..00000000
--- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalid.sol
+++ /dev/null
@@ -1,8 +0,0 @@
-contract C {
- function f() internal returns (uint, uint, uint, uint) {
- var (uint a, uint b,,) = f();
- a; b;
- }
-}
-// ----
-// ParserError: (81-85): Expected identifier but got 'uint'
diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol
index 3ba85f69..224d9614 100644
--- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol
+++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol
@@ -1,5 +1,3 @@
-pragma experimental "v0.5.0";
-
contract C {
function f() internal {
{
@@ -9,4 +7,4 @@ contract C {
}
}
// ----
-// DeclarationError: (130-131): Undeclared identifier.
+// DeclarationError: (99-100): Undeclared identifier.
diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol
index e21181de..242a1f39 100644
--- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol
+++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol
@@ -1,5 +1,3 @@
-pragma experimental "v0.5.0";
-
contract C {
function f() internal {
{
@@ -8,6 +6,6 @@ contract C {
}
}
// ----
-// DeclarationError: (110-111): Undeclared identifier. Did you mean "a"?
-// DeclarationError: (113-114): Undeclared identifier. Did you mean "b"?
-// DeclarationError: (116-117): Undeclared identifier. Did you mean "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.
+// DeclarationError: (85-86): Undeclared identifier. "c" is not (or not yet) visible at this point.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/001_name_references.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/001_name_references.sol
new file mode 100644
index 00000000..dc304a1d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/001_name_references.sol
@@ -0,0 +1,4 @@
+contract test {
+ uint256 variable;
+ function f(uint256) public returns (uint out) { f(variable); test; out; }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/002_undeclared_name.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/002_undeclared_name.sol
new file mode 100644
index 00000000..afe9483f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/002_undeclared_name.sol
@@ -0,0 +1,8 @@
+contract test {
+ uint256 variable;
+ function f(uint256 arg) public {
+ f(notfound);
+ }
+}
+// ----
+// DeclarationError: (85-93): Undeclared identifier.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/003_undeclared_name_is_not_fatal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/003_undeclared_name_is_not_fatal.sol
new file mode 100644
index 00000000..0f2a1526
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/003_undeclared_name_is_not_fatal.sol
@@ -0,0 +1,10 @@
+contract test {
+ uint256 variable;
+ function f(uint256 arg) public {
+ f(notfound);
+ f(notfound);
+ }
+}
+// ----
+// DeclarationError: (85-93): Undeclared identifier.
+// DeclarationError: (106-114): Undeclared identifier.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/004_reference_to_later_declaration.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/004_reference_to_later_declaration.sol
new file mode 100644
index 00000000..e112e16c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/004_reference_to_later_declaration.sol
@@ -0,0 +1,6 @@
+contract test {
+ function g() public { f(); }
+ function f() public {}
+}
+// ----
+// Warning: (53-75): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/006_type_checking_return.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/006_type_checking_return.sol
new file mode 100644
index 00000000..d0e87139
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/006_type_checking_return.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f() public returns (bool r) { return 1 >= 2; }
+}
+// ----
+// Warning: (20-75): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/007_type_checking_return_wrong_number.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/007_type_checking_return_wrong_number.sol
new file mode 100644
index 00000000..13c70ad9
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/007_type_checking_return_wrong_number.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f() public returns (bool r1, bool r2) { return 1 >= 2; }
+}
+// ----
+// TypeError: (69-82): Different number of arguments in return statement than in returns declaration.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/008_type_checking_return_wrong_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/008_type_checking_return_wrong_type.sol
new file mode 100644
index 00000000..a7459ae8
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/008_type_checking_return_wrong_type.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f() public returns (uint256 r) { return 1 >= 2; }
+}
+// ----
+// TypeError: (69-75): Return argument type bool is not implicitly convertible to expected type (type of first return variable) uint256.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/009_type_checking_function_call.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/009_type_checking_function_call.sol
new file mode 100644
index 00000000..abe2beac
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/009_type_checking_function_call.sol
@@ -0,0 +1,6 @@
+contract test {
+ function f() public returns (bool) { return g(12, true) == 3; }
+ function g(uint256, bool) public returns (uint256) { }
+}
+// ----
+// Warning: (88-142): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/010_type_conversion_for_comparison.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/010_type_conversion_for_comparison.sol
new file mode 100644
index 00000000..c0cd87d4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/010_type_conversion_for_comparison.sol
@@ -0,0 +1,6 @@
+contract test {
+ function f() public { uint32(2) == int64(2); }
+}
+// ----
+// Warning: (42-63): Statement has no effect.
+// Warning: (20-66): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/011_type_conversion_for_comparison_invalid.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/011_type_conversion_for_comparison_invalid.sol
new file mode 100644
index 00000000..9cbce0d0
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/011_type_conversion_for_comparison_invalid.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f() public { int32(2) == uint64(2); }
+}
+// ----
+// TypeError: (42-63): Operator == not compatible with types int32 and uint64
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/013_large_string_literal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/013_large_string_literal.sol
new file mode 100644
index 00000000..7f858a4d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/013_large_string_literal.sol
@@ -0,0 +1,6 @@
+contract test {
+ function f() public { string memory x = "123456789012345678901234567890123"; }
+}
+// ----
+// Warning: (42-57): Unused local variable.
+// Warning: (20-98): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/014_balance.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/014_balance.sol
new file mode 100644
index 00000000..e2c9a8bf
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/014_balance.sol
@@ -0,0 +1,8 @@
+contract test {
+ function fun() public {
+ uint256 x = address(0).balance;
+ }
+}
+// ----
+// Warning: (52-61): Unused local variable.
+// Warning: (20-89): Function state mutability can be restricted to view
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/015_balance_invalid.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/015_balance_invalid.sol
new file mode 100644
index 00000000..18658fbe
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/015_balance_invalid.sol
@@ -0,0 +1,7 @@
+contract test {
+ function fun() public {
+ address(0).balance = 7;
+ }
+}
+// ----
+// TypeError: (52-70): Expression has to be an lvalue.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol
new file mode 100644
index 00000000..8bf45c3f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol
@@ -0,0 +1,12 @@
+contract test {
+ struct str {
+ mapping(uint=>uint) map;
+ }
+ str data;
+ function fun() public {
+ mapping(uint=>uint) a = data.map;
+ data.map = a;
+ }
+}
+// ----
+// TypeError: (164-176): Mappings cannot be assigned to.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/017_assignment_to_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/017_assignment_to_struct.sol
new file mode 100644
index 00000000..6fbd09ae
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/017_assignment_to_struct.sol
@@ -0,0 +1,11 @@
+contract test {
+ struct str {
+ mapping(uint=>uint) map;
+ }
+ str data;
+ function fun() public {
+ str storage a = data;
+ data = a;
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/018_forward_function_reference.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/018_forward_function_reference.sol
new file mode 100644
index 00000000..fd9ab7ed
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/018_forward_function_reference.sol
@@ -0,0 +1,10 @@
+contract First {
+ function fun() public returns (bool) {
+ return Second(1).fun(1, true, 3) > 0;
+ }
+}
+contract Second {
+ function fun(uint, bool, uint) public returns (uint) {
+ if (First(2).fun() == true) return 1;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/019_comparison_bitop_precedence.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/019_comparison_bitop_precedence.sol
new file mode 100644
index 00000000..eab272df
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/019_comparison_bitop_precedence.sol
@@ -0,0 +1,7 @@
+contract First {
+ function fun() public returns (bool ret) {
+ return 1 & 2 == 8 & 9 && 1 ^ 2 < 4 | 6;
+ }
+}
+// ----
+// Warning: (21-117): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/020_comparison_of_function_types_lt_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/020_comparison_of_function_types_lt_1.sol
new file mode 100644
index 00000000..1f288ff7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/020_comparison_of_function_types_lt_1.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public returns (bool ret) {
+ return this.f < this.f;
+ }
+}
+// ----
+// TypeError: (73-88): Operator < not compatible with types function () external returns (bool) and function () external returns (bool)
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/021_comparison_of_function_types_lt_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/021_comparison_of_function_types_lt_2.sol
new file mode 100644
index 00000000..a6422d38
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/021_comparison_of_function_types_lt_2.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public returns (bool ret) {
+ return f < f;
+ }
+}
+// ----
+// TypeError: (73-78): Operator < not compatible with types function () returns (bool) and function () returns (bool)
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/022_comparison_of_function_types_gt_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/022_comparison_of_function_types_gt_1.sol
new file mode 100644
index 00000000..ee865912
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/022_comparison_of_function_types_gt_1.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public returns (bool ret) {
+ return this.f > this.f;
+ }
+}
+// ----
+// TypeError: (73-88): Operator > not compatible with types function () external returns (bool) and function () external returns (bool)
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/023_comparison_of_function_types_gt_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/023_comparison_of_function_types_gt_2.sol
new file mode 100644
index 00000000..590cc98b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/023_comparison_of_function_types_gt_2.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public returns (bool ret) {
+ return f > f;
+ }
+}
+// ----
+// TypeError: (73-78): Operator > not compatible with types function () returns (bool) and function () returns (bool)
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/024_comparison_of_function_types_eq.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/024_comparison_of_function_types_eq.sol
new file mode 100644
index 00000000..71dbec6b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/024_comparison_of_function_types_eq.sol
@@ -0,0 +1,11 @@
+contract C {
+ function f() public returns (bool ret) {
+ return f == f;
+ }
+ function g() public returns (bool ret) {
+ return f != f;
+ }
+}
+// ----
+// Warning: (17-86): Function state mutability can be restricted to pure
+// Warning: (91-160): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/025_comparison_of_mapping_types.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/025_comparison_of_mapping_types.sol
new file mode 100644
index 00000000..27651d63
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/025_comparison_of_mapping_types.sol
@@ -0,0 +1,9 @@
+contract C {
+ mapping(uint => uint) x;
+ function f() public returns (bool ret) {
+ mapping(uint => uint) y = x;
+ return x == y;
+ }
+}
+// ----
+// TypeError: (139-145): Operator == not compatible with types mapping(uint256 => uint256) and mapping(uint256 => uint256)
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/029_create_abstract_contract.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/029_create_abstract_contract.sol
new file mode 100644
index 00000000..3a2bf56d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/029_create_abstract_contract.sol
@@ -0,0 +1,7 @@
+contract base { function foo(); }
+contract derived {
+ base b;
+ function foo() public { b = new base(); }
+}
+// ----
+// TypeError: (97-105): Trying to create an instance of an abstract contract.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/030_redeclare_implemented_abstract_function_as_abstract.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/030_redeclare_implemented_abstract_function_as_abstract.sol
new file mode 100644
index 00000000..05bc4bc7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/030_redeclare_implemented_abstract_function_as_abstract.sol
@@ -0,0 +1,5 @@
+contract base { function foo(); }
+contract derived is base { function foo() public {} }
+contract wrong is derived { function foo(); }
+// ----
+// TypeError: (116-131): Redeclaring an already implemented function as abstract
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/039_functions_with_identical_structs_in_interface.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/039_functions_with_identical_structs_in_interface.sol
new file mode 100644
index 00000000..0be0bb2b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/039_functions_with_identical_structs_in_interface.sol
@@ -0,0 +1,11 @@
+pragma experimental ABIEncoderV2;
+
+contract C {
+ struct S1 { int i; }
+ struct S2 { int i; }
+ function f(S1) pure {}
+ function f(S2) pure {}
+}
+// ----
+// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
+// TypeError: (129-151): Function overload clash during conversion to external types for arguments.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/040_functions_with_different_structs_in_interface.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/040_functions_with_different_structs_in_interface.sol
new file mode 100644
index 00000000..2af584b7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/040_functions_with_different_structs_in_interface.sol
@@ -0,0 +1,12 @@
+pragma experimental ABIEncoderV2;
+
+contract C {
+ struct S1 { function() external a; }
+ struct S2 { bytes24 a; }
+ function f(S1) pure {}
+ function f(S2) pure {}
+}
+// ----
+// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
+// Warning: (122-144): No visibility specified. Defaulting to "public".
+// Warning: (149-171): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/041_functions_with_stucts_of_non_external_types_in_interface.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/041_functions_with_stucts_of_non_external_types_in_interface.sol
new file mode 100644
index 00000000..f9937fb9
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/041_functions_with_stucts_of_non_external_types_in_interface.sol
@@ -0,0 +1,9 @@
+pragma experimental ABIEncoderV2;
+
+contract C {
+ struct S { function() internal a; }
+ function f(S) {}
+}
+// ----
+// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
+// TypeError: (103-104): Internal or recursive type is not allowed for public or external functions.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/042_functions_with_stucts_of_non_external_types_in_interface_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/042_functions_with_stucts_of_non_external_types_in_interface_2.sol
new file mode 100644
index 00000000..d9c3bfc4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/042_functions_with_stucts_of_non_external_types_in_interface_2.sol
@@ -0,0 +1,9 @@
+pragma experimental ABIEncoderV2;
+
+contract C {
+ struct S { mapping(uint => uint) a; }
+ function f(S) {}
+}
+// ----
+// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
+// TypeError: (105-106): Internal or recursive type is not allowed for public or external functions.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/043_functions_with_stucts_of_non_external_types_in_interface_nested.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/043_functions_with_stucts_of_non_external_types_in_interface_nested.sol
new file mode 100644
index 00000000..f223cf53
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/043_functions_with_stucts_of_non_external_types_in_interface_nested.sol
@@ -0,0 +1,10 @@
+pragma experimental ABIEncoderV2;
+
+contract C {
+ struct T { mapping(uint => uint) a; }
+ struct S { T[][2] b; }
+ function f(S) {}
+}
+// ----
+// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
+// TypeError: (132-133): Internal or recursive type is not allowed for public or external functions.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/044_returning_multi_dimensional_arrays_new_abi.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/044_returning_multi_dimensional_arrays_new_abi.sol
new file mode 100644
index 00000000..e54e27e9
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/044_returning_multi_dimensional_arrays_new_abi.sol
@@ -0,0 +1,7 @@
+pragma experimental ABIEncoderV2;
+
+contract C {
+ function f() public pure returns (string[][]) {}
+}
+// ----
+// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/045_returning_multi_dimensional_arrays.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/045_returning_multi_dimensional_arrays.sol
new file mode 100644
index 00000000..daa67836
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/045_returning_multi_dimensional_arrays.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f() public pure returns (string[][]) {}
+}
+// ----
+// TypeError: (51-61): 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/nameAndTypeResolution/046_returning_multi_dimensional_static_arrays.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/046_returning_multi_dimensional_static_arrays.sol
new file mode 100644
index 00000000..26af7436
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/046_returning_multi_dimensional_static_arrays.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f() public pure returns (uint[][2]) {}
+}
+// ----
+// TypeError: (51-60): 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/nameAndTypeResolution/047_returning_arrays_in_structs_new_abi.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/047_returning_arrays_in_structs_new_abi.sol
new file mode 100644
index 00000000..81628a12
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/047_returning_arrays_in_structs_new_abi.sol
@@ -0,0 +1,8 @@
+pragma experimental ABIEncoderV2;
+
+contract C {
+ struct S { string[] s; }
+ function f() public pure returns (S) {}
+}
+// ----
+// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/048_returning_arrays_in_structs_arrays.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/048_returning_arrays_in_structs_arrays.sol
new file mode 100644
index 00000000..2f1e5a15
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/048_returning_arrays_in_structs_arrays.sol
@@ -0,0 +1,6 @@
+contract C {
+ struct S { string[] s; }
+ function f() public pure returns (S x) {}
+}
+// ----
+// TypeError: (80-83): 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/nameAndTypeResolution/049_function_external_call_allowed_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/049_function_external_call_allowed_conversion.sol
new file mode 100644
index 00000000..ec72adeb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/049_function_external_call_allowed_conversion.sol
@@ -0,0 +1,11 @@
+contract C {}
+contract Test {
+ function externalCall() public {
+ C arg;
+ this.g(arg);
+ }
+ function g (C c) external {}
+}
+// ----
+// Warning: (125-128): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (113-141): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/050_function_external_call_not_allowed_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/050_function_external_call_not_allowed_conversion.sol
new file mode 100644
index 00000000..18d75948
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/050_function_external_call_not_allowed_conversion.sol
@@ -0,0 +1,10 @@
+contract C {}
+contract Test {
+ function externalCall() public {
+ address arg;
+ this.g(arg);
+ }
+ function g (C c) external {}
+}
+// ----
+// TypeError: (103-106): Invalid type for argument in function call. Invalid implicit conversion from address to contract C requested.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/051_function_internal_allowed_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/051_function_internal_allowed_conversion.sol
new file mode 100644
index 00000000..aedc7b0b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/051_function_internal_allowed_conversion.sol
@@ -0,0 +1,13 @@
+contract C {
+ uint a;
+}
+contract Test {
+ C a;
+ function g (C c) public {}
+ function internalCall() public {
+ g(a);
+ }
+}
+// ----
+// Warning: (68-71): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (56-82): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/052_function_internal_not_allowed_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/052_function_internal_not_allowed_conversion.sol
new file mode 100644
index 00000000..c16d35eb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/052_function_internal_not_allowed_conversion.sol
@@ -0,0 +1,12 @@
+contract C {
+ uint a;
+}
+contract Test {
+ address a;
+ function g (C c) public {}
+ function internalCall() public {
+ g(a);
+ }
+}
+// ----
+// TypeError: (136-137): Invalid type for argument in function call. Invalid implicit conversion from address to contract C requested.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/053_hash_collision_in_interface.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/053_hash_collision_in_interface.sol
new file mode 100644
index 00000000..fe690e16
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/053_hash_collision_in_interface.sol
@@ -0,0 +1,6 @@
+contract test {
+ function gsf() public { }
+ function tgeo() public { }
+}
+// ----
+// TypeError: (0-78): Function signature hash collision for tgeo()
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/054_inheritance_basic.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/054_inheritance_basic.sol
new file mode 100644
index 00000000..6229a1dc
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/054_inheritance_basic.sol
@@ -0,0 +1,5 @@
+contract base { uint baseMember; struct BaseType { uint element; } }
+contract derived is base {
+ BaseType data;
+ function f() public { baseMember = 7; }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/055_inheritance_diamond_basic.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/055_inheritance_diamond_basic.sol
new file mode 100644
index 00000000..c07e59e2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/055_inheritance_diamond_basic.sol
@@ -0,0 +1,9 @@
+contract root { function rootFunction() public {} }
+contract inter1 is root { function f() public {} }
+contract inter2 is root { function f() public {} }
+contract derived is root, inter2, inter1 {
+ function g() public { f(); rootFunction(); }
+}
+// ----
+// Warning: (16-49): Function state mutability can be restricted to pure
+// Warning: (129-151): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/056_cyclic_inheritance.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/056_cyclic_inheritance.sol
new file mode 100644
index 00000000..0e1ec4cb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/056_cyclic_inheritance.sol
@@ -0,0 +1,4 @@
+contract A is B { }
+contract B is A { }
+// ----
+// TypeError: (14-15): Definition of base has to precede definition of derived contract
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/057_legal_override_direct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/057_legal_override_direct.sol
new file mode 100644
index 00000000..062507ee
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/057_legal_override_direct.sol
@@ -0,0 +1,6 @@
+contract B { function f() public {} }
+contract C is B { function f(uint i) public {} }
+// ----
+// Warning: (67-73): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (13-35): Function state mutability can be restricted to pure
+// Warning: (56-84): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/058_legal_override_indirect.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/058_legal_override_indirect.sol
new file mode 100644
index 00000000..f59da472
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/058_legal_override_indirect.sol
@@ -0,0 +1,7 @@
+contract A { function f(uint a) public {} }
+contract B { function f() public {} }
+contract C is A, B { }
+// ----
+// Warning: (24-30): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (13-41): Function state mutability can be restricted to pure
+// Warning: (57-79): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/059_illegal_override_visibility.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/059_illegal_override_visibility.sol
new file mode 100644
index 00000000..8c13a478
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/059_illegal_override_visibility.sol
@@ -0,0 +1,4 @@
+contract B { function f() internal {} }
+contract C is B { function f() public {} }
+// ----
+// TypeError: (58-80): Overriding function visibility differs.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/060_complex_inheritance.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/060_complex_inheritance.sol
new file mode 100644
index 00000000..c7e42238
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/060_complex_inheritance.sol
@@ -0,0 +1,6 @@
+contract A { function f() public { uint8 x = C(0).g(); } }
+contract B { function f() public {} function g() public returns (uint8) {} }
+contract C is A, B { }
+// ----
+// Warning: (35-42): Unused local variable.
+// Warning: (95-133): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/061_missing_base_constructor_arguments.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/061_missing_base_constructor_arguments.sol
new file mode 100644
index 00000000..0ac48ecf
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/061_missing_base_constructor_arguments.sol
@@ -0,0 +1,5 @@
+contract A { function A(uint a) public { } }
+contract B is A { }
+// ----
+// Warning: (13-42): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
+// Warning: (24-30): Unused function parameter. Remove or comment out the variable name to silence this warning.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/062_base_constructor_arguments_override.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/062_base_constructor_arguments_override.sol
new file mode 100644
index 00000000..0ac48ecf
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/062_base_constructor_arguments_override.sol
@@ -0,0 +1,5 @@
+contract A { function A(uint a) public { } }
+contract B is A { }
+// ----
+// Warning: (13-42): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
+// Warning: (24-30): Unused function parameter. Remove or comment out the variable name to silence this warning.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/063_implicit_derived_to_base_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/063_implicit_derived_to_base_conversion.sol
new file mode 100644
index 00000000..f4667996
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/063_implicit_derived_to_base_conversion.sol
@@ -0,0 +1,7 @@
+contract A { }
+contract B is A {
+ function f() public { A a = B(1); }
+}
+// ----
+// Warning: (59-62): Unused local variable.
+// Warning: (37-72): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/064_implicit_base_to_derived_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/064_implicit_base_to_derived_conversion.sol
new file mode 100644
index 00000000..0d23ea87
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/064_implicit_base_to_derived_conversion.sol
@@ -0,0 +1,6 @@
+contract A { }
+contract B is A {
+ function f() public { B b = A(1); }
+}
+// ----
+// TypeError: (59-69): Type contract A is not implicitly convertible to expected type contract B.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/065_super_excludes_current_contract.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/065_super_excludes_current_contract.sol
new file mode 100644
index 00000000..6fa92a6a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/065_super_excludes_current_contract.sol
@@ -0,0 +1,11 @@
+contract A {
+ function b() public {}
+}
+
+contract B is A {
+ function f() public {
+ super.f();
+ }
+}
+// ----
+// TypeError: (95-102): Member "f" not found or not visible after argument-dependent lookup in contract super B
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/067_function_clash_with_state_variable_accessor.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/067_function_clash_with_state_variable_accessor.sol
new file mode 100644
index 00000000..a99682c0
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/067_function_clash_with_state_variable_accessor.sol
@@ -0,0 +1,9 @@
+contract test {
+ function fun() public {
+ uint64(2);
+ }
+ uint256 foo;
+ function foo() public {}
+}
+// ----
+// DeclarationError: (90-114): Identifier already declared.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/069_base_class_state_variable_accessor.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/069_base_class_state_variable_accessor.sol
new file mode 100644
index 00000000..8f2c6438
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/069_base_class_state_variable_accessor.sol
@@ -0,0 +1,9 @@
+// test for issue #1126 https://github.com/ethereum/cpp-ethereum/issues/1126
+contract Parent {
+ uint256 public m_aMember;
+}
+contract Child is Parent {
+ function foo() public returns (uint256) { return Parent.m_aMember; }
+}
+// ----
+// Warning: (158-226): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/070_struct_accessor_one_array_only.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/070_struct_accessor_one_array_only.sol
new file mode 100644
index 00000000..6741a7fa
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/070_struct_accessor_one_array_only.sol
@@ -0,0 +1,6 @@
+contract test {
+ struct Data { uint[15] m_array; }
+ Data public data;
+}
+// ----
+// TypeError: (58-74): Internal or recursive type is not allowed for public state variables.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/071_base_class_state_variable_internal_member.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/071_base_class_state_variable_internal_member.sol
new file mode 100644
index 00000000..774ea38e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/071_base_class_state_variable_internal_member.sol
@@ -0,0 +1,8 @@
+contract Parent {
+ uint256 internal m_aMember;
+}
+contract Child is Parent {
+ function foo() public returns (uint256) { return Parent.m_aMember; }
+}
+// ----
+// Warning: (83-151): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/072_state_variable_member_of_wrong_class1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/072_state_variable_member_of_wrong_class1.sol
new file mode 100644
index 00000000..949761b6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/072_state_variable_member_of_wrong_class1.sol
@@ -0,0 +1,11 @@
+contract Parent1 {
+ uint256 internal m_aMember1;
+}
+contract Parent2 is Parent1 {
+ uint256 internal m_aMember2;
+}
+contract Child is Parent2 {
+ function foo() public returns (uint256) { return Parent2.m_aMember1; }
+}
+// ----
+// TypeError: (200-218): Member "m_aMember1" not found or not visible after argument-dependent lookup in type(contract Parent2)
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/073_state_variable_member_of_wrong_class2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/073_state_variable_member_of_wrong_class2.sol
new file mode 100644
index 00000000..9a0ee8a3
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/073_state_variable_member_of_wrong_class2.sol
@@ -0,0 +1,12 @@
+contract Parent1 {
+ uint256 internal m_aMember1;
+}
+contract Parent2 is Parent1 {
+ uint256 internal m_aMember2;
+}
+contract Child is Parent2 {
+ function foo() public returns (uint256) { return Child.m_aMember2; }
+ uint256 public m_aMember3;
+}
+// ----
+// TypeError: (200-216): Member "m_aMember2" not found or not visible after argument-dependent lookup in type(contract Child)
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/074_fallback_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/074_fallback_function.sol
new file mode 100644
index 00000000..7e64bbe2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/074_fallback_function.sol
@@ -0,0 +1,4 @@
+contract C {
+ uint x;
+ function() public { x = 2; }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/075_fallback_function_with_arguments.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/075_fallback_function_with_arguments.sol
new file mode 100644
index 00000000..2c1d2a1b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/075_fallback_function_with_arguments.sol
@@ -0,0 +1,6 @@
+contract C {
+ uint x;
+ function(uint a) public { x = 2; }
+}
+// ----
+// TypeError: (37-45): Fallback function cannot take parameters.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/076_fallback_function_in_library.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/076_fallback_function_in_library.sol
new file mode 100644
index 00000000..11fef976
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/076_fallback_function_in_library.sol
@@ -0,0 +1,5 @@
+library C {
+ function() public {}
+}
+// ----
+// TypeError: (16-36): Libraries cannot have fallback functions.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/077_fallback_function_with_return_parameters.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/077_fallback_function_with_return_parameters.sol
new file mode 100644
index 00000000..905bcd2d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/077_fallback_function_with_return_parameters.sol
@@ -0,0 +1,5 @@
+contract C {
+ function() public returns (uint) { }
+}
+// ----
+// TypeError: (43-49): Fallback function cannot return values.
diff --git a/test/libsolidity/syntaxTests/functionTypes/warn_function_type_return_parameters_with_names.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/078_fallback_function_twice.sol
index 67a74e54..8d839da0 100644
--- a/test/libsolidity/syntaxTests/functionTypes/warn_function_type_return_parameters_with_names.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/078_fallback_function_twice.sol
@@ -1,5 +1,7 @@
contract C {
- function(uint) returns (bool ret) f;
+ uint x;
+ function() public { x = 2; }
+ function() public { x = 3; }
}
// ----
-// Warning: (41-49): Naming function type return parameters is deprecated.
+// DeclarationError: (62-90): Only one fallback function is allowed.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/079_fallback_function_inheritance.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/079_fallback_function_inheritance.sol
new file mode 100644
index 00000000..a35a8093
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/079_fallback_function_inheritance.sol
@@ -0,0 +1,7 @@
+contract A {
+ uint x;
+ function() public { x = 1; }
+}
+contract C is A {
+ function() public { x = 2; }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/080_event.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/080_event.sol
new file mode 100644
index 00000000..c5f9e4d0
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/080_event.sol
@@ -0,0 +1,5 @@
+contract c {
+ event e(uint indexed a, bytes3 indexed s, bool indexed b);
+ function f() public { emit e(2, "abc", true); }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/081_event_too_many_indexed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/081_event_too_many_indexed.sol
new file mode 100644
index 00000000..ee0af605
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/081_event_too_many_indexed.sol
@@ -0,0 +1,5 @@
+contract c {
+ event e(uint indexed a, bytes3 indexed b, bool indexed c, uint indexed d);
+}
+// ----
+// TypeError: (17-91): More than 3 indexed arguments for event.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/082_anonymous_event_four_indexed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/082_anonymous_event_four_indexed.sol
new file mode 100644
index 00000000..e8b36906
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/082_anonymous_event_four_indexed.sol
@@ -0,0 +1,3 @@
+contract c {
+ event e(uint indexed a, bytes3 indexed b, bool indexed c, uint indexed d) anonymous;
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/083_anonymous_event_too_many_indexed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/083_anonymous_event_too_many_indexed.sol
new file mode 100644
index 00000000..d439c5b9
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/083_anonymous_event_too_many_indexed.sol
@@ -0,0 +1,5 @@
+contract c {
+ event e(uint indexed a, bytes3 indexed b, bool indexed c, uint indexed d, uint indexed e) anonymous;
+}
+// ----
+// TypeError: (17-117): More than 4 indexed arguments for anonymous event.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/084_events_with_same_name.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/084_events_with_same_name.sol
new file mode 100644
index 00000000..24f633b3
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/084_events_with_same_name.sol
@@ -0,0 +1,4 @@
+contract TestIt {
+ event A();
+ event A(uint i);
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/085_events_with_same_name_unnamed_arguments.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/085_events_with_same_name_unnamed_arguments.sol
new file mode 100644
index 00000000..cccd9d57
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/085_events_with_same_name_unnamed_arguments.sol
@@ -0,0 +1,4 @@
+contract test {
+ event A(uint);
+ event A(uint, uint);
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/086_events_with_same_name_different_types.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/086_events_with_same_name_different_types.sol
new file mode 100644
index 00000000..fbeab711
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/086_events_with_same_name_different_types.sol
@@ -0,0 +1,4 @@
+contract test {
+ event A(uint);
+ event A(bytes);
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/087_double_event_declaration.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/087_double_event_declaration.sol
new file mode 100644
index 00000000..af0280c5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/087_double_event_declaration.sol
@@ -0,0 +1,6 @@
+contract test {
+ event A(uint i);
+ event A(uint i);
+}
+// ----
+// DeclarationError: (20-36): Event with same name and arguments defined twice.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/088_double_event_declaration_ignores_anonymous.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/088_double_event_declaration_ignores_anonymous.sol
new file mode 100644
index 00000000..7d4b0ac9
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/088_double_event_declaration_ignores_anonymous.sol
@@ -0,0 +1,6 @@
+contract test {
+ event A(uint i);
+ event A(uint i) anonymous;
+}
+// ----
+// DeclarationError: (20-36): Event with same name and arguments defined twice.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/089_double_event_declaration_ignores_indexed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/089_double_event_declaration_ignores_indexed.sol
new file mode 100644
index 00000000..e6aa3e5f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/089_double_event_declaration_ignores_indexed.sol
@@ -0,0 +1,6 @@
+contract test {
+ event A(uint i);
+ event A(uint indexed i);
+}
+// ----
+// DeclarationError: (20-36): Event with same name and arguments defined twice.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/090_event_call.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/090_event_call.sol
new file mode 100644
index 00000000..8cf50597
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/090_event_call.sol
@@ -0,0 +1,5 @@
+contract c {
+ event e(uint a, bytes3 indexed s, bool indexed b);
+ function f() public { emit e(2, "abc", true); }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/091_event_function_inheritance_clash.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/091_event_function_inheritance_clash.sol
new file mode 100644
index 00000000..5e0f58ea
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/091_event_function_inheritance_clash.sol
@@ -0,0 +1,12 @@
+contract A {
+ function dup() public returns (uint) {
+ return 1;
+ }
+}
+contract B {
+ event dup();
+}
+contract C is A, B {
+}
+// ----
+// DeclarationError: (99-111): Identifier already declared.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/092_function_event_inheritance_clash.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/092_function_event_inheritance_clash.sol
new file mode 100644
index 00000000..c567f992
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/092_function_event_inheritance_clash.sol
@@ -0,0 +1,12 @@
+contract B {
+ event dup();
+}
+contract A {
+ function dup() public returns (uint) {
+ return 1;
+ }
+}
+contract C is B, A {
+}
+// ----
+// DeclarationError: (49-111): Identifier already declared.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/093_function_event_in_contract_clash.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/093_function_event_in_contract_clash.sol
new file mode 100644
index 00000000..7b4fcde9
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/093_function_event_in_contract_clash.sol
@@ -0,0 +1,8 @@
+contract A {
+ event dup();
+ function dup() public returns (uint) {
+ return 1;
+ }
+}
+// ----
+// DeclarationError: (34-96): Identifier already declared.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/094_event_inheritance.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/094_event_inheritance.sol
new file mode 100644
index 00000000..b13d5755
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/094_event_inheritance.sol
@@ -0,0 +1,7 @@
+contract base {
+ event e(uint a, bytes3 indexed s, bool indexed b);
+}
+contract c is base {
+ function f() public { emit e(2, "abc", true); }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/095_multiple_events_argument_clash.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/095_multiple_events_argument_clash.sol
new file mode 100644
index 00000000..79127119
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/095_multiple_events_argument_clash.sol
@@ -0,0 +1,4 @@
+contract c {
+ event e1(uint a, uint e1, uint e2);
+ event e2(uint a, uint e1, uint e2);
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/096_access_to_default_function_visibility.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/096_access_to_default_function_visibility.sol
new file mode 100644
index 00000000..9251df73
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/096_access_to_default_function_visibility.sol
@@ -0,0 +1,8 @@
+contract c {
+ function f() public {}
+}
+contract d {
+ function g() public { c(0).f(); }
+}
+// ----
+// Warning: (17-39): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/097_access_to_internal_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/097_access_to_internal_function.sol
new file mode 100644
index 00000000..e13e1531
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/097_access_to_internal_function.sol
@@ -0,0 +1,8 @@
+contract c {
+ function f() internal {}
+}
+contract d {
+ function g() public { c(0).f(); }
+}
+// ----
+// TypeError: (83-89): Member "f" not found or not visible after argument-dependent lookup in contract c
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/098_access_to_default_state_variable_visibility.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/098_access_to_default_state_variable_visibility.sol
new file mode 100644
index 00000000..ab7546c6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/098_access_to_default_state_variable_visibility.sol
@@ -0,0 +1,8 @@
+contract c {
+ uint a;
+}
+contract d {
+ function g() public { c(0).a(); }
+}
+// ----
+// TypeError: (66-72): Member "a" not found or not visible after argument-dependent lookup in contract c
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/099_access_to_internal_state_variable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/099_access_to_internal_state_variable.sol
new file mode 100644
index 00000000..60aba574
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/099_access_to_internal_state_variable.sol
@@ -0,0 +1,8 @@
+contract c {
+ uint public a;
+}
+contract d {
+ function g() public { c(0).a(); }
+}
+// ----
+// Warning: (51-84): Function state mutability can be restricted to view
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/100_error_count_in_named_args.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/100_error_count_in_named_args.sol
new file mode 100644
index 00000000..a679c25a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/100_error_count_in_named_args.sol
@@ -0,0 +1,11 @@
+contract test {
+ function a(uint a, uint b) public returns (uint r) {
+ r = a + b;
+ }
+ function b() public returns (uint r) {
+ r = a({a: 1});
+ }
+}
+// ----
+// Warning: (31-37): This declaration shadows an existing declaration.
+// TypeError: (153-162): Wrong argument count for function call: 1 arguments given but expected 2.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/101_empty_in_named_args.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/101_empty_in_named_args.sol
new file mode 100644
index 00000000..9da11d6f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/101_empty_in_named_args.sol
@@ -0,0 +1,11 @@
+contract test {
+ function a(uint a, uint b) public returns (uint r) {
+ r = a + b;
+ }
+ function b() public returns (uint r) {
+ r = a({});
+ }
+}
+// ----
+// Warning: (31-37): This declaration shadows an existing declaration.
+// TypeError: (153-158): Wrong argument count for function call: 0 arguments given but expected 2.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/102_duplicate_parameter_names_in_named_args.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/102_duplicate_parameter_names_in_named_args.sol
new file mode 100644
index 00000000..fab4beff
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/102_duplicate_parameter_names_in_named_args.sol
@@ -0,0 +1,11 @@
+contract test {
+ function a(uint a, uint b) public returns (uint r) {
+ r = a + b;
+ }
+ function b() public returns (uint r) {
+ r = a({a: 1, a: 2});
+ }
+}
+// ----
+// Warning: (31-37): This declaration shadows an existing declaration.
+// TypeError: (159-160): Duplicate named argument.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/103_invalid_parameter_names_in_named_args.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/103_invalid_parameter_names_in_named_args.sol
new file mode 100644
index 00000000..bed15186
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/103_invalid_parameter_names_in_named_args.sol
@@ -0,0 +1,11 @@
+contract test {
+ function a(uint a, uint b) public returns (uint r) {
+ r = a + b;
+ }
+ function b() public returns (uint r) {
+ r = a({a: 1, c: 2});
+ }
+}
+// ----
+// Warning: (31-37): This declaration shadows an existing declaration.
+// TypeError: (153-168): Named argument "c" does not match function declaration.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/104_empty_name_input_parameter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/104_empty_name_input_parameter.sol
new file mode 100644
index 00000000..824543ef
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/104_empty_name_input_parameter.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f(uint) public { }
+}
+// ----
+// Warning: (20-47): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/105_constant_input_parameter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/105_constant_input_parameter.sol
new file mode 100644
index 00000000..636d325f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/105_constant_input_parameter.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f(uint[] constant a) public { }
+}
+// ----
+// TypeError: (31-48): Illegal use of "constant" specifier.
+// TypeError: (31-48): Constants of non-value type not yet implemented.
+// TypeError: (31-48): Uninitialized "constant" variable.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/106_empty_name_return_parameter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/106_empty_name_return_parameter.sol
new file mode 100644
index 00000000..a2ffc6e1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/106_empty_name_return_parameter.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f() public returns (bool) { }
+}
+// ----
+// Warning: (20-58): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/107_empty_name_input_parameter_with_named_one.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/107_empty_name_input_parameter_with_named_one.sol
new file mode 100644
index 00000000..e0efa0a0
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/107_empty_name_input_parameter_with_named_one.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f(uint, uint k) public returns (uint ret_k) {
+ return k;
+ }
+}
+// ----
+// Warning: (20-98): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/108_empty_name_return_parameter_with_named_one.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/108_empty_name_return_parameter_with_named_one.sol
new file mode 100644
index 00000000..39ae7877
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/108_empty_name_return_parameter_with_named_one.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public returns (uint ret_k, uint) {
+ return 5;
+ }
+}
+// ----
+// TypeError: (77-85): Different number of arguments in return statement than in returns declaration.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/110_no_overflow_with_large_literal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/110_no_overflow_with_large_literal.sol
new file mode 100644
index 00000000..c3399ddf
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/110_no_overflow_with_large_literal.sol
@@ -0,0 +1,8 @@
+contract c {
+ function c () public {
+ a = 115792089237316195423570985008687907853269984665640564039458;
+ }
+ uint256 a;
+}
+// ----
+// Warning: (17-119): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/111_overflow_caused_by_ether_units.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/111_overflow_caused_by_ether_units.sol
new file mode 100644
index 00000000..88dc1a31
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/111_overflow_caused_by_ether_units.sol
@@ -0,0 +1,9 @@
+contract c {
+ function c () public {
+ a = 115792089237316195423570985008687907853269984665640564039458 ether;
+ }
+ uint256 a;
+}
+// ----
+// Warning: (17-125): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
+// TypeError: (52-118): Type int_const 1157...(70 digits omitted)...0000 is not implicitly convertible to expected type uint256.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/112_exp_operator_exponent_too_big.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/112_exp_operator_exponent_too_big.sol
new file mode 100644
index 00000000..2a9e6204
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/112_exp_operator_exponent_too_big.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f() public returns (uint d) { return 2 ** 10000000000; }
+}
+// ----
+// TypeError: (66-82): Operator ** not compatible with types int_const 2 and int_const 10000000000
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/113_exp_warn_literal_base_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/113_exp_warn_literal_base_1.sol
new file mode 100644
index 00000000..0d91fcab
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/113_exp_warn_literal_base_1.sol
@@ -0,0 +1,8 @@
+contract test {
+ function f() pure public returns(uint) {
+ uint8 x = 100;
+ return 10**x;
+ }
+}
+// ----
+// Warning: (99-104): Result of exponentiation has type uint8 and thus might overflow. Silence this warning by converting the literal to the expected type.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/114_exp_warn_literal_base_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/114_exp_warn_literal_base_2.sol
new file mode 100644
index 00000000..eb430b9a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/114_exp_warn_literal_base_2.sol
@@ -0,0 +1,6 @@
+contract test {
+ function f() pure public returns(uint) {
+ uint8 x = 100;
+ return uint8(10)**x;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/115_exp_warn_literal_base_3.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/115_exp_warn_literal_base_3.sol
new file mode 100644
index 00000000..01c0fc06
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/115_exp_warn_literal_base_3.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f() pure public returns(uint) {
+ return 2**80;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/116_shift_warn_literal_base_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/116_shift_warn_literal_base_1.sol
new file mode 100644
index 00000000..c6a4052e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/116_shift_warn_literal_base_1.sol
@@ -0,0 +1,8 @@
+contract test {
+ function f() pure public returns(uint) {
+ uint8 x = 100;
+ return 10 << x;
+ }
+}
+// ----
+// Warning: (99-106): Result of shift has type uint8 and thus might overflow. Silence this warning by converting the literal to the expected type.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/117_shift_warn_literal_base_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/117_shift_warn_literal_base_2.sol
new file mode 100644
index 00000000..954d1943
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/117_shift_warn_literal_base_2.sol
@@ -0,0 +1,6 @@
+contract test {
+ function f() pure public returns(uint) {
+ uint8 x = 100;
+ return uint8(10) << x;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/118_shift_warn_literal_base_3.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/118_shift_warn_literal_base_3.sol
new file mode 100644
index 00000000..5fbaa806
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/118_shift_warn_literal_base_3.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f() pure public returns(uint) {
+ return 2 << 80;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/119_shift_warn_literal_base_4.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/119_shift_warn_literal_base_4.sol
new file mode 100644
index 00000000..19869157
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/119_shift_warn_literal_base_4.sol
@@ -0,0 +1,6 @@
+contract test {
+ function f() pure public returns(uint) {
+ uint8 x = 100;
+ return 10 >> x;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/124_enum_member_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/124_enum_member_access.sol
new file mode 100644
index 00000000..c428bea7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/124_enum_member_access.sol
@@ -0,0 +1,11 @@
+contract test {
+ enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
+ function test()
+ {
+ choices = ActionChoices.GoStraight;
+ }
+ ActionChoices choices;
+}
+// ----
+// Warning: (80-151): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
+// Warning: (80-151): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/125_enum_member_access_accross_contracts.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/125_enum_member_access_accross_contracts.sol
new file mode 100644
index 00000000..3bed62d6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/125_enum_member_access_accross_contracts.sol
@@ -0,0 +1,10 @@
+contract Interface {
+ enum MyEnum { One, Two }
+}
+contract Impl {
+ function test() public returns (Interface.MyEnum) {
+ return Interface.MyEnum.One;
+ }
+}
+// ----
+// Warning: (72-166): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/126_enum_invalid_member_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/126_enum_invalid_member_access.sol
new file mode 100644
index 00000000..32df613e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/126_enum_invalid_member_access.sol
@@ -0,0 +1,10 @@
+contract test {
+ enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
+ function test() public {
+ choices = ActionChoices.RunAroundWavingYourHands;
+ }
+ ActionChoices choices;
+}
+// ----
+// Warning: (80-168): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
+// TypeError: (123-161): Member "RunAroundWavingYourHands" not found or not visible after argument-dependent lookup in type(enum test.ActionChoices)
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/127_enum_invalid_direct_member_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/127_enum_invalid_direct_member_access.sol
new file mode 100644
index 00000000..f5bd888a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/127_enum_invalid_direct_member_access.sol
@@ -0,0 +1,10 @@
+contract test {
+ enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
+ function test() public {
+ choices = Sit;
+ }
+ ActionChoices choices;
+}
+// ----
+// Warning: (80-133): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
+// DeclarationError: (123-126): Undeclared identifier.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/128_enum_explicit_conversion_is_okay.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/128_enum_explicit_conversion_is_okay.sol
new file mode 100644
index 00000000..ed6a1d04
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/128_enum_explicit_conversion_is_okay.sol
@@ -0,0 +1,11 @@
+contract test {
+ enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
+ function test() public {
+ a = uint256(ActionChoices.GoStraight);
+ b = uint64(ActionChoices.Sit);
+ }
+ uint256 a;
+ uint64 b;
+}
+// ----
+// Warning: (80-196): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/129_int_to_enum_explicit_conversion_is_okay.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/129_int_to_enum_explicit_conversion_is_okay.sol
new file mode 100644
index 00000000..2f3a4cdc
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/129_int_to_enum_explicit_conversion_is_okay.sol
@@ -0,0 +1,11 @@
+contract test {
+ enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
+ function test() public {
+ a = 2;
+ b = ActionChoices(a);
+ }
+ uint256 a;
+ ActionChoices b;
+}
+// ----
+// Warning: (80-155): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/130_enum_implicit_conversion_is_not_okay_256.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/130_enum_implicit_conversion_is_not_okay_256.sol
new file mode 100644
index 00000000..359deba5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/130_enum_implicit_conversion_is_not_okay_256.sol
@@ -0,0 +1,10 @@
+contract test {
+ enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
+ function test() public {
+ a = ActionChoices.GoStraight;
+ }
+ uint256 a;
+}
+// ----
+// Warning: (80-148): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
+// TypeError: (117-141): Type enum test.ActionChoices is not implicitly convertible to expected type uint256.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/131_enum_implicit_conversion_is_not_okay_64.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/131_enum_implicit_conversion_is_not_okay_64.sol
new file mode 100644
index 00000000..af02b2db
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/131_enum_implicit_conversion_is_not_okay_64.sol
@@ -0,0 +1,10 @@
+contract test {
+ enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
+ function test() public {
+ b = ActionChoices.Sit;
+ }
+ uint64 b;
+}
+// ----
+// Warning: (80-141): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
+// TypeError: (117-134): Type enum test.ActionChoices is not implicitly convertible to expected type uint64.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/132_enum_to_enum_conversion_is_not_okay.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/132_enum_to_enum_conversion_is_not_okay.sol
new file mode 100644
index 00000000..054cb34f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/132_enum_to_enum_conversion_is_not_okay.sol
@@ -0,0 +1,10 @@
+contract test {
+ enum Paper { Up, Down, Left, Right }
+ enum Ground { North, South, West, East }
+ function test() public {
+ Ground(Paper.Up);
+ }
+}
+// ----
+// Warning: (106-162): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
+// TypeError: (139-155): Explicit type conversion not allowed from "enum test.Paper" to "enum test.Ground".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/133_enum_duplicate_values.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/133_enum_duplicate_values.sol
new file mode 100644
index 00000000..996a9b78
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/133_enum_duplicate_values.sol
@@ -0,0 +1,5 @@
+ contract test {
+ enum ActionChoices { GoLeft, GoRight, GoLeft, Sit }
+ }
+// ----
+// DeclarationError: (66-72): Identifier already declared.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/134_enum_name_resolution_under_current_contract_name.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/134_enum_name_resolution_under_current_contract_name.sol
new file mode 100644
index 00000000..4a16eee1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/134_enum_name_resolution_under_current_contract_name.sol
@@ -0,0 +1,12 @@
+contract A {
+ enum Foo {
+ First,
+ Second
+ }
+
+ function a() public {
+ A.Foo;
+ }
+}
+// ----
+// Warning: (69-111): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/135_private_visibility.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/135_private_visibility.sol
new file mode 100644
index 00000000..faafc631
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/135_private_visibility.sol
@@ -0,0 +1,8 @@
+contract base {
+ function f() private {}
+}
+contract derived is base {
+ function g() public { f(); }
+}
+// ----
+// DeclarationError: (99-100): Undeclared identifier.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/136_private_visibility_via_explicit_base_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/136_private_visibility_via_explicit_base_access.sol
new file mode 100644
index 00000000..fc89c033
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/136_private_visibility_via_explicit_base_access.sol
@@ -0,0 +1,8 @@
+contract base {
+ function f() private {}
+}
+contract derived is base {
+ function g() public { base.f(); }
+}
+// ----
+// TypeError: (99-105): Member "f" not found or not visible after argument-dependent lookup in type(contract base)
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/137_external_visibility.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/137_external_visibility.sol
new file mode 100644
index 00000000..214ad60a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/137_external_visibility.sol
@@ -0,0 +1,6 @@
+contract c {
+ function f() external {}
+ function g() public { f(); }
+}
+// ----
+// DeclarationError: (68-69): Undeclared identifier. "f" is not (or not yet) visible at this point.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/138_similar_name_suggestions_expected.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/138_similar_name_suggestions_expected.sol
new file mode 100644
index 00000000..8f11f003
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/138_similar_name_suggestions_expected.sol
@@ -0,0 +1,6 @@
+contract c {
+ function func() {}
+ function g() public { fun(); }
+}
+// ----
+// DeclarationError: (62-65): Undeclared identifier. Did you mean "func"?
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/139_no_name_suggestion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/139_no_name_suggestion.sol
new file mode 100644
index 00000000..40827dca
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/139_no_name_suggestion.sol
@@ -0,0 +1,5 @@
+contract c {
+ function g() public { fun(); }
+}
+// ----
+// DeclarationError: (39-42): Undeclared identifier.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/140_multiple_similar_suggestions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/140_multiple_similar_suggestions.sol
new file mode 100644
index 00000000..34b4604d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/140_multiple_similar_suggestions.sol
@@ -0,0 +1,11 @@
+contract c {
+ function g() public {
+ uint var1 = 1;
+ uint var2 = 1;
+ uint var3 = 1;
+ uint var4 = 1;
+ uint var5 = varx;
+ }
+}
+// ----
+// DeclarationError: (151-155): Undeclared identifier. Did you mean "var1", "var2", "var3", "var4" or "var5"?
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/141_multiple_scopes_suggestions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/141_multiple_scopes_suggestions.sol
new file mode 100644
index 00000000..f9471146
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/141_multiple_scopes_suggestions.sol
@@ -0,0 +1,9 @@
+contract c {
+ uint log9 = 2;
+ function g() public {
+ uint log8 = 3;
+ uint var1 = lgox;
+ }
+}
+// ----
+// DeclarationError: (101-105): Undeclared identifier. Did you mean "log8", "log9", "log0", "log1", "log2", "log3" or "log4"?
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/142_inheritence_suggestions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/142_inheritence_suggestions.sol
new file mode 100644
index 00000000..4231e1bd
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/142_inheritence_suggestions.sol
@@ -0,0 +1,8 @@
+contract a { function func() public {} }
+contract c is a {
+ function g() public {
+ uint var1 = fun();
+ }
+}
+// ----
+// DeclarationError: (105-108): Undeclared identifier. Did you mean "func"?
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/143_no_spurious_identifier_suggestions_with_submatch.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/143_no_spurious_identifier_suggestions_with_submatch.sol
new file mode 100644
index 00000000..db9f07c6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/143_no_spurious_identifier_suggestions_with_submatch.sol
@@ -0,0 +1,8 @@
+contract c {
+ function g() public {
+ uint va = 1;
+ uint vb = vaxyz;
+ }
+}
+// ----
+// DeclarationError: (78-83): Undeclared identifier.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/144_no_spurious_identifier_suggestions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/144_no_spurious_identifier_suggestions.sol
new file mode 100644
index 00000000..2316cb3d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/144_no_spurious_identifier_suggestions.sol
@@ -0,0 +1,8 @@
+contract c {
+ function g() public {
+ uint va = 1;
+ uint vb = x;
+ }
+}
+// ----
+// DeclarationError: (78-79): Undeclared identifier.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/145_external_base_visibility.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/145_external_base_visibility.sol
new file mode 100644
index 00000000..2d1baa20
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/145_external_base_visibility.sol
@@ -0,0 +1,8 @@
+contract base {
+ function f() external {}
+}
+contract derived is base {
+ function g() public { base.f(); }
+}
+// ----
+// TypeError: (100-106): Member "f" not found or not visible after argument-dependent lookup in type(contract base)
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/146_external_argument_assign.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/146_external_argument_assign.sol
new file mode 100644
index 00000000..d2c0245c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/146_external_argument_assign.sol
@@ -0,0 +1,5 @@
+contract c {
+ function f(uint a) external { a = 1; }
+}
+// ----
+// TypeError: (47-48): Expression has to be an lvalue.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/147_external_argument_increment.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/147_external_argument_increment.sol
new file mode 100644
index 00000000..2bfba42b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/147_external_argument_increment.sol
@@ -0,0 +1,5 @@
+contract c {
+ function f(uint a) external { a++; }
+}
+// ----
+// TypeError: (47-48): Expression has to be an lvalue.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/148_external_argument_delete.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/148_external_argument_delete.sol
new file mode 100644
index 00000000..30eb204e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/148_external_argument_delete.sol
@@ -0,0 +1,5 @@
+contract c {
+ function f(uint a) external { delete a; }
+}
+// ----
+// TypeError: (54-55): Expression has to be an lvalue.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/149_test_for_bug_override_function_with_bytearray_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/149_test_for_bug_override_function_with_bytearray_type.sol
new file mode 100644
index 00000000..871af310
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/149_test_for_bug_override_function_with_bytearray_type.sol
@@ -0,0 +1,8 @@
+contract Vehicle {
+ function f(bytes) external returns (uint256 r) {r = 1;}
+}
+contract Bike is Vehicle {
+ function f(bytes) external returns (uint256 r) {r = 42;}
+}
+// ----
+// Warning: (23-78): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/150_array_with_nonconstant_length.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/150_array_with_nonconstant_length.sol
new file mode 100644
index 00000000..49a1851c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/150_array_with_nonconstant_length.sol
@@ -0,0 +1,5 @@
+contract c {
+ function f(uint a) public { uint8[a] x; }
+}
+// ----
+// TypeError: (51-52): Invalid array length, expected integer literal or constant expression.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/151_array_with_negative_length.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/151_array_with_negative_length.sol
new file mode 100644
index 00000000..b87160b0
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/151_array_with_negative_length.sol
@@ -0,0 +1,5 @@
+contract c {
+ function f(uint a) public { uint8[-1] x; }
+}
+// ----
+// TypeError: (51-53): Array with negative length specified.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/152_array_copy_with_different_types1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/152_array_copy_with_different_types1.sol
new file mode 100644
index 00000000..a0e71847
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/152_array_copy_with_different_types1.sol
@@ -0,0 +1,7 @@
+contract c {
+ bytes a;
+ uint[] b;
+ function f() public { b = a; }
+}
+// ----
+// TypeError: (70-71): Type bytes storage ref is not implicitly convertible to expected type uint256[] storage ref.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/153_array_copy_with_different_types2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/153_array_copy_with_different_types2.sol
new file mode 100644
index 00000000..8d1cb1ef
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/153_array_copy_with_different_types2.sol
@@ -0,0 +1,7 @@
+contract c {
+ uint32[] a;
+ uint8[] b;
+ function f() public { b = a; }
+}
+// ----
+// TypeError: (74-75): Type uint32[] storage ref is not implicitly convertible to expected type uint8[] storage ref.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/154_array_copy_with_different_types_conversion_possible.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/154_array_copy_with_different_types_conversion_possible.sol
new file mode 100644
index 00000000..b15a9350
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/154_array_copy_with_different_types_conversion_possible.sol
@@ -0,0 +1,5 @@
+contract c {
+ uint32[] a;
+ uint8[] b;
+ function f() public { a = b; }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/155_array_copy_with_different_types_static_dynamic.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/155_array_copy_with_different_types_static_dynamic.sol
new file mode 100644
index 00000000..025593a5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/155_array_copy_with_different_types_static_dynamic.sol
@@ -0,0 +1,5 @@
+contract c {
+ uint32[] a;
+ uint8[80] b;
+ function f() public { a = b; }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/156_array_copy_with_different_types_dynamic_static.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/156_array_copy_with_different_types_dynamic_static.sol
new file mode 100644
index 00000000..90aa53a0
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/156_array_copy_with_different_types_dynamic_static.sol
@@ -0,0 +1,7 @@
+contract c {
+ uint[] a;
+ uint[80] b;
+ function f() public { b = a; }
+}
+// ----
+// TypeError: (73-74): Type uint256[] storage ref is not implicitly convertible to expected type uint256[80] storage ref.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/157_array_of_undeclared_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/157_array_of_undeclared_type.sol
new file mode 100644
index 00000000..1409db5e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/157_array_of_undeclared_type.sol
@@ -0,0 +1,5 @@
+contract c {
+ a[] public foo;
+}
+// ----
+// DeclarationError: (17-18): Identifier not found or not unique.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/158_storage_variable_initialization_with_incorrect_type_int.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/158_storage_variable_initialization_with_incorrect_type_int.sol
new file mode 100644
index 00000000..b1ef153e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/158_storage_variable_initialization_with_incorrect_type_int.sol
@@ -0,0 +1,5 @@
+contract c {
+ uint8 a = 1000;
+}
+// ----
+// TypeError: (27-31): Type int_const 1000 is not implicitly convertible to expected type uint8.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/159_storage_variable_initialization_with_incorrect_type_string.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/159_storage_variable_initialization_with_incorrect_type_string.sol
new file mode 100644
index 00000000..75736d98
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/159_storage_variable_initialization_with_incorrect_type_string.sol
@@ -0,0 +1,5 @@
+contract c {
+ uint a = "abc";
+}
+// ----
+// TypeError: (26-31): Type literal_string "abc" is not implicitly convertible to expected type uint256.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/160_test_byte_is_alias_of_byte1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/160_test_byte_is_alias_of_byte1.sol
new file mode 100644
index 00000000..9977c839
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/160_test_byte_is_alias_of_byte1.sol
@@ -0,0 +1,7 @@
+contract c {
+ bytes arr;
+ function f() public { byte a = arr[0];}
+}
+// ----
+// Warning: (54-60): Unused local variable.
+// Warning: (32-71): Function state mutability can be restricted to view
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/161_warns_assigning_decimal_to_bytesxx.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/161_warns_assigning_decimal_to_bytesxx.sol
new file mode 100644
index 00000000..957322af
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/161_warns_assigning_decimal_to_bytesxx.sol
@@ -0,0 +1,5 @@
+contract Foo {
+ bytes32 a = 7;
+}
+// ----
+// Warning: (31-32): Decimal literal assigned to bytesXX variable will be left-aligned. Use an explicit conversion to silence this warning.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/162_does_not_warn_assigning_hex_number_to_bytesxx.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/162_does_not_warn_assigning_hex_number_to_bytesxx.sol
new file mode 100644
index 00000000..bc32580a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/162_does_not_warn_assigning_hex_number_to_bytesxx.sol
@@ -0,0 +1,3 @@
+contract Foo {
+ bytes32 a = 0x1234;
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/163_explicit_conversion_from_decimal_to_bytesxx.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/163_explicit_conversion_from_decimal_to_bytesxx.sol
new file mode 100644
index 00000000..af921869
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/163_explicit_conversion_from_decimal_to_bytesxx.sol
@@ -0,0 +1,3 @@
+contract Foo {
+ bytes32 a = bytes32(7);
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/164_assigning_value_to_const_variable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/164_assigning_value_to_const_variable.sol
new file mode 100644
index 00000000..4e543e70
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/164_assigning_value_to_const_variable.sol
@@ -0,0 +1,6 @@
+contract Foo {
+ function changeIt() public { x = 9; }
+ uint constant x = 56;
+}
+// ----
+// TypeError: (48-49): Cannot assign to a constant variable.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/165_assigning_state_to_const_variable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/165_assigning_state_to_const_variable.sol
new file mode 100644
index 00000000..f3986580
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/165_assigning_state_to_const_variable.sol
@@ -0,0 +1,5 @@
+contract C {
+ address constant x = msg.sender;
+}
+// ----
+// Warning: (38-48): Initial value for constant variable has to be compile-time constant. This will fail to compile with the next breaking version change.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/166_assigning_state_to_const_variable_050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/166_assigning_state_to_const_variable_050.sol
new file mode 100644
index 00000000..dc0a6e63
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/166_assigning_state_to_const_variable_050.sol
@@ -0,0 +1,7 @@
+pragma experimental "v0.5.0";
+
+contract C {
+ address constant x = msg.sender;
+}
+// ----
+// TypeError: (69-79): Initial value for constant variable has to be compile-time constant.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/167_constant_string_literal_disallows_assignment.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/167_constant_string_literal_disallows_assignment.sol
new file mode 100644
index 00000000..3f19ea3b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/167_constant_string_literal_disallows_assignment.sol
@@ -0,0 +1,10 @@
+contract Test {
+ string constant x = "abefghijklmnopqabcdefghijklmnopqabcdefghijklmnopqabca";
+ function f() public {
+ // Even if this is made possible in the future, we should not allow assignment
+ // to elements of constant arrays.
+ x[0] = "f";
+ }
+}
+// ----
+// TypeError: (261-265): Index access for string is not possible.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/168_assignment_to_const_var_involving_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/168_assignment_to_const_var_involving_conversion.sol
new file mode 100644
index 00000000..fb31e199
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/168_assignment_to_const_var_involving_conversion.sol
@@ -0,0 +1,3 @@
+contract C {
+ C constant x = C(0x123);
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/169_assignment_to_const_var_involving_expression.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/169_assignment_to_const_var_involving_expression.sol
new file mode 100644
index 00000000..692aad9f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/169_assignment_to_const_var_involving_expression.sol
@@ -0,0 +1,3 @@
+contract C {
+ uint constant x = 0x123 + 0x456;
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/170_assignment_to_const_var_involving_keccak.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/170_assignment_to_const_var_involving_keccak.sol
new file mode 100644
index 00000000..54f022bb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/170_assignment_to_const_var_involving_keccak.sol
@@ -0,0 +1,3 @@
+contract C {
+ bytes32 constant x = keccak256("abc");
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/171_assignment_to_const_array_vars.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/171_assignment_to_const_array_vars.sol
new file mode 100644
index 00000000..b9e9aa7a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/171_assignment_to_const_array_vars.sol
@@ -0,0 +1,5 @@
+contract C {
+ uint[3] constant x = [uint(1), 2, 3];
+}
+// ----
+// TypeError: (17-53): Constants of non-value type not yet implemented.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/172_assignment_to_const_string_bytes.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/172_assignment_to_const_string_bytes.sol
new file mode 100644
index 00000000..f0e1528c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/172_assignment_to_const_string_bytes.sol
@@ -0,0 +1,5 @@
+contract C {
+ bytes constant a = "\x00\x01\x02";
+ bytes constant b = hex"000102";
+ string constant c = "hello";
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/173_constant_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/173_constant_struct.sol
new file mode 100644
index 00000000..07bf0439
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/173_constant_struct.sol
@@ -0,0 +1,6 @@
+contract C {
+ struct S { uint x; uint[] y; }
+ S constant x = S(5, new uint[](4));
+}
+// ----
+// TypeError: (52-86): Constants of non-value type not yet implemented.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/174_address_is_constant.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/174_address_is_constant.sol
new file mode 100644
index 00000000..10850e16
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/174_address_is_constant.sol
@@ -0,0 +1,3 @@
+contract C {
+ address constant x = 0x1212121212121212121212121212121212121212;
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/175_uninitialized_const_variable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/175_uninitialized_const_variable.sol
new file mode 100644
index 00000000..13496d8b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/175_uninitialized_const_variable.sol
@@ -0,0 +1,5 @@
+contract Foo {
+ uint constant y;
+}
+// ----
+// TypeError: (19-34): Uninitialized "constant" variable.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/176_overloaded_function_cannot_resolve.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/176_overloaded_function_cannot_resolve.sol
new file mode 100644
index 00000000..bcf25948
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/176_overloaded_function_cannot_resolve.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public returns (uint) { return 1; }
+ function f(uint a) public returns (uint) { return a; }
+ function g() public returns (uint) { return f(3, 5); }
+}
+// ----
+// TypeError: (176-177): No matching declaration found after argument-dependent lookup.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/177_ambiguous_overloaded_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/177_ambiguous_overloaded_function.sol
new file mode 100644
index 00000000..759e02f2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/177_ambiguous_overloaded_function.sol
@@ -0,0 +1,8 @@
+contract test {
+ function f(uint8 a) public returns (uint) { return a; }
+ function f(uint a) public returns (uint) { return 2 * a; }
+ // literal 1 can be both converted to uint and uint8, so the call is ambiguous.
+ function g() public returns (uint) { return f(1); }
+}
+// ----
+// TypeError: (271-272): No unique declaration found after argument-dependent lookup.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/178_assignment_of_nonoverloaded_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/178_assignment_of_nonoverloaded_function.sol
new file mode 100644
index 00000000..07fc1c43
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/178_assignment_of_nonoverloaded_function.sol
@@ -0,0 +1,6 @@
+contract test {
+ function f(uint a) public returns (uint) { return 2 * a; }
+ function g() public returns (uint) { function (uint) returns (uint) x = f; return x(7); }
+}
+// ----
+// Warning: (20-78): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/179_assignment_of_overloaded_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/179_assignment_of_overloaded_function.sol
new file mode 100644
index 00000000..9ed864f1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/179_assignment_of_overloaded_function.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public returns (uint) { return 1; }
+ function f(uint a) public returns (uint) { return 2 * a; }
+ function g() public returns (uint) { function (uint) returns (uint) x = f; return x(7); }
+}
+// ----
+// TypeError: (208-209): No matching declaration found after variable lookup.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/180_external_types_clash.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/180_external_types_clash.sol
new file mode 100644
index 00000000..91ddcd9b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/180_external_types_clash.sol
@@ -0,0 +1,9 @@
+contract base {
+ enum a { X }
+ function f(a) public { }
+}
+contract test is base {
+ function f(uint8 a) public { }
+}
+// ----
+// TypeError: (37-61): Function overload clash during conversion to external types for arguments.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/181_override_changes_return_types.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/181_override_changes_return_types.sol
new file mode 100644
index 00000000..c887f259
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/181_override_changes_return_types.sol
@@ -0,0 +1,8 @@
+contract base {
+ function f(uint a) public returns (uint) { }
+}
+contract test is base {
+ function f(uint a) public returns (uint8) { }
+}
+// ----
+// TypeError: (95-140): Overriding function return types differ.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/182_equal_overload.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/182_equal_overload.sol
new file mode 100644
index 00000000..cb9eb3fa
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/182_equal_overload.sol
@@ -0,0 +1,7 @@
+contract C {
+ function test(uint a) public returns (uint b) { }
+ function test(uint a) external {}
+}
+// ----
+// DeclarationError: (17-66): Function with same name and arguments defined twice.
+// TypeError: (17-66): Overriding function visibility differs.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/185_invalid_utf8_implicit.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/185_invalid_utf8_implicit.sol
new file mode 100644
index 00000000..5440b425
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/185_invalid_utf8_implicit.sol
@@ -0,0 +1,5 @@
+contract C {
+ string s = "\xa0\x00";
+}
+// ----
+// TypeError: (28-38): Type literal_string (contains invalid UTF-8 sequence at position 0) is not implicitly convertible to expected type string storage ref.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/186_invalid_utf8_explicit.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/186_invalid_utf8_explicit.sol
new file mode 100644
index 00000000..401c46e2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/186_invalid_utf8_explicit.sol
@@ -0,0 +1,5 @@
+contract C {
+ string s = string("\xa0\x00");
+}
+// ----
+// TypeError: (28-46): Explicit type conversion not allowed from "literal_string (contains invalid UTF-8 sequence at position 0)" to "string storage pointer".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/187_large_utf8_codepoint.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/187_large_utf8_codepoint.sol
new file mode 100644
index 00000000..5e406d0c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/187_large_utf8_codepoint.sol
@@ -0,0 +1,3 @@
+contract C {
+ string s = "\xf0\x9f\xa6\x84";
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/188_string_index.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/188_string_index.sol
new file mode 100644
index 00000000..9d51e06b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/188_string_index.sol
@@ -0,0 +1,6 @@
+contract C {
+ string s;
+ function f() public { bytes1 a = s[2]; }
+}
+// ----
+// TypeError: (64-68): Index access for string is not possible.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/189_string_length.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/189_string_length.sol
new file mode 100644
index 00000000..9e714d68
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/189_string_length.sol
@@ -0,0 +1,6 @@
+contract C {
+ string s;
+ function f() public { uint a = s.length; }
+}
+// ----
+// TypeError: (62-70): Member "length" not found or not visible after argument-dependent lookup in string storage ref
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/190_negative_integers_to_signed_out_of_bound.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/190_negative_integers_to_signed_out_of_bound.sol
new file mode 100644
index 00000000..2e8503af
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/190_negative_integers_to_signed_out_of_bound.sol
@@ -0,0 +1,5 @@
+contract test {
+ int8 public i = -129;
+}
+// ----
+// TypeError: (36-40): Type int_const -129 is not implicitly convertible to expected type int8.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/191_negative_integers_to_signed_min.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/191_negative_integers_to_signed_min.sol
new file mode 100644
index 00000000..211cfee2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/191_negative_integers_to_signed_min.sol
@@ -0,0 +1,3 @@
+contract test {
+ int8 public i = -128;
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/192_positive_integers_to_signed_out_of_bound.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/192_positive_integers_to_signed_out_of_bound.sol
new file mode 100644
index 00000000..d56045c2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/192_positive_integers_to_signed_out_of_bound.sol
@@ -0,0 +1,5 @@
+contract test {
+ int8 public j = 128;
+}
+// ----
+// TypeError: (36-39): Type int_const 128 is not implicitly convertible to expected type int8.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/193_positive_integers_to_signed_out_of_bound_max.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/193_positive_integers_to_signed_out_of_bound_max.sol
new file mode 100644
index 00000000..66701339
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/193_positive_integers_to_signed_out_of_bound_max.sol
@@ -0,0 +1,3 @@
+contract test {
+ int8 public j = 127;
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/194_negative_integers_to_unsigned.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/194_negative_integers_to_unsigned.sol
new file mode 100644
index 00000000..3702f09b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/194_negative_integers_to_unsigned.sol
@@ -0,0 +1,5 @@
+contract test {
+ uint8 public x = -1;
+}
+// ----
+// TypeError: (37-39): Type int_const -1 is not implicitly convertible to expected type uint8.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/195_positive_integers_to_unsigned_out_of_bound.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/195_positive_integers_to_unsigned_out_of_bound.sol
new file mode 100644
index 00000000..81216229
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/195_positive_integers_to_unsigned_out_of_bound.sol
@@ -0,0 +1,5 @@
+contract test {
+ uint8 public x = 700;
+}
+// ----
+// TypeError: (37-40): Type int_const 700 is not implicitly convertible to expected type uint8.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/196_integer_boolean_or.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/196_integer_boolean_or.sol
new file mode 100644
index 00000000..1b522c00
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/196_integer_boolean_or.sol
@@ -0,0 +1,3 @@
+contract test { function() public { uint x = 1; uint y = 2; x || y; } }
+// ----
+// TypeError: (60-66): Operator || not compatible with types uint256 and uint256
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/197_integer_boolean_and.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/197_integer_boolean_and.sol
new file mode 100644
index 00000000..cbc3732f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/197_integer_boolean_and.sol
@@ -0,0 +1,3 @@
+contract test { function() public { uint x = 1; uint y = 2; x && y; } }
+// ----
+// TypeError: (60-66): Operator && not compatible with types uint256 and uint256
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/198_integer_boolean_not.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/198_integer_boolean_not.sol
new file mode 100644
index 00000000..1d36b0b3
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/198_integer_boolean_not.sol
@@ -0,0 +1,3 @@
+contract test { function() public { uint x = 1; !x; } }
+// ----
+// TypeError: (48-50): Unary operator ! cannot be applied to type uint256
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/199_integer_unsigned_exp_signed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/199_integer_unsigned_exp_signed.sol
new file mode 100644
index 00000000..5b8b2d3f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/199_integer_unsigned_exp_signed.sol
@@ -0,0 +1,3 @@
+contract test { function() public { uint x = 3; int y = -4; x ** y; } }
+// ----
+// TypeError: (60-66): Operator ** not compatible with types uint256 and int256
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/200_integer_signed_exp_unsigned.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/200_integer_signed_exp_unsigned.sol
new file mode 100644
index 00000000..95c19d17
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/200_integer_signed_exp_unsigned.sol
@@ -0,0 +1,3 @@
+contract test { function() public { uint x = 3; int y = -4; y ** x; } }
+// ----
+// TypeError: (60-66): Operator ** not compatible with types int256 and uint256
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/201_integer_signed_exp_signed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/201_integer_signed_exp_signed.sol
new file mode 100644
index 00000000..394dec88
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/201_integer_signed_exp_signed.sol
@@ -0,0 +1,3 @@
+contract test { function() public { int x = -3; int y = -4; x ** y; } }
+// ----
+// TypeError: (60-66): Operator ** not compatible with types int256 and int256
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/202_bytes_reference_compare_operators.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/202_bytes_reference_compare_operators.sol
new file mode 100644
index 00000000..d4c513dd
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/202_bytes_reference_compare_operators.sol
@@ -0,0 +1,3 @@
+contract test { bytes a; bytes b; function() public { a == b; } }
+// ----
+// TypeError: (54-60): Operator == not compatible with types bytes storage ref and bytes storage ref
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/203_struct_reference_compare_operators.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/203_struct_reference_compare_operators.sol
new file mode 100644
index 00000000..de96b798
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/203_struct_reference_compare_operators.sol
@@ -0,0 +1,3 @@
+contract test { struct s {uint a;} s x; s y; function() public { x == y; } }
+// ----
+// TypeError: (65-71): Operator == not compatible with types struct test.s storage ref and struct test.s storage ref
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/204_overwrite_memory_location_external.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/204_overwrite_memory_location_external.sol
new file mode 100644
index 00000000..16d71ca4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/204_overwrite_memory_location_external.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f(uint[] memory a) external {}
+}
+// ----
+// TypeError: (28-43): Location has to be calldata for external functions (remove the "memory" or "storage" keyword).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/205_overwrite_storage_location_external.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/205_overwrite_storage_location_external.sol
new file mode 100644
index 00000000..99c9827d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/205_overwrite_storage_location_external.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f(uint[] storage a) external {}
+}
+// ----
+// TypeError: (28-44): Location has to be calldata for external functions (remove the "memory" or "storage" keyword).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/206_storage_location_local_variables.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/206_storage_location_local_variables.sol
new file mode 100644
index 00000000..5199e5d7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/206_storage_location_local_variables.sol
@@ -0,0 +1,11 @@
+contract C {
+ function f() public {
+ uint[] storage x;
+ uint[] memory y;
+ uint[] memory z;
+ x;y;z;
+ }
+}
+// ----
+// Warning: (47-63): Uninitialized storage pointer.
+// Warning: (17-135): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/207_no_mappings_in_memory_array.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/207_no_mappings_in_memory_array.sol
new file mode 100644
index 00000000..5220ee22
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/207_no_mappings_in_memory_array.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public {
+ mapping(uint=>uint)[] memory x;
+ }
+}
+// ----
+// TypeError: (47-77): Type mapping(uint256 => uint256)[] memory is only valid in storage.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/208_assignment_mem_to_local_storage_variable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/208_assignment_mem_to_local_storage_variable.sol
new file mode 100644
index 00000000..febe39e6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/208_assignment_mem_to_local_storage_variable.sol
@@ -0,0 +1,9 @@
+contract C {
+ uint[] data;
+ function f(uint[] x) public {
+ uint[] storage dataRef = data;
+ dataRef = x;
+ }
+}
+// ----
+// TypeError: (121-122): Type uint256[] memory is not implicitly convertible to expected type uint256[] storage pointer.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/209_storage_assign_to_different_local_variable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/209_storage_assign_to_different_local_variable.sol
new file mode 100644
index 00000000..aabdcd88
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/209_storage_assign_to_different_local_variable.sol
@@ -0,0 +1,12 @@
+contract C {
+ uint[] data;
+ uint8[] otherData;
+ function f() public {
+ uint8[] storage x = otherData;
+ uint[] storage y = data;
+ y = x;
+ // note that data = otherData works
+ }
+}
+// ----
+// TypeError: (163-164): Type uint8[] storage pointer is not implicitly convertible to expected type uint256[] storage pointer.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/210_uninitialized_mapping_variable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/210_uninitialized_mapping_variable.sol
new file mode 100644
index 00000000..6b25cdfe
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/210_uninitialized_mapping_variable.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() public {
+ mapping(uint => uint) x;
+ x;
+ }
+}
+// ----
+// TypeError: (47-70): Uninitialized mapping. Mappings cannot be created dynamically, you have to assign them from a state variable.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/211_uninitialized_mapping_array_variable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/211_uninitialized_mapping_array_variable.sol
new file mode 100644
index 00000000..80467491
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/211_uninitialized_mapping_array_variable.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() pure public {
+ mapping(uint => uint)[] storage x;
+ x;
+ }
+}
+// ----
+// Warning: (52-85): Uninitialized storage pointer.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/212_uninitialized_mapping_array_variable_050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/212_uninitialized_mapping_array_variable_050.sol
new file mode 100644
index 00000000..f2028690
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/212_uninitialized_mapping_array_variable_050.sol
@@ -0,0 +1,9 @@
+pragma experimental "v0.5.0";
+contract C {
+ function f() pure public {
+ mapping(uint => uint)[] storage x;
+ x;
+ }
+}
+// ----
+// DeclarationError: (82-115): Uninitialized storage pointer.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/213_no_delete_on_storage_pointers.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/213_no_delete_on_storage_pointers.sol
new file mode 100644
index 00000000..7a6fb1c7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/213_no_delete_on_storage_pointers.sol
@@ -0,0 +1,9 @@
+contract C {
+ uint[] data;
+ function f() public {
+ uint[] storage x = data;
+ delete x;
+ }
+}
+// ----
+// TypeError: (97-105): Unary operator delete cannot be applied to type uint256[] storage pointer
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/214_assignment_mem_storage_variable_directly.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/214_assignment_mem_storage_variable_directly.sol
new file mode 100644
index 00000000..08737f2d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/214_assignment_mem_storage_variable_directly.sol
@@ -0,0 +1,6 @@
+contract C {
+ uint[] data;
+ function f(uint[] x) public {
+ data = x;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/215_function_argument_mem_to_storage.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/215_function_argument_mem_to_storage.sol
new file mode 100644
index 00000000..4d75732a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/215_function_argument_mem_to_storage.sol
@@ -0,0 +1,9 @@
+contract C {
+ function f(uint[] storage x) private {
+ }
+ function g(uint[] x) public {
+ f(x);
+ }
+}
+// ----
+// TypeError: (106-107): Invalid type for argument in function call. Invalid implicit conversion from uint256[] memory to uint256[] storage pointer requested.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/216_function_argument_storage_to_mem.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/216_function_argument_storage_to_mem.sol
new file mode 100644
index 00000000..157ef4dd
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/216_function_argument_storage_to_mem.sol
@@ -0,0 +1,10 @@
+contract C {
+ function f(uint[] storage x) private {
+ g(x);
+ }
+ function g(uint[] x) public {
+ }
+}
+// ----
+// Warning: (91-99): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (80-115): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/217_mem_array_assignment_changes_base_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/217_mem_array_assignment_changes_base_type.sol
new file mode 100644
index 00000000..3755b935
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/217_mem_array_assignment_changes_base_type.sol
@@ -0,0 +1,10 @@
+contract C {
+ function f(uint8[] memory x) private {
+ // Such an assignment is possible in storage, but not in memory
+ // (because it would incur an otherwise unnecessary copy).
+ // This requirement might be lifted, though.
+ uint[] memory y = x;
+ }
+}
+// ----
+// TypeError: (256-275): Type uint8[] memory is not implicitly convertible to expected type uint256[] memory.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/219_memory_arrays_not_resizeable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/219_memory_arrays_not_resizeable.sol
new file mode 100644
index 00000000..93d8cd42
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/219_memory_arrays_not_resizeable.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() public {
+ uint[] memory x;
+ x.length = 2;
+ }
+}
+// ----
+// TypeError: (72-80): Expression has to be an lvalue.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/220_struct_constructor.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/220_struct_constructor.sol
new file mode 100644
index 00000000..50585c11
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/220_struct_constructor.sol
@@ -0,0 +1,9 @@
+contract C {
+ struct S { uint a; bool x; }
+ function f() public {
+ S memory s = S(1, true);
+ }
+}
+// ----
+// Warning: (80-90): Unused local variable.
+// Warning: (50-110): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/221_struct_constructor_nested.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/221_struct_constructor_nested.sol
new file mode 100644
index 00000000..00222682
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/221_struct_constructor_nested.sol
@@ -0,0 +1,11 @@
+contract C {
+ struct X { uint x1; uint x2; }
+ struct S { uint s1; uint[3] s2; X s3; }
+ function f() public {
+ uint[3] memory s2;
+ S memory s = S(1, s2, X(4, 5));
+ }
+}
+// ----
+// Warning: (153-163): Unused local variable.
+// Warning: (96-190): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/222_struct_named_constructor.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/222_struct_named_constructor.sol
new file mode 100644
index 00000000..8ab8ee46
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/222_struct_named_constructor.sol
@@ -0,0 +1,9 @@
+contract C {
+ struct S { uint a; bool x; }
+ function f() public {
+ S memory s = S({a: 1, x: true});
+ }
+}
+// ----
+// Warning: (80-90): Unused local variable.
+// Warning: (50-118): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/223_literal_strings.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/223_literal_strings.sol
new file mode 100644
index 00000000..1dadcc4d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/223_literal_strings.sol
@@ -0,0 +1,9 @@
+contract Foo {
+ function f() public {
+ string memory long = "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
+ string memory short = "123";
+ long; short;
+ }
+}
+// ----
+// Warning: (19-238): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/224_string_bytes_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/224_string_bytes_conversion.sol
new file mode 100644
index 00000000..137aa893
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/224_string_bytes_conversion.sol
@@ -0,0 +1,17 @@
+contract Test {
+ string s;
+ bytes b;
+ function h(string _s) external { bytes(_s).length; }
+ function i(string _s) internal { bytes(_s).length; }
+ function j() internal { bytes(s).length; }
+ function k(bytes _b) external { string(_b); }
+ function l(bytes _b) internal { string(_b); }
+ function m() internal { string(b); }
+}
+// ----
+// Warning: (47-99): Function state mutability can be restricted to pure
+// Warning: (104-156): Function state mutability can be restricted to pure
+// Warning: (161-203): Function state mutability can be restricted to view
+// Warning: (208-253): Function state mutability can be restricted to pure
+// Warning: (258-303): Function state mutability can be restricted to pure
+// Warning: (308-344): Function state mutability can be restricted to view
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/225_inheriting_from_library.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/225_inheriting_from_library.sol
new file mode 100644
index 00000000..eff7bf86
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/225_inheriting_from_library.sol
@@ -0,0 +1,4 @@
+library Lib {}
+contract Test is Lib {}
+// ----
+// TypeError: (32-35): Libraries cannot be inherited from.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/226_inheriting_library.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/226_inheriting_library.sol
new file mode 100644
index 00000000..2d601c1c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/226_inheriting_library.sol
@@ -0,0 +1,4 @@
+contract Test {}
+library Lib is Test {}
+// ----
+// TypeError: (17-39): Library is not allowed to inherit.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/227_library_having_variables.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/227_library_having_variables.sol
new file mode 100644
index 00000000..804ef3d3
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/227_library_having_variables.sol
@@ -0,0 +1,3 @@
+library Lib { uint x; }
+// ----
+// TypeError: (14-20): Library cannot have non-constant state variables
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/228_valid_library.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/228_valid_library.sol
new file mode 100644
index 00000000..de6b0b3e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/228_valid_library.sol
@@ -0,0 +1 @@
+library Lib { uint constant x = 9; }
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/229_call_to_library_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/229_call_to_library_function.sol
new file mode 100644
index 00000000..c007d9a1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/229_call_to_library_function.sol
@@ -0,0 +1,10 @@
+library Lib {
+ function min(uint, uint) public returns (uint);
+}
+contract Test {
+ function f() public {
+ uint t = Lib.min(12, 7);
+ }
+}
+// ----
+// Warning: (118-124): Unused local variable.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/230_creating_contract_within_the_contract.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/230_creating_contract_within_the_contract.sol
new file mode 100644
index 00000000..8624b0b0
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/230_creating_contract_within_the_contract.sol
@@ -0,0 +1,5 @@
+contract Test {
+ function f() public { Test x = new Test(); }
+}
+// ----
+// TypeError: (51-59): Circular reference for contract creation (cannot create instance of derived or same contract).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/231_array_out_of_bound_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/231_array_out_of_bound_access.sol
new file mode 100644
index 00000000..7230a0a6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/231_array_out_of_bound_access.sol
@@ -0,0 +1,9 @@
+contract c {
+ uint[2] dataArray;
+ function set5th() public returns (bool) {
+ dataArray[5] = 2;
+ return true;
+ }
+}
+// ----
+// TypeError: (90-102): Out of bounds array access.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/232_literal_string_to_storage_pointer.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/232_literal_string_to_storage_pointer.sol
new file mode 100644
index 00000000..a586dc80
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/232_literal_string_to_storage_pointer.sol
@@ -0,0 +1,6 @@
+contract C {
+ function f() public { string x = "abc"; }
+}
+// ----
+// Warning: (39-47): Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning.
+// TypeError: (39-55): Type literal_string "abc" is not implicitly convertible to expected type string storage pointer.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/233_non_initialized_references.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/233_non_initialized_references.sol
new file mode 100644
index 00000000..9d8d4834
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/233_non_initialized_references.sol
@@ -0,0 +1,11 @@
+contract C {
+ struct s {
+ uint a;
+ }
+ function f() public {
+ s storage x;
+ x.a = 2;
+ }
+}
+// ----
+// Warning: (84-95): Uninitialized storage pointer.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/234_non_initialized_references_050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/234_non_initialized_references_050.sol
new file mode 100644
index 00000000..c221b73c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/234_non_initialized_references_050.sol
@@ -0,0 +1,11 @@
+pragma experimental "v0.5.0";
+contract C {
+ struct s {
+ uint a;
+ }
+ function f() public {
+ s storage x;
+ }
+}
+// ----
+// DeclarationError: (114-125): Uninitialized storage pointer.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/235_keccak256_with_large_integer_constant.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/235_keccak256_with_large_integer_constant.sol
new file mode 100644
index 00000000..c39d0fe2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/235_keccak256_with_large_integer_constant.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public { keccak256(2**500); }
+}
+// ----
+// Warning: (39-56): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
+// Warning: (39-56): The provided argument of type int_const 3273...(143 digits omitted)...9376 is not implicitly convertible to expected type bytes memory.
+// TypeError: (49-55): Invalid rational number (too large or division by zero).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/236_cyclic_binary_dependency.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/236_cyclic_binary_dependency.sol
new file mode 100644
index 00000000..c287507d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/236_cyclic_binary_dependency.sol
@@ -0,0 +1,5 @@
+contract A { function f() public { new B(); } }
+contract B { function f() public { new C(); } }
+contract C { function f() public { new A(); } }
+// ----
+// TypeError: (131-136): Circular reference for contract creation (cannot create instance of derived or same contract).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/237_cyclic_binary_dependency_via_inheritance.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/237_cyclic_binary_dependency_via_inheritance.sol
new file mode 100644
index 00000000..00ee536e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/237_cyclic_binary_dependency_via_inheritance.sol
@@ -0,0 +1,5 @@
+contract A is B { }
+contract B { function f() public { new C(); } }
+contract C { function f() public { new A(); } }
+// ----
+// TypeError: (14-15): Definition of base has to precede definition of derived contract
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/239_multi_variable_declaration_wildcards_fine.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/239_multi_variable_declaration_wildcards_fine.sol
new file mode 100644
index 00000000..ae260ce4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/239_multi_variable_declaration_wildcards_fine.sol
@@ -0,0 +1,20 @@
+contract C {
+ function three() public returns (uint, uint, uint);
+ function two() public returns (uint, uint);
+ function none();
+ function f() public {
+ (uint a,) = three();
+ (uint b, uint c,) = two();
+ (,uint d) = three();
+ (,uint e, uint g) = two();
+ var (,,) = three();
+ var () = none();
+ a;b;c;d;e;g;
+ }
+}
+// ----
+// Warning: (172-191): Different number of components on the left hand side (2) than on the right hand side (3).
+// Warning: (201-226): Different number of components on the left hand side (3) than on the right hand side (2).
+// Warning: (236-255): Different number of components on the left hand side (2) than on the right hand side (3).
+// Warning: (265-290): Different number of components on the left hand side (3) than on the right hand side (2).
+// Warning: (121-137): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/240_multi_variable_declaration_wildcards_fail_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/240_multi_variable_declaration_wildcards_fail_1.sol
new file mode 100644
index 00000000..0ccbb327
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/240_multi_variable_declaration_wildcards_fail_1.sol
@@ -0,0 +1,7 @@
+contract C {
+ function one() public returns (uint);
+ function f() public { (uint a, uint b, ) = one(); }
+}
+// ----
+// Warning: (81-107): Different number of components on the left hand side (3) than on the right hand side (1).
+// TypeError: (81-107): Not enough components (1) in value to assign all variables (2).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/241_multi_variable_declaration_wildcards_fail_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/241_multi_variable_declaration_wildcards_fail_2.sol
new file mode 100644
index 00000000..8d5de125
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/241_multi_variable_declaration_wildcards_fail_2.sol
@@ -0,0 +1,7 @@
+contract C {
+ function one() public returns (uint);
+ function f() public { (uint a, , ) = one(); }
+}
+// ----
+// Warning: (81-101): Different number of components on the left hand side (3) than on the right hand side (1).
+// TypeError: (81-101): Not enough components (1) in value to assign all variables (2).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/242_multi_variable_declaration_wildcards_fail_3.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/242_multi_variable_declaration_wildcards_fail_3.sol
new file mode 100644
index 00000000..993df9b9
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/242_multi_variable_declaration_wildcards_fail_3.sol
@@ -0,0 +1,7 @@
+contract C {
+ function one() public returns (uint);
+ function f() public { (, , uint a) = one(); }
+}
+// ----
+// Warning: (81-101): Different number of components on the left hand side (3) than on the right hand side (1).
+// TypeError: (81-101): Not enough components (1) in value to assign all variables (2).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/243_multi_variable_declaration_wildcards_fail_4.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/243_multi_variable_declaration_wildcards_fail_4.sol
new file mode 100644
index 00000000..0697b789
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/243_multi_variable_declaration_wildcards_fail_4.sol
@@ -0,0 +1,7 @@
+contract C {
+ function one() public returns (uint);
+ function f() public { (, uint a, uint b) = one(); }
+}
+// ----
+// Warning: (81-107): Different number of components on the left hand side (3) than on the right hand side (1).
+// TypeError: (81-107): Not enough components (1) in value to assign all variables (2).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/244_tuples.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/244_tuples.sol
new file mode 100644
index 00000000..3112f67a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/244_tuples.sol
@@ -0,0 +1,13 @@
+contract C {
+ function f() public {
+ uint a = (1);
+ (uint b,) = (uint8(1),);
+ (uint c, uint d) = (uint32(1), 2 + a);
+ (uint e,) = (uint64(1), 2, b);
+ a;b;c;d;e;
+ }
+}
+// ----
+// Warning: (69-92): Different number of components on the left hand side (2) than on the right hand side (1).
+// Warning: (149-178): Different number of components on the left hand side (2) than on the right hand side (3).
+// Warning: (17-204): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/245_tuples_empty_components.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/245_tuples_empty_components.sol
new file mode 100644
index 00000000..7815edea
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/245_tuples_empty_components.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public {
+ (1,,2);
+ }
+}
+// ----
+// TypeError: (47-53): Tuple component cannot be empty.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/246_multi_variable_declaration_wildcards_fail_5.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/246_multi_variable_declaration_wildcards_fail_5.sol
new file mode 100644
index 00000000..3d2d0705
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/246_multi_variable_declaration_wildcards_fail_5.sol
@@ -0,0 +1,6 @@
+contract C {
+ function one() public returns (uint);
+ function f() public { var (,) = one(); }
+}
+// ----
+// TypeError: (81-96): Wildcard both at beginning and end of variable declaration list is only allowed if the number of components is equal.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/247_multi_variable_declaration_wildcards_fail_6.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/247_multi_variable_declaration_wildcards_fail_6.sol
new file mode 100644
index 00000000..cc5953db
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/247_multi_variable_declaration_wildcards_fail_6.sol
@@ -0,0 +1,7 @@
+contract C {
+ function two() public returns (uint, uint);
+ function f() public { (uint a, uint b, uint c) = two(); }
+}
+// ----
+// Warning: (87-119): Different number of components on the left hand side (3) than on the right hand side (2).
+// TypeError: (87-119): Not enough components (2) in value to assign all variables (3).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/249_tuple_compound_assignment.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/249_tuple_compound_assignment.sol
new file mode 100644
index 00000000..bcdbde02
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/249_tuple_compound_assignment.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public returns (uint a, uint b) {
+ (a, b) += (1, 1);
+ }
+}
+// ----
+// TypeError: (72-88): Compound assignment is not allowed for tuple types.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/250_member_access_parser_ambiguity.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/250_member_access_parser_ambiguity.sol
new file mode 100644
index 00000000..f5252180
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/250_member_access_parser_ambiguity.sol
@@ -0,0 +1,17 @@
+contract C {
+ struct R { uint[10][10] y; }
+ struct S { uint a; uint b; uint[20][20][20] c; R d; }
+ S data;
+ function f() public {
+ C.S x = data;
+ C.S memory y;
+ C.S[10] memory z;
+ C.S[10];
+ y.a = 2;
+ x.c[1][2][3] = 9;
+ x.d.y[2][2] = 3;
+ }
+}
+// ----
+// Warning: (150-155): Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning.
+// Warning: (194-210): Unused local variable.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/251_using_for_library.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/251_using_for_library.sol
new file mode 100644
index 00000000..c7dcdbcd
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/251_using_for_library.sol
@@ -0,0 +1,4 @@
+library D { }
+contract C {
+ using D for uint;
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/252_using_for_not_library.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/252_using_for_not_library.sol
new file mode 100644
index 00000000..4693b27f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/252_using_for_not_library.sol
@@ -0,0 +1,6 @@
+contract D { }
+contract C {
+ using D for uint;
+}
+// ----
+// TypeError: (38-39): Library name expected.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/253_using_for_function_exists.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/253_using_for_function_exists.sol
new file mode 100644
index 00000000..9e570805
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/253_using_for_function_exists.sol
@@ -0,0 +1,10 @@
+library D { function double(uint self) public returns (uint) { return 2*self; } }
+contract C {
+ using D for uint;
+ function f(uint a) public {
+ a.double;
+ }
+}
+// ----
+// Warning: (12-79): Function state mutability can be restricted to pure
+// Warning: (121-172): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/254_using_for_function_on_int.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/254_using_for_function_on_int.sol
new file mode 100644
index 00000000..a8e23d0f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/254_using_for_function_on_int.sol
@@ -0,0 +1,9 @@
+library D { function double(uint self) public returns (uint) { return 2*self; } }
+contract C {
+ using D for uint;
+ function f(uint a) public returns (uint) {
+ return a.double();
+ }
+}
+// ----
+// Warning: (12-79): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/255_using_for_function_on_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/255_using_for_function_on_struct.sol
new file mode 100644
index 00000000..2c3deb4c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/255_using_for_function_on_struct.sol
@@ -0,0 +1,8 @@
+library D { struct s { uint a; } function mul(s storage self, uint x) public returns (uint) { return self.a *= x; } }
+contract C {
+ using D for D.s;
+ D.s x;
+ function f(uint a) public returns (uint) {
+ return x.mul(a);
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/256_using_for_overload.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/256_using_for_overload.sol
new file mode 100644
index 00000000..155281f5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/256_using_for_overload.sol
@@ -0,0 +1,14 @@
+library D {
+ struct s { uint a; }
+ function mul(s storage self, uint x) public returns (uint) { return self.a *= x; }
+ function mul(s storage, bytes32) public returns (bytes32) { }
+}
+contract C {
+ using D for D.s;
+ D.s x;
+ function f(uint a) public returns (uint) {
+ return x.mul(a);
+ }
+}
+// ----
+// Warning: (128-189): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/257_using_for_by_name.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/257_using_for_by_name.sol
new file mode 100644
index 00000000..b3eab987
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/257_using_for_by_name.sol
@@ -0,0 +1,8 @@
+library D { struct s { uint a; } function mul(s storage self, uint x) public returns (uint) { return self.a *= x; } }
+contract C {
+ using D for D.s;
+ D.s x;
+ function f(uint a) public returns (uint) {
+ return x.mul({x: a});
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/258_using_for_mismatch.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/258_using_for_mismatch.sol
new file mode 100644
index 00000000..84e42072
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/258_using_for_mismatch.sol
@@ -0,0 +1,9 @@
+library D { function double(bytes32 self) public returns (uint) { return 2; } }
+contract C {
+ using D for uint;
+ function f(uint a) public returns (uint) {
+ return a.double();
+ }
+}
+// ----
+// TypeError: (177-185): Member "double" not found or not visible after argument-dependent lookup in uint256
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/259_using_for_not_used.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/259_using_for_not_used.sol
new file mode 100644
index 00000000..fae918b7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/259_using_for_not_used.sol
@@ -0,0 +1,11 @@
+library D { function double(uint self) public returns (uint) { return 2; } }
+contract C {
+ using D for uint;
+ function f(uint16 a) public returns (uint) {
+ // This is an error because the function is only bound to uint.
+ // Had it been bound to *, it would have worked.
+ return a.double();
+ }
+}
+// ----
+// TypeError: (305-313): Member "double" not found or not visible after argument-dependent lookup in uint16
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/260_library_memory_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/260_library_memory_struct.sol
new file mode 100644
index 00000000..e06ba2d1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/260_library_memory_struct.sol
@@ -0,0 +1,8 @@
+pragma experimental ABIEncoderV2;
+library c {
+ struct S { uint x; }
+ function f() public returns (S ) {}
+}
+// ----
+// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
+// Warning: (75-110): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/261_using_for_arbitrary_mismatch.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/261_using_for_arbitrary_mismatch.sol
new file mode 100644
index 00000000..ced4705f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/261_using_for_arbitrary_mismatch.sol
@@ -0,0 +1,10 @@
+library D { function double(bytes32 self) public returns (uint) { return 2; } }
+contract C {
+ using D for *;
+ function f(uint a) public returns (uint) {
+ // Bound to a, but self type does not match.
+ return a.double();
+ }
+}
+// ----
+// TypeError: (227-235): Member "double" not found or not visible after argument-dependent lookup in uint256
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/262_bound_function_in_var.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/262_bound_function_in_var.sol
new file mode 100644
index 00000000..c3cc5232
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/262_bound_function_in_var.sol
@@ -0,0 +1,13 @@
+library D { struct s { uint a; } function mul(s storage self, uint x) public returns (uint) { return self.a *= x; } }
+contract C {
+ using D for D.s;
+ D.s x;
+ function f(uint a) public returns (uint) {
+ function (D.s storage, uint) returns (uint) g = x.mul;
+ g(x, a);
+ g(a);
+ }
+}
+// ----
+// TypeError: (218-271): Type function (struct D.s storage pointer,uint256) returns (uint256) is not implicitly convertible to expected type function (struct D.s storage pointer,uint256) returns (uint256).
+// TypeError: (298-302): Wrong argument count for function call: 1 arguments given but expected 2.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/263_create_memory_arrays.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/263_create_memory_arrays.sol
new file mode 100644
index 00000000..71f43992
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/263_create_memory_arrays.sol
@@ -0,0 +1,14 @@
+library L {
+ struct R { uint[10][10] y; }
+ struct S { uint a; uint b; uint[20][20][20] c; R d; }
+}
+contract C {
+ function f(uint size) public {
+ L.S[][] memory x = new L.S[][](10);
+ uint[] memory y = new uint[](20);
+ bytes memory z = new bytes(size);
+ x;y;z;
+ }
+}
+// ----
+// Warning: (122-301): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/264_mapping_in_memory_array.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/264_mapping_in_memory_array.sol
new file mode 100644
index 00000000..f0bb557b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/264_mapping_in_memory_array.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f(uint size) public {
+ mapping(uint => uint) x = new mapping(uint => uint)[](4);
+ }
+}
+// ----
+// TypeError: (86-109): Type cannot live outside storage.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/265_new_for_non_array.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/265_new_for_non_array.sol
new file mode 100644
index 00000000..c4b2c692
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/265_new_for_non_array.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f(uint size) public {
+ uint x = new uint(7);
+ }
+}
+// ----
+// TypeError: (65-73): Contract or array type expected.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/266_invalid_args_creating_memory_array.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/266_invalid_args_creating_memory_array.sol
new file mode 100644
index 00000000..078255e3
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/266_invalid_args_creating_memory_array.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f(uint size) public {
+ uint[] memory x = new uint[]();
+ }
+}
+// ----
+// TypeError: (74-86): Wrong argument count for function call: 0 arguments given but expected 1.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/267_invalid_args_creating_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/267_invalid_args_creating_struct.sol
new file mode 100644
index 00000000..35671e6f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/267_invalid_args_creating_struct.sol
@@ -0,0 +1,9 @@
+contract C {
+ struct S { uint a; uint b; }
+
+ function f() public {
+ S memory s = S({a: 1});
+ }
+}
+// ----
+// TypeError: (94-103): Wrong argument count for struct constructor: 1 arguments given but expected 2.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/268_function_overload_array_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/268_function_overload_array_type.sol
new file mode 100644
index 00000000..0ff1ed75
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/268_function_overload_array_type.sol
@@ -0,0 +1,7 @@
+ contract M {
+ function f(uint[]);
+ function f(int[]);
+ }
+// ----
+// Warning: (25-44): No visibility specified. Defaulting to "public".
+// Warning: (53-71): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/269_inline_array_declaration_and_passing_implicit_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/269_inline_array_declaration_and_passing_implicit_conversion.sol
new file mode 100644
index 00000000..023404f7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/269_inline_array_declaration_and_passing_implicit_conversion.sol
@@ -0,0 +1,11 @@
+ contract C {
+ function f() public returns (uint) {
+ uint8 x = 7;
+ uint16 y = 8;
+ uint32 z = 9;
+ uint32[3] memory ending = [x, y, z];
+ return (ending[1]);
+ }
+ }
+// ----
+// Warning: (25-229): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/270_inline_array_declaration_and_passing_implicit_conversion_strings.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/270_inline_array_declaration_and_passing_implicit_conversion_strings.sol
new file mode 100644
index 00000000..d7765d7b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/270_inline_array_declaration_and_passing_implicit_conversion_strings.sol
@@ -0,0 +1,10 @@
+contract C {
+ function f() public returns (string) {
+ string memory x = "Hello";
+ string memory y = "World";
+ string[2] memory z = [x, y];
+ return (z[0]);
+ }
+}
+// ----
+// Warning: (17-191): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/271_inline_array_declaration_const_int_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/271_inline_array_declaration_const_int_conversion.sol
new file mode 100644
index 00000000..e7036bdf
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/271_inline_array_declaration_const_int_conversion.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() public returns (uint) {
+ uint8[4] memory z = [1,2,3,5];
+ return (z[0]);
+ }
+}
+// ----
+// Warning: (17-121): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/272_inline_array_declaration_const_string_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/272_inline_array_declaration_const_string_conversion.sol
new file mode 100644
index 00000000..dd39af85
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/272_inline_array_declaration_const_string_conversion.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() public returns (string) {
+ string[2] memory z = ["Hello", "World"];
+ return (z[0]);
+ }
+}
+// ----
+// Warning: (17-133): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/273_inline_array_declaration_no_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/273_inline_array_declaration_no_type.sol
new file mode 100644
index 00000000..4d3e6aed
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/273_inline_array_declaration_no_type.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public returns (uint) {
+ return ([4,5,6][1]);
+ }
+}
+// ----
+// Warning: (17-88): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/274_inline_array_declaration_no_type_strings.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/274_inline_array_declaration_no_type_strings.sol
new file mode 100644
index 00000000..fbc028c5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/274_inline_array_declaration_no_type_strings.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public returns (string) {
+ return (["foo", "man", "choo"][1]);
+ }
+}
+// ----
+// Warning: (17-105): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/275_inline_struct_declaration_arrays.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/275_inline_struct_declaration_arrays.sol
new file mode 100644
index 00000000..e69c2934
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/275_inline_struct_declaration_arrays.sol
@@ -0,0 +1,13 @@
+contract C {
+ struct S {
+ uint a;
+ string b;
+ }
+ function f() {
+ S[2] memory x = [S({a: 1, b: "fish"}), S({a: 2, b: "fish"})];
+ }
+}
+// ----
+// Warning: (72-162): No visibility specified. Defaulting to "public".
+// Warning: (95-108): Unused local variable.
+// Warning: (72-162): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/276_invalid_types_in_inline_array.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/276_invalid_types_in_inline_array.sol
new file mode 100644
index 00000000..6c8aabd5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/276_invalid_types_in_inline_array.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() public {
+ uint[3] x = [45, 'foo', true];
+ }
+}
+// ----
+// Warning: (47-56): Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning.
+// TypeError: (59-76): Unable to deduce common type for array elements.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/277_dynamic_inline_array.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/277_dynamic_inline_array.sol
new file mode 100644
index 00000000..e613758b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/277_dynamic_inline_array.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() public {
+ uint8[4][4] memory dyn = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]];
+ }
+}
+// ----
+// Warning: (47-69): Unused local variable.
+// Warning: (17-135): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/278_lvalues_as_inline_array.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/278_lvalues_as_inline_array.sol
new file mode 100644
index 00000000..5a39f550
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/278_lvalues_as_inline_array.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() public {
+ [1, 2, 3]++;
+ [1, 2, 3] = [4, 5, 6];
+ }
+}
+// ----
+// TypeError: (47-56): Inline array type cannot be declared as LValue.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/279_break_not_in_loop.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/279_break_not_in_loop.sol
new file mode 100644
index 00000000..6b88da44
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/279_break_not_in_loop.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() public {
+ if (true)
+ break;
+ }
+}
+// ----
+// SyntaxError: (69-74): "break" has to be in a "for" or "while" loop.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/280_continue_not_in_loop.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/280_continue_not_in_loop.sol
new file mode 100644
index 00000000..b0e8cda9
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/280_continue_not_in_loop.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() public {
+ if (true)
+ continue;
+ }
+}
+// ----
+// SyntaxError: (69-77): "continue" has to be in a "for" or "while" loop.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/281_continue_not_in_loop_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/281_continue_not_in_loop_2.sol
new file mode 100644
index 00000000..845faf86
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/281_continue_not_in_loop_2.sol
@@ -0,0 +1,10 @@
+contract C {
+ function f() public {
+ while (true)
+ {
+ }
+ continue;
+ }
+}
+// ----
+// SyntaxError: (88-96): "continue" has to be in a "for" or "while" loop.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/282_invalid_different_types_for_conditional_expression.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/282_invalid_different_types_for_conditional_expression.sol
new file mode 100644
index 00000000..e4e75e3f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/282_invalid_different_types_for_conditional_expression.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public {
+ true ? true : 2;
+ }
+}
+// ----
+// TypeError: (47-62): True expression's type bool doesn't match false expression's type uint8.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/283_left_value_in_conditional_expression_not_supported_yet.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/283_left_value_in_conditional_expression_not_supported_yet.sol
new file mode 100644
index 00000000..ef8f9930
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/283_left_value_in_conditional_expression_not_supported_yet.sol
@@ -0,0 +1,10 @@
+contract C {
+ function f() public {
+ uint x;
+ uint y;
+ (true ? x : y) = 1;
+ }
+}
+// ----
+// TypeError: (80-92): Conditional expression as left value is not supported yet.
+// TypeError: (80-92): Expression has to be an lvalue.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/284_conditional_expression_with_different_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/284_conditional_expression_with_different_struct.sol
new file mode 100644
index 00000000..049d9e21
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/284_conditional_expression_with_different_struct.sol
@@ -0,0 +1,15 @@
+contract C {
+ struct s1 {
+ uint x;
+ }
+ struct s2 {
+ uint x;
+ }
+ function f() public {
+ s1 memory x;
+ s2 memory y;
+ true ? x : y;
+ }
+}
+// ----
+// TypeError: (165-177): True expression's type struct C.s1 memory doesn't match false expression's type struct C.s2 memory.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/285_conditional_expression_with_different_function_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/285_conditional_expression_with_different_function_type.sol
new file mode 100644
index 00000000..963fb7da
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/285_conditional_expression_with_different_function_type.sol
@@ -0,0 +1,10 @@
+contract C {
+ function x(bool) public {}
+ function y() public {}
+
+ function f() public {
+ true ? x : y;
+ }
+}
+// ----
+// TypeError: (106-118): True expression's type function (bool) doesn't match false expression's type function ().
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/286_conditional_expression_with_different_enum.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/286_conditional_expression_with_different_enum.sol
new file mode 100644
index 00000000..8c312624
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/286_conditional_expression_with_different_enum.sol
@@ -0,0 +1,13 @@
+contract C {
+ enum small { A, B, C, D }
+ enum big { A, B, C, D }
+
+ function f() public {
+ small x;
+ big y;
+
+ true ? x : y;
+ }
+}
+// ----
+// TypeError: (139-151): True expression's type enum C.small doesn't match false expression's type enum C.big.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/287_conditional_expression_with_different_mapping.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/287_conditional_expression_with_different_mapping.sol
new file mode 100644
index 00000000..8139f3ed
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/287_conditional_expression_with_different_mapping.sol
@@ -0,0 +1,10 @@
+contract C {
+ mapping(uint8 => uint8) table1;
+ mapping(uint32 => uint8) table2;
+
+ function f() public {
+ true ? table1 : table2;
+ }
+}
+// ----
+// TypeError: (121-143): True expression's type mapping(uint8 => uint8) doesn't match false expression's type mapping(uint32 => uint8).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/288_conditional_with_all_types.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/288_conditional_with_all_types.sol
new file mode 100644
index 00000000..41e72d60
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/288_conditional_with_all_types.sol
@@ -0,0 +1,91 @@
+contract C {
+ struct s1 {
+ uint x;
+ }
+ s1 struct_x;
+ s1 struct_y;
+
+ function fun_x() public {}
+ function fun_y() public {}
+
+ enum small { A, B, C, D }
+
+ mapping(uint8 => uint8) table1;
+ mapping(uint8 => uint8) table2;
+
+ function f() public {
+ // integers
+ uint x;
+ uint y;
+ uint g = true ? x : y;
+ g += 1; // Avoid unused var warning
+
+ // integer constants
+ uint h = true ? 1 : 3;
+ h += 1; // Avoid unused var warning
+
+ // string literal
+ string memory i = true ? "hello" : "world";
+ i = "used"; //Avoid unused var warning
+ }
+ function f2() public {
+ // bool
+ bool j = true ? true : false;
+ j = j && true; // Avoid unused var warning
+
+ // real is not there yet.
+
+ // array
+ byte[2] memory a;
+ byte[2] memory b;
+ byte[2] memory k = true ? a : b;
+ k[0] = byte(0); //Avoid unused var warning
+
+ bytes memory e;
+ bytes memory f;
+ bytes memory l = true ? e : f;
+ l[0] = byte(0); // Avoid unused var warning
+
+ // fixed bytes
+ bytes2 c;
+ bytes2 d;
+ bytes2 m = true ? c : d;
+ m &= m;
+
+ }
+ function f3() public {
+ // contract doesn't fit in here
+
+ // struct
+ struct_x = true ? struct_x : struct_y;
+
+ // function
+ function () r = true ? fun_x : fun_y;
+ r(); // Avoid unused var warning
+ // enum
+ small enum_x;
+ small enum_y;
+ enum_x = true ? enum_x : enum_y;
+
+ // tuple
+ (uint n, uint o) = true ? (1, 2) : (3, 4);
+ (n, o) = (o, n); // Avoid unused var warning
+ // mapping
+ mapping(uint8 => uint8) p = true ? table1 : table2;
+ p[0] = 0; // Avoid unused var warning
+ // typetype
+ uint32 q = true ? uint32(1) : uint32(2);
+ q += 1; // Avoid unused var warning
+ // modifier doesn't fit in here
+
+ // magic doesn't fit in here
+
+ // module doesn't fit in here
+ }
+}
+// ----
+// Warning: (1005-1019): This declaration shadows an existing declaration.
+// Warning: (90-116): Function state mutability can be restricted to pure
+// Warning: (121-147): Function state mutability can be restricted to pure
+// Warning: (257-642): Function state mutability can be restricted to pure
+// Warning: (647-1227): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/289_uint7_and_uintM_as_identifier.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/289_uint7_and_uintM_as_identifier.sol
new file mode 100644
index 00000000..58e84090
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/289_uint7_and_uintM_as_identifier.sol
@@ -0,0 +1,12 @@
+contract test {
+string uintM = "Hello 4 you";
+ function f() public {
+ uint8 uint7 = 3;
+ uint7 = 5;
+ string memory intM;
+ uint bytesM = 21;
+ intM; bytesM;
+ }
+}
+// ----
+// Warning: (50-197): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword.sol
new file mode 100644
index 00000000..1b6bbae7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword.sol
@@ -0,0 +1,11 @@
+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/291_modifier_is_not_a_valid_typename.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/291_modifier_is_not_a_valid_typename.sol
new file mode 100644
index 00000000..2f3143d5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/291_modifier_is_not_a_valid_typename.sol
@@ -0,0 +1,9 @@
+contract test {
+ modifier mod() { _; }
+
+ function f() public {
+ mod g;
+ }
+}
+// ----
+// TypeError: (77-80): Name has to refer to a struct, enum or contract.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/292_modifier_is_not_a_valid_typename_is_not_fatal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/292_modifier_is_not_a_valid_typename_is_not_fatal.sol
new file mode 100644
index 00000000..9187c19d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/292_modifier_is_not_a_valid_typename_is_not_fatal.sol
@@ -0,0 +1,10 @@
+contract test {
+ modifier mod() { _; }
+
+ function f() public {
+ mod g;
+ g = f;
+ }
+}
+// ----
+// TypeError: (77-80): Name has to refer to a struct, enum or contract.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/293_function_is_not_a_valid_typename.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/293_function_is_not_a_valid_typename.sol
new file mode 100644
index 00000000..390eccd9
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/293_function_is_not_a_valid_typename.sol
@@ -0,0 +1,10 @@
+contract test {
+ function foo() public {
+ }
+
+ function f() public {
+ foo g;
+ }
+}
+// ----
+// TypeError: (85-88): Name has to refer to a struct, enum or contract.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/294_long_uint_variable_fails.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/294_long_uint_variable_fails.sol
new file mode 100644
index 00000000..1e608320
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/294_long_uint_variable_fails.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ uint99999999999999999999999999 something = 3;
+ }
+}
+// ----
+// DeclarationError: (50-80): Identifier not found or not unique.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/295_bytes10abc_is_identifier.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/295_bytes10abc_is_identifier.sol
new file mode 100644
index 00000000..8b65fc65
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/295_bytes10abc_is_identifier.sol
@@ -0,0 +1,8 @@
+contract test {
+ function f() public {
+ bytes32 bytes10abc = "abc";
+ }
+}
+// ----
+// Warning: (50-68): Unused local variable.
+// Warning: (20-83): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/296_int10abc_is_identifier.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/296_int10abc_is_identifier.sol
new file mode 100644
index 00000000..2678cfb9
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/296_int10abc_is_identifier.sol
@@ -0,0 +1,9 @@
+contract test {
+ function f() public {
+ uint uint10abc = 3;
+ int int10abc = 4;
+ uint10abc; int10abc;
+ }
+}
+// ----
+// Warning: (20-130): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/297_library_functions_do_not_have_value.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/297_library_functions_do_not_have_value.sol
new file mode 100644
index 00000000..918544cc
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/297_library_functions_do_not_have_value.sol
@@ -0,0 +1,8 @@
+library L { function l() public {} }
+contract test {
+ function f() public {
+ L.l.value;
+ }
+}
+// ----
+// TypeError: (87-96): Member "value" not found or not visible after argument-dependent lookup in function () - did you forget the "payable" modifier?
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/298_invalid_fixed_types_0x7_mxn.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/298_invalid_fixed_types_0x7_mxn.sol
new file mode 100644
index 00000000..ea9e5d0f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/298_invalid_fixed_types_0x7_mxn.sol
@@ -0,0 +1,5 @@
+contract test {
+ fixed0x7 a = .3;
+}
+// ----
+// DeclarationError: (20-28): Identifier not found or not unique.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/299_invalid_fixed_types_long_invalid_identifier.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/299_invalid_fixed_types_long_invalid_identifier.sol
new file mode 100644
index 00000000..9ce2b106
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/299_invalid_fixed_types_long_invalid_identifier.sol
@@ -0,0 +1,5 @@
+contract test {
+ fixed99999999999999999999999999999999999999x7 b = 9.5;
+}
+// ----
+// DeclarationError: (20-65): Identifier not found or not unique.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/300_invalid_fixed_types_7x8_mxn.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/300_invalid_fixed_types_7x8_mxn.sol
new file mode 100644
index 00000000..7c511d2f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/300_invalid_fixed_types_7x8_mxn.sol
@@ -0,0 +1,5 @@
+contract test {
+ fixed7x8 c = 3.12345678;
+}
+// ----
+// DeclarationError: (20-28): Identifier not found or not unique.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/301_library_instances_cannot_be_used.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/301_library_instances_cannot_be_used.sol
new file mode 100644
index 00000000..82e4a0d1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/301_library_instances_cannot_be_used.sol
@@ -0,0 +1,9 @@
+library L { function l() public {} }
+contract test {
+ function f() public {
+ L x;
+ x.l();
+ }
+}
+// ----
+// TypeError: (100-103): Member "l" not found or not visible after argument-dependent lookup in library L
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/302_invalid_fixed_type_long.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/302_invalid_fixed_type_long.sol
new file mode 100644
index 00000000..12679631
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/302_invalid_fixed_type_long.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ fixed8x888888888888888888888888888888888888888888888888888 b;
+ }
+}
+// ----
+// DeclarationError: (50-108): Identifier not found or not unique.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/303_fixed_type_int_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/303_fixed_type_int_conversion.sol
new file mode 100644
index 00000000..ddf1e5fb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/303_fixed_type_int_conversion.sol
@@ -0,0 +1,11 @@
+contract test {
+ function f() public {
+ uint64 a = 3;
+ int64 b = 4;
+ fixed c = b;
+ ufixed d = a;
+ c; d;
+ }
+}
+// ----
+// Warning: (20-147): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/304_fixed_type_rational_int_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/304_fixed_type_rational_int_conversion.sol
new file mode 100644
index 00000000..16d2cbad
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/304_fixed_type_rational_int_conversion.sol
@@ -0,0 +1,9 @@
+contract test {
+ function f() public {
+ fixed c = 3;
+ ufixed d = 4;
+ c; d;
+ }
+}
+// ----
+// Warning: (20-104): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/305_fixed_type_rational_fraction_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/305_fixed_type_rational_fraction_conversion.sol
new file mode 100644
index 00000000..27029860
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/305_fixed_type_rational_fraction_conversion.sol
@@ -0,0 +1,9 @@
+contract test {
+ function f() public {
+ fixed a = 4.5;
+ ufixed d = 2.5;
+ a; d;
+ }
+}
+// ----
+// Warning: (20-108): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/306_invalid_int_implicit_conversion_from_fixed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/306_invalid_int_implicit_conversion_from_fixed.sol
new file mode 100644
index 00000000..c0a56314
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/306_invalid_int_implicit_conversion_from_fixed.sol
@@ -0,0 +1,9 @@
+contract test {
+ function f() public {
+ fixed a = 4.5;
+ int b = a;
+ a; b;
+ }
+}
+// ----
+// TypeError: (73-82): Type fixed128x18 is not implicitly convertible to expected type int256.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/307_rational_unary_minus_operation.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/307_rational_unary_minus_operation.sol
new file mode 100644
index 00000000..7827e57b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/307_rational_unary_minus_operation.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() pure public {
+ ufixed16x2 a = 3.25;
+ fixed16x2 b = -3.25;
+ a; b;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/308_rational_unary_plus_operation.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/308_rational_unary_plus_operation.sol
new file mode 100644
index 00000000..eb7c6ea9
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/308_rational_unary_plus_operation.sol
@@ -0,0 +1,9 @@
+contract test {
+ function f() pure public {
+ ufixed16x2 a = +3.25;
+ fixed16x2 b = -3.25;
+ a; b;
+ }
+}
+// ----
+// Warning: (70-75): Use of unary + is deprecated.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/309_rational_unary_plus_assignment.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/309_rational_unary_plus_assignment.sol
new file mode 100644
index 00000000..a5bdd6c8
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/309_rational_unary_plus_assignment.sol
@@ -0,0 +1,8 @@
+contract test {
+ function f(uint x) pure public {
+ uint y = +x;
+ y;
+ }
+}
+// ----
+// Warning: (70-72): Use of unary + is deprecated.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/310_rational_unary_plus_operation_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/310_rational_unary_plus_operation_v050.sol
new file mode 100644
index 00000000..140655af
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/310_rational_unary_plus_operation_v050.sol
@@ -0,0 +1,10 @@
+pragma experimental "v0.5.0";
+contract test {
+ function f() pure public {
+ ufixed16x2 a = +3.25;
+ fixed16x2 b = -3.25;
+ a; b;
+ }
+}
+// ----
+// SyntaxError: (100-105): Use of unary + is deprecated.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/311_rational_unary_plus_assignment_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/311_rational_unary_plus_assignment_v050.sol
new file mode 100644
index 00000000..7e5c0feb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/311_rational_unary_plus_assignment_v050.sol
@@ -0,0 +1,9 @@
+pragma experimental "v0.5.0";
+contract test {
+ function f(uint x) pure public {
+ uint y = +x;
+ y;
+ }
+}
+// ----
+// SyntaxError: (100-102): Use of unary + is deprecated.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/312_leading_zero_rationals_convert.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/312_leading_zero_rationals_convert.sol
new file mode 100644
index 00000000..9fe7c6f7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/312_leading_zero_rationals_convert.sol
@@ -0,0 +1,9 @@
+contract A {
+ function f() pure public {
+ ufixed16x2 a = 0.5;
+ ufixed256x52 b = 0.0000000000000006661338147750939242541790008544921875;
+ fixed16x2 c = -0.5;
+ fixed256x52 d = -0.0000000000000006661338147750939242541790008544921875;
+ a; b; c; d;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/313_fixed_type_size_capabilities.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/313_fixed_type_size_capabilities.sol
new file mode 100644
index 00000000..441cf81e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/313_fixed_type_size_capabilities.sol
@@ -0,0 +1,13 @@
+contract test {
+ function f() public {
+ ufixed256x1 a = 123456781234567979695948382928485849359686494864095409282048094275023098123.5;
+ ufixed256x77 b = 0.920890746623327805482905058466021565416131529487595827354393978494366605267637;
+ ufixed224x78 c = 0.000000000001519884736399797998492268541131529487595827354393978494366605267646;
+ fixed256x1 d = -123456781234567979695948382928485849359686494864095409282048094275023098123.5;
+ fixed256x76 e = -0.93322335481643744342575580035176794825198893968114429702091846411734101080123;
+ fixed256x79 g = -0.0001178860664374434257558003517679482519889396811442970209184641173410108012309;
+ a; b; c; d; e; g;
+ }
+}
+// ----
+// Warning: (20-707): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/314_fixed_type_zero_handling.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/314_fixed_type_zero_handling.sol
new file mode 100644
index 00000000..5f0d2909
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/314_fixed_type_zero_handling.sol
@@ -0,0 +1,8 @@
+contract test {
+ function f() public {
+ fixed16x2 a = 0; a;
+ ufixed32x1 b = 0; b;
+ }
+}
+// ----
+// Warning: (20-104): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/315_fixed_type_invalid_implicit_conversion_size.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/315_fixed_type_invalid_implicit_conversion_size.sol
new file mode 100644
index 00000000..79698228
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/315_fixed_type_invalid_implicit_conversion_size.sol
@@ -0,0 +1,8 @@
+contract test {
+ function f() public {
+ ufixed a = 11/4;
+ ufixed248x8 b = a; b;
+ }
+}
+// ----
+// TypeError: (75-92): Type ufixed128x18 is not implicitly convertible to expected type ufixed248x8.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/316_fixed_type_invalid_implicit_conversion_lost_data.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/316_fixed_type_invalid_implicit_conversion_lost_data.sol
new file mode 100644
index 00000000..76c0284e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/316_fixed_type_invalid_implicit_conversion_lost_data.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ ufixed256x1 a = 1/3; a;
+ }
+}
+// ----
+// TypeError: (50-69): Type rational_const 1 / 3 is not implicitly convertible to expected type ufixed256x1. Try converting to type ufixed256x77 or use an explicit conversion.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/317_fixed_type_valid_explicit_conversions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/317_fixed_type_valid_explicit_conversions.sol
new file mode 100644
index 00000000..38801457
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/317_fixed_type_valid_explicit_conversions.sol
@@ -0,0 +1,9 @@
+contract test {
+ function f() public {
+ ufixed256x80 a = ufixed256x80(1/3); a;
+ ufixed248x80 b = ufixed248x80(1/3); b;
+ ufixed8x1 c = ufixed8x1(1/3); c;
+ }
+}
+// ----
+// Warning: (20-182): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/318_invalid_array_declaration_with_rational.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/318_invalid_array_declaration_with_rational.sol
new file mode 100644
index 00000000..3dd779ec
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/318_invalid_array_declaration_with_rational.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ uint[3.5] a; a;
+ }
+}
+// ----
+// TypeError: (55-58): Array with fractional length specified.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/319_invalid_array_declaration_with_signed_fixed_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/319_invalid_array_declaration_with_signed_fixed_type.sol
new file mode 100644
index 00000000..83f0950d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/319_invalid_array_declaration_with_signed_fixed_type.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ uint[fixed(3.5)] a; a;
+ }
+}
+// ----
+// TypeError: (55-65): Invalid array length, expected integer literal or constant expression.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/320_invalid_array_declaration_with_unsigned_fixed_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/320_invalid_array_declaration_with_unsigned_fixed_type.sol
new file mode 100644
index 00000000..26d5a85e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/320_invalid_array_declaration_with_unsigned_fixed_type.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ uint[ufixed(3.5)] a; a;
+ }
+}
+// ----
+// TypeError: (55-66): Invalid array length, expected integer literal or constant expression.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/321_rational_to_bytes_implicit_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/321_rational_to_bytes_implicit_conversion.sol
new file mode 100644
index 00000000..d209eb76
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/321_rational_to_bytes_implicit_conversion.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ bytes32 c = 3.2; c;
+ }
+}
+// ----
+// TypeError: (50-65): Type rational_const 16 / 5 is not implicitly convertible to expected type bytes32. Try converting to type ufixed8x1 or use an explicit conversion.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/322_fixed_to_bytes_implicit_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/322_fixed_to_bytes_implicit_conversion.sol
new file mode 100644
index 00000000..86736481
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/322_fixed_to_bytes_implicit_conversion.sol
@@ -0,0 +1,8 @@
+contract test {
+ function f() public {
+ fixed a = 3.25;
+ bytes32 c = a; c;
+ }
+}
+// ----
+// TypeError: (74-87): Type fixed128x18 is not implicitly convertible to expected type bytes32.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/323_mapping_with_fixed_literal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/323_mapping_with_fixed_literal.sol
new file mode 100644
index 00000000..8e28d4e1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/323_mapping_with_fixed_literal.sol
@@ -0,0 +1,6 @@
+contract test {
+ mapping(ufixed8x1 => string) fixedString;
+ function f() public {
+ fixedString[0.5] = "Half";
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/324_fixed_points_inside_structs.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/324_fixed_points_inside_structs.sol
new file mode 100644
index 00000000..8aa0abc2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/324_fixed_points_inside_structs.sol
@@ -0,0 +1,7 @@
+contract test {
+ struct myStruct {
+ ufixed a;
+ int b;
+ }
+ myStruct a = myStruct(3.125, 3);
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/325_inline_array_fixed_types.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/325_inline_array_fixed_types.sol
new file mode 100644
index 00000000..c46297c3
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/325_inline_array_fixed_types.sol
@@ -0,0 +1,8 @@
+contract test {
+ function f() public {
+ fixed[3] memory a = [fixed(3.5), fixed(-4.25), fixed(967.125)];
+ }
+}
+// ----
+// Warning: (50-67): Unused local variable.
+// Warning: (20-119): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/326_inline_array_rationals.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/326_inline_array_rationals.sol
new file mode 100644
index 00000000..bdc3c2c1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/326_inline_array_rationals.sol
@@ -0,0 +1,8 @@
+contract test {
+ function f() public {
+ ufixed128x3[4] memory a = [ufixed128x3(3.5), 4.125, 2.5, 4.0];
+ }
+}
+// ----
+// Warning: (50-73): Unused local variable.
+// Warning: (20-118): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/327_rational_index_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/327_rational_index_access.sol
new file mode 100644
index 00000000..46e58521
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/327_rational_index_access.sol
@@ -0,0 +1,8 @@
+contract test {
+ function f() public {
+ uint[] memory a;
+ a[.5];
+ }
+}
+// ----
+// TypeError: (77-79): Type rational_const 1 / 2 is not implicitly convertible to expected type uint256. Try converting to type ufixed8x1 or use an explicit conversion.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/328_rational_to_fixed_literal_expression.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/328_rational_to_fixed_literal_expression.sol
new file mode 100644
index 00000000..35456fa6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/328_rational_to_fixed_literal_expression.sol
@@ -0,0 +1,15 @@
+contract test {
+ function f() public {
+ ufixed64x8 a = 3.5 * 3;
+ ufixed64x8 b = 4 - 2.5;
+ ufixed64x8 c = 11 / 4;
+ ufixed240x5 d = 599 + 0.21875;
+ ufixed256x80 e = ufixed256x80(35.245 % 12.9);
+ ufixed256x80 f = ufixed256x80(1.2 % 2);
+ fixed g = 2 ** -2;
+ a; b; c; d; e; f; g;
+ }
+}
+// ----
+// Warning: (238-252): This declaration shadows an existing declaration.
+// Warning: (20-339): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/329_rational_as_exponent_value_signed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/329_rational_as_exponent_value_signed.sol
new file mode 100644
index 00000000..b835e309
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/329_rational_as_exponent_value_signed.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ fixed g = 2 ** -2.2;
+ }
+}
+// ----
+// TypeError: (60-69): Operator ** not compatible with types int_const 2 and rational_const -11 / 5
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/330_rational_as_exponent_value_unsigned.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/330_rational_as_exponent_value_unsigned.sol
new file mode 100644
index 00000000..04ddf0fd
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/330_rational_as_exponent_value_unsigned.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ ufixed b = 3 ** 2.5;
+ }
+}
+// ----
+// TypeError: (61-69): Operator ** not compatible with types int_const 3 and rational_const 5 / 2
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/331_rational_as_exponent_half.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/331_rational_as_exponent_half.sol
new file mode 100644
index 00000000..4e0894c5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/331_rational_as_exponent_half.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ 2 ** (1/2);
+ }
+}
+// ----
+// TypeError: (50-60): Operator ** not compatible with types int_const 2 and rational_const 1 / 2
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/332_rational_as_exponent_value_neg_quarter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/332_rational_as_exponent_value_neg_quarter.sol
new file mode 100644
index 00000000..bc127bf5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/332_rational_as_exponent_value_neg_quarter.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ 42 ** (-1/4);
+ }
+}
+// ----
+// TypeError: (50-62): Operator ** not compatible with types int_const 42 and rational_const -1 / 4
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/333_fixed_point_casting_exponents_15.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/333_fixed_point_casting_exponents_15.sol
new file mode 100644
index 00000000..0fd5f331
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/333_fixed_point_casting_exponents_15.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ ufixed a = 3 ** ufixed(1.5);
+ }
+}
+// ----
+// TypeError: (61-77): Operator ** not compatible with types int_const 3 and ufixed128x18
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/334_fixed_point_casting_exponents_neg.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/334_fixed_point_casting_exponents_neg.sol
new file mode 100644
index 00000000..03d10f7c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/334_fixed_point_casting_exponents_neg.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ ufixed c = 42 ** fixed(-1/4);
+ }
+}
+// ----
+// TypeError: (61-78): Operator ** not compatible with types int_const 42 and fixed128x18
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/338_rational_bitnot_unary_operation.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/338_rational_bitnot_unary_operation.sol
new file mode 100644
index 00000000..44a6ab5e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/338_rational_bitnot_unary_operation.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ ~fixed(3.5);
+ }
+}
+// ----
+// TypeError: (50-61): Unary operator ~ cannot be applied to type fixed128x18
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/339_rational_bitor_binary_operation.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/339_rational_bitor_binary_operation.sol
new file mode 100644
index 00000000..29871b04
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/339_rational_bitor_binary_operation.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ fixed(1.5) | 3;
+ }
+}
+// ----
+// TypeError: (50-64): Operator | not compatible with types fixed128x18 and int_const 3
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/340_rational_bitxor_binary_operation.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/340_rational_bitxor_binary_operation.sol
new file mode 100644
index 00000000..1fa7f38f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/340_rational_bitxor_binary_operation.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ fixed(1.75) ^ 3;
+ }
+}
+// ----
+// TypeError: (50-65): Operator ^ not compatible with types fixed128x18 and int_const 3
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/341_rational_bitand_binary_operation.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/341_rational_bitand_binary_operation.sol
new file mode 100644
index 00000000..5a433a61
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/341_rational_bitand_binary_operation.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ fixed(1.75) & 3;
+ }
+}
+// ----
+// TypeError: (50-65): Operator & not compatible with types fixed128x18 and int_const 3
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/342_missing_bool_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/342_missing_bool_conversion.sol
new file mode 100644
index 00000000..5546a099
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/342_missing_bool_conversion.sol
@@ -0,0 +1,7 @@
+contract test {
+ function b(uint a) public {
+ bool(a == 1);
+ }
+}
+// ----
+// Warning: (20-75): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/343_integer_and_fixed_interaction.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/343_integer_and_fixed_interaction.sol
new file mode 100644
index 00000000..af4d048b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/343_integer_and_fixed_interaction.sol
@@ -0,0 +1,8 @@
+contract test {
+ function f() public {
+ ufixed a = uint64(1) + ufixed(2);
+ }
+}
+// ----
+// Warning: (50-58): Unused local variable.
+// Warning: (20-89): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/344_one_divided_by_three_integer_conversion.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/344_one_divided_by_three_integer_conversion.sol
new file mode 100644
index 00000000..ffc168eb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/344_one_divided_by_three_integer_conversion.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ uint a = 1/3;
+ }
+}
+// ----
+// TypeError: (50-62): Type rational_const 1 / 3 is not implicitly convertible to expected type uint256. Try converting to type ufixed256x77 or use an explicit conversion.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/345_unused_return_value.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/345_unused_return_value.sol
new file mode 100644
index 00000000..7f640505
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/345_unused_return_value.sol
@@ -0,0 +1,8 @@
+contract test {
+ function g() public returns (uint) {}
+ function f() public {
+ g();
+ }
+}
+// ----
+// Warning: (20-57): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/346_unused_return_value_send.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/346_unused_return_value_send.sol
new file mode 100644
index 00000000..929e54b2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/346_unused_return_value_send.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ address(0x12).send(1);
+ }
+}
+// ----
+// Warning: (50-71): Failure condition of 'send' ignored. Consider using 'transfer' instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/347_unused_return_value_call.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/347_unused_return_value_call.sol
new file mode 100644
index 00000000..994a5bdf
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/347_unused_return_value_call.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ address(0x12).call("abc");
+ }
+}
+// ----
+// Warning: (50-75): Return value of low-level calls not used.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/348_unused_return_value_call_value.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/348_unused_return_value_call_value.sol
new file mode 100644
index 00000000..1ac7c6f3
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/348_unused_return_value_call_value.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ address(0x12).call.value(2)("abc");
+ }
+}
+// ----
+// Warning: (50-84): Return value of low-level calls not used.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/350_unused_return_value_delegatecall.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/350_unused_return_value_delegatecall.sol
new file mode 100644
index 00000000..701b6e7d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/350_unused_return_value_delegatecall.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ address(0x12).delegatecall("abc");
+ }
+}
+// ----
+// Warning: (50-83): Return value of low-level calls not used.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/351_callcode_deprecated.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/351_callcode_deprecated.sol
new file mode 100644
index 00000000..554f2e11
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/351_callcode_deprecated.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() pure public {
+ address(0x12).callcode;
+ }
+}
+// ----
+// TypeError: (55-77): "callcode" has been deprecated in favour of "delegatecall".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/352_callcode_deprecated_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/352_callcode_deprecated_v050.sol
new file mode 100644
index 00000000..c0e29b38
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/352_callcode_deprecated_v050.sol
@@ -0,0 +1,8 @@
+pragma experimental "v0.5.0";
+contract test {
+ function f() pure public {
+ address(0x12).callcode;
+ }
+}
+// ----
+// TypeError: (85-107): "callcode" has been deprecated in favour of "delegatecall".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/353_callcode_not_deprecated_as_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/353_callcode_not_deprecated_as_function.sol
new file mode 100644
index 00000000..714014f8
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/353_callcode_not_deprecated_as_function.sol
@@ -0,0 +1,5 @@
+contract test {
+ function callcode() pure public {
+ test.callcode();
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/354_payable_in_library.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/354_payable_in_library.sol
new file mode 100644
index 00000000..410842cb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/354_payable_in_library.sol
@@ -0,0 +1,5 @@
+library test {
+ function f() payable public {}
+}
+// ----
+// TypeError: (19-49): Library functions cannot be payable.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/355_payable_external.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/355_payable_external.sol
new file mode 100644
index 00000000..3b75e1b7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/355_payable_external.sol
@@ -0,0 +1,3 @@
+contract test {
+ function f() payable external {}
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/356_payable_internal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/356_payable_internal.sol
new file mode 100644
index 00000000..f6ccf6b6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/356_payable_internal.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f() payable internal {}
+}
+// ----
+// TypeError: (20-52): Internal functions cannot be payable.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/357_payable_private.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/357_payable_private.sol
new file mode 100644
index 00000000..7b00ea6c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/357_payable_private.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f() payable private {}
+}
+// ----
+// TypeError: (20-51): Internal functions cannot be payable.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/358_illegal_override_payable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/358_illegal_override_payable.sol
new file mode 100644
index 00000000..6696772e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/358_illegal_override_payable.sol
@@ -0,0 +1,4 @@
+contract B { function f() payable public {} }
+contract C is B { function f() public {} }
+// ----
+// TypeError: (64-86): Overriding function changes state mutability from "payable" to "nonpayable".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/359_illegal_override_payable_nonpayable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/359_illegal_override_payable_nonpayable.sol
new file mode 100644
index 00000000..99b45fdd
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/359_illegal_override_payable_nonpayable.sol
@@ -0,0 +1,4 @@
+contract B { function f() public {} }
+contract C is B { function f() payable public {} }
+// ----
+// TypeError: (56-86): Overriding function changes state mutability from "nonpayable" to "payable".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/360_function_variable_mixin.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/360_function_variable_mixin.sol
new file mode 100644
index 00000000..583e0d46
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/360_function_variable_mixin.sol
@@ -0,0 +1,12 @@
+// bug #1798 (cpp-ethereum), related to #1286 (solidity)
+contract attribute {
+ bool ok = false;
+}
+contract func {
+ function ok() public returns (bool) { return true; }
+}
+contract attr_func is attribute, func {
+ function checkOk() public returns (bool) { return ok(); }
+}
+// ----
+// DeclarationError: (121-173): Identifier already declared.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/361_calling_payable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/361_calling_payable.sol
new file mode 100644
index 00000000..8ef4d579
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/361_calling_payable.sol
@@ -0,0 +1,6 @@
+contract receiver { function pay() payable public {} }
+contract test {
+ function f() public { (new receiver()).pay.value(10)(); }
+ receiver r = new receiver();
+ function g() public { r.pay.value(10)(); }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/362_calling_nonpayable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/362_calling_nonpayable.sol
new file mode 100644
index 00000000..d47ea2bd
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/362_calling_nonpayable.sol
@@ -0,0 +1,6 @@
+contract receiver { function nopay() public {} }
+contract test {
+ function f() public { (new receiver()).nopay.value(10)(); }
+}
+// ----
+// TypeError: (91-119): Member "value" not found or not visible after argument-dependent lookup in function () external - did you forget the "payable" modifier?
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/363_non_payable_constructor.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/363_non_payable_constructor.sol
new file mode 100644
index 00000000..5a6b7b11
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/363_non_payable_constructor.sol
@@ -0,0 +1,12 @@
+contract C {
+ function C() { }
+}
+contract D {
+ function f() public returns (uint) {
+ (new C).value(2)();
+ return 2;
+ }
+}
+// ----
+// Warning: (17-33): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
+// TypeError: (98-111): Member "value" not found or not visible after argument-dependent lookup in function () returns (contract C) - did you forget the "payable" modifier?
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/366_invalid_array_as_statement.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/366_invalid_array_as_statement.sol
new file mode 100644
index 00000000..150ba9ca
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/366_invalid_array_as_statement.sol
@@ -0,0 +1,7 @@
+contract test {
+ struct S { uint x; }
+ function test(uint k) public { S[k]; }
+}
+// ----
+// Warning: (45-83): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
+// TypeError: (78-79): Integer constant expected.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/367_using_directive_for_missing_selftype.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/367_using_directive_for_missing_selftype.sol
new file mode 100644
index 00000000..415acb3c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/367_using_directive_for_missing_selftype.sol
@@ -0,0 +1,14 @@
+library B {
+ function b() public {}
+}
+
+contract A {
+ using B for bytes;
+
+ function a() public {
+ bytes memory x;
+ x.b();
+ }
+}
+// ----
+// TypeError: (137-140): Member "b" not found or not visible after argument-dependent lookup in bytes memory
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/368_shift_constant_left_negative_rvalue.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/368_shift_constant_left_negative_rvalue.sol
new file mode 100644
index 00000000..9c941a68
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/368_shift_constant_left_negative_rvalue.sol
@@ -0,0 +1,5 @@
+contract C {
+ uint public a = 0x42 << -8;
+}
+// ----
+// TypeError: (33-43): Operator << not compatible with types int_const 66 and int_const -8
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/369_shift_constant_right_negative_rvalue.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/369_shift_constant_right_negative_rvalue.sol
new file mode 100644
index 00000000..55f385c6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/369_shift_constant_right_negative_rvalue.sol
@@ -0,0 +1,5 @@
+contract C {
+ uint public a = 0x42 >> -8;
+}
+// ----
+// TypeError: (33-43): Operator >> not compatible with types int_const 66 and int_const -8
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/370_shift_constant_left_excessive_rvalue.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/370_shift_constant_left_excessive_rvalue.sol
new file mode 100644
index 00000000..e23c7a84
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/370_shift_constant_left_excessive_rvalue.sol
@@ -0,0 +1,5 @@
+contract C {
+ uint public a = 0x42 << 0x100000000;
+}
+// ----
+// TypeError: (33-52): Operator << not compatible with types int_const 66 and int_const 4294967296
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/371_shift_constant_right_excessive_rvalue.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/371_shift_constant_right_excessive_rvalue.sol
new file mode 100644
index 00000000..5533644f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/371_shift_constant_right_excessive_rvalue.sol
@@ -0,0 +1,5 @@
+contract C {
+ uint public a = 0x42 >> 0x100000000;
+}
+// ----
+// TypeError: (33-52): Operator >> not compatible with types int_const 66 and int_const 4294967296
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/372_shift_constant_right_fractional.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/372_shift_constant_right_fractional.sol
new file mode 100644
index 00000000..38d9b051
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/372_shift_constant_right_fractional.sol
@@ -0,0 +1,5 @@
+contract C {
+ uint public a = 0x42 >> (1 / 2);
+}
+// ----
+// TypeError: (33-48): Operator >> not compatible with types int_const 66 and rational_const 1 / 2
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
new file mode 100644
index 00000000..273e1844
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol
@@ -0,0 +1,10 @@
+contract test {
+ function f() public {
+ assembly {
+ 1
+ }
+ }
+}
+// ----
+// Warning: (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
new file mode 100644
index 00000000..bda090b4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol
@@ -0,0 +1,10 @@
+contract test {
+ function f() public {
+ assembly {
+ pop
+ }
+ }
+}
+// ----
+// Warning: (73-76): The use of non-functional instructions is deprecated. 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/375_inline_assembly_unbalanced_two_stack_load.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/375_inline_assembly_unbalanced_two_stack_load.sol
new file mode 100644
index 00000000..4cda64e7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/375_inline_assembly_unbalanced_two_stack_load.sol
@@ -0,0 +1,9 @@
+pragma experimental "v0.5.0";
+contract c {
+ uint8 x;
+ function f() public {
+ assembly { pop(x) }
+ }
+}
+// ----
+// TypeError: (105-106): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/376_inline_assembly_in_modifier.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/376_inline_assembly_in_modifier.sol
new file mode 100644
index 00000000..d6dcc4d0
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/376_inline_assembly_in_modifier.sol
@@ -0,0 +1,14 @@
+pragma experimental "v0.5.0";
+contract test {
+ modifier m {
+ uint a = 1;
+ assembly {
+ a := 2
+ }
+ _;
+ }
+ function f() public m {
+ }
+}
+// ----
+// Warning: (152-181): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/377_inline_assembly_storage.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/377_inline_assembly_storage.sol
new file mode 100644
index 00000000..9a2065e2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/377_inline_assembly_storage.sol
@@ -0,0 +1,11 @@
+pragma experimental "v0.5.0";
+contract test {
+ uint x = 1;
+ function f() public {
+ assembly {
+ x := 2
+ }
+ }
+}
+// ----
+// TypeError: (119-120): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/378_inline_assembly_storage_in_modifiers.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/378_inline_assembly_storage_in_modifiers.sol
new file mode 100644
index 00000000..b99179ef
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/378_inline_assembly_storage_in_modifiers.sol
@@ -0,0 +1,14 @@
+pragma experimental "v0.5.0";
+contract test {
+ uint x = 1;
+ modifier m {
+ assembly {
+ x := 2
+ }
+ _;
+ }
+ function f() public m {
+ }
+}
+// ----
+// TypeError: (110-111): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/379_inline_assembly_constant_assign.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/379_inline_assembly_constant_assign.sol
new file mode 100644
index 00000000..866232dd
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/379_inline_assembly_constant_assign.sol
@@ -0,0 +1,11 @@
+pragma experimental "v0.5.0";
+contract test {
+ uint constant x = 1;
+ function f() public {
+ assembly {
+ x := 2
+ }
+ }
+}
+// ----
+// TypeError: (128-129): Constant variables not supported by inline assembly.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/380_inline_assembly_constant_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/380_inline_assembly_constant_access.sol
new file mode 100644
index 00000000..a41858a0
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/380_inline_assembly_constant_access.sol
@@ -0,0 +1,11 @@
+pragma experimental "v0.5.0";
+contract test {
+ uint constant x = 1;
+ function f() public {
+ assembly {
+ let y := x
+ }
+ }
+}
+// ----
+// TypeError: (137-138): Constant variables not supported by inline assembly.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/381_inline_assembly_local_variable_access_out_of_functions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/381_inline_assembly_local_variable_access_out_of_functions.sol
new file mode 100644
index 00000000..93004ef6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/381_inline_assembly_local_variable_access_out_of_functions.sol
@@ -0,0 +1,11 @@
+pragma experimental "v0.5.0";
+contract test {
+ function f() public {
+ uint a;
+ assembly {
+ function g() -> x { x := a }
+ }
+ }
+}
+// ----
+// DeclarationError: (144-145): Cannot access local Solidity variables from inside an inline assembly function.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/382_inline_assembly_local_variable_access_out_of_functions_storage_ptr.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/382_inline_assembly_local_variable_access_out_of_functions_storage_ptr.sol
new file mode 100644
index 00000000..913ea725
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/382_inline_assembly_local_variable_access_out_of_functions_storage_ptr.sol
@@ -0,0 +1,12 @@
+pragma experimental "v0.5.0";
+contract test {
+ uint[] r;
+ function f() public {
+ uint[] storage a = r;
+ assembly {
+ function g() -> x { x := a_offset }
+ }
+ }
+}
+// ----
+// DeclarationError: (172-180): Cannot access local Solidity variables from inside an inline assembly function.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/383_inline_assembly_storage_variable_access_out_of_functions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/383_inline_assembly_storage_variable_access_out_of_functions.sol
new file mode 100644
index 00000000..7528f355
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/383_inline_assembly_storage_variable_access_out_of_functions.sol
@@ -0,0 +1,9 @@
+pragma experimental "v0.5.0";
+contract test {
+ uint a;
+ function f() pure public {
+ assembly {
+ function g() -> x { x := a_slot }
+ }
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/384_inline_assembly_constant_variable_via_offset.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/384_inline_assembly_constant_variable_via_offset.sol
new file mode 100644
index 00000000..6470a210
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/384_inline_assembly_constant_variable_via_offset.sol
@@ -0,0 +1,10 @@
+contract test {
+ uint constant x = 2;
+ function f() pure public {
+ assembly {
+ let r := x_offset
+ }
+ }
+}
+// ----
+// TypeError: (112-120): Constant variables not supported by inline assembly.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/385_inline_assembly_calldata_variables.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/385_inline_assembly_calldata_variables.sol
new file mode 100644
index 00000000..d95fd978
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/385_inline_assembly_calldata_variables.sol
@@ -0,0 +1,10 @@
+pragma experimental "v0.5.0";
+contract C {
+ function f(bytes bytesAsCalldata) external {
+ assembly {
+ let x := bytesAsCalldata
+ }
+ }
+}
+// ----
+// TypeError: (132-147): Call data elements cannot be accessed directly. Copy to a local variable first or use "calldataload" or "calldatacopy" with manually determined offsets and sizes.
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
new file mode 100644
index 00000000..a5f0f96c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol
@@ -0,0 +1,11 @@
+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
new file mode 100644
index 00000000..7b68c60b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol
@@ -0,0 +1,10 @@
+contract C {
+ function f() pure public {
+ assembly {
+ 1
+ }
+ }
+}
+// ----
+// Warning: (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
new file mode 100644
index 00000000..4a7aca8a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol
@@ -0,0 +1,12 @@
+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
new file mode 100644
index 00000000..c44412cf
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol
@@ -0,0 +1,11 @@
+contract C {
+ function f() view public {
+ assembly {
+ address
+ pop
+ }
+ }
+}
+// ----
+// 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.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol
new file mode 100644
index 00000000..77a73ebc
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol
@@ -0,0 +1,11 @@
+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
new file mode 100644
index 00000000..15bd6660
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol
@@ -0,0 +1,10 @@
+contract C {
+ function f() pure public {
+ assembly {
+ label:
+ }
+ }
+}
+// ----
+// 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.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/392_inline_assembly_050_jump.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/392_inline_assembly_050_jump.sol
new file mode 100644
index 00000000..0c98ada1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/392_inline_assembly_050_jump.sol
@@ -0,0 +1,10 @@
+pragma experimental "v0.5.0";
+contract C {
+ function f() pure public {
+ assembly {
+ jump(2)
+ }
+ }
+}
+// ----
+// SyntaxError: (105-112): 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
new file mode 100644
index 00000000..c3c82ce8
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol
@@ -0,0 +1,10 @@
+contract C {
+ function f() pure public {
+ assembly {
+ jump(2)
+ }
+ }
+}
+// ----
+// 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.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/394_inline_assembly_050_leave_items_on_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/394_inline_assembly_050_leave_items_on_stack.sol
new file mode 100644
index 00000000..f72fe741
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/394_inline_assembly_050_leave_items_on_stack.sol
@@ -0,0 +1,11 @@
+pragma experimental "v0.5.0";
+contract C {
+ function f() pure public {
+ assembly {
+ mload(0)
+ }
+ }
+}
+// ----
+// SyntaxError: (105-113): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
+// DeclarationError: (91-123): Unbalanced stack at the end of a block: 1 surplus item(s).
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
new file mode 100644
index 00000000..56043ccf
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol
@@ -0,0 +1,10 @@
+contract C {
+ function f() pure public {
+ assembly {
+ mload(0)
+ }
+ }
+}
+// ----
+// Warning: (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/396_invalid_mobile_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/396_invalid_mobile_type.sol
new file mode 100644
index 00000000..536dd317
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/396_invalid_mobile_type.sol
@@ -0,0 +1,8 @@
+ contract C {
+ function f() public {
+ // Invalid number
+ [1, 78901234567890123456789012345678901234567890123456789345678901234567890012345678012345678901234567];
+ }
+ }
+// ----
+// TypeError: (93-191): Invalid rational number.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/397_warns_msg_value_in_non_payable_public_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/397_warns_msg_value_in_non_payable_public_function.sol
new file mode 100644
index 00000000..4e1f62e1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/397_warns_msg_value_in_non_payable_public_function.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() view public {
+ msg.value;
+ }
+}
+// ----
+// Warning: (52-61): "msg.value" used in non-payable function. Do you want to add the "payable" modifier to this function?
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/398_does_not_warn_msg_value_in_payable_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/398_does_not_warn_msg_value_in_payable_function.sol
new file mode 100644
index 00000000..f14e86ed
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/398_does_not_warn_msg_value_in_payable_function.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f() payable public {
+ msg.value;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/399_does_not_warn_msg_value_in_internal_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/399_does_not_warn_msg_value_in_internal_function.sol
new file mode 100644
index 00000000..8492e691
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/399_does_not_warn_msg_value_in_internal_function.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f() view internal {
+ msg.value;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/400_does_not_warn_msg_value_in_library.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/400_does_not_warn_msg_value_in_library.sol
new file mode 100644
index 00000000..ce59047e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/400_does_not_warn_msg_value_in_library.sol
@@ -0,0 +1,5 @@
+library C {
+ function f() view public {
+ msg.value;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/401_does_not_warn_msg_value_in_modifier_following_non_payable_public_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/401_does_not_warn_msg_value_in_modifier_following_non_payable_public_function.sol
new file mode 100644
index 00000000..dc1da7c4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/401_does_not_warn_msg_value_in_modifier_following_non_payable_public_function.sol
@@ -0,0 +1,4 @@
+contract c {
+ function f() pure public { }
+ modifier m() { msg.value; _; }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/402_assignment_to_constant.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/402_assignment_to_constant.sol
new file mode 100644
index 00000000..7433bdea
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/402_assignment_to_constant.sol
@@ -0,0 +1,6 @@
+contract c {
+ uint constant a = 1;
+ function f() public { a = 2; }
+}
+// ----
+// TypeError: (64-65): Cannot assign to a constant variable.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/403_return_structs.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/403_return_structs.sol
new file mode 100644
index 00000000..5583dbff
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/403_return_structs.sol
@@ -0,0 +1,11 @@
+pragma experimental ABIEncoderV2;
+contract C {
+ struct S { uint a; T[] sub; }
+ struct T { uint[] x; }
+ function f() returns (uint, S) {
+ }
+}
+// ----
+// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
+// Warning: (112-150): No visibility specified. Defaulting to "public".
+// Warning: (112-150): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/404_read_returned_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/404_read_returned_struct.sol
new file mode 100644
index 00000000..dd16eae4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/404_read_returned_struct.sol
@@ -0,0 +1,12 @@
+pragma experimental ABIEncoderV2;
+contract A {
+ struct T {
+ int x;
+ int y;
+ }
+ function g() public returns (T) {
+ return this.g();
+ }
+}
+// ----
+// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/405_address_checksum_type_deduction.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/405_address_checksum_type_deduction.sol
new file mode 100644
index 00000000..81cc7d0d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/405_address_checksum_type_deduction.sol
@@ -0,0 +1,6 @@
+contract C {
+ function f() public {
+ (0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E).transfer(2);
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/406_invalid_address_checksum.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/406_invalid_address_checksum.sol
new file mode 100644
index 00000000..fe4691c2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/406_invalid_address_checksum.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() pure public {
+ address x = 0xFA0bFc97E48458494Ccd857e1A85DC91F7F0046E;
+ x;
+ }
+}
+// ----
+// SyntaxError: (64-106): This looks like an address but has an invalid checksum. Correct checksummed address: "0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E". If this is not used as an address, please prepend '00'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/407_invalid_address_no_checksum.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/407_invalid_address_no_checksum.sol
new file mode 100644
index 00000000..6f4ac730
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/407_invalid_address_no_checksum.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() pure public {
+ address x = 0xfa0bfc97e48458494ccd857e1a85dc91f7f0046e;
+ x;
+ }
+}
+// ----
+// SyntaxError: (64-106): This looks like an address but has an invalid checksum. Correct checksummed address: "0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E". If this is not used as an address, please prepend '00'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/408_invalid_address_length_short.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/408_invalid_address_length_short.sol
new file mode 100644
index 00000000..da5dc380
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/408_invalid_address_length_short.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() pure public {
+ address x = 0xA0bFc97E48458494Ccd857e1A85DC91F7F0046E;
+ x;
+ }
+}
+// ----
+// SyntaxError: (64-105): This looks like an address but is not exactly 40 hex digits. It is 39 hex digits. If this is not used as an address, please prepend '00'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/409_invalid_address_length_long.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/409_invalid_address_length_long.sol
new file mode 100644
index 00000000..749612c9
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/409_invalid_address_length_long.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() pure public {
+ address x = 0xFA0bFc97E48458494Ccd857e1A85DC91F7F0046E0;
+ x;
+ }
+}
+// ----
+// SyntaxError: (64-107): This looks like an address but is not exactly 40 hex digits. It is 41 hex digits. If this is not used as an address, please prepend '00'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/410_string_literal_not_convertible_to_address_as_assignment.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/410_string_literal_not_convertible_to_address_as_assignment.sol
new file mode 100644
index 00000000..13bd1a8f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/410_string_literal_not_convertible_to_address_as_assignment.sol
@@ -0,0 +1,6 @@
+// A previous implementation claimed the string would be an address
+contract AddrString {
+ address public test = "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c";
+}
+// ----
+// TypeError: (116-160): Type literal_string "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c" is not implicitly convertible to expected type address.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/411_string_literal_not_convertible_to_address_as_return_value.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/411_string_literal_not_convertible_to_address_as_return_value.sol
new file mode 100644
index 00000000..d6b7b987
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/411_string_literal_not_convertible_to_address_as_return_value.sol
@@ -0,0 +1,8 @@
+// A previous implementation claimed the string would be an address
+contract AddrString {
+ function f() public returns (address) {
+ return "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c";
+ }
+}
+// ----
+// TypeError: (149-193): Return argument type literal_string "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c" is not implicitly convertible to expected type (type of first return variable) address.
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
new file mode 100644
index 00000000..979f0eb6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol
@@ -0,0 +1,11 @@
+// This tests a crash that occured because we did not stop for fatal errors.
+contract C {
+ struct S {
+ ftring a;
+ }
+ S public s;
+ function s() s {
+ }
+}
+// ----
+// DeclarationError: (113-119): Identifier not found or not unique.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/413_address_methods.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/413_address_methods.sol
new file mode 100644
index 00000000..d0c3769c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/413_address_methods.sol
@@ -0,0 +1,12 @@
+contract C {
+ function f() public {
+ address addr;
+ uint balance = addr.balance;
+ bool callRet = addr.call();
+ bool delegatecallRet = addr.delegatecall();
+ bool sendRet = addr.send(1);
+ addr.transfer(1);
+ balance; callRet; delegatecallRet; sendRet;
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/414_interface.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/414_interface.sol
new file mode 100644
index 00000000..77baf7bf
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/414_interface.sol
@@ -0,0 +1,2 @@
+interface I {
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/415_interface_functions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/415_interface_functions.sol
new file mode 100644
index 00000000..1f227b54
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/415_interface_functions.sol
@@ -0,0 +1,9 @@
+interface I {
+ function();
+ function f();
+}
+// ----
+// Warning: (18-29): Functions in interfaces should be declared external.
+// Warning: (34-47): Functions in interfaces should be declared external.
+// Warning: (18-29): No visibility specified. Defaulting to "public". In interfaces it defaults to external.
+// Warning: (34-47): No visibility specified. Defaulting to "public". In interfaces it defaults to external.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/416_interface_function_bodies.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/416_interface_function_bodies.sol
new file mode 100644
index 00000000..24b26c04
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/416_interface_function_bodies.sol
@@ -0,0 +1,7 @@
+interface I {
+ function f() public {
+ }
+}
+// ----
+// TypeError: (18-45): Functions in interfaces cannot have an implementation.
+// Warning: (18-45): Functions in interfaces should be declared external.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/417_interface_events.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/417_interface_events.sol
new file mode 100644
index 00000000..5959f50d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/417_interface_events.sol
@@ -0,0 +1,3 @@
+interface I {
+ event E();
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/418_interface_inheritance.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/418_interface_inheritance.sol
new file mode 100644
index 00000000..92683cda
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/418_interface_inheritance.sol
@@ -0,0 +1,6 @@
+interface A {
+}
+interface I is A {
+}
+// ----
+// TypeError: (31-32): Interfaces cannot inherit.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/419_interface_structs.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/419_interface_structs.sol
new file mode 100644
index 00000000..c74d52d3
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/419_interface_structs.sol
@@ -0,0 +1,9 @@
+interface I {
+ struct A {
+ // This is currently expected to break, but it *may* change in the future.
+ int dummy;
+ }
+}
+// ----
+// TypeError: (18-136): Structs cannot be defined in interfaces.
+// TypeError: (120-129): Variables cannot be declared in interfaces.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/420_interface_variables.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/420_interface_variables.sol
new file mode 100644
index 00000000..a4292c41
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/420_interface_variables.sol
@@ -0,0 +1,5 @@
+interface I {
+ uint a;
+}
+// ----
+// TypeError: (18-24): Variables cannot be declared in interfaces.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/421_interface_function_parameters.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/421_interface_function_parameters.sol
new file mode 100644
index 00000000..05e2dcfd
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/421_interface_function_parameters.sol
@@ -0,0 +1,5 @@
+interface I {
+ function f(uint a) public returns (bool);
+}
+// ----
+// Warning: (18-59): Functions in interfaces should be declared external.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/422_interface_enums.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/422_interface_enums.sol
new file mode 100644
index 00000000..5513817d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/422_interface_enums.sol
@@ -0,0 +1,5 @@
+interface I {
+ enum A { B, C }
+}
+// ----
+// TypeError: (18-33): Enumerable cannot be declared in interfaces.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/423_using_interface.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/423_using_interface.sol
new file mode 100644
index 00000000..f06ffa62
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/423_using_interface.sol
@@ -0,0 +1,10 @@
+interface I {
+ function f();
+}
+contract C is I {
+ function f() public {
+ }
+}
+// ----
+// Warning: (18-31): Functions in interfaces should be declared external.
+// Warning: (18-31): No visibility specified. Defaulting to "public". In interfaces it defaults to external.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/424_using_interface_complex.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/424_using_interface_complex.sol
new file mode 100644
index 00000000..a73c29bf
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/424_using_interface_complex.sol
@@ -0,0 +1,17 @@
+interface I {
+ event A();
+ function f();
+ function g();
+ function();
+}
+contract C is I {
+ function f() public {
+ }
+}
+// ----
+// Warning: (33-46): Functions in interfaces should be declared external.
+// Warning: (51-64): Functions in interfaces should be declared external.
+// Warning: (69-80): Functions in interfaces should be declared external.
+// Warning: (33-46): No visibility specified. Defaulting to "public". In interfaces it defaults to external.
+// Warning: (51-64): No visibility specified. Defaulting to "public". In interfaces it defaults to external.
+// Warning: (69-80): No visibility specified. Defaulting to "public". In interfaces it defaults to external.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/425_interface_implement_public_contract.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/425_interface_implement_public_contract.sol
new file mode 100644
index 00000000..d8540288
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/425_interface_implement_public_contract.sol
@@ -0,0 +1,7 @@
+interface I {
+ function f() external;
+}
+contract C is I {
+ function f() public {
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/426_throw_is_deprecated.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/426_throw_is_deprecated.sol
new file mode 100644
index 00000000..510c0d01
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/426_throw_is_deprecated.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() pure public {
+ throw;
+ }
+}
+// ----
+// Warning: (52-57): "throw" is deprecated in favour of "revert()", "require()" and "assert()".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/427_throw_is_deprecated_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/427_throw_is_deprecated_v050.sol
new file mode 100644
index 00000000..170d47d9
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/427_throw_is_deprecated_v050.sol
@@ -0,0 +1,8 @@
+pragma experimental "v0.5.0";
+contract C {
+ function f() pure public {
+ throw;
+ }
+}
+// ----
+// SyntaxError: (82-87): "throw" is deprecated in favour of "revert()", "require()" and "assert()".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/428_bare_revert.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/428_bare_revert.sol
new file mode 100644
index 00000000..8e7817ff
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/428_bare_revert.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f(uint x) pure public {
+ if (x > 7)
+ revert;
+ }
+}
+// ----
+// TypeError: (81-87): No matching declaration found after variable lookup.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/429_revert_with_reason.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/429_revert_with_reason.sol
new file mode 100644
index 00000000..36c238be
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/429_revert_with_reason.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f(uint x) pure public {
+ if (x > 7)
+ revert("abc");
+ else
+ revert();
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/430_bare_selfdestruct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/430_bare_selfdestruct.sol
new file mode 100644
index 00000000..9adc3d39
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/430_bare_selfdestruct.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f() pure public { selfdestruct; }
+}
+// ----
+// Warning: (44-56): Statement has no effect.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/431_bare_assert.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/431_bare_assert.sol
new file mode 100644
index 00000000..38cea057
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/431_bare_assert.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f() pure public { assert; }
+}
+// ----
+// Warning: (44-50): Statement has no effect.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/432_bare_require.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/432_bare_require.sol
new file mode 100644
index 00000000..62fe8baf
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/432_bare_require.sol
@@ -0,0 +1,6 @@
+contract C {
+ // This is different because it does have overloads.
+ function f() pure public { require; }
+}
+// ----
+// TypeError: (101-108): No matching declaration found after variable lookup.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/433_pure_statement_in_for_loop.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/433_pure_statement_in_for_loop.sol
new file mode 100644
index 00000000..8cb090bb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/433_pure_statement_in_for_loop.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() pure public {
+ for (uint x = 0; x < 10; true)
+ x++;
+ }
+}
+// ----
+// Warning: (77-81): Statement has no effect.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/434_pure_statement_check_for_regular_for_loop.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/434_pure_statement_check_for_regular_for_loop.sol
new file mode 100644
index 00000000..319e4202
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/434_pure_statement_check_for_regular_for_loop.sol
@@ -0,0 +1,6 @@
+contract C {
+ function f() pure public {
+ for (uint x = 0; true; x++)
+ {}
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/435_warn_unused_local.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/435_warn_unused_local.sol
new file mode 100644
index 00000000..7d7f5728
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/435_warn_unused_local.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() pure public {
+ uint a;
+ }
+}
+// ----
+// Warning: (52-58): Unused local variable.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/436_warn_unused_local_assigned.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/436_warn_unused_local_assigned.sol
new file mode 100644
index 00000000..b3d28374
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/436_warn_unused_local_assigned.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() pure public {
+ uint a = 1;
+ }
+}
+// ----
+// Warning: (52-58): Unused local variable.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/437_warn_unused_function_parameter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/437_warn_unused_function_parameter.sol
new file mode 100644
index 00000000..8a36eaad
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/437_warn_unused_function_parameter.sol
@@ -0,0 +1,6 @@
+contract C {
+ function f(uint a) pure public {
+ }
+}
+// ----
+// Warning: (28-34): Unused function parameter. Remove or comment out the variable name to silence this warning.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/438_unused_unnamed_function_parameter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/438_unused_unnamed_function_parameter.sol
new file mode 100644
index 00000000..5d059b93
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/438_unused_unnamed_function_parameter.sol
@@ -0,0 +1,4 @@
+contract C {
+ function f(uint) pure public {
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/439_warn_unused_return_parameter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/439_warn_unused_return_parameter.sol
new file mode 100644
index 00000000..b1422c4f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/439_warn_unused_return_parameter.sol
@@ -0,0 +1,6 @@
+contract C {
+ function f() pure public returns (uint a) {
+ }
+}
+// ----
+// Warning: (51-57): Unused function parameter. Remove or comment out the variable name to silence this warning.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/440_warn_unused_return_parameter_with_explicit_return.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/440_warn_unused_return_parameter_with_explicit_return.sol
new file mode 100644
index 00000000..af67f491
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/440_warn_unused_return_parameter_with_explicit_return.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() pure public returns (uint a) {
+ return;
+ }
+}
+// ----
+// Warning: (51-57): Unused function parameter. Remove or comment out the variable name to silence this warning.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/441_unused_unnamed_return_parameter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/441_unused_unnamed_return_parameter.sol
new file mode 100644
index 00000000..8c47484b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/441_unused_unnamed_return_parameter.sol
@@ -0,0 +1,4 @@
+contract C {
+ function f() pure public returns (uint) {
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/442_named_return_parameter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/442_named_return_parameter.sol
new file mode 100644
index 00000000..a2faf06a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/442_named_return_parameter.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f() pure public returns (uint a) {
+ a = 1;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/443_named_return_parameter_with_explicit_return.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/443_named_return_parameter_with_explicit_return.sol
new file mode 100644
index 00000000..93851e7c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/443_named_return_parameter_with_explicit_return.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f() pure public returns (uint a) {
+ return 1;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/444_unnamed_return_parameter_with_explicit_return.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/444_unnamed_return_parameter_with_explicit_return.sol
new file mode 100644
index 00000000..b552a745
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/444_unnamed_return_parameter_with_explicit_return.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f() pure public returns (uint) {
+ return 1;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/445_no_unused_warning_interface_arguments.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/445_no_unused_warning_interface_arguments.sol
new file mode 100644
index 00000000..203217ce
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/445_no_unused_warning_interface_arguments.sol
@@ -0,0 +1,3 @@
+interface I {
+ function f(uint a) pure external returns (uint b);
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/446_no_unused_warning_abstract_arguments.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/446_no_unused_warning_abstract_arguments.sol
new file mode 100644
index 00000000..fbb6e079
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/446_no_unused_warning_abstract_arguments.sol
@@ -0,0 +1,3 @@
+contract C {
+ function f(uint a) pure public returns (uint b);
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/447_no_unused_warnings.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/447_no_unused_warnings.sol
new file mode 100644
index 00000000..f549308a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/447_no_unused_warnings.sol
@@ -0,0 +1,6 @@
+contract C {
+ function f(uint a) pure public returns (uint b) {
+ uint c = 1;
+ b = a + c;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/449_no_unused_inline_asm.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/449_no_unused_inline_asm.sol
new file mode 100644
index 00000000..2b39b9fd
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/449_no_unused_inline_asm.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() pure public {
+ uint a;
+ assembly {
+ a := 1
+ }
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/450_shadowing_builtins_with_functions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/450_shadowing_builtins_with_functions.sol
new file mode 100644
index 00000000..33ccb356
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/450_shadowing_builtins_with_functions.sol
@@ -0,0 +1,5 @@
+contract C {
+ function keccak256() pure public {}
+}
+// ----
+// Warning: (17-52): This declaration shadows a builtin symbol.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/451_shadowing_builtins_with_variables.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/451_shadowing_builtins_with_variables.sol
new file mode 100644
index 00000000..1d6f098e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/451_shadowing_builtins_with_variables.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() pure public {
+ uint msg;
+ msg;
+ }
+}
+// ----
+// Warning: (52-60): This declaration shadows a builtin symbol.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/452_shadowing_builtins_with_storage_variables.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/452_shadowing_builtins_with_storage_variables.sol
new file mode 100644
index 00000000..d5635887
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/452_shadowing_builtins_with_storage_variables.sol
@@ -0,0 +1,5 @@
+contract C {
+ uint msg;
+}
+// ----
+// Warning: (17-25): This declaration shadows a builtin symbol.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/453_shadowing_builtin_at_global_scope.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/453_shadowing_builtin_at_global_scope.sol
new file mode 100644
index 00000000..0946dc57
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/453_shadowing_builtin_at_global_scope.sol
@@ -0,0 +1,4 @@
+contract msg {
+}
+// ----
+// Warning: (0-16): This declaration shadows a builtin symbol.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/454_shadowing_builtins_with_parameters.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/454_shadowing_builtins_with_parameters.sol
new file mode 100644
index 00000000..454929d1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/454_shadowing_builtins_with_parameters.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f(uint require) pure public {
+ require = 2;
+ }
+}
+// ----
+// Warning: (28-40): This declaration shadows a builtin symbol.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/455_shadowing_builtins_with_return_parameters.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/455_shadowing_builtins_with_return_parameters.sol
new file mode 100644
index 00000000..7931053f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/455_shadowing_builtins_with_return_parameters.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() pure public returns (uint require) {
+ require = 2;
+ }
+}
+// ----
+// Warning: (51-63): This declaration shadows a builtin symbol.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/456_shadowing_builtins_with_events.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/456_shadowing_builtins_with_events.sol
new file mode 100644
index 00000000..e5b635df
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/456_shadowing_builtins_with_events.sol
@@ -0,0 +1,5 @@
+contract C {
+ event keccak256();
+}
+// ----
+// Warning: (17-35): This declaration shadows a builtin symbol.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/457_shadowing_builtins_ignores_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/457_shadowing_builtins_ignores_struct.sol
new file mode 100644
index 00000000..4c70b4ce
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/457_shadowing_builtins_ignores_struct.sol
@@ -0,0 +1,5 @@
+contract C {
+ struct a {
+ uint msg;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/458_shadowing_builtins_ignores_constructor.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/458_shadowing_builtins_ignores_constructor.sol
new file mode 100644
index 00000000..86c0b4f0
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/458_shadowing_builtins_ignores_constructor.sol
@@ -0,0 +1,3 @@
+contract C {
+ constructor() public {}
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/459_function_overload_is_not_shadowing.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/459_function_overload_is_not_shadowing.sol
new file mode 100644
index 00000000..1b44b5c6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/459_function_overload_is_not_shadowing.sol
@@ -0,0 +1,4 @@
+contract C {
+ function f() pure public {}
+ function f(uint) pure public {}
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/460_function_override_is_not_shadowing.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/460_function_override_is_not_shadowing.sol
new file mode 100644
index 00000000..c765ff00
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/460_function_override_is_not_shadowing.sol
@@ -0,0 +1,4 @@
+contract D { function f() pure public {} }
+contract C is D {
+ function f(uint) pure public {}
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/461_event_parameter_cannot_shadow_state_variable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/461_event_parameter_cannot_shadow_state_variable.sol
new file mode 100644
index 00000000..6e1f654d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/461_event_parameter_cannot_shadow_state_variable.sol
@@ -0,0 +1,4 @@
+contract C {
+ address a;
+ event E(address a);
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/462_callable_crash.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/462_callable_crash.sol
new file mode 100644
index 00000000..94e81de6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/462_callable_crash.sol
@@ -0,0 +1,10 @@
+contract C {
+ struct S { uint a; bool x; }
+ S public s;
+ function C() public {
+ 3({a: 1, x: true});
+ }
+}
+// ----
+// Warning: (66-121): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
+// TypeError: (96-114): Type is not callable
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/463_error_transfer_non_payable_fallback.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/463_error_transfer_non_payable_fallback.sol
new file mode 100644
index 00000000..3f6b0283
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/463_error_transfer_non_payable_fallback.sol
@@ -0,0 +1,17 @@
+// This used to be a test for a.transfer to generate a warning
+// because A's fallback function is not payable.
+
+contract A {
+ function() public {}
+}
+
+contract B {
+ A a;
+
+ function() public {
+ a.transfer(100);
+ }
+}
+// ----
+// Warning: (209-219): Using contract member "transfer" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).transfer" instead.
+// TypeError: (209-219): Value transfer to a contract without a payable fallback function.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/464_error_transfer_no_fallback.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/464_error_transfer_no_fallback.sol
new file mode 100644
index 00000000..afa86040
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/464_error_transfer_no_fallback.sol
@@ -0,0 +1,15 @@
+// This used to be a test for a.transfer to generate a warning
+// because A does not have a payable fallback function.
+
+contract A {}
+
+contract B {
+ A a;
+
+ function() public {
+ a.transfer(100);
+ }
+}
+// ----
+// Warning: (190-200): Using contract member "transfer" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).transfer" instead.
+// TypeError: (190-200): Value transfer to a contract without a payable fallback function.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/465_error_send_non_payable_fallback.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/465_error_send_non_payable_fallback.sol
new file mode 100644
index 00000000..36f7470b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/465_error_send_non_payable_fallback.sol
@@ -0,0 +1,17 @@
+// This used to be a test for a.send to generate a warning
+// because A does not have a payable fallback function.
+
+contract A {
+ function() public {}
+}
+
+contract B {
+ A a;
+
+ function() public {
+ require(a.send(100));
+ }
+}
+// ----
+// Warning: (220-226): Using contract member "send" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).send" instead.
+// TypeError: (220-226): Value transfer to a contract without a payable fallback function.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/466_does_not_error_transfer_payable_fallback.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/466_does_not_error_transfer_payable_fallback.sol
new file mode 100644
index 00000000..1fa567eb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/466_does_not_error_transfer_payable_fallback.sol
@@ -0,0 +1,16 @@
+// This used to be a test for a.transfer to generate a warning
+// because A does not have a payable fallback function.
+
+contract A {
+ function() payable public {}
+}
+
+contract B {
+ A a;
+
+ function() public {
+ a.transfer(100);
+ }
+}
+// ----
+// Warning: (224-234): Using contract member "transfer" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).transfer" instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/467_does_not_error_transfer_regular_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/467_does_not_error_transfer_regular_function.sol
new file mode 100644
index 00000000..bf027e22
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/467_does_not_error_transfer_regular_function.sol
@@ -0,0 +1,11 @@
+contract A {
+ function transfer() pure public {}
+}
+
+contract B {
+ A a;
+
+ function() public {
+ a.transfer();
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/470_specified_storage_no_warn.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/470_specified_storage_no_warn.sol
new file mode 100644
index 00000000..490a0032
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/470_specified_storage_no_warn.sol
@@ -0,0 +1,8 @@
+contract C {
+ struct S { uint a; string b; }
+ S x;
+ function f() view public {
+ S storage y = x;
+ y;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/471_unspecified_storage_warn.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/471_unspecified_storage_warn.sol
new file mode 100644
index 00000000..aa16a6b4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/471_unspecified_storage_warn.sol
@@ -0,0 +1,10 @@
+contract C {
+ struct S { uint a; }
+ S x;
+ function f() view public {
+ S y = x;
+ y;
+ }
+}
+// ----
+// Warning: (86-89): Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/472_unspecified_storage_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/472_unspecified_storage_v050.sol
new file mode 100644
index 00000000..179c9931
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/472_unspecified_storage_v050.sol
@@ -0,0 +1,11 @@
+pragma experimental "v0.5.0";
+contract C {
+ struct S { uint a; }
+ S x;
+ function f() view public {
+ S y = x;
+ y;
+ }
+}
+// ----
+// TypeError: (116-119): Data location must be specified as either "memory" or "storage".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/473_storage_location_non_array_or_struct_disallowed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/473_storage_location_non_array_or_struct_disallowed.sol
new file mode 100644
index 00000000..6c9f50af
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/473_storage_location_non_array_or_struct_disallowed.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f(uint storage a) public { }
+}
+// ----
+// TypeError: (28-42): Data location can only be given for array or struct types.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/474_storage_location_non_array_or_struct_disallowed_is_not_fatal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/474_storage_location_non_array_or_struct_disallowed_is_not_fatal.sol
new file mode 100644
index 00000000..a2f47407
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/474_storage_location_non_array_or_struct_disallowed_is_not_fatal.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f(uint storage a) public {
+ a = f;
+ }
+}
+// ----
+// TypeError: (28-42): Data location can only be given for array or struct types.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/475_implicit_conversion_disallowed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/475_implicit_conversion_disallowed.sol
new file mode 100644
index 00000000..232e701d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/475_implicit_conversion_disallowed.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() public returns (bytes4) {
+ uint32 tmp = 1;
+ return tmp;
+ }
+}
+// ----
+// TypeError: (95-98): Return argument type uint32 is not implicitly convertible to expected type (type of first return variable) bytes4.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/476_too_large_arrays_for_calldata_external.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/476_too_large_arrays_for_calldata_external.sol
new file mode 100644
index 00000000..de8b7501
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/476_too_large_arrays_for_calldata_external.sol
@@ -0,0 +1,6 @@
+contract C {
+ function f(uint[85678901234] a) pure external {
+ }
+}
+// ----
+// TypeError: (28-47): Array is too large to be encoded.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/477_too_large_arrays_for_calldata_internal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/477_too_large_arrays_for_calldata_internal.sol
new file mode 100644
index 00000000..ab57f489
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/477_too_large_arrays_for_calldata_internal.sol
@@ -0,0 +1,6 @@
+contract C {
+ function f(uint[85678901234] a) pure internal {
+ }
+}
+// ----
+// TypeError: (28-47): Array is too large to be encoded.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/478_too_large_arrays_for_calldata_public.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/478_too_large_arrays_for_calldata_public.sol
new file mode 100644
index 00000000..1493f3ca
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/478_too_large_arrays_for_calldata_public.sol
@@ -0,0 +1,6 @@
+contract C {
+ function f(uint[85678901234] a) pure public {
+ }
+}
+// ----
+// TypeError: (28-47): Array is too large to be encoded.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/479_explicit_literal_to_memory_string_assignment.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/479_explicit_literal_to_memory_string_assignment.sol
new file mode 100644
index 00000000..508a9439
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/479_explicit_literal_to_memory_string_assignment.sol
@@ -0,0 +1,6 @@
+contract C {
+ function f() pure public {
+ string memory x = "abc";
+ x;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/480_explicit_literal_to_storage_string_assignment.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/480_explicit_literal_to_storage_string_assignment.sol
new file mode 100644
index 00000000..ee56204a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/480_explicit_literal_to_storage_string_assignment.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() pure public {
+ string storage x = "abc";
+ }
+}
+// ----
+// TypeError: (52-76): Type literal_string "abc" is not implicitly convertible to expected type string storage pointer.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/481_explicit_literal_to_unspecified_string_assignment.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/481_explicit_literal_to_unspecified_string_assignment.sol
new file mode 100644
index 00000000..9801b831
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/481_explicit_literal_to_unspecified_string_assignment.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() pure public {
+ string x = "abc";
+ }
+}
+// ----
+// Warning: (52-60): Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning.
+// TypeError: (52-68): Type literal_string "abc" is not implicitly convertible to expected type string storage pointer.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/482_explicit_literal_to_unspecified_string.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/482_explicit_literal_to_unspecified_string.sol
new file mode 100644
index 00000000..a83eee72
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/482_explicit_literal_to_unspecified_string.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() pure public {
+ string("abc");
+ }
+}
+// ----
+// TypeError: (52-65): Explicit type conversion not allowed from "literal_string "abc"" to "string storage pointer".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/483_modifiers_access_storage_pointer.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/483_modifiers_access_storage_pointer.sol
new file mode 100644
index 00000000..be1920e9
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/483_modifiers_access_storage_pointer.sol
@@ -0,0 +1,7 @@
+contract C {
+ struct S { uint a; }
+ modifier m(S storage x) {
+ x;
+ _;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/484_function_types_selector_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/484_function_types_selector_1.sol
new file mode 100644
index 00000000..76c3fcd6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/484_function_types_selector_1.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() view returns (bytes4) {
+ return f.selector;
+ }
+}
+// ----
+// TypeError: (69-79): Member "selector" not found or not visible after argument-dependent lookup in function () view returns (bytes4)
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/485_function_types_selector_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/485_function_types_selector_2.sol
new file mode 100644
index 00000000..b21a5d3d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/485_function_types_selector_2.sol
@@ -0,0 +1,9 @@
+contract C {
+ function g() pure internal {
+ }
+ function f() view returns (bytes4) {
+ return g.selector;
+ }
+}
+// ----
+// TypeError: (108-118): Member "selector" not found or not visible after argument-dependent lookup in function () pure
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/486_function_types_selector_3.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/486_function_types_selector_3.sol
new file mode 100644
index 00000000..3567c44f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/486_function_types_selector_3.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() view returns (bytes4) {
+ function () g;
+ return g.selector;
+ }
+}
+// ----
+// TypeError: (92-102): Member "selector" not found or not visible after argument-dependent lookup in function ()
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/487_function_types_selector_4.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/487_function_types_selector_4.sol
new file mode 100644
index 00000000..4c3c72e8
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/487_function_types_selector_4.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f() pure external returns (bytes4) {
+ return this.f.selector;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/488_function_types_selector_5.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/488_function_types_selector_5.sol
new file mode 100644
index 00000000..5f601db2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/488_function_types_selector_5.sol
@@ -0,0 +1,8 @@
+contract C {
+ function h() pure external {
+ }
+ function f() pure external returns (bytes4) {
+ return this.h.selector;
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/489_function_types_selector_6.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/489_function_types_selector_6.sol
new file mode 100644
index 00000000..0114e282
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/489_function_types_selector_6.sol
@@ -0,0 +1,8 @@
+contract C {
+ function h() pure external {
+ }
+ function f() view external returns (bytes4) {
+ function () pure external g = this.h;
+ return g.selector;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/490_function_types_selector_7.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/490_function_types_selector_7.sol
new file mode 100644
index 00000000..9ee7d9bb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/490_function_types_selector_7.sol
@@ -0,0 +1,9 @@
+contract C {
+ function h() pure external {
+ }
+ function f() view external returns (bytes4) {
+ function () pure external g = this.h;
+ return g.selector;
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/491_using_this_in_constructor.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/491_using_this_in_constructor.sol
new file mode 100644
index 00000000..7921a1fa
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/491_using_this_in_constructor.sol
@@ -0,0 +1,9 @@
+contract C {
+ constructor() public {
+ this.f();
+ }
+ function f() pure public {
+ }
+}
+// ----
+// Warning: (48-52): "this" used in constructor. Note that external functions of a contract cannot be called while it is being constructed.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/492_do_not_crash_on_not_lvalue.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/492_do_not_crash_on_not_lvalue.sol
new file mode 100644
index 00000000..90275804
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/492_do_not_crash_on_not_lvalue.sol
@@ -0,0 +1,11 @@
+// This checks for a bug that caused a crash because of continued analysis.
+contract C {
+ mapping (uint => uint) m;
+ function f() public {
+ m(1) = 2;
+ }
+}
+// ----
+// TypeError: (153-157): Type is not callable
+// TypeError: (153-157): Expression has to be an lvalue.
+// TypeError: (160-161): Type int_const 2 is not implicitly convertible to expected type tuple().
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/493_builtin_keccak256_reject_gas.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/493_builtin_keccak256_reject_gas.sol
new file mode 100644
index 00000000..bc8c7867
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/493_builtin_keccak256_reject_gas.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public {
+ keccak256.gas();
+ }
+}
+// ----
+// TypeError: (47-60): Member "gas" not found or not visible after argument-dependent lookup in function () pure returns (bytes32)
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/494_builtin_sha256_reject_gas.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/494_builtin_sha256_reject_gas.sol
new file mode 100644
index 00000000..f29cd7dd
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/494_builtin_sha256_reject_gas.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public {
+ sha256.gas();
+ }
+}
+// ----
+// TypeError: (47-57): Member "gas" not found or not visible after argument-dependent lookup in function () pure returns (bytes32)
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/495_builtin_ripemd160_reject_gas.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/495_builtin_ripemd160_reject_gas.sol
new file mode 100644
index 00000000..b20255fb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/495_builtin_ripemd160_reject_gas.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public {
+ ripemd160.gas();
+ }
+}
+// ----
+// TypeError: (47-60): Member "gas" not found or not visible after argument-dependent lookup in function () pure returns (bytes20)
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/496_builtin_ecrecover_reject_gas.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/496_builtin_ecrecover_reject_gas.sol
new file mode 100644
index 00000000..0a874f5d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/496_builtin_ecrecover_reject_gas.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public {
+ ecrecover.gas();
+ }
+}
+// ----
+// TypeError: (47-60): Member "gas" not found or not visible after argument-dependent lookup in function (bytes32,uint8,bytes32,bytes32) pure returns (address)
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/497_gasleft.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/497_gasleft.sol
new file mode 100644
index 00000000..20f33887
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/497_gasleft.sol
@@ -0,0 +1,3 @@
+contract C {
+ function f() public view returns (uint256 val) { return gasleft(); }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/498_msg_gas_deprecated.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/498_msg_gas_deprecated.sol
new file mode 100644
index 00000000..d917b840
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/498_msg_gas_deprecated.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f() public view returns (uint256 val) { return msg.gas; }
+}
+// ----
+// Warning: (73-80): "msg.gas" has been deprecated in favor of "gasleft()"
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/499_msg_gas_deprecated_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/499_msg_gas_deprecated_v050.sol
new file mode 100644
index 00000000..31fd40da
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/499_msg_gas_deprecated_v050.sol
@@ -0,0 +1,6 @@
+pragma experimental "v0.5.0";
+contract C {
+ function f() public returns (uint256 val) { return msg.gas; }
+}
+// ----
+// TypeError: (98-105): "msg.gas" has been deprecated in favor of "gasleft()"
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/500_gasleft_shadowing_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/500_gasleft_shadowing_1.sol
new file mode 100644
index 00000000..66b88c49
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/500_gasleft_shadowing_1.sol
@@ -0,0 +1,6 @@
+contract C {
+ function gasleft() public pure returns (bytes32 val) { return "abc"; }
+ function f() public pure returns (bytes32 val) { return gasleft(); }
+}
+// ----
+// Warning: (17-87): This declaration shadows a builtin symbol.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/501_gasleft_shadowing_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/501_gasleft_shadowing_2.sol
new file mode 100644
index 00000000..2679c89d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/501_gasleft_shadowing_2.sol
@@ -0,0 +1,6 @@
+contract C {
+ uint gasleft;
+ function f() public { gasleft = 42; }
+}
+// ----
+// Warning: (17-29): This declaration shadows a builtin symbol.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/502_builtin_keccak256_reject_value.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/502_builtin_keccak256_reject_value.sol
new file mode 100644
index 00000000..a58891d2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/502_builtin_keccak256_reject_value.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public {
+ keccak256.value();
+ }
+}
+// ----
+// TypeError: (47-62): Member "value" not found or not visible after argument-dependent lookup in function () pure returns (bytes32) - did you forget the "payable" modifier?
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/503_builtin_sha256_reject_value.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/503_builtin_sha256_reject_value.sol
new file mode 100644
index 00000000..19d671ff
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/503_builtin_sha256_reject_value.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public {
+ sha256.value();
+ }
+}
+// ----
+// TypeError: (47-59): Member "value" not found or not visible after argument-dependent lookup in function () pure returns (bytes32) - did you forget the "payable" modifier?
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/504_builtin_ripemd160_reject_value.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/504_builtin_ripemd160_reject_value.sol
new file mode 100644
index 00000000..38bb2cb6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/504_builtin_ripemd160_reject_value.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public {
+ ripemd160.value();
+ }
+}
+// ----
+// TypeError: (47-62): Member "value" not found or not visible after argument-dependent lookup in function () pure returns (bytes20) - did you forget the "payable" modifier?
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/505_builtin_ecrecover_reject_value.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/505_builtin_ecrecover_reject_value.sol
new file mode 100644
index 00000000..e0215901
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/505_builtin_ecrecover_reject_value.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public {
+ ecrecover.value();
+ }
+}
+// ----
+// TypeError: (47-62): Member "value" not found or not visible after argument-dependent lookup in function (bytes32,uint8,bytes32,bytes32) pure returns (address) - did you forget the "payable" modifier?
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/506_large_storage_array_fine.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/506_large_storage_array_fine.sol
new file mode 100644
index 00000000..13e6dd80
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/506_large_storage_array_fine.sol
@@ -0,0 +1,3 @@
+contract C {
+ uint[2**64 - 1] x;
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/507_large_storage_array_simple.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/507_large_storage_array_simple.sol
new file mode 100644
index 00000000..3f8ee996
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/507_large_storage_array_simple.sol
@@ -0,0 +1,5 @@
+contract C {
+ uint[2**64] x;
+}
+// ----
+// Warning: (17-30): Variable covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/508_large_storage_arrays_combined.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/508_large_storage_arrays_combined.sol
new file mode 100644
index 00000000..917dcec1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/508_large_storage_arrays_combined.sol
@@ -0,0 +1,5 @@
+contract C {
+ uint[200][200][2**30][][2**30] x;
+}
+// ----
+// Warning: (17-49): Variable covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/509_large_storage_arrays_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/509_large_storage_arrays_struct.sol
new file mode 100644
index 00000000..656201f4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/509_large_storage_arrays_struct.sol
@@ -0,0 +1,6 @@
+contract C {
+ struct S { uint[2**30] x; uint[2**50] y; }
+ S[2**20] x;
+}
+// ----
+// Warning: (64-74): Variable covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/510_large_storage_array_mapping.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/510_large_storage_array_mapping.sol
new file mode 100644
index 00000000..046a27f7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/510_large_storage_array_mapping.sol
@@ -0,0 +1,5 @@
+contract C {
+ mapping(uint => uint[2**100]) x;
+}
+// ----
+// Warning: (17-48): Variable covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/511_library_function_without_implementation_public.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/511_library_function_without_implementation_public.sol
new file mode 100644
index 00000000..fe5e4955
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/511_library_function_without_implementation_public.sol
@@ -0,0 +1,4 @@
+library L {
+ // This can be used as an "interface", hence it is allowed.
+ function f() public;
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/512_library_function_without_implementation_internal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/512_library_function_without_implementation_internal.sol
new file mode 100644
index 00000000..d5dfb260
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/512_library_function_without_implementation_internal.sol
@@ -0,0 +1,5 @@
+library L {
+ function f() internal;
+}
+// ----
+// TypeError: (16-38): Internal library function must be implemented if declared.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/513_library_function_without_implementation_private.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/513_library_function_without_implementation_private.sol
new file mode 100644
index 00000000..70585e8c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/513_library_function_without_implementation_private.sol
@@ -0,0 +1,5 @@
+library L {
+ function f() private;
+}
+// ----
+// TypeError: (16-37): Internal library function must be implemented if declared.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/514_using_for_with_non_library.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/514_using_for_with_non_library.sol
new file mode 100644
index 00000000..ab139dd5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/514_using_for_with_non_library.sol
@@ -0,0 +1,10 @@
+// This tests a crash that was resolved by making the first error fatal.
+library L {
+ struct S { uint d; }
+ using S for S;
+ function f(S _s) internal {
+ _s.d = 1;
+ }
+}
+// ----
+// TypeError: (120-121): Library name expected.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/515_experimental_pragma_empty.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/515_experimental_pragma_empty.sol
new file mode 100644
index 00000000..66afb7a2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/515_experimental_pragma_empty.sol
@@ -0,0 +1,3 @@
+pragma experimental;
+// ----
+// SyntaxError: (0-20): Experimental feature name is missing.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/516_experimental_pragma_unknown_number_literal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/516_experimental_pragma_unknown_number_literal.sol
new file mode 100644
index 00000000..445c6f54
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/516_experimental_pragma_unknown_number_literal.sol
@@ -0,0 +1,3 @@
+pragma experimental 123;
+// ----
+// SyntaxError: (0-24): Unsupported experimental feature name.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/517_experimental_pragma_unknown_string_literal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/517_experimental_pragma_unknown_string_literal.sol
new file mode 100644
index 00000000..48d8b968
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/517_experimental_pragma_unknown_string_literal.sol
@@ -0,0 +1,3 @@
+pragma experimental unsupportedName;
+// ----
+// SyntaxError: (0-36): Unsupported experimental feature name.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/518_experimental_pragma_unknown_quoted_string_literal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/518_experimental_pragma_unknown_quoted_string_literal.sol
new file mode 100644
index 00000000..6405f062
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/518_experimental_pragma_unknown_quoted_string_literal.sol
@@ -0,0 +1,3 @@
+pragma experimental "unsupportedName";
+// ----
+// SyntaxError: (0-38): Unsupported experimental feature name.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/519_experimental_pragma_empy_string_literal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/519_experimental_pragma_empy_string_literal.sol
new file mode 100644
index 00000000..1a1fde9c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/519_experimental_pragma_empy_string_literal.sol
@@ -0,0 +1,3 @@
+pragma experimental "";
+// ----
+// SyntaxError: (0-23): Empty experimental feature name is invalid.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/520_experimental_pragma_multiple_same_line.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/520_experimental_pragma_multiple_same_line.sol
new file mode 100644
index 00000000..2eb2bf2a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/520_experimental_pragma_multiple_same_line.sol
@@ -0,0 +1,3 @@
+pragma experimental unsupportedName unsupportedName;
+// ----
+// SyntaxError: (0-52): Stray arguments.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/521_experimental_pragma_test_warning.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/521_experimental_pragma_test_warning.sol
new file mode 100644
index 00000000..5f6962f4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/521_experimental_pragma_test_warning.sol
@@ -0,0 +1,3 @@
+pragma experimental __test;
+// ----
+// Warning: (0-27): Experimental features are turned on. Do not use experimental features on live deployments.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/522_experimental_pragma_duplicate.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/522_experimental_pragma_duplicate.sol
new file mode 100644
index 00000000..ba772a21
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/522_experimental_pragma_duplicate.sol
@@ -0,0 +1,5 @@
+pragma experimental __test;
+pragma experimental __test;
+// ----
+// Warning: (0-27): Experimental features are turned on. Do not use experimental features on live deployments.
+// SyntaxError: (28-55): Duplicate experimental feature name.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/523_reject_interface_creation.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/523_reject_interface_creation.sol
new file mode 100644
index 00000000..35bba5b3
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/523_reject_interface_creation.sol
@@ -0,0 +1,8 @@
+interface I {}
+contract C {
+ function f() public {
+ new I();
+ }
+}
+// ----
+// TypeError: (62-67): Cannot instantiate an interface.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/524_accept_library_creation.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/524_accept_library_creation.sol
new file mode 100644
index 00000000..6a5e97af
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/524_accept_library_creation.sol
@@ -0,0 +1,6 @@
+library L {}
+contract C {
+ function f() public {
+ new L();
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/525_reject_interface_constructors.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/525_reject_interface_constructors.sol
new file mode 100644
index 00000000..d65c639f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/525_reject_interface_constructors.sol
@@ -0,0 +1,4 @@
+interface I {}
+contract C is I(2) {}
+// ----
+// TypeError: (29-33): Wrong argument count for constructor call: 1 arguments given but expected 0.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external_v050.sol
new file mode 100644
index 00000000..f13a87ec
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external_v050.sol
@@ -0,0 +1,4 @@
+pragma experimental "v0.5.0";
+contract C {
+ function () external { }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal_v050.sol
new file mode 100644
index 00000000..6c8b23c8
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal_v050.sol
@@ -0,0 +1,6 @@
+pragma experimental "v0.5.0";
+contract C {
+ function () internal { }
+}
+// ----
+// TypeError: (47-71): Fallback function must be defined as "external".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private_v050.sol
new file mode 100644
index 00000000..be381909
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private_v050.sol
@@ -0,0 +1,6 @@
+pragma experimental "v0.5.0";
+contract C {
+ function () private { }
+}
+// ----
+// TypeError: (47-70): Fallback function must be defined as "external".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public_v050.sol
new file mode 100644
index 00000000..d0beffda
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public_v050.sol
@@ -0,0 +1,6 @@
+pragma experimental "v0.5.0";
+contract C {
+ function () public { }
+}
+// ----
+// TypeError: (47-69): Fallback function must be defined as "external".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/530_tuple_invalid_literal_too_large_for_uint.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/530_tuple_invalid_literal_too_large_for_uint.sol
new file mode 100644
index 00000000..bbfe2206
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/530_tuple_invalid_literal_too_large_for_uint.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() pure public {
+ uint x;
+ (x, ) = (1E111);
+ }
+}
+// ----
+// TypeError: (76-83): Type int_const 1000...(104 digits omitted)...0000 is not implicitly convertible to expected type tuple(uint256,).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/531_tuple_invalid_literal_too_large_unassigned.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/531_tuple_invalid_literal_too_large_unassigned.sol
new file mode 100644
index 00000000..6b9cbf79
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/531_tuple_invalid_literal_too_large_unassigned.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() pure public {
+ uint x;
+ (x, ) = (1, 1E111);
+ }
+}
+// ----
+// TypeError: (80-85): Invalid rational number.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/532_tuple_invalid_literal_too_large_for_uint_multi.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/532_tuple_invalid_literal_too_large_for_uint_multi.sol
new file mode 100644
index 00000000..a26f9c04
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/532_tuple_invalid_literal_too_large_for_uint_multi.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() pure public {
+ uint x;
+ (x, ) = (1E111, 1);
+ }
+}
+// ----
+// TypeError: (77-82): Invalid rational number.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/533_tuple_invalid_literal_too_large_exp.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/533_tuple_invalid_literal_too_large_exp.sol
new file mode 100644
index 00000000..9384ec53
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/533_tuple_invalid_literal_too_large_exp.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() pure public {
+ (2**270, 1);
+ }
+}
+// ----
+// TypeError: (53-59): Invalid rational number.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/534_tuple_invalid_literal_too_large_expression.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/534_tuple_invalid_literal_too_large_expression.sol
new file mode 100644
index 00000000..3c322444
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/534_tuple_invalid_literal_too_large_expression.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() pure public {
+ ((2**270) / 2**100, 1);
+ }
+}
+// ----
+// Warning: (52-74): Statement has no effect.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol
new file mode 100644
index 00000000..35f4639e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol
@@ -0,0 +1,21 @@
+contract C {
+ function balance() returns (uint) {
+ this.balance; // to avoid pureness warning
+ return 1;
+ }
+ function transfer(uint amount) {
+ address(this).transfer(amount); // to avoid pureness warning
+ }
+}
+contract D {
+ function f() {
+ uint x = (new C()).balance();
+ x;
+ (new C()).transfer(5);
+ }
+}
+// ----
+// Warning: (17-127): No visibility specified. Defaulting to "public".
+// Warning: (132-239): No visibility specified. Defaulting to "public".
+// Warning: (259-359): No visibility specified. Defaulting to "public".
+// Warning: (17-127): Function state mutability can be restricted to view
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/536_array_length_invalid_expression_negative_bool.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/536_array_length_invalid_expression_negative_bool.sol
new file mode 100644
index 00000000..c92861eb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/536_array_length_invalid_expression_negative_bool.sol
@@ -0,0 +1,5 @@
+contract C {
+ uint[-true] ids;
+}
+// ----
+// TypeError: (22-27): Invalid array length, expected integer literal or constant expression.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/537_array_length_invalid_expression_int_divides_bool.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/537_array_length_invalid_expression_int_divides_bool.sol
new file mode 100644
index 00000000..92e3c3cf
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/537_array_length_invalid_expression_int_divides_bool.sol
@@ -0,0 +1,5 @@
+contract C {
+ uint[true/1] ids;
+}
+// ----
+// TypeError: (22-28): Invalid array length, expected integer literal or constant expression.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/538_array_length_invalid_expression_bool_divides_int.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/538_array_length_invalid_expression_bool_divides_int.sol
new file mode 100644
index 00000000..26add45c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/538_array_length_invalid_expression_bool_divides_int.sol
@@ -0,0 +1,5 @@
+contract C {
+ uint[1/true] ids;
+}
+// ----
+// TypeError: (22-28): Invalid array length, expected integer literal or constant expression.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/539_array_length_invalid_expression_scientific_literal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/539_array_length_invalid_expression_scientific_literal.sol
new file mode 100644
index 00000000..a0d58f4a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/539_array_length_invalid_expression_scientific_literal.sol
@@ -0,0 +1,5 @@
+contract C {
+ uint[1.111111E1111111111111] ids;
+}
+// ----
+// TypeError: (22-44): Invalid array length, expected integer literal or constant expression.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/540_array_length_invalid_expression_division_by_zero.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/540_array_length_invalid_expression_division_by_zero.sol
new file mode 100644
index 00000000..38a80867
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/540_array_length_invalid_expression_division_by_zero.sol
@@ -0,0 +1,5 @@
+contract C {
+ uint[3/0] ids;
+}
+// ----
+// TypeError: (22-25): Operator / not compatible with types int_const 3 and int_const 0
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/541_warn_about_address_members_on_contract_balance.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/541_warn_about_address_members_on_contract_balance.sol
new file mode 100644
index 00000000..4acb0dc2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/541_warn_about_address_members_on_contract_balance.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() view public {
+ this.balance;
+ }
+}
+// ----
+// Warning: (52-64): Using contract member "balance" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).balance" instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/542_warn_about_address_members_on_contract_transfer.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/542_warn_about_address_members_on_contract_transfer.sol
new file mode 100644
index 00000000..45ee1f5b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/542_warn_about_address_members_on_contract_transfer.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() view public {
+ this.transfer;
+ }
+}
+// ----
+// Warning: (52-65): Using contract member "transfer" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).transfer" instead.
+// TypeError: (52-65): Value transfer to a contract without a payable fallback function.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/543_warn_about_address_members_on_contract_send.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/543_warn_about_address_members_on_contract_send.sol
new file mode 100644
index 00000000..99b7b8b2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/543_warn_about_address_members_on_contract_send.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() view public {
+ this.send;
+ }
+}
+// ----
+// Warning: (52-61): Using contract member "send" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).send" instead.
+// TypeError: (52-61): Value transfer to a contract without a payable fallback function.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/544_warn_about_address_members_on_contract_call.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/544_warn_about_address_members_on_contract_call.sol
new file mode 100644
index 00000000..446410ba
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/544_warn_about_address_members_on_contract_call.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() view public {
+ this.call;
+ }
+}
+// ----
+// Warning: (52-61): Using contract member "call" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).call" instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/545_warn_about_address_members_on_contract_callcode.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/545_warn_about_address_members_on_contract_callcode.sol
new file mode 100644
index 00000000..43ee4d88
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/545_warn_about_address_members_on_contract_callcode.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() view public {
+ this.callcode;
+ }
+}
+// ----
+// Warning: (52-65): Using contract member "callcode" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).callcode" instead.
+// TypeError: (52-65): "callcode" has been deprecated in favour of "delegatecall".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/546_warn_about_address_members_on_contract_delegatecall.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/546_warn_about_address_members_on_contract_delegatecall.sol
new file mode 100644
index 00000000..7cbd832a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/546_warn_about_address_members_on_contract_delegatecall.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() view public {
+ this.delegatecall;
+ }
+}
+// ----
+// Warning: (52-69): Using contract member "delegatecall" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).delegatecall" instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/547_warn_about_address_members_on_non_this_contract_balance.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/547_warn_about_address_members_on_non_this_contract_balance.sol
new file mode 100644
index 00000000..3ba59a9f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/547_warn_about_address_members_on_non_this_contract_balance.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() view public {
+ C c;
+ c.balance;
+ }
+}
+// ----
+// Warning: (65-74): Using contract member "balance" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).balance" instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/548_warn_about_address_members_on_non_this_contract_transfer.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/548_warn_about_address_members_on_non_this_contract_transfer.sol
new file mode 100644
index 00000000..17455124
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/548_warn_about_address_members_on_non_this_contract_transfer.sol
@@ -0,0 +1,9 @@
+contract C {
+ function f() view public {
+ C c;
+ c.transfer;
+ }
+}
+// ----
+// Warning: (65-75): Using contract member "transfer" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).transfer" instead.
+// TypeError: (65-75): Value transfer to a contract without a payable fallback function.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/549_warn_about_address_members_on_non_this_contract_send.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/549_warn_about_address_members_on_non_this_contract_send.sol
new file mode 100644
index 00000000..ca0630c4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/549_warn_about_address_members_on_non_this_contract_send.sol
@@ -0,0 +1,9 @@
+contract C {
+ function f() view public {
+ C c;
+ c.send;
+ }
+}
+// ----
+// Warning: (65-71): Using contract member "send" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).send" instead.
+// TypeError: (65-71): Value transfer to a contract without a payable fallback function.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/550_warn_about_address_members_on_non_this_contract_call.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/550_warn_about_address_members_on_non_this_contract_call.sol
new file mode 100644
index 00000000..c06e0f61
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/550_warn_about_address_members_on_non_this_contract_call.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() pure public {
+ C c;
+ c.call;
+ }
+}
+// ----
+// Warning: (65-71): Using contract member "call" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).call" instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/551_warn_about_address_members_on_non_this_contract_callcode.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/551_warn_about_address_members_on_non_this_contract_callcode.sol
new file mode 100644
index 00000000..3c1e0280
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/551_warn_about_address_members_on_non_this_contract_callcode.sol
@@ -0,0 +1,9 @@
+contract C {
+ function f() pure public {
+ C c;
+ c.callcode;
+ }
+}
+// ----
+// Warning: (65-75): Using contract member "callcode" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).callcode" instead.
+// TypeError: (65-75): "callcode" has been deprecated in favour of "delegatecall".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/552_warn_about_address_members_on_non_this_contract_delegatecall.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/552_warn_about_address_members_on_non_this_contract_delegatecall.sol
new file mode 100644
index 00000000..8e286945
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/552_warn_about_address_members_on_non_this_contract_delegatecall.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() pure public {
+ C c;
+ c.delegatecall;
+ }
+}
+// ----
+// Warning: (65-79): Using contract member "delegatecall" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).delegatecall" instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/553_no_address_members_on_contract_balance_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/553_no_address_members_on_contract_balance_v050.sol
new file mode 100644
index 00000000..7c4ad16a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/553_no_address_members_on_contract_balance_v050.sol
@@ -0,0 +1,8 @@
+pragma experimental "v0.5.0";
+contract C {
+ function f() public {
+ this.balance;
+ }
+}
+// ----
+// TypeError: (77-89): Member "balance" not found or not visible after argument-dependent lookup in contract C
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/554_no_address_members_on_contract_transfer_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/554_no_address_members_on_contract_transfer_v050.sol
new file mode 100644
index 00000000..74bdabd2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/554_no_address_members_on_contract_transfer_v050.sol
@@ -0,0 +1,8 @@
+pragma experimental "v0.5.0";
+contract C {
+ function f() public {
+ this.transfer;
+ }
+}
+// ----
+// TypeError: (77-90): Member "transfer" not found or not visible after argument-dependent lookup in contract C
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/555_no_address_members_on_contract_send_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/555_no_address_members_on_contract_send_v050.sol
new file mode 100644
index 00000000..0852e47e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/555_no_address_members_on_contract_send_v050.sol
@@ -0,0 +1,8 @@
+pragma experimental "v0.5.0";
+contract C {
+ function f() public {
+ this.send;
+ }
+}
+// ----
+// TypeError: (77-86): Member "send" not found or not visible after argument-dependent lookup in contract C
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/556_no_address_members_on_contract_call_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/556_no_address_members_on_contract_call_v050.sol
new file mode 100644
index 00000000..b9a226ad
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/556_no_address_members_on_contract_call_v050.sol
@@ -0,0 +1,8 @@
+pragma experimental "v0.5.0";
+contract C {
+ function f() public {
+ this.call;
+ }
+}
+// ----
+// TypeError: (77-86): Member "call" not found or not visible after argument-dependent lookup in contract C
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/557_no_address_members_on_contract_callcode_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/557_no_address_members_on_contract_callcode_v050.sol
new file mode 100644
index 00000000..95198a94
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/557_no_address_members_on_contract_callcode_v050.sol
@@ -0,0 +1,8 @@
+pragma experimental "v0.5.0";
+contract C {
+ function f() public {
+ this.callcode;
+ }
+}
+// ----
+// TypeError: (77-90): Member "callcode" not found or not visible after argument-dependent lookup in contract C
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/558_no_address_members_on_contract_delegatecall_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/558_no_address_members_on_contract_delegatecall_v050.sol
new file mode 100644
index 00000000..b7a7053e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/558_no_address_members_on_contract_delegatecall_v050.sol
@@ -0,0 +1,8 @@
+pragma experimental "v0.5.0";
+contract C {
+ function f() public {
+ this.delegatecall;
+ }
+}
+// ----
+// TypeError: (77-94): Member "delegatecall" not found or not visible after argument-dependent lookup in contract C
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/559_no_warning_for_using_members_that_look_like_address_members.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/559_no_warning_for_using_members_that_look_like_address_members.sol
new file mode 100644
index 00000000..9355853a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/559_no_warning_for_using_members_that_look_like_address_members.sol
@@ -0,0 +1,7 @@
+pragma experimental "v0.5.0";
+contract C {
+ function transfer(uint) public;
+ function f() public {
+ this.transfer(10);
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/560_event_emit_simple.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/560_event_emit_simple.sol
new file mode 100644
index 00000000..445c9949
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/560_event_emit_simple.sol
@@ -0,0 +1,6 @@
+contract C {
+ event e();
+ function f() public {
+ emit e();
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/561_event_emit_complex.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/561_event_emit_complex.sol
new file mode 100644
index 00000000..19448615
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/561_event_emit_complex.sol
@@ -0,0 +1,7 @@
+contract C {
+ event e(uint a, string b);
+ function f() public {
+ emit e(2, "abc");
+ emit e({b: "abc", a: 8});
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/562_event_emit_foreign_class.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/562_event_emit_foreign_class.sol
new file mode 100644
index 00000000..afac609a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/562_event_emit_foreign_class.sol
@@ -0,0 +1,7 @@
+contract A { event e(uint a, string b); }
+contract C is A {
+ function f() public {
+ emit A.e(2, "abc");
+ emit A.e({b: "abc", a: 8});
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/563_event_without_emit_deprecated.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/563_event_without_emit_deprecated.sol
new file mode 100644
index 00000000..e9a56671
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/563_event_without_emit_deprecated.sol
@@ -0,0 +1,8 @@
+contract C {
+ event e();
+ function f() public {
+ e();
+ }
+}
+// ----
+// TypeError: (62-65): Event invocations have to be prefixed by "emit".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/564_events_without_emit_deprecated_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/564_events_without_emit_deprecated_v050.sol
new file mode 100644
index 00000000..e148d65a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/564_events_without_emit_deprecated_v050.sol
@@ -0,0 +1,9 @@
+pragma experimental "v0.5.0";
+contract C {
+ event e();
+ function f() public {
+ e();
+ }
+}
+// ----
+// TypeError: (92-95): Event invocations have to be prefixed by "emit".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/566_require_visibility_specifiers.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/566_require_visibility_specifiers.sol
new file mode 100644
index 00000000..7330ef8d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/566_require_visibility_specifiers.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f() pure { }
+}
+// ----
+// Warning: (17-38): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/567_require_visibility_specifiers_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/567_require_visibility_specifiers_v050.sol
new file mode 100644
index 00000000..ec7c0937
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/567_require_visibility_specifiers_v050.sol
@@ -0,0 +1,6 @@
+pragma experimental "v0.5.0";
+contract C {
+ function f() pure { }
+}
+// ----
+// SyntaxError: (47-68): No visibility specified.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/568_blockhash.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/568_blockhash.sol
new file mode 100644
index 00000000..f6cc63a5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/568_blockhash.sol
@@ -0,0 +1,3 @@
+contract C {
+ function f() public view returns (bytes32) { return blockhash(3); }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/569_block_blockhash_deprecated.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/569_block_blockhash_deprecated.sol
new file mode 100644
index 00000000..f2e5a2c4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/569_block_blockhash_deprecated.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public view returns (bytes32) {
+ return block.blockhash(3);
+ }
+}
+// ----
+// Warning: (77-92): "block.blockhash()" has been deprecated in favor of "blockhash()"
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/570_block_blockhash_deprecated_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/570_block_blockhash_deprecated_v050.sol
new file mode 100644
index 00000000..b954eab7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/570_block_blockhash_deprecated_v050.sol
@@ -0,0 +1,6 @@
+pragma experimental "v0.5.0";
+contract C {
+ function f() public returns (bytes32) { return block.blockhash(3); }
+}
+// ----
+// TypeError: (94-109): "block.blockhash()" has been deprecated in favor of "blockhash()"
diff --git a/test/libsolidity/syntaxTests/parsing/arrays_in_events.sol b/test/libsolidity/syntaxTests/parsing/arrays_in_events.sol
new file mode 100644
index 00000000..edbc9665
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/arrays_in_events.sol
@@ -0,0 +1,3 @@
+contract c {
+ event e(uint[10] a, bytes7[8] indexed b, c[3] x);
+}
diff --git a/test/libsolidity/syntaxTests/parsing/arrays_in_expressions.sol b/test/libsolidity/syntaxTests/parsing/arrays_in_expressions.sol
new file mode 100644
index 00000000..626e865e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/arrays_in_expressions.sol
@@ -0,0 +1,8 @@
+contract c {
+ function f() { c[10] a = 7; uint8[10 * 2] x; }
+}
+// ----
+// Warning: (32-39): Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning.
+// Warning: (45-60): Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning.
+// TypeError: (32-43): Type int_const 7 is not implicitly convertible to expected type contract c[10] storage pointer.
+// Warning: (45-60): Uninitialized storage pointer. Did you mean '<type> memory x'?
diff --git a/test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol b/test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol
new file mode 100644
index 00000000..9181222e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol
@@ -0,0 +1,6 @@
+contract c {
+ uint[10] a;
+ uint[] a2;
+ struct x { uint[2**20] b; y[0] c; }
+ struct y { uint d; mapping(uint=>x)[] e; }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/calling_function.sol b/test/libsolidity/syntaxTests/parsing/calling_function.sol
new file mode 100644
index 00000000..4c4fc1fc
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/calling_function.sol
@@ -0,0 +1,9 @@
+contract test {
+ function f() {
+ function() returns(function() returns(function() returns(function() returns(uint)))) x;
+ uint y;
+ y = x()()()();
+ }
+}
+// ----
+// Warning: (20-175): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/parsing/conditional_multiple.sol b/test/libsolidity/syntaxTests/parsing/conditional_multiple.sol
new file mode 100644
index 00000000..c7d11ed6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/conditional_multiple.sol
@@ -0,0 +1,9 @@
+contract A {
+ function f() {
+ uint x = 3 < 0 ? 2 > 1 ? 2 : 1 : 7 > 2 ? 7 : 6;
+ }
+}
+// ----
+// Warning: (17-93): No visibility specified. Defaulting to "public".
+// Warning: (40-46): Unused local variable.
+// Warning: (17-93): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/conditional_true_false_literal.sol b/test/libsolidity/syntaxTests/parsing/conditional_true_false_literal.sol
new file mode 100644
index 00000000..90974e96
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/conditional_true_false_literal.sol
@@ -0,0 +1,11 @@
+contract A {
+ function f() {
+ uint x = true ? 1 : 0;
+ uint y = false ? 0 : 1;
+ }
+}
+// ----
+// Warning: (17-100): No visibility specified. Defaulting to "public".
+// Warning: (40-46): Unused local variable.
+// Warning: (71-77): Unused local variable.
+// Warning: (17-100): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/conditional_with_assignment.sol b/test/libsolidity/syntaxTests/parsing/conditional_with_assignment.sol
new file mode 100644
index 00000000..7489aaf9
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/conditional_with_assignment.sol
@@ -0,0 +1,8 @@
+contract A {
+ function f() public pure {
+ uint y = 1;
+ uint x = 3 < 0 ? y = 3 : 6;
+ true ? x = 3 : 4;
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol b/test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol
new file mode 100644
index 00000000..35da69c6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol
@@ -0,0 +1,11 @@
+contract A {
+ function f() {
+ uint x = 3 > 0 ? 3 : 0;
+ uint y = (3 > 0) ? 3 : 0;
+ }
+}
+// ----
+// Warning: (17-103): No visibility specified. Defaulting to "public".
+// Warning: (40-46): Unused local variable.
+// Warning: (72-78): Unused local variable.
+// Warning: (17-103): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/conditional_with_variables.sol b/test/libsolidity/syntaxTests/parsing/conditional_with_variables.sol
new file mode 100644
index 00000000..eb4c7091
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/conditional_with_variables.sol
@@ -0,0 +1,13 @@
+contract A {
+ function f() {
+ uint x = 3;
+ uint y = 1;
+ uint z = (x > y) ? x : y;
+ uint w = x > y ? x : y;
+ }
+}
+// ----
+// Warning: (17-143): No visibility specified. Defaulting to "public".
+// Warning: (80-86): Unused local variable.
+// Warning: (114-120): Unused local variable.
+// Warning: (17-143): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol b/test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol
new file mode 100644
index 00000000..8be9667a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol
@@ -0,0 +1,14 @@
+contract A {
+ fixed40x40 storeMe;
+ function f(ufixed x, fixed32x32 y) {
+ ufixed8x8 a;
+ fixed b;
+ }
+}
+// ----
+// Warning: (41-121): No visibility specified. Defaulting to "public".
+// Warning: (52-60): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (62-74): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (86-97): Unused local variable.
+// Warning: (107-114): Unused local variable.
+// Warning: (41-121): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/declaring_fixed_literal_variables.sol b/test/libsolidity/syntaxTests/parsing/declaring_fixed_literal_variables.sol
new file mode 100644
index 00000000..b0d938a0
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/declaring_fixed_literal_variables.sol
@@ -0,0 +1,5 @@
+contract A {
+ fixed40x40 pi = 3.14;
+}
+// ----
+// TypeError: (33-37): Type rational_const 157 / 50 is not implicitly convertible to expected type fixed40x40. Try converting to type ufixed16x2 or use an explicit conversion.
diff --git a/test/libsolidity/syntaxTests/parsing/else_if_statement.sol b/test/libsolidity/syntaxTests/parsing/else_if_statement.sol
new file mode 100644
index 00000000..37763697
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/else_if_statement.sol
@@ -0,0 +1,8 @@
+contract test {
+ function fun(uint256 a) returns (uint8 b) {
+ if (a < 0) b = 0x67; else if (a == 0) b = 0x12; else b = 0x78;
+ }
+}
+// ----
+// Warning: (20-140): No visibility specified. Defaulting to "public".
+// Warning: (20-140): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol b/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol
new file mode 100644
index 00000000..4c4a1217
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol
@@ -0,0 +1,10 @@
+contract c {
+ enum validEnum { Value1, Value2, Value3, Value4 }
+ function c() {
+ a = validEnum.Value3;
+ }
+ validEnum a;
+}
+// ----
+// Warning: (71-121): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
+// Warning: (71-121): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/parsing/event.sol b/test/libsolidity/syntaxTests/parsing/event.sol
new file mode 100644
index 00000000..2aaa873f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/event.sol
@@ -0,0 +1,3 @@
+contract c {
+ event e();
+}
diff --git a/test/libsolidity/syntaxTests/parsing/event_arguments.sol b/test/libsolidity/syntaxTests/parsing/event_arguments.sol
new file mode 100644
index 00000000..3228853a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/event_arguments.sol
@@ -0,0 +1,3 @@
+contract c {
+ event e(uint a, bytes32 s);
+}
diff --git a/test/libsolidity/syntaxTests/parsing/event_arguments_indexed.sol b/test/libsolidity/syntaxTests/parsing/event_arguments_indexed.sol
new file mode 100644
index 00000000..d603fc08
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/event_arguments_indexed.sol
@@ -0,0 +1,3 @@
+contract c {
+ event e(uint a, bytes32 indexed s, bool indexed b);
+}
diff --git a/test/libsolidity/syntaxTests/parsing/exp_expression.sol b/test/libsolidity/syntaxTests/parsing/exp_expression.sol
new file mode 100644
index 00000000..cdabb996
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/exp_expression.sol
@@ -0,0 +1,9 @@
+contract test {
+ function fun(uint256 a) {
+ uint256 x = 3 ** a;
+ }
+}
+// ----
+// Warning: (20-79): No visibility specified. Defaulting to "public".
+// Warning: (54-63): Unused local variable.
+// Warning: (20-79): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/external_function.sol b/test/libsolidity/syntaxTests/parsing/external_function.sol
new file mode 100644
index 00000000..3aa3ceec
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/external_function.sol
@@ -0,0 +1,5 @@
+contract c {
+ function x() external {}
+}
+// ----
+// Warning: (17-41): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/fallback_function.sol b/test/libsolidity/syntaxTests/parsing/fallback_function.sol
new file mode 100644
index 00000000..de32b030
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/fallback_function.sol
@@ -0,0 +1,5 @@
+contract c {
+ function() { }
+}
+// ----
+// Warning: (17-31): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol b/test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol
new file mode 100644
index 00000000..bd86f2f5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol
@@ -0,0 +1,13 @@
+contract test {
+ function fun(uint256 a) {
+ uint256 i =0;
+ for (i = 0; i < 10; i++) {
+ uint256 x = i; break; continue;
+ }
+ }
+}
+// ----
+// Warning: (20-162): No visibility specified. Defaulting to "public".
+// Warning: (33-42): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (115-124): Unused local variable.
+// Warning: (20-162): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/for_loop_simple_noexpr.sol b/test/libsolidity/syntaxTests/parsing/for_loop_simple_noexpr.sol
new file mode 100644
index 00000000..4a27e0fb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/for_loop_simple_noexpr.sol
@@ -0,0 +1,13 @@
+contract test {
+ function fun(uint256 a) {
+ uint256 i =0;
+ for (;;) {
+ uint256 x = i; break; continue;
+ }
+ }
+ }
+// ----
+// Warning: (24-170): No visibility specified. Defaulting to "public".
+// Warning: (37-46): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (115-124): Unused local variable.
+// Warning: (24-170): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/for_loop_single_stmt_body.sol b/test/libsolidity/syntaxTests/parsing/for_loop_single_stmt_body.sol
new file mode 100644
index 00000000..3df88ef5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/for_loop_single_stmt_body.sol
@@ -0,0 +1,11 @@
+contract test {
+ function fun(uint256 a) {
+ uint256 i = 0;
+ for (i = 0; i < 10; i++)
+ continue;
+ }
+}
+// ----
+// Warning: (20-129): No visibility specified. Defaulting to "public".
+// Warning: (33-42): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (20-129): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/for_loop_vardef_initexpr.sol b/test/libsolidity/syntaxTests/parsing/for_loop_vardef_initexpr.sol
new file mode 100644
index 00000000..a7c5e8bb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/for_loop_vardef_initexpr.sol
@@ -0,0 +1,12 @@
+contract test {
+ function fun(uint256 a) {
+ for (uint256 i = 0; i < 10; i++) {
+ uint256 x = i; break; continue;
+ }
+ }
+}
+// ----
+// Warning: (20-148): No visibility specified. Defaulting to "public".
+// Warning: (33-42): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (101-110): Unused local variable.
+// Warning: (20-148): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/from_is_not_keyword.sol b/test/libsolidity/syntaxTests/parsing/from_is_not_keyword.sol
new file mode 100644
index 00000000..38175572
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/from_is_not_keyword.sol
@@ -0,0 +1,3 @@
+// "from" is not a keyword although it is used as a keyword in import directives.
+contract from {
+}
diff --git a/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol b/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol
new file mode 100644
index 00000000..c7a023ac
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol
@@ -0,0 +1,10 @@
+contract test {
+ uint256 stateVar;
+ // We won't see this comment
+ function functionName(bytes32 input) returns (bytes32 out) {}
+}
+// ----
+// Warning: (75-136): No visibility specified. Defaulting to "public".
+// Warning: (97-110): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (121-132): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (75-136): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/function_type_as_parameter.sol b/test/libsolidity/syntaxTests/parsing/function_type_as_parameter.sol
new file mode 100644
index 00000000..4075d74a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/function_type_as_parameter.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f(function(uint) external returns (uint) g) internal returns (uint a) {
+ return g(1);
+ }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable.sol b/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable.sol
new file mode 100644
index 00000000..e3d41f48
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable.sol
@@ -0,0 +1,3 @@
+contract test {
+ function (uint, uint) internal returns (uint) f1;
+}
diff --git a/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol b/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol
new file mode 100644
index 00000000..3b784733
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol
@@ -0,0 +1,10 @@
+contract test {
+ function f(uint x, uint y) returns (uint a) {}
+ function (uint, uint) internal returns (uint) f1 = f;
+}
+// ----
+// Warning: (20-66): No visibility specified. Defaulting to "public".
+// Warning: (31-37): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (39-45): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (56-62): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (20-66): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol b/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol
new file mode 100644
index 00000000..fd6447c7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol
@@ -0,0 +1,15 @@
+contract test {
+ function f(uint x, uint y) returns (uint a) {}
+ function g() {
+ function (uint, uint) internal returns (uint) f1 = f;
+ }
+}
+// ----
+// Warning: (20-66): No visibility specified. Defaulting to "public".
+// Warning: (31-37): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (39-45): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (56-62): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (71-153): No visibility specified. Defaulting to "public".
+// Warning: (94-142): Unused local variable.
+// Warning: (20-66): Function state mutability can be restricted to pure
+// Warning: (71-153): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/function_type_in_struct.sol b/test/libsolidity/syntaxTests/parsing/function_type_in_struct.sol
new file mode 100644
index 00000000..c7703b47
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/function_type_in_struct.sol
@@ -0,0 +1,10 @@
+contract test {
+ struct S {
+ function (uint x, uint y) internal returns (uint) f;
+ function (uint, uint) external returns (uint) g;
+ uint d;
+ }
+}
+// ----
+// Warning: (49-55): Naming function type parameters is deprecated.
+// Warning: (57-63): Naming function type parameters is deprecated.
diff --git a/test/libsolidity/syntaxTests/parsing/if_statement.sol b/test/libsolidity/syntaxTests/parsing/if_statement.sol
new file mode 100644
index 00000000..451fba1f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/if_statement.sol
@@ -0,0 +1,9 @@
+contract test {
+ function fun(uint256 a) returns (uint) {
+ if (a >= 8) { return 2; } else { uint b = 7; }
+ }
+}
+// ----
+// Warning: (20-121): No visibility specified. Defaulting to "public".
+// Warning: (102-108): Unused local variable.
+// Warning: (20-121): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol b/test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol
new file mode 100644
index 00000000..f42f8f16
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol
@@ -0,0 +1,9 @@
+contract c {
+ uint[] a;
+ function f() returns (uint, uint) {
+ a = [1,2,3];
+ return (a[3], [2,3,4][0]);
+ }
+}
+// ----
+// Warning: (31-128): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/parsing/library_simple.sol b/test/libsolidity/syntaxTests/parsing/library_simple.sol
new file mode 100644
index 00000000..fcf2638e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/library_simple.sol
@@ -0,0 +1,6 @@
+library Lib {
+ function f() { }
+}
+// ----
+// Warning: (18-34): No visibility specified. Defaulting to "public".
+// Warning: (18-34): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol
new file mode 100644
index 00000000..452b52c7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol
@@ -0,0 +1,16 @@
+contract c {
+ function f()
+ {
+ a = 1 wei;
+ b = 2 szabo;
+ c = 3 finney;
+ b = 4 ether;
+ }
+ uint256 a;
+ uint256 b;
+ uint256 c;
+ uint256 d;
+}
+// ----
+// Warning: (163-172): This declaration shadows an existing declaration.
+// Warning: (17-128): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol
new file mode 100644
index 00000000..d2cdc875
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol
@@ -0,0 +1,10 @@
+contract c {
+ function c ()
+ {
+ a = 1 wei * 100 wei + 7 szabo - 3;
+ }
+ uint256 a;
+}
+// ----
+// Warning: (17-86): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
+// Warning: (17-86): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol
new file mode 100644
index 00000000..5d6c8dc5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol
@@ -0,0 +1,12 @@
+contract Foo {
+ function f() {
+ uint[] storage x;
+ uint[] memory y;
+ }
+}
+// ----
+// Warning: (42-58): Uninitialized storage pointer.
+// Warning: (19-90): No visibility specified. Defaulting to "public".
+// Warning: (42-58): Unused local variable.
+// Warning: (68-83): Unused local variable.
+// Warning: (19-90): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol
new file mode 100644
index 00000000..72b6ce84
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol
@@ -0,0 +1,5 @@
+contract Foo {
+ function f(uint[] storage constant x, uint[] memory y) internal { }
+}
+// ----
+// TypeError: (30-55): Data location has to be "memory" (or unspecified) for constants.
diff --git a/test/libsolidity/syntaxTests/parsing/mapping.sol b/test/libsolidity/syntaxTests/parsing/mapping.sol
new file mode 100644
index 00000000..d6bf3f14
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/mapping.sol
@@ -0,0 +1,3 @@
+contract test {
+ mapping(address => bytes32) names;
+}
diff --git a/test/libsolidity/syntaxTests/parsing/mapping_and_array_of_functions.sol b/test/libsolidity/syntaxTests/parsing/mapping_and_array_of_functions.sol
new file mode 100644
index 00000000..b7cf34e4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/mapping_and_array_of_functions.sol
@@ -0,0 +1,6 @@
+contract test {
+ mapping (address => function() internal returns (uint)) a;
+ mapping (address => function() external) b;
+ mapping (address => function() external[]) c;
+ function() external[] d;
+}
diff --git a/test/libsolidity/syntaxTests/parsing/mapping_in_struct.sol b/test/libsolidity/syntaxTests/parsing/mapping_in_struct.sol
new file mode 100644
index 00000000..980d5750
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/mapping_in_struct.sol
@@ -0,0 +1,7 @@
+contract test {
+ struct test_struct {
+ address addr;
+ uint256 count;
+ mapping(bytes32 => test_struct) self_reference;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/mapping_to_mapping_in_struct.sol b/test/libsolidity/syntaxTests/parsing/mapping_to_mapping_in_struct.sol
new file mode 100644
index 00000000..c06220b7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/mapping_to_mapping_in_struct.sol
@@ -0,0 +1,6 @@
+contract test {
+ struct test_struct {
+ address addr;
+ mapping (uint64 => mapping (bytes32 => uint)) complex_mapping;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/modifier.sol b/test/libsolidity/syntaxTests/parsing/modifier.sol
new file mode 100644
index 00000000..b995ce89
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/modifier.sol
@@ -0,0 +1,3 @@
+contract c {
+ modifier mod { if (msg.sender == 0x0000000000000000000000000000000000000000) _; }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/modifier_arguments.sol b/test/libsolidity/syntaxTests/parsing/modifier_arguments.sol
new file mode 100644
index 00000000..27b5b13b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/modifier_arguments.sol
@@ -0,0 +1,3 @@
+contract c {
+ modifier mod(address a) { if (msg.sender == a) _; }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol b/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol
new file mode 100644
index 00000000..cb2f2985
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol
@@ -0,0 +1,8 @@
+contract c {
+ modifier mod1(uint a) { if (msg.sender == address(a)) _; }
+ modifier mod2 { if (msg.sender == address(2)) _; }
+ function f() mod1(7) mod2 { }
+}
+// ----
+// Warning: (135-164): No visibility specified. Defaulting to "public".
+// Warning: (135-164): Function state mutability can be restricted to view
diff --git a/test/libsolidity/syntaxTests/parsing/multi_arrays.sol b/test/libsolidity/syntaxTests/parsing/multi_arrays.sol
new file mode 100644
index 00000000..ef20ecee
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/multi_arrays.sol
@@ -0,0 +1,3 @@
+contract c {
+ mapping(uint => mapping(uint => int8)[8][][9])[] x;
+}
diff --git a/test/libsolidity/syntaxTests/parsing/multi_variable_declarations.sol b/test/libsolidity/syntaxTests/parsing/multi_variable_declarations.sol
index 818999df..1984ed36 100644
--- a/test/libsolidity/syntaxTests/parsing/multi_variable_declarations.sol
+++ b/test/libsolidity/syntaxTests/parsing/multi_variable_declarations.sol
@@ -1,29 +1,15 @@
contract C {
- function f() {
- var (a,b,c) = g();
- var (d) = 2;
- var (,e) = 3;
- var (f,) = 4;
- var (x,,) = g();
- var (,y,) = g();
- var () = g();
- var (,,) = g();
+ function f() pure public {
+ (uint a, uint b, uint c) = g();
+ (uint d) = 2;
+ (, uint e) = 3;
+ (uint h,) = 4;
+ (uint x,,) = g();
+ (, uint y,) = g();
+ a; b; c; d; e; h; x; y;
}
- function g() returns (uint, uint, uint) {}
+ function g() pure public returns (uint, uint, uint) {}
}
// ----
-// Warning: (36-37): Use of the "var" keyword is deprecated.
-// Warning: (38-39): Use of the "var" keyword is deprecated.
-// Warning: (40-41): Use of the "var" keyword is deprecated.
-// Warning: (57-58): Use of the "var" keyword is deprecated.
-// Warning: (73-74): Use of the "var" keyword is deprecated.
-// Warning: (88-89): Use of the "var" keyword is deprecated.
-// Warning: (104-105): Use of the "var" keyword is deprecated.
-// Warning: (124-125): Use of the "var" keyword is deprecated.
-// Warning: (88-89): This declaration shadows an existing declaration.
-// Warning: (52-63): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning.
-// Warning: (67-79): Different number of components on the left hand side (2) than on the right hand side (1).
-// Warning: (67-79): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning.
-// Warning: (83-95): Different number of components on the left hand side (2) than on the right hand side (1).
-// Warning: (83-95): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning.
-// TypeError: (137-149): Too many components (3) in value for variable assignment (0) needed
+// Warning: (93-107): Different number of components on the left hand side (2) than on the right hand side (1).
+// Warning: (111-124): Different number of components on the left hand side (2) than on the right hand side (1).
diff --git a/test/libsolidity/syntaxTests/parsing/multiple_event_arg_trailing_comma.sol b/test/libsolidity/syntaxTests/parsing/multiple_event_arg_trailing_comma.sol
new file mode 100644
index 00000000..bfbe7e5c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/multiple_event_arg_trailing_comma.sol
@@ -0,0 +1,6 @@
+contract test {
+ event Test(uint a, uint b,);
+ function(uint a) {}
+}
+// ----
+// ParserError: (45-46): Unexpected trailing comma in parameter list.
diff --git a/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol b/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol
new file mode 100644
index 00000000..95a4d1e7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol
@@ -0,0 +1,28 @@
+contract test {
+ uint256 stateVar;
+ /// This is test function 1
+ function functionName1(bytes32 input) returns (bytes32 out) {}
+ /// This is test function 2
+ function functionName2(bytes32 input) returns (bytes32 out) {}
+ // nothing to see here
+ function functionName3(bytes32 input) returns (bytes32 out) {}
+ /// This is test function 4
+ function functionName4(bytes32 input) returns (bytes32 out) {}
+}
+// ----
+// Warning: (74-136): No visibility specified. Defaulting to "public".
+// Warning: (97-110): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (121-132): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (173-235): No visibility specified. Defaulting to "public".
+// Warning: (196-209): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (220-231): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (267-329): No visibility specified. Defaulting to "public".
+// Warning: (290-303): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (314-325): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (366-428): No visibility specified. Defaulting to "public".
+// Warning: (389-402): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (413-424): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (74-136): Function state mutability can be restricted to pure
+// Warning: (173-235): Function state mutability can be restricted to pure
+// Warning: (267-329): Function state mutability can be restricted to pure
+// Warning: (366-428): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/multiple_modifier_arg_trailing_comma.sol b/test/libsolidity/syntaxTests/parsing/multiple_modifier_arg_trailing_comma.sol
new file mode 100644
index 00000000..eb206fb7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/multiple_modifier_arg_trailing_comma.sol
@@ -0,0 +1,6 @@
+contract test {
+ modifier modTest(uint a, uint b,) { _; }
+ function(uint a) {}
+}
+// ----
+// ParserError: (51-52): Unexpected trailing comma in parameter list.
diff --git a/test/libsolidity/syntaxTests/parsing/multiple_return_param_trailing_comma.sol b/test/libsolidity/syntaxTests/parsing/multiple_return_param_trailing_comma.sol
new file mode 100644
index 00000000..2dd8f196
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/multiple_return_param_trailing_comma.sol
@@ -0,0 +1,5 @@
+contract test {
+ function() returns (uint a, uint b,) {}
+}
+// ----
+// ParserError: (54-55): Unexpected trailing comma in parameter list.
diff --git a/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol b/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol
new file mode 100644
index 00000000..e331440d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol
@@ -0,0 +1,9 @@
+contract c {
+ function fun() returns (uint r) {
+ uint _ = 8;
+ return _ + 1;
+ }
+}
+// ----
+// Warning: (17-98): No visibility specified. Defaulting to "public".
+// Warning: (17-98): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/struct_definition.sol b/test/libsolidity/syntaxTests/parsing/struct_definition.sol
new file mode 100644
index 00000000..0c859e5d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/struct_definition.sol
@@ -0,0 +1,7 @@
+contract test {
+ uint256 stateVar;
+ struct MyStructName {
+ address addr;
+ uint256 count;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/trailing_dot1.sol b/test/libsolidity/syntaxTests/parsing/trailing_dot1.sol
new file mode 100644
index 00000000..7f26242c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/trailing_dot1.sol
@@ -0,0 +1,7 @@
+contract test {
+ uint256 a = 2.2e10;
+ uint256 b = .5E10;
+ uint256 c = 4.e-2;
+}
+// ----
+// TypeError: (70-73): Member "e" not found or not visible after argument-dependent lookup in int_const 4
diff --git a/test/libsolidity/syntaxTests/parsing/trailing_dot2.sol b/test/libsolidity/syntaxTests/parsing/trailing_dot2.sol
new file mode 100644
index 00000000..38a7ab2d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/trailing_dot2.sol
@@ -0,0 +1,7 @@
+contract test {
+ uint256 a = 2.2e10;
+ uint256 b = .5E10;
+ uint256 c = 2 + 2.;
+}
+// ----
+// ParserError: (76-77): Expected identifier but got ';'
diff --git a/test/libsolidity/syntaxTests/parsing/trailing_dot3.sol b/test/libsolidity/syntaxTests/parsing/trailing_dot3.sol
new file mode 100644
index 00000000..6a126cb3
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/trailing_dot3.sol
@@ -0,0 +1,4 @@
+contract test {
+ uint a = 2.
+// ----
+// ParserError: (29-29): Expected identifier but got end of source
diff --git a/test/libsolidity/syntaxTests/parsing/tuples.sol b/test/libsolidity/syntaxTests/parsing/tuples.sol
index 6f739740..d691da44 100644
--- a/test/libsolidity/syntaxTests/parsing/tuples.sol
+++ b/test/libsolidity/syntaxTests/parsing/tuples.sol
@@ -1,24 +1,17 @@
contract C {
function f() {
uint a = (1);
- var (b,) = (1,);
- var (c,d) = (1, 2 + a);
- var (e,) = (1, 2, b);
+ (uint b,) = (1,);
+ (uint c, uint d) = (1, 2 + a);
+ (uint e,) = (1, 2, b);
(a) = 3;
}
}
// ----
-// Warning: (52-53): Use of the "var" keyword is deprecated.
-// Warning: (71-72): Use of the "var" keyword is deprecated.
-// Warning: (73-74): Use of the "var" keyword is deprecated.
-// Warning: (97-98): Use of the "var" keyword is deprecated.
-// Warning: (47-62): Different number of components on the left hand side (2) than on the right hand side (1).
-// Warning: (47-62): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning.
-// Warning: (66-88): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning.
-// Warning: (92-112): Different number of components on the left hand side (2) than on the right hand side (3).
-// Warning: (92-112): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning.
-// Warning: (14-127): No visibility specified. Defaulting to "public".
-// Warning: (71-72): Unused local variable.
-// Warning: (73-74): Unused local variable.
-// Warning: (97-98): Unused local variable.
-// Warning: (14-127): Function state mutability can be restricted to pure
+// Warning: (47-63): Different number of components on the left hand side (2) than on the right hand side (1).
+// Warning: (100-121): Different number of components on the left hand side (2) than on the right hand side (3).
+// Warning: (14-136): No visibility specified. Defaulting to "public".
+// Warning: (68-74): Unused local variable.
+// Warning: (76-82): Unused local variable.
+// Warning: (101-107): Unused local variable.
+// Warning: (14-136): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/two_exact_functions.sol b/test/libsolidity/syntaxTests/parsing/two_exact_functions.sol
new file mode 100644
index 00000000..0b3dda56
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/two_exact_functions.sol
@@ -0,0 +1,9 @@
+// with support of overloaded functions, during parsing,
+// we can't determine whether they match exactly, however
+// it will throw DeclarationError in following stage.
+contract test {
+ function fun(uint a) returns(uint r) { return a; }
+ function fun(uint a) returns(uint r) { return a; }
+}
+// ----
+// DeclarationError: (189-239): Function with same name and arguments defined twice.
diff --git a/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol b/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol
new file mode 100644
index 00000000..4706a26d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol
@@ -0,0 +1,17 @@
+contract c {
+ uint private a;
+ uint internal b;
+ uint public c;
+ uint d;
+ function f() {}
+ function f_priv() private {}
+ function f_public() public {}
+ function f_internal() internal {}
+}
+// ----
+// Warning: (58-71): This declaration shadows an existing declaration.
+// Warning: (89-104): No visibility specified. Defaulting to "public".
+// Warning: (89-104): Function state mutability can be restricted to pure
+// Warning: (109-137): Function state mutability can be restricted to pure
+// Warning: (142-171): Function state mutability can be restricted to pure
+// Warning: (176-209): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/while_loop.sol b/test/libsolidity/syntaxTests/parsing/while_loop.sol
new file mode 100644
index 00000000..dbb00a69
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/while_loop.sol
@@ -0,0 +1,7 @@
+contract test {
+ function fun() public pure {
+ uint256 x;
+ while (true) { x = 1; break; continue; } x = 9;
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope.sol b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope.sol
index d90ec2d7..36bae6a8 100644
--- a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope.sol
+++ b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope.sol
@@ -5,4 +5,5 @@ contract test {
}
}
// ----
-// DeclarationError: (77-83): Identifier already declared.
+// Warning: (57-63): Unused local variable.
+// Warning: (77-83): Unused local variable.
diff --git a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_050.sol b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_050.sol
deleted file mode 100644
index 06bfe7be..00000000
--- a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_050.sol
+++ /dev/null
@@ -1,10 +0,0 @@
-pragma experimental "v0.5.0";
-contract test {
- function f() pure public {
- { uint x; }
- { uint x; }
- }
-}
-// ----
-// Warning: (87-93): Unused local variable.
-// Warning: (107-113): Unused local variable.
diff --git a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation.sol b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation.sol
index 1a5ff2f9..0c03ec3e 100644
--- a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation.sol
+++ b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation.sol
@@ -5,4 +5,5 @@ contract test {
}
}
// ----
-// DeclarationError: (75-81): Identifier already declared.
+// Warning: (57-63): Unused local variable.
+// Warning: (75-81): Unused local variable.
diff --git a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation_050.sol b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation_050.sol
deleted file mode 100644
index 20ea0349..00000000
--- a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation_050.sol
+++ /dev/null
@@ -1,10 +0,0 @@
-pragma experimental "v0.5.0";
-contract test {
- function f() pure public {
- { uint x; }
- uint x;
- }
-}
-// ----
-// Warning: (87-93): Unused local variable.
-// Warning: (105-111): Unused local variable.
diff --git a/test/libsolidity/syntaxTests/scoping/scoping.sol b/test/libsolidity/syntaxTests/scoping/scoping.sol
index 34b055d9..dae5a42d 100644
--- a/test/libsolidity/syntaxTests/scoping/scoping.sol
+++ b/test/libsolidity/syntaxTests/scoping/scoping.sol
@@ -1,4 +1,3 @@
-pragma experimental "v0.5.0";
contract test {
function f() public {
{
@@ -8,4 +7,4 @@ contract test {
}
}
// ----
-// DeclarationError: (123-124): Undeclared identifier.
+// DeclarationError: (93-94): Undeclared identifier.
diff --git a/test/libsolidity/syntaxTests/scoping/scoping_activation.sol b/test/libsolidity/syntaxTests/scoping/scoping_activation.sol
index 7334bc49..8522a0e3 100644
--- a/test/libsolidity/syntaxTests/scoping/scoping_activation.sol
+++ b/test/libsolidity/syntaxTests/scoping/scoping_activation.sol
@@ -1,4 +1,3 @@
-pragma experimental "v0.5.0";
contract test {
function f() pure public {
x = 3;
@@ -6,4 +5,4 @@ contract test {
}
}
// ----
-// DeclarationError: (85-86): Undeclared identifier. Did you mean "x"?
+// DeclarationError: (55-56): Undeclared identifier. "x" is not (or not yet) visible at this point.
diff --git a/test/libsolidity/syntaxTests/scoping/scoping_activation_old.sol b/test/libsolidity/syntaxTests/scoping/scoping_activation_old.sol
index d893a889..8522a0e3 100644
--- a/test/libsolidity/syntaxTests/scoping/scoping_activation_old.sol
+++ b/test/libsolidity/syntaxTests/scoping/scoping_activation_old.sol
@@ -4,3 +4,5 @@ contract test {
uint x;
}
}
+// ----
+// DeclarationError: (55-56): Undeclared identifier. "x" is not (or not yet) visible at this point.
diff --git a/test/libsolidity/syntaxTests/scoping/scoping_for.sol b/test/libsolidity/syntaxTests/scoping/scoping_for.sol
index 6e5b7095..a882d1ca 100644
--- a/test/libsolidity/syntaxTests/scoping/scoping_for.sol
+++ b/test/libsolidity/syntaxTests/scoping/scoping_for.sol
@@ -1,4 +1,3 @@
-pragma experimental "v0.5.0";
contract test {
function f() pure public {
for (uint x = 0; x < 10; x ++){
diff --git a/test/libsolidity/syntaxTests/scoping/scoping_for2.sol b/test/libsolidity/syntaxTests/scoping/scoping_for2.sol
index eb74b8ab..f8c5c19b 100644
--- a/test/libsolidity/syntaxTests/scoping/scoping_for2.sol
+++ b/test/libsolidity/syntaxTests/scoping/scoping_for2.sol
@@ -1,4 +1,3 @@
-pragma experimental "v0.5.0";
contract test {
function f() pure public {
for (uint x = 0; x < 10; x ++)
diff --git a/test/libsolidity/syntaxTests/scoping/scoping_for3.sol b/test/libsolidity/syntaxTests/scoping/scoping_for3.sol
index 1814cb47..81e34562 100644
--- a/test/libsolidity/syntaxTests/scoping/scoping_for3.sol
+++ b/test/libsolidity/syntaxTests/scoping/scoping_for3.sol
@@ -1,4 +1,3 @@
-pragma experimental "v0.5.0";
contract test {
function f() pure public {
for (uint x = 0; x < 10; x ++){
@@ -8,4 +7,4 @@ contract test {
}
}
// ----
-// DeclarationError: (154-155): Undeclared identifier.
+// DeclarationError: (124-125): Undeclared identifier.
diff --git a/test/libsolidity/syntaxTests/scoping/scoping_for_decl_in_body.sol b/test/libsolidity/syntaxTests/scoping/scoping_for_decl_in_body.sol
index 3e80b385..28b88525 100644
--- a/test/libsolidity/syntaxTests/scoping/scoping_for_decl_in_body.sol
+++ b/test/libsolidity/syntaxTests/scoping/scoping_for_decl_in_body.sol
@@ -1,4 +1,3 @@
-pragma experimental "v0.5.0";
contract test {
function f() pure public {
for (;; y++){
@@ -7,4 +6,4 @@ contract test {
}
}
// ----
-// DeclarationError: (93-94): Undeclared identifier.
+// DeclarationError: (63-64): Undeclared identifier.
diff --git a/test/libsolidity/syntaxTests/scoping/scoping_old.sol b/test/libsolidity/syntaxTests/scoping/scoping_old.sol
index 83f6b60b..70e5ee0c 100644
--- a/test/libsolidity/syntaxTests/scoping/scoping_old.sol
+++ b/test/libsolidity/syntaxTests/scoping/scoping_old.sol
@@ -4,3 +4,5 @@ contract test {
uint256 x = 2;
}
}
+// ----
+// DeclarationError: (55-56): Undeclared identifier. "x" is not (or not yet) visible at this point.
diff --git a/test/libsolidity/syntaxTests/scoping/scoping_self_use.sol b/test/libsolidity/syntaxTests/scoping/scoping_self_use.sol
index 9e2c0171..a5087c57 100644
--- a/test/libsolidity/syntaxTests/scoping/scoping_self_use.sol
+++ b/test/libsolidity/syntaxTests/scoping/scoping_self_use.sol
@@ -3,3 +3,5 @@ contract test {
uint a = a;
}
}
+// ----
+// DeclarationError: (64-65): Undeclared identifier. "a" is not (or not yet) visible at this point.
diff --git a/test/libsolidity/syntaxTests/scoping/scoping_self_use_050.sol b/test/libsolidity/syntaxTests/scoping/scoping_self_use_050.sol
deleted file mode 100644
index ab3dcefb..00000000
--- a/test/libsolidity/syntaxTests/scoping/scoping_self_use_050.sol
+++ /dev/null
@@ -1,8 +0,0 @@
-pragma experimental "v0.5.0";
-contract test {
- function f() pure public {
- uint a = a;
- }
-}
-// ----
-// DeclarationError: (94-95): Undeclared identifier. Did you mean "a"?
diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol
index d10c1718..e46a9050 100644
--- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol
+++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol
@@ -1,7 +1,7 @@
contract C {
struct S { uint x; }
S s;
- struct T { }
+ struct T { uint y; }
T t;
enum A { X, Y }
function f() public pure {
@@ -9,9 +9,8 @@ contract C {
}
}
// ----
-// Warning: (51-63): Defining empty structs is deprecated.
-// TypeError: (168-169): This type cannot be encoded.
-// TypeError: (171-172): This type cannot be encoded.
+// TypeError: (176-177): This type cannot be encoded.
// TypeError: (179-180): This type cannot be encoded.
-// TypeError: (182-186): This type cannot be encoded.
-// TypeError: (188-194): This type cannot be encoded.
+// TypeError: (187-188): This type cannot be encoded.
+// TypeError: (190-194): This type cannot be encoded.
+// TypeError: (196-202): This type cannot be encoded.
diff --git a/test/libsolidity/syntaxTests/tight_packing_literals.sol b/test/libsolidity/syntaxTests/tight_packing_literals.sol
index a190adc3..d6c7f0ba 100644
--- a/test/libsolidity/syntaxTests/tight_packing_literals.sol
+++ b/test/libsolidity/syntaxTests/tight_packing_literals.sol
@@ -2,9 +2,6 @@ contract C {
function f() pure public returns (bytes32) {
return keccak256(1);
}
- function g() pure public returns (bytes32) {
- return sha3(1);
- }
function h() pure public returns (bytes32) {
return sha256(1);
}
@@ -20,14 +17,10 @@ contract C {
// Warning: (87-88): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
// Warning: (77-89): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
// Warning: (77-89): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory.
-// Warning: (161-168): "sha3" has been deprecated in favour of "keccak256"
-// Warning: (166-167): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
-// Warning: (161-168): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
-// Warning: (161-168): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory.
-// Warning: (247-248): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
-// Warning: (240-249): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
-// Warning: (240-249): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory.
-// Warning: (331-332): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
-// Warning: (321-333): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
-// Warning: (321-333): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory.
-// Warning: (420-421): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
+// Warning: (168-169): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
+// Warning: (161-170): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
+// Warning: (161-170): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory.
+// Warning: (252-253): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
+// Warning: (242-254): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
+// Warning: (242-254): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory.
+// Warning: (341-342): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
diff --git a/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol b/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol
index 2b9b688a..27665b52 100644
--- a/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol
+++ b/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol
@@ -2,9 +2,6 @@ contract C {
function f() pure public returns (bytes32) {
return keccak256(uint8(1));
}
- function g() pure public returns (bytes32) {
- return sha3(uint8(1));
- }
function h() pure public returns (bytes32) {
return sha256(uint8(1));
}
@@ -21,10 +18,7 @@ contract C {
// ----
// Warning: (77-96): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
// Warning: (77-96): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory.
-// Warning: (168-182): "sha3" has been deprecated in favour of "keccak256"
-// Warning: (168-182): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
-// Warning: (168-182): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory.
-// Warning: (254-270): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
-// Warning: (254-270): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory.
-// Warning: (342-361): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
-// Warning: (342-361): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory.
+// Warning: (168-184): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
+// Warning: (168-184): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory.
+// Warning: (256-275): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
+// Warning: (256-275): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory.
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/warn_fill_vardecl.sol b/test/libsolidity/syntaxTests/tupleAssignments/warn_fill_vardecl.sol
index 1d243c7c..23484567 100644
--- a/test/libsolidity/syntaxTests/tupleAssignments/warn_fill_vardecl.sol
+++ b/test/libsolidity/syntaxTests/tupleAssignments/warn_fill_vardecl.sol
@@ -1,11 +1,8 @@
contract C {
function f() public pure returns (uint, uint, uint, uint) {
- // Can later be replaced by (uint a, uint b,) = f();
- var (a,b,) = f();
+ (uint a, uint b,) = f();
a; b;
}
}
// ----
-// Warning: (136-137): Use of the "var" keyword is deprecated.
-// Warning: (138-139): Use of the "var" keyword is deprecated.
-// Warning: (131-147): Different number of components on the left hand side (3) than on the right hand side (4).
+// Warning: (76-99): Different number of components on the left hand side (3) than on the right hand side (4).
diff --git a/test/libsolidity/syntaxTests/types/bool_ops.sol b/test/libsolidity/syntaxTests/types/bool_ops.sol
new file mode 100644
index 00000000..91033906
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/bool_ops.sol
@@ -0,0 +1,53 @@
+contract C {
+ function f(bool a, bool b) public pure {
+ bool c;
+ // OK
+ c = !a;
+ c = !b;
+ c = a == b;
+ c = a != b;
+ c = a || b;
+ c = a && b;
+
+ // Not OK
+ c = a > b;
+ c = a < b;
+ c = a >= b;
+ c = a <= b;
+ c = a & b;
+ c = a | b;
+ c = a ^ b;
+ c = ~a;
+ c = ~b;
+ c = a + b;
+ c = a - b;
+ c = -a;
+ c = -b;
+ c = a * b;
+ c = a / b;
+ c = a ** b;
+ c = a % b;
+ c = a << b;
+ c = a >> b;
+ }
+}
+// ----
+// TypeError: (231-236): Operator > not compatible with types bool and bool
+// TypeError: (250-255): Operator < not compatible with types bool and bool
+// TypeError: (269-275): Operator >= not compatible with types bool and bool
+// TypeError: (289-295): Operator <= not compatible with types bool and bool
+// TypeError: (309-314): Operator & not compatible with types bool and bool
+// TypeError: (328-333): Operator | not compatible with types bool and bool
+// TypeError: (347-352): Operator ^ not compatible with types bool and bool
+// TypeError: (366-368): Unary operator ~ cannot be applied to type bool
+// TypeError: (382-384): Unary operator ~ cannot be applied to type bool
+// TypeError: (398-403): Operator + not compatible with types bool and bool
+// TypeError: (417-422): Operator - not compatible with types bool and bool
+// TypeError: (436-438): Unary operator - cannot be applied to type bool
+// TypeError: (452-454): Unary operator - cannot be applied to type bool
+// TypeError: (468-473): Operator * not compatible with types bool and bool
+// TypeError: (487-492): Operator / not compatible with types bool and bool
+// TypeError: (506-512): Operator ** not compatible with types bool and bool
+// TypeError: (526-531): Operator % not compatible with types bool and bool
+// TypeError: (545-551): Operator << not compatible with types bool and bool
+// TypeError: (565-571): Operator >> not compatible with types bool and bool
diff --git a/test/libsolidity/syntaxTests/types/bytes1_to_uint256.sol b/test/libsolidity/syntaxTests/types/bytes1_to_uint256.sol
new file mode 100644
index 00000000..58828a62
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/bytes1_to_uint256.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public pure returns(uint256) {
+ return uint256(bytes1(''));
+ }
+}
+// ----
+// TypeError: (76-95): Explicit type conversion not allowed from "bytes1" to "uint256".
diff --git a/test/libsolidity/syntaxTests/types/bytes32_to_uint32.sol b/test/libsolidity/syntaxTests/types/bytes32_to_uint32.sol
new file mode 100644
index 00000000..77e813ab
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/bytes32_to_uint32.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public pure returns(uint32) {
+ return uint32(bytes32(''));
+ }
+}
+// ----
+// TypeError: (75-94): Explicit type conversion not allowed from "bytes32" to "uint32".
diff --git a/test/libsolidity/syntaxTests/types/bytes_to_contract.sol b/test/libsolidity/syntaxTests/types/bytes_to_contract.sol
index 2a3219ec..820dbf9b 100644
--- a/test/libsolidity/syntaxTests/types/bytes_to_contract.sol
+++ b/test/libsolidity/syntaxTests/types/bytes_to_contract.sol
@@ -1,7 +1,7 @@
contract C {
function f() public pure {
- C(bytes20(0x1234));
+ C(bytes20(uint160(0x1234)));
}
}
// ----
-// TypeError: (64-82): Explicit type conversion not allowed from "bytes20" to "contract C".
+// TypeError: (64-91): Explicit type conversion not allowed from "bytes20" to "contract C".
diff --git a/test/libsolidity/syntaxTests/types/bytes_to_uint_same_size.sol b/test/libsolidity/syntaxTests/types/bytes_to_uint_same_size.sol
new file mode 100644
index 00000000..2963cfd2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/bytes_to_uint_same_size.sol
@@ -0,0 +1,20 @@
+contract C {
+ function f() public pure returns (uint256) {
+ return uint256(bytes32(uint256(0)));
+ }
+ function g() public pure returns (uint128) {
+ return uint128(bytes16(uint128(0)));
+ }
+ function h() public pure returns (uint64) {
+ return uint64(bytes8(uint64(0)));
+ }
+ function i() public pure returns (uint32) {
+ return uint32(bytes4(uint32(0)));
+ }
+ function j() public pure returns (uint16) {
+ return uint16(bytes2(uint16(0)));
+ }
+ function k() public pure returns (uint8) {
+ return uint8(bytes1(uint8(0)));
+ }
+}
diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_event.sol b/test/libsolidity/syntaxTests/types/empty_tuple_event.sol
index 3e40b155..24327db0 100644
--- a/test/libsolidity/syntaxTests/types/empty_tuple_event.sol
+++ b/test/libsolidity/syntaxTests/types/empty_tuple_event.sol
@@ -2,9 +2,8 @@ pragma solidity ^0.4.3;
contract C {
event SomeEvent();
function a() public {
- (SomeEvent(), 7);
+ (emit SomeEvent(), 7);
}
}
// ----
-// Warning: (95-106): Invoking events without "emit" prefix is deprecated.
-// Warning: (95-106): Tuple component cannot be empty.
+// ParserError: (95-99): Expected primary expression.
diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_event_050.sol b/test/libsolidity/syntaxTests/types/empty_tuple_event_050.sol
deleted file mode 100644
index aec5ff2a..00000000
--- a/test/libsolidity/syntaxTests/types/empty_tuple_event_050.sol
+++ /dev/null
@@ -1,10 +0,0 @@
-pragma experimental "v0.5.0";
-contract C {
- event SomeEvent();
- function a() public {
- (SomeEvent(), 7);
- }
-}
-// ----
-// TypeError: (101-112): Event invocations have to be prefixed by "emit".
-// TypeError: (101-112): Tuple component cannot be empty.
diff --git a/test/libsolidity/syntaxTests/types/index_access_for_bytes.sol b/test/libsolidity/syntaxTests/types/index_access_for_bytes.sol
new file mode 100644
index 00000000..f31b4cc0
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/index_access_for_bytes.sol
@@ -0,0 +1,6 @@
+contract C {
+ bytes20 x;
+ function f(bytes16 b) public view {
+ b[uint8(x[2])];
+ }
+}
diff --git a/test/libsolidity/syntaxTests/types/uint256_to_bytes1.sol b/test/libsolidity/syntaxTests/types/uint256_to_bytes1.sol
new file mode 100644
index 00000000..f70c89ed
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/uint256_to_bytes1.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public pure returns(bytes1) {
+ return bytes1(uint256(0));
+ }
+}
+// ----
+// TypeError: (75-93): Explicit type conversion not allowed from "uint256" to "bytes1".
diff --git a/test/libsolidity/syntaxTests/types/uint32_to_bytes32.sol b/test/libsolidity/syntaxTests/types/uint32_to_bytes32.sol
new file mode 100644
index 00000000..4153c5c3
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/uint32_to_bytes32.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public pure returns(bytes32) {
+ return bytes32(uint32(0));
+ }
+}
+// ----
+// TypeError: (76-94): Explicit type conversion not allowed from "uint32" to "bytes32".
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/assembly.sol b/test/libsolidity/syntaxTests/viewPureChecker/assembly.sol
new file mode 100644
index 00000000..0a11dc3a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/assembly.sol
@@ -0,0 +1,23 @@
+contract C {
+ struct S { uint x; }
+ S s;
+ function e() pure public {
+ assembly { mstore(keccak256(0, 20), mul(s_slot, 2)) }
+ }
+ function f() pure public {
+ uint x;
+ assembly { x := 7 }
+ }
+ function g() view public {
+ assembly { for {} 1 { pop(sload(0)) } { } pop(gas) }
+ }
+ function h() view public {
+ assembly { function g() { pop(blockhash(20)) } }
+ }
+ function j() public {
+ assembly { pop(call(0, 1, 2, 3, 4, 5, 6)) }
+ }
+ function k() public {
+ assembly { pop(call(gas, 1, 2, 3, 4, 5, 6)) }
+ }
+}
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump.sol b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump.sol
new file mode 100644
index 00000000..418be561
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump.sol
@@ -0,0 +1,7 @@
+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/builtin_functions.sol b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol
new file mode 100644
index 00000000..dbefb8b6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol
@@ -0,0 +1,18 @@
+contract C {
+ function f() public {
+ address(this).transfer(1);
+ require(address(this).send(2));
+ selfdestruct(address(this));
+ require(address(this).delegatecall());
+ require(address(this).call());
+ }
+ function g() pure public {
+ bytes32 x = keccak256("abc");
+ bytes32 y = sha256("abc");
+ address z = ecrecover(1, 2, 3, 4);
+ require(true);
+ assert(true);
+ x; y; z;
+ }
+ function() payable public {}
+}
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/call_internal_functions_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/call_internal_functions_fail.sol
new file mode 100644
index 00000000..22855c34
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/call_internal_functions_fail.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() pure public { g(); }
+ function g() view public {}
+}
+// ----
+// TypeError: (44-47): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
+// Warning: (55-82): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/call_internal_functions_success.sol b/test/libsolidity/syntaxTests/viewPureChecker/call_internal_functions_success.sol
new file mode 100644
index 00000000..5aa21ce1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/call_internal_functions_success.sol
@@ -0,0 +1,6 @@
+contract C {
+ function g() pure public { g(); }
+ function f() view public returns (uint) { f(); g(); }
+ function h() public { h(); g(); f(); }
+ function i() payable public { i(); h(); g(); f(); }
+}
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/constant.sol b/test/libsolidity/syntaxTests/viewPureChecker/constant.sol
new file mode 100644
index 00000000..36d93497
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/constant.sol
@@ -0,0 +1,6 @@
+contract C {
+ uint constant x = 2;
+ function k() pure public returns (uint) {
+ return x;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/creation.sol b/test/libsolidity/syntaxTests/viewPureChecker/creation.sol
new file mode 100644
index 00000000..d80edd1b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/creation.sol
@@ -0,0 +1,4 @@
+contract D {}
+contract C {
+ function f() public { new D(); }
+}
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/function_types.sol b/test/libsolidity/syntaxTests/viewPureChecker/function_types.sol
new file mode 100644
index 00000000..92943889
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/function_types.sol
@@ -0,0 +1,22 @@
+contract C {
+ function f() pure public {
+ function () external nonpayFun;
+ function () external view viewFun;
+ function () external pure pureFun;
+
+ nonpayFun;
+ viewFun;
+ pureFun;
+ pureFun();
+ }
+ function g() view public {
+ function () external view viewFun;
+
+ viewFun();
+ }
+ function h() public {
+ function () external nonpayFun;
+
+ nonpayFun();
+ }
+}
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/interface.sol b/test/libsolidity/syntaxTests/viewPureChecker/interface.sol
new file mode 100644
index 00000000..0874e78a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/interface.sol
@@ -0,0 +1,6 @@
+interface D {
+ function f() view external;
+}
+contract C is D {
+ function f() view external {}
+}
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/local_storage_variables.sol b/test/libsolidity/syntaxTests/viewPureChecker/local_storage_variables.sol
new file mode 100644
index 00000000..7d01118a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/local_storage_variables.sol
@@ -0,0 +1,19 @@
+contract C {
+ struct S { uint a; }
+ S s;
+ function f() view public {
+ S storage x = s;
+ x;
+ }
+ function g() view public {
+ S storage x = s;
+ x = s;
+ }
+ function i() public {
+ s.a = 2;
+ }
+ function h() public {
+ S storage x = s;
+ x.a = 2;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/mappings.sol b/test/libsolidity/syntaxTests/viewPureChecker/mappings.sol
new file mode 100644
index 00000000..eb0ccbfb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/mappings.sol
@@ -0,0 +1,12 @@
+contract C {
+ mapping(uint => uint) a;
+ function f() view public {
+ a;
+ }
+ function g() view public {
+ a[2];
+ }
+ function h() public {
+ a[2] = 3;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/modifiers.sol b/test/libsolidity/syntaxTests/viewPureChecker/modifiers.sol
new file mode 100644
index 00000000..f8f6b2cb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/modifiers.sol
@@ -0,0 +1,17 @@
+contract D {
+ uint x;
+ modifier purem(uint) { _; }
+ modifier viewm(uint) { uint a = x; _; a; }
+ modifier nonpayablem(uint) { x = 2; _; }
+}
+contract C is D {
+ function f() purem(0) pure public {}
+ function g() viewm(0) view public {}
+ function h() nonpayablem(0) public {}
+ function i() purem(x) view public {}
+ function j() viewm(x) view public {}
+ function k() nonpayablem(x) public {}
+ function l() purem(x = 2) public {}
+ function m() viewm(x = 2) public {}
+ function n() nonpayablem(x = 2) public {}
+}
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/overriding.sol b/test/libsolidity/syntaxTests/viewPureChecker/overriding.sol
new file mode 100644
index 00000000..c82c7908
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/overriding.sol
@@ -0,0 +1,7 @@
+contract D {
+ uint x;
+ function f() public { x = 2; }
+}
+contract C is D {
+ function f() public {}
+}
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/returning_structs.sol b/test/libsolidity/syntaxTests/viewPureChecker/returning_structs.sol
new file mode 100644
index 00000000..9b4eb466
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/returning_structs.sol
@@ -0,0 +1,14 @@
+contract C {
+ struct S { uint x; }
+ S s;
+ function f() view internal returns (S storage) {
+ return s;
+ }
+ function g() public {
+ f().x = 2;
+ }
+ function h() view public {
+ f();
+ f().x;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/selector.sol b/test/libsolidity/syntaxTests/viewPureChecker/selector.sol
new file mode 100644
index 00000000..2ad4518d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/selector.sol
@@ -0,0 +1,8 @@
+contract C {
+ uint public x;
+ function f() payable public {
+ }
+ function g() pure public returns (bytes4) {
+ return this.f.selector ^ this.x.selector;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/selector_complex.sol b/test/libsolidity/syntaxTests/viewPureChecker/selector_complex.sol
new file mode 100644
index 00000000..311dec4a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/selector_complex.sol
@@ -0,0 +1,11 @@
+contract C {
+ function f(C c) pure public returns (C) {
+ return c;
+ }
+ function g() pure public returns (bytes4) {
+ // By passing `this`, we read from the state, even if f itself is pure.
+ return f(this).f.selector;
+ }
+}
+// ----
+// TypeError: (228-232): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/selector_complex2.sol b/test/libsolidity/syntaxTests/viewPureChecker/selector_complex2.sol
new file mode 100644
index 00000000..d1543fed
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/selector_complex2.sol
@@ -0,0 +1,9 @@
+contract C {
+ function f() payable public returns (C) {
+ return this;
+ }
+ function g() pure public returns (bytes4) {
+ C x = C(0x123);
+ return x.f.selector;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/smoke_test.sol b/test/libsolidity/syntaxTests/viewPureChecker/smoke_test.sol
new file mode 100644
index 00000000..0e397efc
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/smoke_test.sol
@@ -0,0 +1,7 @@
+contract C {
+ uint x;
+ function g() pure public {}
+ function f() view public returns (uint) { return now; }
+ function h() public { x = 2; }
+ function i() payable public { x = 2; }
+}
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/suggest_pure.sol b/test/libsolidity/syntaxTests/viewPureChecker/suggest_pure.sol
new file mode 100644
index 00000000..87719eb3
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/suggest_pure.sol
@@ -0,0 +1,5 @@
+contract C {
+ function g() view public { }
+}
+// ----
+// Warning: (17-45): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/suggest_view.sol b/test/libsolidity/syntaxTests/viewPureChecker/suggest_view.sol
new file mode 100644
index 00000000..c045dfc4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/suggest_view.sol
@@ -0,0 +1,6 @@
+contract C {
+ uint x;
+ function g() public returns (uint) { return x; }
+}
+// ----
+// Warning: (29-77): Function state mutability can be restricted to view
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/write_storage_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/write_storage_fail.sol
new file mode 100644
index 00000000..2a8bba31
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/write_storage_fail.sol
@@ -0,0 +1,6 @@
+contract C {
+ uint x;
+ function f() view public { x = 2; }
+}
+// ----
+// Warning: (56-57): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/write_storage_fail_v050.sol b/test/libsolidity/syntaxTests/viewPureChecker/write_storage_fail_v050.sol
new file mode 100644
index 00000000..b85078ed
--- /dev/null
+++ b/test/libsolidity/syntaxTests/viewPureChecker/write_storage_fail_v050.sol
@@ -0,0 +1,7 @@
+pragma experimental "v0.5.0";
+contract C {
+ uint x;
+ function f() view public { x = 2; }
+}
+// ----
+// TypeError: (86-87): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
diff --git a/test/solcjsTests.sh b/test/solcjsTests.sh
index 27797cb4..e0bbc5df 100755
--- a/test/solcjsTests.sh
+++ b/test/solcjsTests.sh
@@ -53,6 +53,11 @@ DIR=$(mktemp -d)
rm -f soljson.js
cp "$SOLJSON" soljson.js
+ # ensure to use always 0.5.0 sources
+ # FIXME: should be removed once the version bump in this repo is done
+ rm -rf test/DAO040
+ cp -R test/DAO test/DAO040
+
# Update version (needed for some tests)
echo "Updating package.json to version $VERSION"
npm version --no-git-tag-version $VERSION
diff --git a/test/tools/CMakeLists.txt b/test/tools/CMakeLists.txt
index 11714017..257b4f24 100644
--- a/test/tools/CMakeLists.txt
+++ b/test/tools/CMakeLists.txt
@@ -1,5 +1,7 @@
add_executable(solfuzzer fuzzer.cpp)
target_link_libraries(solfuzzer PRIVATE libsolc evmasm ${Boost_PROGRAM_OPTIONS_LIBRARIES} ${Boost_SYSTEM_LIBRARIES})
-add_executable(isoltest isoltest.cpp ../Options.cpp ../libsolidity/SyntaxTest.cpp ../libsolidity/AnalysisFramework.cpp)
+add_executable(isoltest isoltest.cpp ../Options.cpp ../libsolidity/TestCase.cpp ../libsolidity/SyntaxTest.cpp
+ ../libsolidity/AnalysisFramework.cpp ../libsolidity/SolidityExecutionFramework.cpp ../ExecutionFramework.cpp
+ ../RPCSession.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 7a147bd0..41dff148 100644
--- a/test/tools/isoltest.cpp
+++ b/test/tools/isoltest.cpp
@@ -37,18 +37,22 @@ using namespace std;
namespace po = boost::program_options;
namespace fs = boost::filesystem;
-struct SyntaxTestStats
+struct TestStats
{
int successCount;
int runCount;
operator bool() const { return successCount == runCount; }
};
-class SyntaxTestTool
+class TestTool
{
public:
- SyntaxTestTool(string const& _name, fs::path const& _path, bool _formatted):
- m_formatted(_formatted), m_name(_name), m_path(_path)
+ TestTool(
+ TestCase::TestCaseCreator _testCaseCreator,
+ string const& _name,
+ fs::path const& _path,
+ bool _formatted
+ ): m_testCaseCreator(_testCaseCreator), m_formatted(_formatted), m_name(_name), m_path(_path)
{}
enum class Result
@@ -60,7 +64,8 @@ public:
Result process();
- static SyntaxTestStats processPath(
+ static TestStats processPath(
+ TestCase::TestCaseCreator _testCaseCreator,
fs::path const& _basepath,
fs::path const& _path,
bool const _formatted
@@ -77,68 +82,16 @@ private:
Request handleResponse(bool const _exception);
- void printContract() const;
-
+ TestCase::TestCaseCreator m_testCaseCreator;
bool const m_formatted;
string const m_name;
fs::path const m_path;
- unique_ptr<SyntaxTest> m_test;
+ unique_ptr<TestCase> m_test;
};
-string SyntaxTestTool::editor;
+string TestTool::editor;
-void SyntaxTestTool::printContract() const
-{
- if (m_formatted)
- {
- string const& source = m_test->source();
- if (source.empty())
- return;
-
- std::vector<char const*> sourceFormatting(source.length(), formatting::RESET);
- for (auto const& error: m_test->errorList())
- if (error.locationStart >= 0 && error.locationEnd >= 0)
- {
- assert(static_cast<size_t>(error.locationStart) < source.length());
- assert(static_cast<size_t>(error.locationEnd) < source.length());
- bool isWarning = error.type == "Warning";
- for (int i = error.locationStart; i < error.locationEnd; i++)
- if (isWarning)
- {
- if (sourceFormatting[i] == formatting::RESET)
- sourceFormatting[i] = formatting::ORANGE_BACKGROUND;
- }
- else
- sourceFormatting[i] = formatting::RED_BACKGROUND;
- }
-
- cout << " " << sourceFormatting.front() << source.front();
- for (size_t i = 1; i < source.length(); i++)
- {
- if (sourceFormatting[i] != sourceFormatting[i - 1])
- cout << sourceFormatting[i];
- if (source[i] != '\n')
- cout << source[i];
- else
- {
- cout << formatting::RESET << endl;
- if (i + 1 < source.length())
- cout << " " << sourceFormatting[i];
- }
- }
- cout << formatting::RESET << endl;
- }
- else
- {
- stringstream stream(m_test->source());
- string line;
- while (getline(stream, line))
- cout << " " << line << endl;
- cout << endl;
- }
-}
-
-SyntaxTestTool::Result SyntaxTestTool::process()
+TestTool::Result TestTool::process()
{
bool success;
std::stringstream outputMessages;
@@ -147,42 +100,25 @@ SyntaxTestTool::Result SyntaxTestTool::process()
try
{
- m_test = unique_ptr<SyntaxTest>(new SyntaxTest(m_path.string()));
+ m_test = m_testCaseCreator(m_path.string());
success = m_test->run(outputMessages, " ", m_formatted);
}
- catch(CompilerError const& _e)
- {
- FormattedScope(cout, m_formatted, {BOLD, RED}) <<
- "Exception: " << SyntaxTest::errorMessage(_e) << endl;
- return Result::Exception;
- }
- catch(InternalCompilerError const& _e)
- {
- FormattedScope(cout, m_formatted, {BOLD, RED}) <<
- "InternalCompilerError: " << SyntaxTest::errorMessage(_e) << endl;
- return Result::Exception;
- }
- catch(FatalError const& _e)
- {
- FormattedScope(cout, m_formatted, {BOLD, RED}) <<
- "FatalError: " << SyntaxTest::errorMessage(_e) << endl;
- return Result::Exception;
- }
- catch(UnimplementedFeatureError const& _e)
+ catch(boost::exception const& _e)
{
FormattedScope(cout, m_formatted, {BOLD, RED}) <<
- "UnimplementedFeatureError: " << SyntaxTest::errorMessage(_e) << endl;
+ "Exception during syntax test: " << boost::diagnostic_information(_e) << endl;
return Result::Exception;
}
catch (std::exception const& _e)
{
- FormattedScope(cout, m_formatted, {BOLD, RED}) << "Exception: " << _e.what() << endl;
+ FormattedScope(cout, m_formatted, {BOLD, RED}) <<
+ "Exception during syntax test: " << _e.what() << endl;
return Result::Exception;
}
catch(...)
{
FormattedScope(cout, m_formatted, {BOLD, RED}) <<
- "Unknown Exception" << endl;
+ "Unknown exception during syntax test." << endl;
return Result::Exception;
}
@@ -196,14 +132,14 @@ SyntaxTestTool::Result SyntaxTestTool::process()
FormattedScope(cout, m_formatted, {BOLD, RED}) << "FAIL" << endl;
FormattedScope(cout, m_formatted, {BOLD, CYAN}) << " Contract:" << endl;
- printContract();
+ m_test->printSource(cout, " ", m_formatted);
- cout << outputMessages.str() << endl;
+ cout << endl << outputMessages.str() << endl;
return Result::Failure;
}
}
-SyntaxTestTool::Request SyntaxTestTool::handleResponse(bool const _exception)
+TestTool::Request TestTool::handleResponse(bool const _exception)
{
if (_exception)
cout << "(e)dit/(s)kip/(q)uit? ";
@@ -225,15 +161,14 @@ SyntaxTestTool::Request SyntaxTestTool::handleResponse(bool const _exception)
{
cout << endl;
ofstream file(m_path.string(), ios::trunc);
- file << m_test->source();
+ m_test->printSource(file);
file << "// ----" << endl;
- if (!m_test->errorList().empty())
- m_test->printErrorList(file, m_test->errorList(), "// ", false);
+ m_test->printUpdatedExpectations(file, "// ");
return Request::Rerun;
}
case 'e':
cout << endl << endl;
- if (system((editor + " \"" + m_path.string() + "\"").c_str()))
+ if (system((TestTool::editor + " \"" + m_path.string() + "\"").c_str()))
cerr << "Error running editor command." << endl << endl;
return Request::Rerun;
case 'q':
@@ -245,8 +180,8 @@ SyntaxTestTool::Request SyntaxTestTool::handleResponse(bool const _exception)
}
}
-
-SyntaxTestStats SyntaxTestTool::processPath(
+TestStats TestTool::processPath(
+ TestCase::TestCaseCreator _testCaseCreator,
fs::path const& _basepath,
fs::path const& _path,
bool const _formatted
@@ -269,12 +204,12 @@ SyntaxTestStats SyntaxTestTool::processPath(
fs::directory_iterator(fullpath),
fs::directory_iterator()
))
- if (fs::is_directory(entry.path()) || SyntaxTest::isTestFilename(entry.path().filename()))
+ if (fs::is_directory(entry.path()) || TestCase::isTestFilename(entry.path().filename()))
paths.push(currentPath / entry.path().filename());
}
else
{
- SyntaxTestTool testTool(currentPath.string(), fullpath, _formatted);
+ TestTool testTool(_testCaseCreator, currentPath.string(), fullpath, _formatted);
++runCount;
auto result = testTool.process();
@@ -310,9 +245,9 @@ SyntaxTestStats SyntaxTestTool::processPath(
int main(int argc, char *argv[])
{
if (getenv("EDITOR"))
- SyntaxTestTool::editor = getenv("EDITOR");
+ TestTool::editor = getenv("EDITOR");
else if (fs::exists("/usr/bin/editor"))
- SyntaxTestTool::editor = "/usr/bin/editor";
+ TestTool::editor = "/usr/bin/editor";
fs::path testPath;
bool formatted = true;
@@ -328,7 +263,7 @@ Allowed options)",
("help", "Show this help screen.")
("testpath", po::value<fs::path>(&testPath), "path to test files")
("no-color", "don't use colors")
- ("editor", po::value<string>(&SyntaxTestTool::editor), "editor for opening contracts");
+ ("editor", po::value<string>(&TestTool::editor), "editor for opening contracts");
po::variables_map arguments;
try
@@ -348,7 +283,7 @@ Allowed options)",
po::notify(arguments);
}
- catch (po::error const& _exception)
+ catch (std::exception const& _exception)
{
cerr << _exception.what() << endl;
return 1;
@@ -379,7 +314,7 @@ Allowed options)",
if (fs::exists(syntaxTestPath) && fs::is_directory(syntaxTestPath))
{
- auto stats = SyntaxTestTool::processPath(testPath / "libsolidity", "syntaxTests", formatted);
+ auto stats = TestTool::processPath(SyntaxTest::create, testPath / "libsolidity", "syntaxTests", formatted);
cout << endl << "Summary: ";
FormattedScope(cout, formatted, {BOLD, stats ? GREEN : RED}) <<
@@ -390,7 +325,7 @@ Allowed options)",
}
else
{
- cerr << "Test path not found. Use the --testpath argument." << endl;
+ cerr << "Syntax tests not found. Use the --testpath argument." << endl;
return 1;
}
}