2018-05-30 16:41:34 +00:00
|
|
|
contract C {
|
|
|
|
struct s1 {
|
|
|
|
uint x;
|
|
|
|
}
|
|
|
|
s1 struct_x;
|
|
|
|
s1 struct_y;
|
|
|
|
|
|
|
|
function fun_x() public {}
|
|
|
|
function fun_y() public {}
|
|
|
|
|
|
|
|
enum small { A, B, C, D }
|
|
|
|
|
|
|
|
mapping(uint8 => uint8) table1;
|
|
|
|
mapping(uint8 => uint8) table2;
|
|
|
|
|
|
|
|
function f() public {
|
|
|
|
// integers
|
|
|
|
uint x;
|
|
|
|
uint y;
|
|
|
|
uint g = true ? x : y;
|
|
|
|
g += 1; // Avoid unused var warning
|
|
|
|
|
|
|
|
// integer constants
|
|
|
|
uint h = true ? 1 : 3;
|
|
|
|
h += 1; // Avoid unused var warning
|
|
|
|
|
|
|
|
// string literal
|
2018-06-11 12:15:27 +00:00
|
|
|
string memory i = true ? "hello" : "world";
|
2018-05-30 16:41:34 +00:00
|
|
|
i = "used"; //Avoid unused var warning
|
|
|
|
}
|
|
|
|
function f2() public {
|
|
|
|
// bool
|
|
|
|
bool j = true ? true : false;
|
|
|
|
j = j && true; // Avoid unused var warning
|
|
|
|
|
|
|
|
// real is not there yet.
|
|
|
|
|
|
|
|
// array
|
|
|
|
byte[2] memory a;
|
|
|
|
byte[2] memory b;
|
2018-06-11 12:15:27 +00:00
|
|
|
byte[2] memory k = true ? a : b;
|
2018-05-30 16:41:34 +00:00
|
|
|
k[0] = byte(0); //Avoid unused var warning
|
|
|
|
|
|
|
|
bytes memory e;
|
|
|
|
bytes memory f;
|
2018-06-11 12:15:27 +00:00
|
|
|
bytes memory l = true ? e : f;
|
2018-05-30 16:41:34 +00:00
|
|
|
l[0] = byte(0); // Avoid unused var warning
|
|
|
|
|
|
|
|
// fixed bytes
|
|
|
|
bytes2 c;
|
|
|
|
bytes2 d;
|
2018-06-11 12:15:27 +00:00
|
|
|
bytes2 m = true ? c : d;
|
2018-05-30 16:41:34 +00:00
|
|
|
m &= m;
|
|
|
|
|
|
|
|
}
|
|
|
|
function f3() public {
|
|
|
|
// contract doesn't fit in here
|
|
|
|
|
|
|
|
// struct
|
|
|
|
struct_x = true ? struct_x : struct_y;
|
|
|
|
|
|
|
|
// function
|
2018-06-11 12:15:27 +00:00
|
|
|
function () r = true ? fun_x : fun_y;
|
2018-05-30 16:41:34 +00:00
|
|
|
r(); // Avoid unused var warning
|
|
|
|
// enum
|
|
|
|
small enum_x;
|
|
|
|
small enum_y;
|
|
|
|
enum_x = true ? enum_x : enum_y;
|
|
|
|
|
|
|
|
// tuple
|
2018-06-11 12:15:27 +00:00
|
|
|
(uint n, uint o) = true ? (1, 2) : (3, 4);
|
2018-05-30 16:41:34 +00:00
|
|
|
(n, o) = (o, n); // Avoid unused var warning
|
|
|
|
// mapping
|
2018-07-18 15:20:26 +00:00
|
|
|
mapping(uint8 => uint8) storage p = true ? table1 : table2;
|
2018-05-30 16:41:34 +00:00
|
|
|
p[0] = 0; // Avoid unused var warning
|
|
|
|
// typetype
|
2018-06-11 12:15:27 +00:00
|
|
|
uint32 q = true ? uint32(1) : uint32(2);
|
2018-05-30 16:41:34 +00:00
|
|
|
q += 1; // Avoid unused var warning
|
|
|
|
// modifier doesn't fit in here
|
|
|
|
|
|
|
|
// magic doesn't fit in here
|
|
|
|
|
|
|
|
// module doesn't fit in here
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// ----
|
2018-06-11 12:15:27 +00:00
|
|
|
// Warning: (1005-1019): This declaration shadows an existing declaration.
|
|
|
|
// Warning: (257-642): Function state mutability can be restricted to pure
|
|
|
|
// Warning: (647-1227): Function state mutability can be restricted to pure
|