Restrict mobileType of TypeType

This commit is contained in:
Matheus Aguiar
2023-07-18 12:58:11 +02:00
committed by Kamil Śliwak
parent 2c82873a2c
commit 4fd5bbf50b
23 changed files with 204 additions and 1 deletions
@@ -0,0 +1,17 @@
contract C {
function f() pure public {
abi.decode("", ((uint)[2]));
abi.decode("", ((uint)[]));
abi.decode("", ((uint)[][3]));
abi.decode("", ((uint)[4][]));
abi.decode("", ((uint)[5][6]));
abi.decode("", (((uint))[5][6]));
}
}
// ----
// Warning 6133: (52-79): Statement has no effect.
// Warning 6133: (89-115): Statement has no effect.
// Warning 6133: (125-154): Statement has no effect.
// Warning 6133: (164-193): Statement has no effect.
// Warning 6133: (203-233): Statement has no effect.
// Warning 6133: (243-275): Statement has no effect.
@@ -0,0 +1,8 @@
contract C {
enum Color { red, green, blue }
function f() pure public {
abi.decode("", (Color));
}
}
// ----
// Warning 6133: (88-111): Statement has no effect.
@@ -0,0 +1,9 @@
contract C {
function f() pure public {
bool x;
abi.decode("", (uint[type(x = true ? uint8 : uint8).max]));
}
}
// ----
// TypeError 9717: (105-110): Invalid mobile type in true expression.
// TypeError 3703: (113-118): Invalid mobile type in false expression.
@@ -0,0 +1,7 @@
contract C {
function f() pure public {
abi.decode("", ((uint, int)[5][6]));
}
}
// ----
// TypeError 2614: (68-79): Indexed expression has to be a type, mapping or array (is tuple(type(uint256),type(int256)))
@@ -0,0 +1,7 @@
contract C {
function f() pure public {
abi.decode("", ([uint][2]));
}
}
// ----
// TypeError 9563: (69-73): Invalid mobile type.
@@ -0,0 +1,9 @@
contract C {
function f() pure public {
bool x;
abi.decode("", ((x = true ? uint : uint)[0]));
}
}
// ----
// TypeError 9717: (96-100): Invalid mobile type in true expression.
// TypeError 3703: (103-107): Invalid mobile type in false expression.
@@ -0,0 +1,8 @@
contract C {
function f() pure public {
abi.decode("", (true ? uint : uint));
}
}
// ----
// TypeError 9717: (75-79): Invalid mobile type in true expression.
// TypeError 3703: (82-86): Invalid mobile type in false expression.
@@ -0,0 +1,8 @@
contract C {
function f() pure public {
abi.decode("", ((true ? uint : uint)));
}
}
// ----
// TypeError 9717: (76-80): Invalid mobile type in true expression.
// TypeError 3703: (83-87): Invalid mobile type in false expression.
@@ -0,0 +1,9 @@
contract C {
function f() pure public {
int x;
abi.decode("", ((x = 1) > 0 ? int : int));
}
}
// ----
// TypeError 9717: (97-100): Invalid mobile type in true expression.
// TypeError 3703: (103-106): Invalid mobile type in false expression.
@@ -0,0 +1,7 @@
contract C {
function f() pure public {
abi.decode("", ((uint, int)));
}
}
// ----
// TypeError 1039: (68-79): Argument has to be a type name.
@@ -0,0 +1,7 @@
contract C {
function f() pure public {
abi.decode("", (type(uint)));
}
}
// ----
// TypeError 1039: (68-78): Argument has to be a type name.
@@ -0,0 +1,19 @@
library L {
struct S { int a; }
enum State { idle, running, blocked }
}
contract D {
struct X { uint b; }
enum Color { red, green, blue }
}
contract C {
function f() pure public {
abi.decode("", (L.S));
abi.decode("", (L.State));
abi.decode("", (D.X));
abi.decode("", (D.Color));
}
}
// ----
@@ -0,0 +1,13 @@
struct S { int a; }
contract C {
function f() pure public {
abi.decode("", (((uint))));
abi.decode("", ((((uint)))));
abi.decode("", (((S))));
}
}
// ----
// Warning 6133: (73-99): Statement has no effect.
// Warning 6133: (109-137): Statement has no effect.
// Warning 6133: (147-170): Statement has no effect.