slither icon indicating copy to clipboard operation
slither copied to clipboard

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

Open CodeSandwich opened this issue 2 years ago • 1 comments

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:

// 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:

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

CodeSandwich avatar Sep 20 '23 11:09 CodeSandwich

Are #2138 and #2126 related to https://github.com/crytic/slither/pull/1861 @smonicas ?

0xalpharush avatar Sep 29 '23 21:09 0xalpharush