crytic / crytic/slither

What is the difference between `storage pointer` and `storage ref`

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

Description

### Describe the issue:

For some calls slither gives arguments of `storage pointer` or `storage ref` or even both. What is the difference and why we should differ them if it cannot be explicitly declared in the source code

### Code example to reproduce the issue:

```solidity
pragma solidity 0.8.7;

struct GlobalStruct {
string name;
uint age;
}
contract C {
GlobalStruct[] public globalPeople;

function addPerson(string memory _name, uint _age) public {
StructInContract memory newPerson = StructInContract(_name, _age);
people.push(newPerson); // here the called type is
}
}

library Search {function ind(uint[] storage self) public view {}}

contract C2 {
using Search for uint[];
uint[] data;
function rep(uint _old,uint _new) public {
data.ind();
}
}
```

### Version:

0.9.6

### Relevant log output:

```shell
>>> from slither import Slither
>>> addPerson = Slither('structs.sol').contracts[0].functions[0]
>>> addPerson.nodes[2].expression.called.type
'function (struct MyContract.StructInContract storage ref[] storage pointer,struct MyContract.StructInContract storage ref)'
>>> rep = Slither('structs.sol').contracts[2].functions[0]
>>> rep.nodes[1].expression.called.type
'function (uint256[] storage pointer) view'
```

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.