slither
slither copied to clipboard
[Bug]: Temp variable for new dynamic array has wrong type
Describe the issue:
When we print slithir for the following source file:
contract Test {
function test() external {
int[] memory a = new int[](5);
}
}
the temp variable in the generated IR has the wrong type. It's an array of arrays instead of a 1-dimensional array:
INFO:Printers:Contract Test
Function Test.test() (*)
Expression: a = new int256[](5)
IRs:
TMP_1int256[][]) = new int256[](5)
a(int256[]) := TMP_1(int256[][])
Code example to reproduce the issue:
contract Test {
function test() external {
int[] memory a = new int[](5);
}
}
Version:
0.9.5
Relevant log output:
INFO:Printers:Contract Test
Function Test.test() (*)
Expression: a = new int256[](5)
IRs:
TMP_1int256[][]) = new int256[](5)
a(int256[]) := TMP_1(int256[][])
The linked PR doesn't handle late type conversion for literals in the case of an EventCall
, NewStructure
, or NewContract
.
contract New {
constructor(int x) {
}
function b(int a) external {
}
}
contract Test {
struct X {
int x;
}
event Log(int message);
function test() external {
emit Log(5);
New n = new New(5);
n.b(5);
X(5);
}
}
similar to make the contract available in NewContract
we need to that for EventCall
and make Event
readily available https://github.com/crytic/slither/pull/2370
https://github.com/crytic/slither/blob/13d7d9f66a6be4f798478fa3735fb63444b46c3d/slither/slithir/convert.py#L1920