crytic / crytic/slither

[False-Positive]: unused-return when using only some values

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

Description

### Describe the false alarm that Slither raise and how you know it's inaccurate:

Slither emits a false positive unused-return when taking only some of multiple values from a call to another contract. There are 2 examples with slightly different syntax, because they cause slightly different logs.

### Frequency

Occasionally

### Code example to reproduce the issue:

```solidity
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;

contract One {
Data public constant DATA = Data(address(1));

function one() public view returns (uint256 out) {
(out,) = DATA.data();
}

function two() public view returns (uint256) {
(, uint256 out) = DATA.data();
return out;
}
}

contract Data {
function data() public pure returns (uint256, uint256) {
return (1, 2);
}
}
```

### Version:

0.9.5

### Relevant log output:

```shell
INFO:Detectors:
One.one() (src/Pass.sol#7-9) ignores return value by (out,None) = DATA.data() (src/Pass.sol#8)
One.two() (src/Pass.sol#11-14) ignores return value by (out) = DATA.data() (src/Pass.sol#12)
Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#unused-return
INFO:Slither:. analyzed (2 contracts with 87 detectors), 2 result(s) found
```

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.