diff --git a/test/libsolidity/syntaxTests/array/new_no_parentheses.sol b/test/libsolidity/syntaxTests/array/new_no_parentheses.sol new file mode 100644 index 000000000..d42c75539 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/new_no_parentheses.sol @@ -0,0 +1,7 @@ +contract C { + function f(uint size) public { + new uint[1]; + } +} +// ---- +// TypeError: (60-67): Length has to be placed in parentheses after the array type for new expression. diff --git a/test/libsolidity/syntaxTests/constructor/not_a_contract.sol b/test/libsolidity/syntaxTests/constructor/not_a_contract.sol new file mode 100644 index 000000000..9b05b46e3 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor/not_a_contract.sol @@ -0,0 +1,9 @@ +// This used to cause an internal error because of the visitation order. +contract Test { + struct S { uint a; } + function f() public { + new S(); + } +} +// ---- +// TypeError: (147-152): Identifier is not a contract. diff --git a/test/libsolidity/syntaxTests/inheritance/wrong_type_base_arguments.sol b/test/libsolidity/syntaxTests/inheritance/wrong_type_base_arguments.sol new file mode 100644 index 000000000..aa29af52a --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/wrong_type_base_arguments.sol @@ -0,0 +1,9 @@ +contract Base { + constructor(uint8) public {} +} +contract Derived is Base(300) { } +contract Derived2 is Base { + constructor() Base(2) public { } +} +// ---- +// TypeError: (74-77): Invalid type for argument in constructor call. Invalid implicit conversion from int_const 300 to uint8 requested. diff --git a/test/libsolidity/syntaxTests/memberLookup/member_not_unique.sol b/test/libsolidity/syntaxTests/memberLookup/member_not_unique.sol new file mode 100644 index 000000000..37ef32b01 --- /dev/null +++ b/test/libsolidity/syntaxTests/memberLookup/member_not_unique.sol @@ -0,0 +1,13 @@ +contract C { + function a(uint256) public returns (uint) { return 1; } + function a(uint8) public returns (uint) { return 1; } + + function f() public returns (C) { return this; } + + function g() internal returns (function(uint8) internal returns(uint)) + { + return f().a; + } +} +// ---- +// TypeError: (282-287): Member "a" not unique after argument-dependent lookup in contract C. diff --git a/test/libsolidity/syntaxTests/memberLookup/member_value_not_unique.sol b/test/libsolidity/syntaxTests/memberLookup/member_value_not_unique.sol new file mode 100644 index 000000000..e1c69fe3e --- /dev/null +++ b/test/libsolidity/syntaxTests/memberLookup/member_value_not_unique.sol @@ -0,0 +1,13 @@ +contract C { + function value(uint256) public returns (uint) { return 1; } + function value(uint8) public returns (uint) { return 1; } + + function f() public returns (C) { return this; } + + function g() internal returns (function(uint8) internal returns(uint)) + { + return f().value; + } +} +// ---- +// TypeError: (290-299): Member "value" not unique after argument-dependent lookup in contract C - did you forget the "payable" modifier? diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/typeChecking/return_tuple_not_convertible.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/typeChecking/return_tuple_not_convertible.sol new file mode 100644 index 000000000..cd6f71f28 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/typeChecking/return_tuple_not_convertible.sol @@ -0,0 +1,5 @@ +contract test { + function f() public returns (uint256 r, uint8) { return ((12, "")); } +} +// ---- +// TypeError: (76-86): Return argument type tuple(int_const 12,literal_string "") is not implicitly convertible to expected type tuple(uint256,uint8). diff --git a/test/libsolidity/syntaxTests/types/var_type_invalid_rational.sol b/test/libsolidity/syntaxTests/types/var_type_invalid_rational.sol new file mode 100644 index 000000000..a7c006411 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/var_type_invalid_rational.sol @@ -0,0 +1,8 @@ +contract C { + function f() internal pure { + var i = 31415999999999999999999999999999999999999999999999999999999999999999933**3; + var unreachable = 123; + } +} +// ---- +// TypeError: (62-136): Invalid rational int_const 3100...(204 digits omitted)...9237 (absolute value too large or division by zero). diff --git a/test/libsolidity/syntaxTests/types/var_type_suggest.sol b/test/libsolidity/syntaxTests/types/var_type_suggest.sol index cc35fdd64..2de893cb7 100644 --- a/test/libsolidity/syntaxTests/types/var_type_suggest.sol +++ b/test/libsolidity/syntaxTests/types/var_type_suggest.sol @@ -6,6 +6,7 @@ contract C { return x; } function f() internal pure { + var s = -31415; var i = 31415; var t = "string"; var g2 = g; @@ -19,17 +20,18 @@ contract C { } } // ---- -// SyntaxError: (224-237): Use of the "var" keyword is disallowed. Use explicit declaration `uint16 i = ...´ instead. -// SyntaxError: (247-263): Use of the "var" keyword is disallowed. Use explicit declaration `string memory t = ...´ instead. -// SyntaxError: (273-283): Use of the "var" keyword is disallowed. Use explicit declaration `function (uint256) pure returns (uint256) g2 = ...´ instead. -// SyntaxError: (293-326): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. -// SyntaxError: (336-360): Use of the "var" keyword is disallowed. Use explicit declaration `(uint8 a, string memory b) = ...´ instead. -// SyntaxError: (370-387): Use of the "var" keyword is disallowed. Use explicit declaration `(uint256 x, , uint256 z) = ...´ instead. -// TypeError: (397-414): Different number of components on the left hand side (2) than on the right hand side (1). -// SyntaxError: (397-414): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. -// TypeError: (424-440): Different number of components on the left hand side (2) than on the right hand side (1). -// SyntaxError: (424-440): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. -// TypeError: (450-464): Different number of components on the left hand side (2) than on the right hand side (1). -// SyntaxError: (450-464): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. -// TypeError: (474-489): Different number of components on the left hand side (2) than on the right hand side (1). -// SyntaxError: (474-489): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. +// SyntaxError: (224-238): Use of the "var" keyword is disallowed. Use explicit declaration `int16 s = ...´ instead. +// SyntaxError: (248-261): Use of the "var" keyword is disallowed. Use explicit declaration `uint16 i = ...´ instead. +// SyntaxError: (271-287): Use of the "var" keyword is disallowed. Use explicit declaration `string memory t = ...´ instead. +// SyntaxError: (297-307): Use of the "var" keyword is disallowed. Use explicit declaration `function (uint256) pure returns (uint256) g2 = ...´ instead. +// SyntaxError: (317-350): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. +// SyntaxError: (360-384): Use of the "var" keyword is disallowed. Use explicit declaration `(uint8 a, string memory b) = ...´ instead. +// SyntaxError: (394-411): Use of the "var" keyword is disallowed. Use explicit declaration `(uint256 x, , uint256 z) = ...´ instead. +// TypeError: (421-438): Different number of components on the left hand side (2) than on the right hand side (1). +// SyntaxError: (421-438): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. +// TypeError: (448-464): Different number of components on the left hand side (2) than on the right hand side (1). +// SyntaxError: (448-464): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. +// TypeError: (474-488): Different number of components on the left hand side (2) than on the right hand side (1). +// SyntaxError: (474-488): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. +// TypeError: (498-513): Different number of components on the left hand side (2) than on the right hand side (1). +// SyntaxError: (498-513): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax.