mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add tests to increase coverage of TypeChecker
This commit is contained in:
parent
42240a69e9
commit
ee28cb65a6
@ -0,0 +1,6 @@
|
||||
contract X {}
|
||||
contract D {
|
||||
constructor() X(5) public {}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (45-49): Referenced declaration is neither modifier nor base class.
|
@ -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.
|
||||
|
@ -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.
|
@ -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.
|
@ -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.
|
@ -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.
|
@ -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.
|
@ -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.
|
Loading…
Reference in New Issue
Block a user