[Bug]: Temp variable for new dynamic array has wrong type
- Dominant language
- Python
- Stars
- 6.4k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
### 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:
```shell
INFO:Printers:Contract Test
Function Test.test() (*)
Expression: a = new int256[](5)
IRs:
TMP_1int256[][]) = new int256[](5)
a(int256[]) := TMP_1(int256[][])
```
Contributor guide
Research direction
Reproduce the issue with the provided Test contract and inspect the generated SlithIR and printer output. Trace how the temporary variable type is produced for the dynamic array allocation; done means the temporary is typed as a one-dimensional int256[] and matches the assignment to a.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, solidity
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100