diff options
Diffstat (limited to 'test/libsolidity')
34 files changed, 1434 insertions, 7 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/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_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/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/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/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_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/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/address/literal_to_address.sol b/test/libsolidity/syntaxTests/types/address/literal_to_address.sol new file mode 100644 index 00000000..9d599ea5 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address/literal_to_address.sol @@ -0,0 +1,8 @@ +contract C { + function f() public pure { + address a = address(0); + a = address(1); + address b = 0x0123456789012345678901234567890123456789; + b = 0x9876543210987654321098765432109876543210; + } +} 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_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. |