crytic / crytic/slither

[Bug]: incorrect IR for array initialization

Open
#1,829 1 comment 0 reactions 0 assignees View on GitHub
bug ir
Dominant language
Python
Stars
6.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

### Describe the issue:

When declaring a new array variable using another previously defined array variable, `InitArray` IR operation is used, which is incorrect.
To my understanding, `InitArray` only represents initializing an array literal by listing its elements.
In the example code below, `Assignment` IR operation should be used instead of `InitArray`.

### Code example to reproduce the issue:

```solidity
contract Contract {
function foo(uint[] memory arr) public {
uint[] memory arr2 = arr;
}
}
```

### Version:

0.9.3

### Relevant log output:

```shell
INFO:Printers:Contract Contract
Function Contract.foo(uint256[]) (*)
Expression: arr2 = arr
IRs:
arr2(uint256[]) = ['arr'] # InitArray operation, which is incorrect
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.