aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/ASTJSON/address_payable.json560
-rw-r--r--test/libsolidity/ASTJSON/address_payable.sol11
-rw-r--r--test/libsolidity/ASTJSON/address_payable_legacy.json600
-rw-r--r--test/libsolidity/SMTChecker.cpp4
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp111
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp19
-rw-r--r--test/libsolidity/SolidityOptimizer.cpp2
-rw-r--r--test/libsolidity/SolidityScanner.cpp5
-rw-r--r--test/libsolidity/StandardCompiler.cpp67
-rw-r--r--test/libsolidity/syntaxTests/array/length/fixed_size_multidim_zero_length.sol15
-rw-r--r--test/libsolidity/syntaxTests/array/length/fixed_size_zero_length.sol15
-rw-r--r--test/libsolidity/syntaxTests/array/length/parentheses.sol2
-rw-r--r--test/libsolidity/syntaxTests/conversion/allowed_conversion_to_bytes_array.sol9
-rw-r--r--test/libsolidity/syntaxTests/conversion/allowed_conversion_to_string.sol9
-rw-r--r--test/libsolidity/syntaxTests/conversion/explicit_conversion_from_storage_array_ref.sol10
-rw-r--r--test/libsolidity/syntaxTests/conversion/implicit_conversion_from_storage_array_ref.sol7
-rw-r--r--test/libsolidity/syntaxTests/conversion/not_allowed_conversion_to_int_array_pointer1.sol10
-rw-r--r--test/libsolidity/syntaxTests/conversion/not_allowed_conversion_to_int_array_pointer2.sol10
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/memory_storage_data_location.sol12
-rw-r--r--test/libsolidity/syntaxTests/functionTypes/external_function_type_to_address_payable.sol7
-rw-r--r--test/libsolidity/syntaxTests/multiline_comments.sol13
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/413_address_methods.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol2
-rw-r--r--test/libsolidity/syntaxTests/parsing/address_constant_payable.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/address_function_arguments_and_returns.sol4
-rw-r--r--test/libsolidity/syntaxTests/parsing/address_in_struct.sol6
-rw-r--r--test/libsolidity/syntaxTests/parsing/address_invalid_state_mutability.sol26
-rw-r--r--test/libsolidity/syntaxTests/parsing/address_nonpayable.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/address_payable.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/address_payable_constant.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/address_payable_conversion.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/address_payable_function_type.sol6
-rw-r--r--test/libsolidity/syntaxTests/parsing/address_payable_library.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/address_payable_local.sol11
-rw-r--r--test/libsolidity/syntaxTests/parsing/address_payable_state_variable.sol8
-rw-r--r--test/libsolidity/syntaxTests/parsing/address_payable_struct.sol8
-rw-r--r--test/libsolidity/syntaxTests/parsing/address_payable_type_expression.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/address_public_payable_error.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol2
-rw-r--r--test/libsolidity/syntaxTests/parsing/elemantary_non_address_payable_state_variable.sol29
-rw-r--r--test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_argument.sol29
-rw-r--r--test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_local.sol31
-rw-r--r--test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_return.sol29
-rw-r--r--test/libsolidity/syntaxTests/parsing/mapping_from_address_payable.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/new_address_payable.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/payable_accessor.sol2
-rw-r--r--test/libsolidity/syntaxTests/string/string_escapes.sol7
-rw-r--r--test/libsolidity/syntaxTests/string/string_new_line.sol9
-rw-r--r--test/libsolidity/syntaxTests/string/string_terminated_by_backslash.sol8
-rw-r--r--test/libsolidity/syntaxTests/string/string_unterminated.sol7
-rw-r--r--test/libsolidity/syntaxTests/string/string_unterminated_no_new_line.sol4
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_abi_decode.sol6
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_constant.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_constant_assignment.sol11
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_in_struct_fail.sol11
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_in_struct_fine.sol20
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_members_in_contract.sol (renamed from test/libsolidity/syntaxTests/types/address_members_in_contract.sol)0
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_nonpayable_selfdestruct.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_payable_external_overload.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_payable_internal_overload_nonpayable.sol10
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_payable_internal_overload_payable.sol10
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_payable_memory_array_conversion.sol11
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_payable_public_overload.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_payable_selfdestruct.sol5
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_payable_storage_array_conversion.sol11
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_payable_storage_array_conversion_fail.sol11
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_to_contract.sol (renamed from test/libsolidity/syntaxTests/types/address_to_contract.sol)0
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_to_contract_implicitly.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_to_contract_payable_fallback.sol8
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_to_payable_address.sol10
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_to_payable_address_double.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_tuple_fail.sol8
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_tuple_fine.sol6
-rw-r--r--test/libsolidity/syntaxTests/types/address/bytes_long_to_payable_address.sol8
-rw-r--r--test/libsolidity/syntaxTests/types/address/bytes_short_to_payable_address.sol8
-rw-r--r--test/libsolidity/syntaxTests/types/address/bytes_to_payable_address.sol5
-rw-r--r--test/libsolidity/syntaxTests/types/address/contract_no_fallback_to_payable_address.sol8
-rw-r--r--test/libsolidity/syntaxTests/types/address/contract_non_payable_fallback_to_payable_address.sol10
-rw-r--r--test/libsolidity/syntaxTests/types/address/contract_payable_fallback_to_payable_address.sol9
-rw-r--r--test/libsolidity/syntaxTests/types/address/contract_payable_fallback_to_payable_address_implicitly.sol10
-rw-r--r--test/libsolidity/syntaxTests/types/address/contract_to_address.sol (renamed from test/libsolidity/syntaxTests/types/contract_to_address.sol)0
-rw-r--r--test/libsolidity/syntaxTests/types/address/contract_to_address_implicitly.sol (renamed from test/libsolidity/syntaxTests/types/contract_to_address_implicitly.sol)0
-rw-r--r--test/libsolidity/syntaxTests/types/address/literal_to_address.sol9
-rw-r--r--test/libsolidity/syntaxTests/types/address/literal_to_payable_address.sol8
-rw-r--r--test/libsolidity/syntaxTests/types/address/nonpayable_address_to_contract_payable_fallback.sol10
-rw-r--r--test/libsolidity/syntaxTests/types/address/payable_address_to_address.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/address/uint_to_payable_address.sol5
-rw-r--r--test/libsolidity/syntaxTests/types/address_to_contract_implicitly.sol7
-rw-r--r--test/libsolidity/syntaxTests/unicode_escape_literals.sol31
-rw-r--r--test/libsolidity/syntaxTests/unterminatedBlocks/one_dot.sol4
-rw-r--r--test/libsolidity/syntaxTests/unterminatedBlocks/one_dot_x.sol5
-rw-r--r--test/libsolidity/syntaxTests/unterminatedBlocks/zero_dot.sol4
-rw-r--r--test/libsolidity/syntaxTests/unterminatedBlocks/zero_dot_x.sol5
-rw-r--r--test/libsolidity/syntaxTests/upper_case_hex_literals.sol9
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_view_fail.sol2
95 files changed, 2075 insertions, 53 deletions
diff --git a/test/libsolidity/ASTJSON/address_payable.json b/test/libsolidity/ASTJSON/address_payable.json
new file mode 100644
index 00000000..42ad33e5
--- /dev/null
+++ b/test/libsolidity/ASTJSON/address_payable.json
@@ -0,0 +1,560 @@
+{
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 37
+ ]
+ },
+ "id" : 38,
+ "nodeType" : "SourceUnit",
+ "nodes" :
+ [
+ {
+ "baseContracts" : [],
+ "contractDependencies" : [],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "id" : 37,
+ "linearizedBaseContracts" :
+ [
+ 37
+ ],
+ "name" : "C",
+ "nodeType" : "ContractDefinition",
+ "nodes" :
+ [
+ {
+ "constant" : false,
+ "id" : 4,
+ "name" : "m",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 37,
+ "src" : "17:44:1",
+ "stateVariable" : true,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_mapping$_t_address_$_t_address_payable_$",
+ "typeString" : "mapping(address => address payable)"
+ },
+ "typeName" :
+ {
+ "id" : 3,
+ "keyType" :
+ {
+ "id" : 1,
+ "name" : "address",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "25:7:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_address",
+ "typeString" : "address"
+ }
+ },
+ "nodeType" : "Mapping",
+ "src" : "17:35:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_mapping$_t_address_$_t_address_payable_$",
+ "typeString" : "mapping(address => address payable)"
+ },
+ "valueType" :
+ {
+ "id" : 2,
+ "name" : "address",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "36:15:1",
+ "stateMutability" : "payable",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_address_payable",
+ "typeString" : "address payable"
+ }
+ }
+ },
+ "value" : null,
+ "visibility" : "public"
+ },
+ {
+ "body" :
+ {
+ "id" : 35,
+ "nodeType" : "Block",
+ "src" : "134:122:1",
+ "statements" :
+ [
+ {
+ "assignments" :
+ [
+ 12
+ ],
+ "declarations" :
+ [
+ {
+ "constant" : false,
+ "id" : 12,
+ "name" : "a",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 35,
+ "src" : "144:17:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_address_payable",
+ "typeString" : "address payable"
+ },
+ "typeName" :
+ {
+ "id" : 11,
+ "name" : "address",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "144:15:1",
+ "stateMutability" : "payable",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_address_payable",
+ "typeString" : "address payable"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "id" : 16,
+ "initialValue" :
+ {
+ "argumentTypes" : null,
+ "baseExpression" :
+ {
+ "argumentTypes" : null,
+ "id" : 13,
+ "name" : "m",
+ "nodeType" : "Identifier",
+ "overloadedDeclarations" : [],
+ "referencedDeclaration" : 4,
+ "src" : "164:1:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_mapping$_t_address_$_t_address_payable_$",
+ "typeString" : "mapping(address => address payable)"
+ }
+ },
+ "id" : 15,
+ "indexExpression" :
+ {
+ "argumentTypes" : null,
+ "id" : 14,
+ "name" : "arg",
+ "nodeType" : "Identifier",
+ "overloadedDeclarations" : [],
+ "referencedDeclaration" : 6,
+ "src" : "166:3:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_address_payable",
+ "typeString" : "address payable"
+ }
+ },
+ "isConstant" : false,
+ "isLValue" : true,
+ "isPure" : false,
+ "lValueRequested" : false,
+ "nodeType" : "IndexAccess",
+ "src" : "164:6:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_address_payable",
+ "typeString" : "address payable"
+ }
+ },
+ "nodeType" : "VariableDeclarationStatement",
+ "src" : "144:26:1"
+ },
+ {
+ "expression" :
+ {
+ "argumentTypes" : null,
+ "id" : 19,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : false,
+ "lValueRequested" : false,
+ "leftHandSide" :
+ {
+ "argumentTypes" : null,
+ "id" : 17,
+ "name" : "r",
+ "nodeType" : "Identifier",
+ "overloadedDeclarations" : [],
+ "referencedDeclaration" : 9,
+ "src" : "180:1:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_address_payable",
+ "typeString" : "address payable"
+ }
+ },
+ "nodeType" : "Assignment",
+ "operator" : "=",
+ "rightHandSide" :
+ {
+ "argumentTypes" : null,
+ "id" : 18,
+ "name" : "arg",
+ "nodeType" : "Identifier",
+ "overloadedDeclarations" : [],
+ "referencedDeclaration" : 6,
+ "src" : "184:3:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_address_payable",
+ "typeString" : "address payable"
+ }
+ },
+ "src" : "180:7:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_address_payable",
+ "typeString" : "address payable"
+ }
+ },
+ "id" : 20,
+ "nodeType" : "ExpressionStatement",
+ "src" : "180:7:1"
+ },
+ {
+ "assignments" :
+ [
+ 22
+ ],
+ "declarations" :
+ [
+ {
+ "constant" : false,
+ "id" : 22,
+ "name" : "c",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 35,
+ "src" : "197:9:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_address",
+ "typeString" : "address"
+ },
+ "typeName" :
+ {
+ "id" : 21,
+ "name" : "address",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "197:7:1",
+ "stateMutability" : "nonpayable",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_address",
+ "typeString" : "address"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "id" : 26,
+ "initialValue" :
+ {
+ "argumentTypes" : null,
+ "arguments" :
+ [
+ {
+ "argumentTypes" : null,
+ "id" : 24,
+ "name" : "this",
+ "nodeType" : "Identifier",
+ "overloadedDeclarations" : [],
+ "referencedDeclaration" : 65,
+ "src" : "217:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_contract$_C_$37",
+ "typeString" : "contract C"
+ }
+ }
+ ],
+ "expression" :
+ {
+ "argumentTypes" :
+ [
+ {
+ "typeIdentifier" : "t_contract$_C_$37",
+ "typeString" : "contract C"
+ }
+ ],
+ "id" : 23,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "nodeType" : "ElementaryTypeNameExpression",
+ "src" : "209:7:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_type$_t_address_$",
+ "typeString" : "type(address)"
+ },
+ "typeName" : "address"
+ },
+ "id" : 25,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : false,
+ "kind" : "typeConversion",
+ "lValueRequested" : false,
+ "names" : [],
+ "nodeType" : "FunctionCall",
+ "src" : "209:13:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_address",
+ "typeString" : "address"
+ }
+ },
+ "nodeType" : "VariableDeclarationStatement",
+ "src" : "197:25:1"
+ },
+ {
+ "expression" :
+ {
+ "argumentTypes" : null,
+ "id" : 33,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : false,
+ "lValueRequested" : false,
+ "leftHandSide" :
+ {
+ "argumentTypes" : null,
+ "baseExpression" :
+ {
+ "argumentTypes" : null,
+ "id" : 27,
+ "name" : "m",
+ "nodeType" : "Identifier",
+ "overloadedDeclarations" : [],
+ "referencedDeclaration" : 4,
+ "src" : "232:1:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_mapping$_t_address_$_t_address_payable_$",
+ "typeString" : "mapping(address => address payable)"
+ }
+ },
+ "id" : 29,
+ "indexExpression" :
+ {
+ "argumentTypes" : null,
+ "id" : 28,
+ "name" : "c",
+ "nodeType" : "Identifier",
+ "overloadedDeclarations" : [],
+ "referencedDeclaration" : 22,
+ "src" : "234:1:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_address",
+ "typeString" : "address"
+ }
+ },
+ "isConstant" : false,
+ "isLValue" : true,
+ "isPure" : false,
+ "lValueRequested" : true,
+ "nodeType" : "IndexAccess",
+ "src" : "232:4:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_address_payable",
+ "typeString" : "address payable"
+ }
+ },
+ "nodeType" : "Assignment",
+ "operator" : "=",
+ "rightHandSide" :
+ {
+ "argumentTypes" : null,
+ "arguments" :
+ [
+ {
+ "argumentTypes" : null,
+ "hexValue" : "30",
+ "id" : 31,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "kind" : "number",
+ "lValueRequested" : false,
+ "nodeType" : "Literal",
+ "src" : "247:1:1",
+ "subdenomination" : null,
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_rational_0_by_1",
+ "typeString" : "int_const 0"
+ },
+ "value" : "0"
+ }
+ ],
+ "expression" :
+ {
+ "argumentTypes" :
+ [
+ {
+ "typeIdentifier" : "t_rational_0_by_1",
+ "typeString" : "int_const 0"
+ }
+ ],
+ "id" : 30,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "nodeType" : "ElementaryTypeNameExpression",
+ "src" : "239:7:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_type$_t_address_$",
+ "typeString" : "type(address)"
+ },
+ "typeName" : "address"
+ },
+ "id" : 32,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "kind" : "typeConversion",
+ "lValueRequested" : false,
+ "names" : [],
+ "nodeType" : "FunctionCall",
+ "src" : "239:10:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_address_payable",
+ "typeString" : "address payable"
+ }
+ },
+ "src" : "232:17:1",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_address_payable",
+ "typeString" : "address payable"
+ }
+ },
+ "id" : 34,
+ "nodeType" : "ExpressionStatement",
+ "src" : "232:17:1"
+ }
+ ]
+ },
+ "documentation" : null,
+ "id" : 36,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" : [],
+ "name" : "f",
+ "nodeType" : "FunctionDefinition",
+ "parameters" :
+ {
+ "id" : 7,
+ "nodeType" : "ParameterList",
+ "parameters" :
+ [
+ {
+ "constant" : false,
+ "id" : 6,
+ "name" : "arg",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 36,
+ "src" : "78:19:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_address_payable",
+ "typeString" : "address payable"
+ },
+ "typeName" :
+ {
+ "id" : 5,
+ "name" : "address",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "78:15:1",
+ "stateMutability" : "payable",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_address_payable",
+ "typeString" : "address payable"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "src" : "77:21:1"
+ },
+ "returnParameters" :
+ {
+ "id" : 10,
+ "nodeType" : "ParameterList",
+ "parameters" :
+ [
+ {
+ "constant" : false,
+ "id" : 9,
+ "name" : "r",
+ "nodeType" : "VariableDeclaration",
+ "scope" : 36,
+ "src" : "115:17:1",
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_address_payable",
+ "typeString" : "address payable"
+ },
+ "typeName" :
+ {
+ "id" : 8,
+ "name" : "address",
+ "nodeType" : "ElementaryTypeName",
+ "src" : "115:15:1",
+ "stateMutability" : "payable",
+ "typeDescriptions" :
+ {
+ "typeIdentifier" : "t_address_payable",
+ "typeString" : "address payable"
+ }
+ },
+ "value" : null,
+ "visibility" : "internal"
+ }
+ ],
+ "src" : "114:19:1"
+ },
+ "scope" : 37,
+ "src" : "67:189:1",
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ }
+ ],
+ "scope" : 38,
+ "src" : "0:258:1"
+ }
+ ],
+ "src" : "0:259:1"
+}
diff --git a/test/libsolidity/ASTJSON/address_payable.sol b/test/libsolidity/ASTJSON/address_payable.sol
new file mode 100644
index 00000000..f7cc66cb
--- /dev/null
+++ b/test/libsolidity/ASTJSON/address_payable.sol
@@ -0,0 +1,11 @@
+contract C {
+ mapping(address => address payable) public m;
+ function f(address payable arg) public returns (address payable r) {
+ address payable a = m[arg];
+ r = arg;
+ address c = address(this);
+ m[c] = address(0);
+ }
+}
+
+// ----
diff --git a/test/libsolidity/ASTJSON/address_payable_legacy.json b/test/libsolidity/ASTJSON/address_payable_legacy.json
new file mode 100644
index 00000000..11a634c3
--- /dev/null
+++ b/test/libsolidity/ASTJSON/address_payable_legacy.json
@@ -0,0 +1,600 @@
+{
+ "attributes" :
+ {
+ "absolutePath" : "a",
+ "exportedSymbols" :
+ {
+ "C" :
+ [
+ 37
+ ]
+ }
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "baseContracts" :
+ [
+ null
+ ],
+ "contractDependencies" :
+ [
+ null
+ ],
+ "contractKind" : "contract",
+ "documentation" : null,
+ "fullyImplemented" : true,
+ "linearizedBaseContracts" :
+ [
+ 37
+ ],
+ "name" : "C",
+ "scope" : 38
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "m",
+ "scope" : 37,
+ "stateVariable" : true,
+ "storageLocation" : "default",
+ "type" : "mapping(address => address payable)",
+ "value" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "type" : "mapping(address => address payable)"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "address",
+ "type" : "address"
+ },
+ "id" : 1,
+ "name" : "ElementaryTypeName",
+ "src" : "25:7:1"
+ },
+ {
+ "attributes" :
+ {
+ "name" : "address",
+ "stateMutability" : "payable",
+ "type" : "address payable"
+ },
+ "id" : 2,
+ "name" : "ElementaryTypeName",
+ "src" : "36:15:1"
+ }
+ ],
+ "id" : 3,
+ "name" : "Mapping",
+ "src" : "17:35:1"
+ }
+ ],
+ "id" : 4,
+ "name" : "VariableDeclaration",
+ "src" : "17:44:1"
+ },
+ {
+ "attributes" :
+ {
+ "documentation" : null,
+ "implemented" : true,
+ "isConstructor" : false,
+ "modifiers" :
+ [
+ null
+ ],
+ "name" : "f",
+ "scope" : 37,
+ "stateMutability" : "nonpayable",
+ "superFunction" : null,
+ "visibility" : "public"
+ },
+ "children" :
+ [
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "arg",
+ "scope" : 36,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "address payable",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "address",
+ "stateMutability" : "payable",
+ "type" : "address payable"
+ },
+ "id" : 5,
+ "name" : "ElementaryTypeName",
+ "src" : "78:15:1"
+ }
+ ],
+ "id" : 6,
+ "name" : "VariableDeclaration",
+ "src" : "78:19:1"
+ }
+ ],
+ "id" : 7,
+ "name" : "ParameterList",
+ "src" : "77:21:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "r",
+ "scope" : 36,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "address payable",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "address",
+ "stateMutability" : "payable",
+ "type" : "address payable"
+ },
+ "id" : 8,
+ "name" : "ElementaryTypeName",
+ "src" : "115:15:1"
+ }
+ ],
+ "id" : 9,
+ "name" : "VariableDeclaration",
+ "src" : "115:17:1"
+ }
+ ],
+ "id" : 10,
+ "name" : "ParameterList",
+ "src" : "114:19:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "assignments" :
+ [
+ 12
+ ]
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "a",
+ "scope" : 35,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "address payable",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "address",
+ "stateMutability" : "payable",
+ "type" : "address payable"
+ },
+ "id" : 11,
+ "name" : "ElementaryTypeName",
+ "src" : "144:15:1"
+ }
+ ],
+ "id" : 12,
+ "name" : "VariableDeclaration",
+ "src" : "144:17:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "isConstant" : false,
+ "isLValue" : true,
+ "isPure" : false,
+ "lValueRequested" : false,
+ "type" : "address payable"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "overloadedDeclarations" :
+ [
+ null
+ ],
+ "referencedDeclaration" : 4,
+ "type" : "mapping(address => address payable)",
+ "value" : "m"
+ },
+ "id" : 13,
+ "name" : "Identifier",
+ "src" : "164:1:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "overloadedDeclarations" :
+ [
+ null
+ ],
+ "referencedDeclaration" : 6,
+ "type" : "address payable",
+ "value" : "arg"
+ },
+ "id" : 14,
+ "name" : "Identifier",
+ "src" : "166:3:1"
+ }
+ ],
+ "id" : 15,
+ "name" : "IndexAccess",
+ "src" : "164:6:1"
+ }
+ ],
+ "id" : 16,
+ "name" : "VariableDeclarationStatement",
+ "src" : "144:26:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : false,
+ "lValueRequested" : false,
+ "operator" : "=",
+ "type" : "address payable"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "overloadedDeclarations" :
+ [
+ null
+ ],
+ "referencedDeclaration" : 9,
+ "type" : "address payable",
+ "value" : "r"
+ },
+ "id" : 17,
+ "name" : "Identifier",
+ "src" : "180:1:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "overloadedDeclarations" :
+ [
+ null
+ ],
+ "referencedDeclaration" : 6,
+ "type" : "address payable",
+ "value" : "arg"
+ },
+ "id" : 18,
+ "name" : "Identifier",
+ "src" : "184:3:1"
+ }
+ ],
+ "id" : 19,
+ "name" : "Assignment",
+ "src" : "180:7:1"
+ }
+ ],
+ "id" : 20,
+ "name" : "ExpressionStatement",
+ "src" : "180:7:1"
+ },
+ {
+ "attributes" :
+ {
+ "assignments" :
+ [
+ 22
+ ]
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "constant" : false,
+ "name" : "c",
+ "scope" : 35,
+ "stateVariable" : false,
+ "storageLocation" : "default",
+ "type" : "address",
+ "value" : null,
+ "visibility" : "internal"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "name" : "address",
+ "stateMutability" : "nonpayable",
+ "type" : "address"
+ },
+ "id" : 21,
+ "name" : "ElementaryTypeName",
+ "src" : "197:7:1"
+ }
+ ],
+ "id" : 22,
+ "name" : "VariableDeclaration",
+ "src" : "197:9:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : false,
+ "isStructConstructorCall" : false,
+ "lValueRequested" : false,
+ "names" :
+ [
+ null
+ ],
+ "type" : "address",
+ "type_conversion" : true
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" :
+ [
+ {
+ "typeIdentifier" : "t_contract$_C_$37",
+ "typeString" : "contract C"
+ }
+ ],
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "type" : "type(address)",
+ "value" : "address"
+ },
+ "id" : 23,
+ "name" : "ElementaryTypeNameExpression",
+ "src" : "209:7:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "overloadedDeclarations" :
+ [
+ null
+ ],
+ "referencedDeclaration" : 65,
+ "type" : "contract C",
+ "value" : "this"
+ },
+ "id" : 24,
+ "name" : "Identifier",
+ "src" : "217:4:1"
+ }
+ ],
+ "id" : 25,
+ "name" : "FunctionCall",
+ "src" : "209:13:1"
+ }
+ ],
+ "id" : 26,
+ "name" : "VariableDeclarationStatement",
+ "src" : "197:25:1"
+ },
+ {
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : false,
+ "lValueRequested" : false,
+ "operator" : "=",
+ "type" : "address payable"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "isConstant" : false,
+ "isLValue" : true,
+ "isPure" : false,
+ "lValueRequested" : true,
+ "type" : "address payable"
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "overloadedDeclarations" :
+ [
+ null
+ ],
+ "referencedDeclaration" : 4,
+ "type" : "mapping(address => address payable)",
+ "value" : "m"
+ },
+ "id" : 27,
+ "name" : "Identifier",
+ "src" : "232:1:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "overloadedDeclarations" :
+ [
+ null
+ ],
+ "referencedDeclaration" : 22,
+ "type" : "address",
+ "value" : "c"
+ },
+ "id" : 28,
+ "name" : "Identifier",
+ "src" : "234:1:1"
+ }
+ ],
+ "id" : 29,
+ "name" : "IndexAccess",
+ "src" : "232:4:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "isStructConstructorCall" : false,
+ "lValueRequested" : false,
+ "names" :
+ [
+ null
+ ],
+ "type" : "address payable",
+ "type_conversion" : true
+ },
+ "children" :
+ [
+ {
+ "attributes" :
+ {
+ "argumentTypes" :
+ [
+ {
+ "typeIdentifier" : "t_rational_0_by_1",
+ "typeString" : "int_const 0"
+ }
+ ],
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "type" : "type(address)",
+ "value" : "address"
+ },
+ "id" : 30,
+ "name" : "ElementaryTypeNameExpression",
+ "src" : "239:7:1"
+ },
+ {
+ "attributes" :
+ {
+ "argumentTypes" : null,
+ "hexvalue" : "30",
+ "isConstant" : false,
+ "isLValue" : false,
+ "isPure" : true,
+ "lValueRequested" : false,
+ "subdenomination" : null,
+ "token" : "number",
+ "type" : "int_const 0",
+ "value" : "0"
+ },
+ "id" : 31,
+ "name" : "Literal",
+ "src" : "247:1:1"
+ }
+ ],
+ "id" : 32,
+ "name" : "FunctionCall",
+ "src" : "239:10:1"
+ }
+ ],
+ "id" : 33,
+ "name" : "Assignment",
+ "src" : "232:17:1"
+ }
+ ],
+ "id" : 34,
+ "name" : "ExpressionStatement",
+ "src" : "232:17:1"
+ }
+ ],
+ "id" : 35,
+ "name" : "Block",
+ "src" : "134:122:1"
+ }
+ ],
+ "id" : 36,
+ "name" : "FunctionDefinition",
+ "src" : "67:189:1"
+ }
+ ],
+ "id" : 37,
+ "name" : "ContractDefinition",
+ "src" : "0:258:1"
+ }
+ ],
+ "id" : 38,
+ "name" : "SourceUnit",
+ "src" : "0:259:1"
+}
diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp
index 736aa46c..1f6f765f 100644
--- a/test/libsolidity/SMTChecker.cpp
+++ b/test/libsolidity/SMTChecker.cpp
@@ -343,7 +343,7 @@ BOOST_AUTO_TEST_CASE(bool_simple)
text = R"(
contract C {
function f(bool x) public pure {
- if(x) {
+ if (x) {
assert(x);
} else {
assert(!x);
@@ -380,7 +380,7 @@ BOOST_AUTO_TEST_CASE(bool_int_mixed)
contract C {
function f(bool x) public pure {
uint a;
- if(x)
+ if (x)
a = 1;
assert(!x || a > 0);
}
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 6be9d95b..f65c8b27 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -2215,7 +2215,7 @@ BOOST_AUTO_TEST_CASE(send_ether)
char const* sourceCode = R"(
contract test {
constructor() payable public {}
- function a(address addr, uint amount) public returns (uint ret) {
+ function a(address payable addr, uint amount) public returns (uint ret) {
addr.send(amount);
return address(this).balance;
}
@@ -2233,11 +2233,11 @@ BOOST_AUTO_TEST_CASE(transfer_ether)
char const* sourceCode = R"(
contract A {
constructor() public payable {}
- function a(address addr, uint amount) public returns (uint) {
+ function a(address payable addr, uint amount) public returns (uint) {
addr.transfer(amount);
return address(this).balance;
}
- function b(address addr, uint amount) public {
+ function b(address payable addr, uint amount) public {
addr.transfer(amount);
}
}
@@ -2406,7 +2406,7 @@ BOOST_AUTO_TEST_CASE(selfdestruct)
char const* sourceCode = R"(
contract test {
constructor() public payable {}
- function a(address receiver) public returns (uint ret) {
+ function a(address payable receiver) public returns (uint ret) {
selfdestruct(receiver);
return 10;
}
@@ -3039,26 +3039,26 @@ BOOST_AUTO_TEST_CASE(gasprice)
BOOST_AUTO_TEST_CASE(blockhash)
{
- char const* sourceCode = R"(
- contract C {
- uint256 counter;
- function g() public returns (bool) { counter++; return true; }
- function f() public returns (bytes32[] memory r) {
- r = new bytes32[](259);
- for (uint i = 0; i < 259; i++)
- r[i] = blockhash(block.number - 257 + i);
- }
- }
- )";
- compileAndRun(sourceCode);
- // generate a sufficient amount of blocks
- while (blockNumber() < u256(255))
- ABI_CHECK(callContractFunction("g()"), encodeArgs(true));
-
- vector<u256> hashes;
- // currently the test only works for pre-constantinople
+ // depending on the aleth version, this test only works for pre-constantinople
if (Options::get().evmVersion() < EVMVersion::constantinople())
{
+ char const* sourceCode = R"(
+ contract C {
+ uint256 counter;
+ function g() public returns (bool) { counter++; return true; }
+ function f() public returns (bytes32[] memory r) {
+ r = new bytes32[](259);
+ for (uint i = 0; i < 259; i++)
+ r[i] = blockhash(block.number - 257 + i);
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ // generate a sufficient amount of blocks
+ while (blockNumber() < u256(255))
+ ABI_CHECK(callContractFunction("g()"), encodeArgs(true));
+
+ vector<u256> hashes;
// ``blockhash()`` is only valid for the last 256 blocks, otherwise zero
hashes.emplace_back(0);
for (u256 i = blockNumber() - u256(255); i <= blockNumber(); i++)
@@ -3067,18 +3067,9 @@ BOOST_AUTO_TEST_CASE(blockhash)
hashes.emplace_back(0);
// future block hashes are zero
hashes.emplace_back(0);
- }
- else
- // TODO: Starting from constantinople blockhash always seems to return zero.
- // The blockhash contract introduced in EIP96 seems to break in our setup of
- // aleth (setting the constantinople fork block to zero and resetting the chain
- // to block zero before each test run). Pre-deploying the blockchain contract
- // during genesis seems to help, but currently causes problems with other tests.
- // Set the expectation to zero for now, so that this test tracks changes in this
- // behavior.
- hashes.assign(259, 0);
- ABI_CHECK(callContractFunction("f()"), encodeDyn(hashes));
+ ABI_CHECK(callContractFunction("f()"), encodeDyn(hashes));
+ }
}
BOOST_AUTO_TEST_CASE(value_complex)
@@ -7151,7 +7142,7 @@ BOOST_AUTO_TEST_CASE(failing_send)
}
contract Main {
constructor() public payable {}
- function callHelper(address _a) public returns (bool r, uint bal) {
+ function callHelper(address payable _a) public returns (bool r, uint bal) {
r = !_a.send(5);
bal = address(this).balance;
}
@@ -8838,7 +8829,7 @@ BOOST_AUTO_TEST_CASE(reject_ether_sent_to_library)
library lib {}
contract c {
constructor() public payable {}
- function f(address x) public returns (bool) {
+ function f(address payable x) public returns (bool) {
return x.send(1);
}
function () external payable {}
@@ -10095,6 +10086,54 @@ BOOST_AUTO_TEST_CASE(cleanup_bytes_types_shortening)
ABI_CHECK(callContractFunction("f()"), encodeArgs("\xff\xff\xff\xff"));
}
+BOOST_AUTO_TEST_CASE(cleanup_address_types)
+{
+ // Checks that address types are properly cleaned before they are compared.
+ char const* sourceCode = R"(
+ contract C {
+ function f(address a) public returns (uint) {
+ if (a != 0x1234567890123456789012345678901234567890) return 1;
+ return 0;
+ }
+ function g(address payable a) public returns (uint) {
+ if (a != 0x1234567890123456789012345678901234567890) return 1;
+ return 0;
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ // We input longer data on purpose.
+ ABI_CHECK(callContractFunction("f(address)", u256("0xFFFF1234567890123456789012345678901234567890")), encodeArgs(0));
+ ABI_CHECK(callContractFunction("g(address)", u256("0xFFFF1234567890123456789012345678901234567890")), encodeArgs(0));
+}
+
+BOOST_AUTO_TEST_CASE(cleanup_address_types_shortening)
+{
+ char const* sourceCode = R"(
+ contract C {
+ function f() public pure returns (address r) {
+ bytes21 x = 0x1122334455667788990011223344556677889900ff;
+ bytes20 y;
+ assembly { y := x }
+ address z = address(y);
+ assembly { r := z }
+ require(z == 0x1122334455667788990011223344556677889900);
+ }
+ function g() public pure returns (address payable r) {
+ bytes21 x = 0x1122334455667788990011223344556677889900ff;
+ bytes20 y;
+ assembly { y := x }
+ address payable z = address(y);
+ assembly { r := z }
+ require(z == 0x1122334455667788990011223344556677889900);
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(u256("0x1122334455667788990011223344556677889900")));
+ ABI_CHECK(callContractFunction("g()"), encodeArgs(u256("0x1122334455667788990011223344556677889900")));
+}
+
BOOST_AUTO_TEST_CASE(skip_dynamic_types)
{
// The EVM cannot provide access to dynamically-sized return values, so we have to skip them.
@@ -12446,7 +12485,7 @@ BOOST_AUTO_TEST_CASE(interface_contract)
}
contract C {
- function f(address _interfaceAddress) public returns (bool) {
+ function f(address payable _interfaceAddress) public returns (bool) {
I i = I(_interfaceAddress);
return i.f();
}
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index af8465fc..640bf4d0 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -396,7 +396,7 @@ BOOST_AUTO_TEST_CASE(returndatasize_as_variable)
{Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"}
});
if (!dev::test::Options::get().evmVersion().supportsReturndata())
- expectations.emplace_back(make_pair(Error::Type::Warning, std::string("\"returndatasize\" instruction is only available for Byzantium-compatible")));
+ expectations.emplace_back(make_pair(Error::Type::Warning, std::string("\"returndatasize\" instruction is only available for Byzantium-compatible VMs.")));
CHECK_ALLOW_MULTI(text, expectations);
}
@@ -407,9 +407,24 @@ BOOST_AUTO_TEST_CASE(create2_as_variable)
)";
// This needs special treatment, because the message mentions the EVM version,
// so cannot be run via isoltest.
+ vector<pair<Error::Type, std::string>> expectations(vector<pair<Error::Type, std::string>>{
+ {Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"}
+ });
+ if (!dev::test::Options::get().evmVersion().hasCreate2())
+ expectations.emplace_back(make_pair(Error::Type::Warning, std::string("\"create2\" instruction is only available for Constantinople-compatible VMs.")));
+ CHECK_ALLOW_MULTI(text, expectations);
+}
+
+BOOST_AUTO_TEST_CASE(extcodehash_as_variable)
+{
+ char const* text = R"(
+ contract c { function f() public view { uint extcodehash; extcodehash; assembly { pop(extcodehash(0)) } }}
+ )";
+ // This needs special treatment, because the message mentions the EVM version,
+ // so cannot be run via isoltest.
CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{
{Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"},
- {Error::Type::Warning, "The \"create2\" instruction is not supported by the VM version"},
+ {Error::Type::Warning, "The \"extcodehash\" instruction is not supported by the VM version"},
}));
}
diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp
index 1c80e82e..f925d36e 100644
--- a/test/libsolidity/SolidityOptimizer.cpp
+++ b/test/libsolidity/SolidityOptimizer.cpp
@@ -352,7 +352,7 @@ BOOST_AUTO_TEST_CASE(incorrect_storage_access_bug)
mapping(uint => uint) data;
function f() public returns (uint)
{
- if(data[now] == 0)
+ if (data[now] == 0)
data[uint(-7)] = 5;
return data[now];
}
diff --git a/test/libsolidity/SolidityScanner.cpp b/test/libsolidity/SolidityScanner.cpp
index 3a210f94..93db236b 100644
--- a/test/libsolidity/SolidityScanner.cpp
+++ b/test/libsolidity/SolidityScanner.cpp
@@ -105,6 +105,11 @@ BOOST_AUTO_TEST_CASE(hex_numbers)
BOOST_CHECK_EQUAL(scanner.currentLiteral(), "0x765432536763762734623472346");
BOOST_CHECK_EQUAL(scanner.next(), Token::Semicolon);
BOOST_CHECK_EQUAL(scanner.next(), Token::EOS);
+ scanner.reset(CharStream("0x1234"), "");
+ BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number);
+ BOOST_CHECK_EQUAL(scanner.currentLiteral(), "0x1234");
+ scanner.reset(CharStream("0X1234"), "");
+ BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Illegal);
}
BOOST_AUTO_TEST_CASE(octal_numbers)
diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp
index 3aa1dc24..1570a9d2 100644
--- a/test/libsolidity/StandardCompiler.cpp
+++ b/test/libsolidity/StandardCompiler.cpp
@@ -225,6 +225,71 @@ BOOST_AUTO_TEST_CASE(smoke_test)
BOOST_CHECK(containsAtMostWarnings(result));
}
+BOOST_AUTO_TEST_CASE(optimizer_enabled_not_boolean)
+{
+ char const* input = R"(
+ {
+ "language": "Solidity",
+ "settings": {
+ "optimizer": {
+ "enabled": "wrong"
+ }
+ },
+ "sources": {
+ "empty": {
+ "content": ""
+ }
+ }
+ }
+ )";
+ Json::Value result = compile(input);
+ BOOST_CHECK(containsError(result, "JSONError", "The \"enabled\" setting must be a boolean."));
+}
+
+BOOST_AUTO_TEST_CASE(optimizer_runs_not_a_number)
+{
+ char const* input = R"(
+ {
+ "language": "Solidity",
+ "settings": {
+ "optimizer": {
+ "enabled": true,
+ "runs": "not a number"
+ }
+ },
+ "sources": {
+ "empty": {
+ "content": ""
+ }
+ }
+ }
+ )";
+ Json::Value result = compile(input);
+ BOOST_CHECK(containsError(result, "JSONError", "The \"runs\" setting must be an unsigned number."));
+}
+
+BOOST_AUTO_TEST_CASE(optimizer_runs_not_an_unsigned_number)
+{
+ char const* input = R"(
+ {
+ "language": "Solidity",
+ "settings": {
+ "optimizer": {
+ "enabled": true,
+ "runs": -1
+ }
+ },
+ "sources": {
+ "empty": {
+ "content": ""
+ }
+ }
+ }
+ )";
+ Json::Value result = compile(input);
+ BOOST_CHECK(containsError(result, "JSONError", "The \"runs\" setting must be an unsigned number."));
+}
+
BOOST_AUTO_TEST_CASE(basic_compilation)
{
char const* input = R"(
@@ -640,7 +705,7 @@ BOOST_AUTO_TEST_CASE(libraries_invalid_entry)
}
)";
Json::Value result = compile(input);
- BOOST_CHECK(containsError(result, "JSONError", "library entry is not a JSON object."));
+ BOOST_CHECK(containsError(result, "JSONError", "Library entry is not a JSON object."));
}
BOOST_AUTO_TEST_CASE(libraries_invalid_hex)
diff --git a/test/libsolidity/syntaxTests/array/length/fixed_size_multidim_zero_length.sol b/test/libsolidity/syntaxTests/array/length/fixed_size_multidim_zero_length.sol
new file mode 100644
index 00000000..fd8f3078
--- /dev/null
+++ b/test/libsolidity/syntaxTests/array/length/fixed_size_multidim_zero_length.sol
@@ -0,0 +1,15 @@
+contract C {
+ function a() public pure returns(int[0][500] memory) {}
+ function b() public pure returns(uint[0][500] memory) {}
+ function c() public pure returns(byte[0][500] memory) {}
+ function d() public pure returns(bytes32[0][500] memory) {}
+ function e() public pure returns(bytes[0][500] memory) {}
+ function e() public pure returns(string[0][500] memory) {}
+}
+// ----
+// TypeError: (52-53): Array with zero length specified.
+// TypeError: (111-112): Array with zero length specified.
+// TypeError: (170-171): Array with zero length specified.
+// TypeError: (232-233): Array with zero length specified.
+// TypeError: (292-293): Array with zero length specified.
+// TypeError: (353-354): Array with zero length specified.
diff --git a/test/libsolidity/syntaxTests/array/length/fixed_size_zero_length.sol b/test/libsolidity/syntaxTests/array/length/fixed_size_zero_length.sol
new file mode 100644
index 00000000..b38939e3
--- /dev/null
+++ b/test/libsolidity/syntaxTests/array/length/fixed_size_zero_length.sol
@@ -0,0 +1,15 @@
+contract C {
+ int[0] a;
+ uint[0] b;
+ byte[0] c;
+ bytes32[0] d;
+ bytes[0] e;
+ string[0] f;
+}
+// ----
+// TypeError: (19-20): Array with zero length specified.
+// TypeError: (32-33): Array with zero length specified.
+// TypeError: (45-46): Array with zero length specified.
+// TypeError: (61-62): Array with zero length specified.
+// TypeError: (75-76): Array with zero length specified.
+// TypeError: (90-91): Array with zero length specified.
diff --git a/test/libsolidity/syntaxTests/array/length/parentheses.sol b/test/libsolidity/syntaxTests/array/length/parentheses.sol
index 40f55ad6..8dbcc0a4 100644
--- a/test/libsolidity/syntaxTests/array/length/parentheses.sol
+++ b/test/libsolidity/syntaxTests/array/length/parentheses.sol
@@ -21,5 +21,5 @@ contract C {
uint[((2) + 1) + 1] a12;
uint[(2 + 1) + ((1))] a13;
uint[(((2) + 1)) + (((1)))] a14;
- uint[((((2) + 1)) + (((1))))%1] a15;
+ uint[((((3) + 1)) + (((1))))%2] a15;
}
diff --git a/test/libsolidity/syntaxTests/conversion/allowed_conversion_to_bytes_array.sol b/test/libsolidity/syntaxTests/conversion/allowed_conversion_to_bytes_array.sol
new file mode 100644
index 00000000..78c40e53
--- /dev/null
+++ b/test/libsolidity/syntaxTests/conversion/allowed_conversion_to_bytes_array.sol
@@ -0,0 +1,9 @@
+contract C {
+ bytes a;
+ bytes b;
+ function f() public view {
+ bytes storage c = a;
+ bytes memory d = b;
+ d = bytes(c);
+ }
+}
diff --git a/test/libsolidity/syntaxTests/conversion/allowed_conversion_to_string.sol b/test/libsolidity/syntaxTests/conversion/allowed_conversion_to_string.sol
new file mode 100644
index 00000000..f7e96f35
--- /dev/null
+++ b/test/libsolidity/syntaxTests/conversion/allowed_conversion_to_string.sol
@@ -0,0 +1,9 @@
+contract C {
+ string a;
+ string b;
+ function f() public view {
+ string storage c = a;
+ string memory d = b;
+ d = string(c);
+ }
+}
diff --git a/test/libsolidity/syntaxTests/conversion/explicit_conversion_from_storage_array_ref.sol b/test/libsolidity/syntaxTests/conversion/explicit_conversion_from_storage_array_ref.sol
new file mode 100644
index 00000000..458adda6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/conversion/explicit_conversion_from_storage_array_ref.sol
@@ -0,0 +1,10 @@
+contract C {
+ int[10] x;
+ function f() public view {
+ int[](x);
+ int(x);
+ }
+}
+// ----
+// TypeError: (55-63): Explicit type conversion not allowed from "int256[10] storage ref" to "int256[] storage pointer".
+// TypeError: (67-73): Explicit type conversion not allowed from "int256[10] storage ref" to "int256".
diff --git a/test/libsolidity/syntaxTests/conversion/implicit_conversion_from_storage_array_ref.sol b/test/libsolidity/syntaxTests/conversion/implicit_conversion_from_storage_array_ref.sol
new file mode 100644
index 00000000..31e298d0
--- /dev/null
+++ b/test/libsolidity/syntaxTests/conversion/implicit_conversion_from_storage_array_ref.sol
@@ -0,0 +1,7 @@
+contract C {
+ int[10] x;
+ int[] y;
+ function f() public {
+ y = x;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/conversion/not_allowed_conversion_to_int_array_pointer1.sol b/test/libsolidity/syntaxTests/conversion/not_allowed_conversion_to_int_array_pointer1.sol
new file mode 100644
index 00000000..3aa59612
--- /dev/null
+++ b/test/libsolidity/syntaxTests/conversion/not_allowed_conversion_to_int_array_pointer1.sol
@@ -0,0 +1,10 @@
+contract C {
+ uint[] a;
+ uint[] b;
+ function f() public view {
+ uint[] storage c = a;
+ uint[] storage d = b;
+ d = uint[](c);
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/conversion/not_allowed_conversion_to_int_array_pointer2.sol b/test/libsolidity/syntaxTests/conversion/not_allowed_conversion_to_int_array_pointer2.sol
new file mode 100644
index 00000000..060c9707
--- /dev/null
+++ b/test/libsolidity/syntaxTests/conversion/not_allowed_conversion_to_int_array_pointer2.sol
@@ -0,0 +1,10 @@
+contract C {
+ uint[] a;
+ uint[] b;
+ function f() public view {
+ uint[] storage c = a;
+ uint[] memory d = b;
+ d = uint[](c);
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/dataLocations/memory_storage_data_location.sol b/test/libsolidity/syntaxTests/dataLocations/memory_storage_data_location.sol
new file mode 100644
index 00000000..a441b540
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/memory_storage_data_location.sol
@@ -0,0 +1,12 @@
+contract C {
+ int[] x;
+ function f() public {
+ int[] storage a = x;
+ int[] memory b;
+ a = b;
+ a = int[](b);
+ }
+}
+// ----
+// TypeError: (93-94): Type int256[] memory is not implicitly convertible to expected type int256[] storage pointer.
+// TypeError: (102-110): Type int256[] memory is not implicitly convertible to expected type int256[] storage pointer.
diff --git a/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_address_payable.sol b/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_address_payable.sol
new file mode 100644
index 00000000..adffb14b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_address_payable.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public view returns (address payable) {
+ return address(this.f);
+ }
+}
+// ----
+// TypeError: (85-100): Return argument type address is not implicitly convertible to expected type (type of first return variable) address payable.
diff --git a/test/libsolidity/syntaxTests/multiline_comments.sol b/test/libsolidity/syntaxTests/multiline_comments.sol
new file mode 100644
index 00000000..480fde6c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/multiline_comments.sol
@@ -0,0 +1,13 @@
+/*
+ * This is a multi-line comment
+ * it should create no problems
+ *
+*/
+
+contract test {
+ /*
+ * this is another multi-line comment
+ *
+ */
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/413_address_methods.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/413_address_methods.sol
index b63d2a55..ad57224c 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/413_address_methods.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/413_address_methods.sol
@@ -1,6 +1,6 @@
contract C {
function f() public {
- address addr;
+ address payable addr;
uint balance = addr.balance;
(bool callSuc,) = addr.call("");
(bool delegatecallSuc,) = addr.delegatecall("");
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol
index 157ea36b..01b7b294 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol
@@ -6,6 +6,8 @@ contract C {
function transfer(uint amount) public {
address(this).transfer(amount); // to avoid pureness warning
}
+ function() payable external {
+ }
}
contract D {
function f() public {
diff --git a/test/libsolidity/syntaxTests/parsing/address_constant_payable.sol b/test/libsolidity/syntaxTests/parsing/address_constant_payable.sol
new file mode 100644
index 00000000..d98f4ae3
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/address_constant_payable.sol
@@ -0,0 +1,5 @@
+contract C {
+ address constant payable b = address(0);
+}
+// ----
+// ParserError: (34-41): Expected identifier but got 'payable'
diff --git a/test/libsolidity/syntaxTests/parsing/address_function_arguments_and_returns.sol b/test/libsolidity/syntaxTests/parsing/address_function_arguments_and_returns.sol
new file mode 100644
index 00000000..c377600a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/address_function_arguments_and_returns.sol
@@ -0,0 +1,4 @@
+contract C {
+ function f(address) public pure returns (address) {}
+ function g(address payable) public pure returns (address payable) {}
+}
diff --git a/test/libsolidity/syntaxTests/parsing/address_in_struct.sol b/test/libsolidity/syntaxTests/parsing/address_in_struct.sol
new file mode 100644
index 00000000..68049b50
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/address_in_struct.sol
@@ -0,0 +1,6 @@
+contract C {
+ struct S {
+ address payable a;
+ address b;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/address_invalid_state_mutability.sol b/test/libsolidity/syntaxTests/parsing/address_invalid_state_mutability.sol
new file mode 100644
index 00000000..606f5cd0
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/address_invalid_state_mutability.sol
@@ -0,0 +1,26 @@
+contract C {
+ address view m_a;
+ address pure m_b;
+ address view[] m_c;
+ mapping(uint => address view) m_d;
+ function f() public pure {
+ address view a;
+ address pure b;
+ a; b;
+ }
+ function g(address view) public pure {}
+ function h(address pure) public pure {}
+ function i() public pure returns (address view) {}
+ function j() public pure returns (address pure) {}
+}
+// ----
+// TypeError: (14-26): Address types can only be payable or non-payable.
+// TypeError: (33-45): Address types can only be payable or non-payable.
+// TypeError: (52-64): Address types can only be payable or non-payable.
+// TypeError: (89-101): Address types can only be payable or non-payable.
+// TypeError: (195-207): Address types can only be payable or non-payable.
+// TypeError: (236-248): Address types can only be payable or non-payable.
+// TypeError: (300-312): Address types can only be payable or non-payable.
+// TypeError: (352-364): Address types can only be payable or non-payable.
+// TypeError: (138-150): Address types can only be payable or non-payable.
+// TypeError: (156-168): Address types can only be payable or non-payable.
diff --git a/test/libsolidity/syntaxTests/parsing/address_nonpayable.sol b/test/libsolidity/syntaxTests/parsing/address_nonpayable.sol
new file mode 100644
index 00000000..fea67138
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/address_nonpayable.sol
@@ -0,0 +1,7 @@
+contract C {
+ address a;
+ function f(address b) public pure returns (address c) {
+ address d = b;
+ return d;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/address_payable.sol b/test/libsolidity/syntaxTests/parsing/address_payable.sol
new file mode 100644
index 00000000..c29ae1b7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/address_payable.sol
@@ -0,0 +1,7 @@
+contract C {
+ address payable a;
+ function f(address payable b) public pure returns (address payable c) {
+ address payable d = b;
+ return d;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/address_payable_constant.sol b/test/libsolidity/syntaxTests/parsing/address_payable_constant.sol
new file mode 100644
index 00000000..154bfb54
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/address_payable_constant.sol
@@ -0,0 +1,3 @@
+contract C {
+ address payable constant a = address(0);
+}
diff --git a/test/libsolidity/syntaxTests/parsing/address_payable_conversion.sol b/test/libsolidity/syntaxTests/parsing/address_payable_conversion.sol
new file mode 100644
index 00000000..bf073a52
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/address_payable_conversion.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public pure {
+ address payable a = address payable(this);
+ }
+}
+// ----
+// ParserError: (80-87): Expected ';' but got 'payable'
diff --git a/test/libsolidity/syntaxTests/parsing/address_payable_function_type.sol b/test/libsolidity/syntaxTests/parsing/address_payable_function_type.sol
new file mode 100644
index 00000000..234b528a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/address_payable_function_type.sol
@@ -0,0 +1,6 @@
+contract C {
+ function (address payable) view internal returns (address payable) f;
+ function g(function (address payable) payable external returns (address payable)) public payable returns (function (address payable) payable external returns (address payable)) {
+ function (address payable) payable external returns (address payable) h; h;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/address_payable_library.sol b/test/libsolidity/syntaxTests/parsing/address_payable_library.sol
new file mode 100644
index 00000000..33787d33
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/address_payable_library.sol
@@ -0,0 +1,5 @@
+library L {
+}
+contract C {
+ using L for address payable;
+} \ No newline at end of file
diff --git a/test/libsolidity/syntaxTests/parsing/address_payable_local.sol b/test/libsolidity/syntaxTests/parsing/address_payable_local.sol
new file mode 100644
index 00000000..544f7c21
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/address_payable_local.sol
@@ -0,0 +1,11 @@
+contract C {
+ mapping(uint => address payable) m;
+ mapping(uint => address payable[]) n;
+ function f() public view {
+ address payable a;
+ address payable[] memory b;
+ mapping(uint => address payable) storage c = m;
+ mapping(uint => address payable[]) storage d = n;
+ a; b; c; d;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/address_payable_state_variable.sol b/test/libsolidity/syntaxTests/parsing/address_payable_state_variable.sol
new file mode 100644
index 00000000..12c2468d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/address_payable_state_variable.sol
@@ -0,0 +1,8 @@
+contract C {
+ address payable a;
+ address payable public b;
+ address payable[] c;
+ address payable[] public d;
+ mapping(uint => address payable) e;
+ mapping(uint => address payable[]) f;
+}
diff --git a/test/libsolidity/syntaxTests/parsing/address_payable_struct.sol b/test/libsolidity/syntaxTests/parsing/address_payable_struct.sol
new file mode 100644
index 00000000..6c281bc7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/address_payable_struct.sol
@@ -0,0 +1,8 @@
+contract C {
+ struct S {
+ address payable a;
+ address payable[] b;
+ mapping(uint => address payable) c;
+ mapping(uint => address payable[]) d;
+ }
+} \ No newline at end of file
diff --git a/test/libsolidity/syntaxTests/parsing/address_payable_type_expression.sol b/test/libsolidity/syntaxTests/parsing/address_payable_type_expression.sol
new file mode 100644
index 00000000..394b39c0
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/address_payable_type_expression.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public pure {
+ address payable;
+ }
+}
+// ----
+// ParserError: (67-68): Expected identifier but got ';'
diff --git a/test/libsolidity/syntaxTests/parsing/address_public_payable_error.sol b/test/libsolidity/syntaxTests/parsing/address_public_payable_error.sol
new file mode 100644
index 00000000..0acf5e4b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/address_public_payable_error.sol
@@ -0,0 +1,5 @@
+contract C {
+ address public payable a;
+}
+// ----
+// ParserError: (32-39): Expected identifier but got 'payable'
diff --git a/test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol b/test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol
index 9181222e..9adf6f12 100644
--- a/test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol
+++ b/test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol
@@ -1,6 +1,6 @@
contract c {
uint[10] a;
uint[] a2;
- struct x { uint[2**20] b; y[0] c; }
+ struct x { uint[2**20] b; y[1] c; }
struct y { uint d; mapping(uint=>x)[] e; }
}
diff --git a/test/libsolidity/syntaxTests/parsing/elemantary_non_address_payable_state_variable.sol b/test/libsolidity/syntaxTests/parsing/elemantary_non_address_payable_state_variable.sol
new file mode 100644
index 00000000..41b2762b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/elemantary_non_address_payable_state_variable.sol
@@ -0,0 +1,29 @@
+contract C {
+ bool payable a;
+ string payable b;
+ int payable c;
+ int256 payable d;
+ uint payable e;
+ uint256 payable f;
+ byte payable g;
+ bytes payable h;
+ bytes32 payable i;
+ fixed payable j;
+ fixed80x80 payable k;
+ ufixed payable l;
+ ufixed80x80 payable m;
+}
+// ----
+// ParserError: (22-29): State mutability can only be specified for address types.
+// ParserError: (44-51): State mutability can only be specified for address types.
+// ParserError: (63-70): State mutability can only be specified for address types.
+// ParserError: (85-92): State mutability can only be specified for address types.
+// ParserError: (105-112): State mutability can only be specified for address types.
+// ParserError: (128-135): State mutability can only be specified for address types.
+// ParserError: (148-155): State mutability can only be specified for address types.
+// ParserError: (169-176): State mutability can only be specified for address types.
+// ParserError: (192-199): State mutability can only be specified for address types.
+// ParserError: (213-220): State mutability can only be specified for address types.
+// ParserError: (239-246): State mutability can only be specified for address types.
+// ParserError: (261-268): State mutability can only be specified for address types.
+// ParserError: (288-295): State mutability can only be specified for address types.
diff --git a/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_argument.sol b/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_argument.sol
new file mode 100644
index 00000000..9cb0fb4f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_argument.sol
@@ -0,0 +1,29 @@
+contract C {
+ function a(bool payable) public pure {}
+ function b(string payable) public pure {}
+ function c(int payable) public pure {}
+ function d(int256 payable) public pure {}
+ function e(uint payable) public pure {}
+ function f(uint256 payable) public pure {}
+ function g(byte payable) public pure {}
+ function h(bytes payable) public pure {}
+ function i(bytes32 payable) public pure {}
+ function j(fixed payable) public pure {}
+ function k(fixed80x80 payable) public pure {}
+ function l(ufixed payable) public pure {}
+ function m(ufixed80x80 payable) public pure {}
+}
+// ----
+// ParserError: (33-40): State mutability can only be specified for address types.
+// ParserError: (79-86): State mutability can only be specified for address types.
+// ParserError: (122-129): State mutability can only be specified for address types.
+// ParserError: (168-175): State mutability can only be specified for address types.
+// ParserError: (212-219): State mutability can only be specified for address types.
+// ParserError: (259-266): State mutability can only be specified for address types.
+// ParserError: (303-310): State mutability can only be specified for address types.
+// ParserError: (348-355): State mutability can only be specified for address types.
+// ParserError: (395-402): State mutability can only be specified for address types.
+// ParserError: (440-447): State mutability can only be specified for address types.
+// ParserError: (490-497): State mutability can only be specified for address types.
+// ParserError: (536-543): State mutability can only be specified for address types.
+// ParserError: (587-594): State mutability can only be specified for address types.
diff --git a/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_local.sol b/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_local.sol
new file mode 100644
index 00000000..3d47f1c7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_local.sol
@@ -0,0 +1,31 @@
+contract C {
+ function f() public pure {
+ bool payable a;
+ string payable b;
+ int payable c;
+ int256 payable d;
+ uint payable e;
+ uint256 payable f;
+ byte payable g;
+ bytes payable h;
+ bytes32 payable i;
+ fixed payable j;
+ fixed80x80 payable k;
+ ufixed payable l;
+ ufixed80x80 payable m;
+ }
+}
+// ----
+// ParserError: (57-64): State mutability can only be specified for address types.
+// ParserError: (83-90): State mutability can only be specified for address types.
+// ParserError: (106-113): State mutability can only be specified for address types.
+// ParserError: (132-139): State mutability can only be specified for address types.
+// ParserError: (156-163): State mutability can only be specified for address types.
+// ParserError: (183-190): State mutability can only be specified for address types.
+// ParserError: (207-214): State mutability can only be specified for address types.
+// ParserError: (232-239): State mutability can only be specified for address types.
+// ParserError: (259-266): State mutability can only be specified for address types.
+// ParserError: (284-291): State mutability can only be specified for address types.
+// ParserError: (314-321): State mutability can only be specified for address types.
+// ParserError: (340-347): State mutability can only be specified for address types.
+// ParserError: (371-378): State mutability can only be specified for address types.
diff --git a/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_return.sol b/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_return.sol
new file mode 100644
index 00000000..fc7a3c25
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/elementary_non_address_payable_return.sol
@@ -0,0 +1,29 @@
+contract C {
+ function a() public pure returns (bool payable) {}
+ function b() public pure returns (string payable) {}
+ function c() public pure returns (int payable) {}
+ function d() public pure returns (int256 payable) {}
+ function e() public pure returns (uint payable) {}
+ function f() public pure returns (uint256 payable) {}
+ function g() public pure returns (byte payable) {}
+ function h() public pure returns (bytes payable) {}
+ function i() public pure returns (bytes32 payable) {}
+ function j() public pure returns (fixed payable) {}
+ function k() public pure returns (fixed80x80 payable) {}
+ function l() public pure returns (ufixed payable) {}
+ function m() public pure returns (ufixed80x80 payable) {}
+}
+// ----
+// ParserError: (56-63): State mutability can only be specified for address types.
+// ParserError: (113-120): State mutability can only be specified for address types.
+// ParserError: (167-174): State mutability can only be specified for address types.
+// ParserError: (224-231): State mutability can only be specified for address types.
+// ParserError: (279-286): State mutability can only be specified for address types.
+// ParserError: (337-344): State mutability can only be specified for address types.
+// ParserError: (392-399): State mutability can only be specified for address types.
+// ParserError: (448-455): State mutability can only be specified for address types.
+// ParserError: (506-513): State mutability can only be specified for address types.
+// ParserError: (562-569): State mutability can only be specified for address types.
+// ParserError: (623-630): State mutability can only be specified for address types.
+// ParserError: (680-687): State mutability can only be specified for address types.
+// ParserError: (742-749): State mutability can only be specified for address types.
diff --git a/test/libsolidity/syntaxTests/parsing/mapping_from_address_payable.sol b/test/libsolidity/syntaxTests/parsing/mapping_from_address_payable.sol
new file mode 100644
index 00000000..7e6f98d7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/mapping_from_address_payable.sol
@@ -0,0 +1,5 @@
+contract C {
+ mapping(address payable => uint) m;
+}
+// ----
+// ParserError: (33-40): Expected '=>' but got 'payable'
diff --git a/test/libsolidity/syntaxTests/parsing/new_address_payable.sol b/test/libsolidity/syntaxTests/parsing/new_address_payable.sol
new file mode 100644
index 00000000..a52001db
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/new_address_payable.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f() public pure returns(address payable[] memory m) {
+ m = new address payable[](10);
+ }
+} \ No newline at end of file
diff --git a/test/libsolidity/syntaxTests/parsing/payable_accessor.sol b/test/libsolidity/syntaxTests/parsing/payable_accessor.sol
index 6504004b..0bc85784 100644
--- a/test/libsolidity/syntaxTests/parsing/payable_accessor.sol
+++ b/test/libsolidity/syntaxTests/parsing/payable_accessor.sol
@@ -2,4 +2,4 @@ contract test {
uint payable x;
}
// ----
-// ParserError: (22-29): Expected identifier but got 'payable'
+// ParserError: (22-29): State mutability can only be specified for address types.
diff --git a/test/libsolidity/syntaxTests/string/string_escapes.sol b/test/libsolidity/syntaxTests/string/string_escapes.sol
new file mode 100644
index 00000000..51b90d73
--- /dev/null
+++ b/test/libsolidity/syntaxTests/string/string_escapes.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public pure returns (bytes32) {
+ bytes32 escapeCharacters = "\t\b\n\r\f\'\"\\\b";
+ return escapeCharacters;
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/string/string_new_line.sol b/test/libsolidity/syntaxTests/string/string_new_line.sol
new file mode 100644
index 00000000..da2240f7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/string/string_new_line.sol
@@ -0,0 +1,9 @@
+contract test {
+ function f() public pure returns (bytes32) {
+ bytes32 escapeCharacters = "This a test
+ ";
+ return escapeCharacters;
+ }
+}
+// ----
+// ParserError: (100-112): Expected primary expression.
diff --git a/test/libsolidity/syntaxTests/string/string_terminated_by_backslash.sol b/test/libsolidity/syntaxTests/string/string_terminated_by_backslash.sol
new file mode 100644
index 00000000..3eaba6af
--- /dev/null
+++ b/test/libsolidity/syntaxTests/string/string_terminated_by_backslash.sol
@@ -0,0 +1,8 @@
+contract test {
+ function f() public pure returns (bytes32) {
+ bytes32 escapeCharacters = "text \";
+ return escapeCharacters;
+ }
+}
+// ----
+// ParserError: (100-109): Expected primary expression. \ No newline at end of file
diff --git a/test/libsolidity/syntaxTests/string/string_unterminated.sol b/test/libsolidity/syntaxTests/string/string_unterminated.sol
new file mode 100644
index 00000000..3291781e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/string/string_unterminated.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public pure returns (bytes32) {
+ bytes32 escapeCharacters = "This a test
+ }
+}
+// ----
+// ParserError: (100-112): Expected primary expression. \ No newline at end of file
diff --git a/test/libsolidity/syntaxTests/string/string_unterminated_no_new_line.sol b/test/libsolidity/syntaxTests/string/string_unterminated_no_new_line.sol
new file mode 100644
index 00000000..e7be50d2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/string/string_unterminated_no_new_line.sol
@@ -0,0 +1,4 @@
+contract test {
+ function f() pure public { "abc\
+// ----
+// ParserError: (47-53): Expected primary expression. \ No newline at end of file
diff --git a/test/libsolidity/syntaxTests/types/address/address_abi_decode.sol b/test/libsolidity/syntaxTests/types/address/address_abi_decode.sol
new file mode 100644
index 00000000..7be61ad2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/address_abi_decode.sol
@@ -0,0 +1,6 @@
+contract C {
+ function f(bytes memory b) public pure returns (address payable) {
+ (address payable c) = abi.decode(b, (address));
+ return c;
+ }
+} \ No newline at end of file
diff --git a/test/libsolidity/syntaxTests/types/address/address_constant.sol b/test/libsolidity/syntaxTests/types/address/address_constant.sol
new file mode 100644
index 00000000..0b1af991
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/address_constant.sol
@@ -0,0 +1,7 @@
+contract C {
+ address constant a = address(0);
+ address payable constant b = address(0);
+ function f() public pure returns (address, address) {
+ return (a,b);
+ }
+}
diff --git a/test/libsolidity/syntaxTests/types/address/address_constant_assignment.sol b/test/libsolidity/syntaxTests/types/address/address_constant_assignment.sol
new file mode 100644
index 00000000..da17ae33
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/address_constant_assignment.sol
@@ -0,0 +1,11 @@
+contract C {
+ address constant a = address(0);
+ address payable constant b = address(0);
+ function f() public {
+ a = address(0);
+ b = address(0);
+ }
+}
+// ----
+// TypeError: (129-130): Cannot assign to a constant variable.
+// TypeError: (153-154): Cannot assign to a constant variable.
diff --git a/test/libsolidity/syntaxTests/types/address/address_in_struct_fail.sol b/test/libsolidity/syntaxTests/types/address/address_in_struct_fail.sol
new file mode 100644
index 00000000..9a5b2abb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/address_in_struct_fail.sol
@@ -0,0 +1,11 @@
+contract A {
+ struct S {
+ address payable a;
+ }
+ S s;
+ function f() public {
+ s.a = address(this);
+ }
+}
+// ----
+// TypeError: (110-123): Type address is not implicitly convertible to expected type address payable.
diff --git a/test/libsolidity/syntaxTests/types/address/address_in_struct_fine.sol b/test/libsolidity/syntaxTests/types/address/address_in_struct_fine.sol
new file mode 100644
index 00000000..5519f0ef
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/address_in_struct_fine.sol
@@ -0,0 +1,20 @@
+contract A {
+ struct S {
+ address a;
+ }
+ S s;
+ function f() public {
+ s.a = address(this);
+ }
+}
+contract B {
+ struct S {
+ address payable a;
+ }
+ S s;
+ function f() public {
+ s.a = address(this);
+ }
+ function() external payable {
+ }
+} \ No newline at end of file
diff --git a/test/libsolidity/syntaxTests/types/address_members_in_contract.sol b/test/libsolidity/syntaxTests/types/address/address_members_in_contract.sol
index eafc8268..eafc8268 100644
--- a/test/libsolidity/syntaxTests/types/address_members_in_contract.sol
+++ b/test/libsolidity/syntaxTests/types/address/address_members_in_contract.sol
diff --git a/test/libsolidity/syntaxTests/types/address/address_nonpayable_selfdestruct.sol b/test/libsolidity/syntaxTests/types/address/address_nonpayable_selfdestruct.sol
new file mode 100644
index 00000000..cc680ff3
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/address_nonpayable_selfdestruct.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f(address a) public {
+ selfdestruct(a);
+ }
+}
+// ----
+// TypeError: (69-70): Invalid type for argument in function call. Invalid implicit conversion from address to address payable requested.
diff --git a/test/libsolidity/syntaxTests/types/address/address_payable_external_overload.sol b/test/libsolidity/syntaxTests/types/address/address_payable_external_overload.sol
new file mode 100644
index 00000000..875532c4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/address_payable_external_overload.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f(address) external pure {}
+ function f(address payable) external pure {}
+
+}
+// ----
+// TypeError: (58-102): Function overload clash during conversion to external types for arguments.
diff --git a/test/libsolidity/syntaxTests/types/address/address_payable_internal_overload_nonpayable.sol b/test/libsolidity/syntaxTests/types/address/address_payable_internal_overload_nonpayable.sol
new file mode 100644
index 00000000..65600544
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/address_payable_internal_overload_nonpayable.sol
@@ -0,0 +1,10 @@
+contract C {
+ function f(address payable) internal pure {}
+ function f(address) internal pure returns (uint) {}
+ function g() internal pure {
+ address a = address(0);
+ uint b = f(a); // TODO: should this be valid?
+ b;
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/types/address/address_payable_internal_overload_payable.sol b/test/libsolidity/syntaxTests/types/address/address_payable_internal_overload_payable.sol
new file mode 100644
index 00000000..84142a31
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/address_payable_internal_overload_payable.sol
@@ -0,0 +1,10 @@
+contract C {
+ function f(address payable) internal pure {}
+ function f(address) internal pure {}
+ function g() internal pure {
+ address payable a = address(0);
+ f(a);
+ }
+}
+// ----
+// TypeError: (184-185): No unique declaration found after argument-dependent lookup.
diff --git a/test/libsolidity/syntaxTests/types/address/address_payable_memory_array_conversion.sol b/test/libsolidity/syntaxTests/types/address/address_payable_memory_array_conversion.sol
new file mode 100644
index 00000000..ec58170b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/address_payable_memory_array_conversion.sol
@@ -0,0 +1,11 @@
+contract C {
+ function f() public pure {
+ address payable[] memory a = new address payable[](4);
+ address[] memory b = new address[](4);
+ a = b;
+ b = a;
+ }
+}
+// ----
+// TypeError: (166-167): Type address[] memory is not implicitly convertible to expected type address payable[] memory.
+// TypeError: (181-182): Type address payable[] memory is not implicitly convertible to expected type address[] memory.
diff --git a/test/libsolidity/syntaxTests/types/address/address_payable_public_overload.sol b/test/libsolidity/syntaxTests/types/address/address_payable_public_overload.sol
new file mode 100644
index 00000000..839abc26
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/address_payable_public_overload.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f(address) public pure {}
+ function f(address payable) public pure {}
+
+}
+// ----
+// TypeError: (56-98): Function overload clash during conversion to external types for arguments.
diff --git a/test/libsolidity/syntaxTests/types/address/address_payable_selfdestruct.sol b/test/libsolidity/syntaxTests/types/address/address_payable_selfdestruct.sol
new file mode 100644
index 00000000..bdf43be7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/address_payable_selfdestruct.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f(address payable a) public {
+ selfdestruct(a);
+ }
+}
diff --git a/test/libsolidity/syntaxTests/types/address/address_payable_storage_array_conversion.sol b/test/libsolidity/syntaxTests/types/address/address_payable_storage_array_conversion.sol
new file mode 100644
index 00000000..40f85ccc
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/address_payable_storage_array_conversion.sol
@@ -0,0 +1,11 @@
+contract C {
+ address payable[] a;
+ address[] b;
+ function f() public view {
+ address payable[] storage c = a;
+ address[] storage d = b;
+ d = c; // TODO: this could be allowed in the future
+ }
+}
+// ----
+// TypeError: (172-173): Type address payable[] storage pointer is not implicitly convertible to expected type address[] storage pointer.
diff --git a/test/libsolidity/syntaxTests/types/address/address_payable_storage_array_conversion_fail.sol b/test/libsolidity/syntaxTests/types/address/address_payable_storage_array_conversion_fail.sol
new file mode 100644
index 00000000..3c3eb859
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/address_payable_storage_array_conversion_fail.sol
@@ -0,0 +1,11 @@
+contract C {
+ address payable[] a;
+ address[] b;
+ function f() public view {
+ address payable[] storage c = a;
+ address[] storage d = b;
+ c = d;
+ }
+}
+// ----
+// TypeError: (172-173): Type address[] storage pointer is not implicitly convertible to expected type address payable[] storage pointer.
diff --git a/test/libsolidity/syntaxTests/types/address_to_contract.sol b/test/libsolidity/syntaxTests/types/address/address_to_contract.sol
index 629a3df0..629a3df0 100644
--- a/test/libsolidity/syntaxTests/types/address_to_contract.sol
+++ b/test/libsolidity/syntaxTests/types/address/address_to_contract.sol
diff --git a/test/libsolidity/syntaxTests/types/address/address_to_contract_implicitly.sol b/test/libsolidity/syntaxTests/types/address/address_to_contract_implicitly.sol
new file mode 100644
index 00000000..c9e5ddf6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/address_to_contract_implicitly.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public view {
+ C c = address(2);
+ }
+}
+// ----
+// TypeError: (46-62): Type address payable is not implicitly convertible to expected type contract C.
diff --git a/test/libsolidity/syntaxTests/types/address/address_to_contract_payable_fallback.sol b/test/libsolidity/syntaxTests/types/address/address_to_contract_payable_fallback.sol
new file mode 100644
index 00000000..6917444b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/address_to_contract_payable_fallback.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() public pure returns (C c) {
+ c = C(address(2));
+ }
+ function() external payable {
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/types/address/address_to_payable_address.sol b/test/libsolidity/syntaxTests/types/address/address_to_payable_address.sol
new file mode 100644
index 00000000..1aab9b51
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/address_to_payable_address.sol
@@ -0,0 +1,10 @@
+contract C {
+ function f(address a) public pure {
+ address b;
+ address payable c = a;
+ c = b;
+ }
+}
+// ----
+// TypeError: (80-101): Type address is not implicitly convertible to expected type address payable.
+// TypeError: (115-116): Type address is not implicitly convertible to expected type address payable.
diff --git a/test/libsolidity/syntaxTests/types/address/address_to_payable_address_double.sol b/test/libsolidity/syntaxTests/types/address/address_to_payable_address_double.sol
new file mode 100644
index 00000000..1e755033
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/address_to_payable_address_double.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f(address a) public pure returns (address payable) {
+ return address(address(a));
+ }
+}
+// ----
+// TypeError: (94-113): Return argument type address is not implicitly convertible to expected type (type of first return variable) address payable.
diff --git a/test/libsolidity/syntaxTests/types/address/address_tuple_fail.sol b/test/libsolidity/syntaxTests/types/address/address_tuple_fail.sol
new file mode 100644
index 00000000..17e9e7c1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/address_tuple_fail.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() public view returns (address payable a, address b) {
+ (address c, address payable d) = (address(this), address(0));
+ (a,b) = (c,d);
+ }
+}
+// ----
+// TypeError: (169-174): Type tuple(address,address payable) is not implicitly convertible to expected type tuple(address payable,address).
diff --git a/test/libsolidity/syntaxTests/types/address/address_tuple_fine.sol b/test/libsolidity/syntaxTests/types/address/address_tuple_fine.sol
new file mode 100644
index 00000000..846de1f4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/address_tuple_fine.sol
@@ -0,0 +1,6 @@
+contract C {
+ function f() public view returns (address payable a, address b) {
+ (address c, address payable d) = (address(this), address(0));
+ (a,b) = (d,c);
+ }
+} \ No newline at end of file
diff --git a/test/libsolidity/syntaxTests/types/address/bytes_long_to_payable_address.sol b/test/libsolidity/syntaxTests/types/address/bytes_long_to_payable_address.sol
new file mode 100644
index 00000000..ef87ac55
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/bytes_long_to_payable_address.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f(bytes32 x) public pure returns (address payable) {
+ return address(x);
+ }
+}
+// ----
+// TypeError: (94-104): Explicit type conversion not allowed from "bytes32" to "address".
+// TypeError: (94-104): Return argument type address is not implicitly convertible to expected type (type of first return variable) address payable.
diff --git a/test/libsolidity/syntaxTests/types/address/bytes_short_to_payable_address.sol b/test/libsolidity/syntaxTests/types/address/bytes_short_to_payable_address.sol
new file mode 100644
index 00000000..2aa60251
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/bytes_short_to_payable_address.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f(bytes10 x) public pure returns (address payable) {
+ return address(x);
+ }
+}
+// ----
+// TypeError: (94-104): Explicit type conversion not allowed from "bytes10" to "address".
+// TypeError: (94-104): Return argument type address is not implicitly convertible to expected type (type of first return variable) address payable.
diff --git a/test/libsolidity/syntaxTests/types/address/bytes_to_payable_address.sol b/test/libsolidity/syntaxTests/types/address/bytes_to_payable_address.sol
new file mode 100644
index 00000000..5b6a6714
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/bytes_to_payable_address.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f(bytes20 x) public pure returns (address payable) {
+ return address(x);
+ }
+}
diff --git a/test/libsolidity/syntaxTests/types/address/contract_no_fallback_to_payable_address.sol b/test/libsolidity/syntaxTests/types/address/contract_no_fallback_to_payable_address.sol
new file mode 100644
index 00000000..777bce00
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/contract_no_fallback_to_payable_address.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() public view {
+ address payable a = address(this);
+ a;
+ }
+}
+// ----
+// TypeError: (46-79): Type address is not implicitly convertible to expected type address payable.
diff --git a/test/libsolidity/syntaxTests/types/address/contract_non_payable_fallback_to_payable_address.sol b/test/libsolidity/syntaxTests/types/address/contract_non_payable_fallback_to_payable_address.sol
new file mode 100644
index 00000000..6518eebb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/contract_non_payable_fallback_to_payable_address.sol
@@ -0,0 +1,10 @@
+contract C {
+ function f() public view {
+ address payable a = address(this);
+ a;
+ }
+ function() external {
+ }
+}
+// ----
+// TypeError: (46-79): Type address is not implicitly convertible to expected type address payable.
diff --git a/test/libsolidity/syntaxTests/types/address/contract_payable_fallback_to_payable_address.sol b/test/libsolidity/syntaxTests/types/address/contract_payable_fallback_to_payable_address.sol
new file mode 100644
index 00000000..359beeb4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/contract_payable_fallback_to_payable_address.sol
@@ -0,0 +1,9 @@
+contract C {
+ function f() public view {
+ address payable a = address(this);
+ a;
+ }
+ function() external payable {
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/types/address/contract_payable_fallback_to_payable_address_implicitly.sol b/test/libsolidity/syntaxTests/types/address/contract_payable_fallback_to_payable_address_implicitly.sol
new file mode 100644
index 00000000..4b20b1c6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/contract_payable_fallback_to_payable_address_implicitly.sol
@@ -0,0 +1,10 @@
+contract C {
+ function f() public view {
+ address payable a = this;
+ a;
+ }
+ function() external payable {
+ }
+}
+// ----
+// TypeError: (46-70): Type contract C is not implicitly convertible to expected type address payable.
diff --git a/test/libsolidity/syntaxTests/types/contract_to_address.sol b/test/libsolidity/syntaxTests/types/address/contract_to_address.sol
index ec2f8184..ec2f8184 100644
--- a/test/libsolidity/syntaxTests/types/contract_to_address.sol
+++ b/test/libsolidity/syntaxTests/types/address/contract_to_address.sol
diff --git a/test/libsolidity/syntaxTests/types/contract_to_address_implicitly.sol b/test/libsolidity/syntaxTests/types/address/contract_to_address_implicitly.sol
index 8be9daac..8be9daac 100644
--- a/test/libsolidity/syntaxTests/types/contract_to_address_implicitly.sol
+++ b/test/libsolidity/syntaxTests/types/address/contract_to_address_implicitly.sol
diff --git a/test/libsolidity/syntaxTests/types/address/literal_to_address.sol b/test/libsolidity/syntaxTests/types/address/literal_to_address.sol
new file mode 100644
index 00000000..20ee56de
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/literal_to_address.sol
@@ -0,0 +1,9 @@
+contract C {
+ function f() public pure {
+ address a = address(0);
+ a = address(1);
+ address b = 0x0123456789012345678901234567890123456789;
+ b = 0x9876543210987654321098765432109876543210;
+ b = 0x9876_5432_1098_7654_3210_9876_5432_1098_7654_3210;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/types/address/literal_to_payable_address.sol b/test/libsolidity/syntaxTests/types/address/literal_to_payable_address.sol
new file mode 100644
index 00000000..97f4d85d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/literal_to_payable_address.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() public pure {
+ address payable a = address(0);
+ a = address(1);
+ address payable b = 0x0123456789012345678901234567890123456789;
+ b = 0x9876543210987654321098765432109876543210;
+ }
+} \ No newline at end of file
diff --git a/test/libsolidity/syntaxTests/types/address/nonpayable_address_to_contract_payable_fallback.sol b/test/libsolidity/syntaxTests/types/address/nonpayable_address_to_contract_payable_fallback.sol
new file mode 100644
index 00000000..e13a0897
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/nonpayable_address_to_contract_payable_fallback.sol
@@ -0,0 +1,10 @@
+contract C {
+ function f() public pure returns (C c) {
+ address a = address(2);
+ c = C(a);
+ }
+ function() external payable {
+ }
+}
+// ----
+// TypeError: (92-96): Explicit type conversion not allowed from non-payable "address" to "contract C", which has a payable fallback function.
diff --git a/test/libsolidity/syntaxTests/types/address/payable_address_to_address.sol b/test/libsolidity/syntaxTests/types/address/payable_address_to_address.sol
new file mode 100644
index 00000000..f5dbf937
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/payable_address_to_address.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f(address payable a) public pure {
+ address payable b;
+ address c = a;
+ c = b;
+ }
+} \ No newline at end of file
diff --git a/test/libsolidity/syntaxTests/types/address/uint_to_payable_address.sol b/test/libsolidity/syntaxTests/types/address/uint_to_payable_address.sol
new file mode 100644
index 00000000..9a33985a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/uint_to_payable_address.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f(uint x) public pure returns (address payable) {
+ return address(x);
+ }
+}
diff --git a/test/libsolidity/syntaxTests/types/address_to_contract_implicitly.sol b/test/libsolidity/syntaxTests/types/address_to_contract_implicitly.sol
deleted file mode 100644
index efab7c27..00000000
--- a/test/libsolidity/syntaxTests/types/address_to_contract_implicitly.sol
+++ /dev/null
@@ -1,7 +0,0 @@
-contract C {
- function f() public view {
- C c = address(2);
- }
-}
-// ----
-// TypeError: (46-62): Type address is not implicitly convertible to expected type contract C.
diff --git a/test/libsolidity/syntaxTests/unicode_escape_literals.sol b/test/libsolidity/syntaxTests/unicode_escape_literals.sol
new file mode 100644
index 00000000..a340487b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/unicode_escape_literals.sol
@@ -0,0 +1,31 @@
+contract test {
+
+ function oneByteUTF8() public pure returns (bytes32) {
+ bytes32 usdollar = "aaa\u0024aaa";
+ return usdollar;
+ }
+
+ function twoBytesUTF8() public pure returns (bytes32) {
+ bytes32 cent = "aaa\u00A2aaa";
+ return cent;
+ }
+
+ function threeBytesUTF8() public pure returns (bytes32) {
+ bytes32 eur = "aaa\u20ACaaa";
+ return eur;
+ }
+
+ function together() public pure returns (bytes32) {
+ bytes32 res = "\u0024\u00A2\u20AC";
+ return res;
+ }
+
+ // this function returns an invalid unicode character
+ function invalidLiteral() public pure returns(bytes32) {
+ bytes32 invalid = "\u00xx";
+ return invalid;
+ }
+
+}
+// ----
+// ParserError: (678-681): Expected primary expression.
diff --git a/test/libsolidity/syntaxTests/unterminatedBlocks/one_dot.sol b/test/libsolidity/syntaxTests/unterminatedBlocks/one_dot.sol
new file mode 100644
index 00000000..a678f004
--- /dev/null
+++ b/test/libsolidity/syntaxTests/unterminatedBlocks/one_dot.sol
@@ -0,0 +1,4 @@
+contract c {
+ function f() pure public { 1.
+// ----
+// ParserError: (47-47): Expected identifier but got end of source \ No newline at end of file
diff --git a/test/libsolidity/syntaxTests/unterminatedBlocks/one_dot_x.sol b/test/libsolidity/syntaxTests/unterminatedBlocks/one_dot_x.sol
new file mode 100644
index 00000000..3cc59374
--- /dev/null
+++ b/test/libsolidity/syntaxTests/unterminatedBlocks/one_dot_x.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f() pure public { 1.x; }
+}
+// ----
+// TypeError: (47-50): Member "x" not found or not visible after argument-dependent lookup in int_const 1. \ No newline at end of file
diff --git a/test/libsolidity/syntaxTests/unterminatedBlocks/zero_dot.sol b/test/libsolidity/syntaxTests/unterminatedBlocks/zero_dot.sol
new file mode 100644
index 00000000..6ba2b4c2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/unterminatedBlocks/zero_dot.sol
@@ -0,0 +1,4 @@
+contract c {
+ function f() pure public { 0.
+// ----
+// ParserError: (47-47): Expected identifier but got end of source \ No newline at end of file
diff --git a/test/libsolidity/syntaxTests/unterminatedBlocks/zero_dot_x.sol b/test/libsolidity/syntaxTests/unterminatedBlocks/zero_dot_x.sol
new file mode 100644
index 00000000..8648bce2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/unterminatedBlocks/zero_dot_x.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f() pure public { 0.x; }
+}
+// ----
+// TypeError: (47-50): Member "x" not found or not visible after argument-dependent lookup in int_const 0. \ No newline at end of file
diff --git a/test/libsolidity/syntaxTests/upper_case_hex_literals.sol b/test/libsolidity/syntaxTests/upper_case_hex_literals.sol
new file mode 100644
index 00000000..0842c2ec
--- /dev/null
+++ b/test/libsolidity/syntaxTests/upper_case_hex_literals.sol
@@ -0,0 +1,9 @@
+contract test {
+
+ function f() public pure returns (uint256) {
+ uint256 a = 0x1234aAbcC;
+ uint256 b = 0x1234ABCDEF;
+ return a + b;
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_view_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_view_fail.sol
index f951feb4..5356f0b8 100644
--- a/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_view_fail.sol
+++ b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_view_fail.sol
@@ -16,6 +16,8 @@ contract C {
(bool success,) = address(this).call("");
require(success);
}
+ function() payable external {
+ }
}
// ----
// TypeError: (52-77): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.