Add tests to increase coverage of TypeChecker

This commit is contained in:
Mathias Baumann 2019-02-06 20:43:53 +01:00
parent 42240a69e9
commit ee28cb65a6
8 changed files with 63 additions and 1 deletions

View File

@ -0,0 +1,6 @@
contract X {}
contract D {
constructor() X(5) public {}
}
// ----
// TypeError: (45-49): Referenced declaration is neither modifier nor base class.

View File

@ -1,8 +1,10 @@
contract C {
function f() public {
// Invalid number
78901234567890123456789012345678901234567890123456789345678901234567890012345678012345678901234567;
[1, 78901234567890123456789012345678901234567890123456789345678901234567890012345678012345678901234567];
}
}
// ----
// TypeError: (93-191): Invalid rational number.
// TypeError: (89-187): Invalid rational number.
// TypeError: (205-303): Invalid rational number.

View File

@ -0,0 +1,8 @@
contract C {
struct s { uint a; uint b; }
function f() pure public {
abi.decode("", (s));
}
}
// ----
// TypeError: (98-99): Decoding type struct C.s memory not supported.

View File

@ -0,0 +1,12 @@
contract C {
constructor(bytes32 _arg) public {
}
}
contract A {
function f() public {
new C((1234));
}
}
// ----
// TypeError: (115-121): Invalid type for argument in function call. Invalid implicit conversion from int_const 1234 to bytes32 requested.

View File

@ -0,0 +1,7 @@
contract c {
event e(uint indexed a, mapping(uint => uint) indexed b, bool indexed c, uint indexed d, uint indexed e) anonymous;
}
// ----
// TypeError: (41-72): Type is required to live outside storage.
// TypeError: (41-72): Internal or recursive type is not allowed as event parameter type.
// TypeError: (17-132): More than 4 indexed arguments for anonymous event.

View File

@ -0,0 +1,10 @@
contract C {
function f() pure external {
function() external two_stack_slots;
assembly {
let x := two_stack_slots
}
}
}
// ----
// TypeError: (132-147): Only types that use one stack slot are supported.

View File

@ -0,0 +1,9 @@
contract C
{
function g() public pure returns (uint)
{
return "string";
}
}
// ----
// TypeError: (78-86): Return argument type literal_string "string" is not implicitly convertible to expected type (type of first return variable) uint256.

View File

@ -0,0 +1,8 @@
contract C {
function f() public pure {
abi.decode(uint, uint);
}
}
// ----
// TypeError: (57-61): Invalid type for argument in function call. Invalid implicit conversion from type(uint256) to bytes memory requested.
// TypeError: (63-67): The second argument to "abi.decode" has to be a tuple of types.