Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: uninitialized-local-variables FP in destructuring assignment #1505

Open
kevinclancy opened this issue Dec 15, 2022 · 1 comment
Open
Labels
bug Something isn't working

Comments

@kevinclancy
Copy link
Contributor

kevinclancy commented Dec 15, 2022

Describe the issue:

Running slither on the provided code example produces a false positive regarding an uninitialized local variable.

The slither parser renames variables so that multiple declarations in the same function don't have the same name. Printing the IR of the provided code example shows that in the second branch, the returned identifier is renamed to q_scope_0 while the identifier in the declaration remains q. The declaration identifier should have been renamed to q_scope_0. I think the solution to this might be to copy the id field from the json ast here so that it can be used for renaming lookup.

Code example to reproduce the issue:

pragma solidity 0.8.13;

contract Test
{
    function f1() public view returns (int, string memory)  {
        return (0,"hello");
    }

    function f2(bool a) public view returns (string memory)  {
        if (a) {
            (int x, string memory z) = f1();
            return z;
        } else {
            (int x, string memory z) = f1();
            return z;
        }

    }
}

Version:

0.9.1

Relevant log output:

Test.f2(bool).q_scope_0 (test.sol#15) is a local variable never initialized
Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#uninitialized-local-variables
@kevinclancy kevinclancy added the bug-candidate Bugs reports that are not yet confirmed label Dec 15, 2022
@0xalpharush 0xalpharush changed the title [Bug-Candidate]: uninitialized-local-variables FP in destructuring assignment [Bug]: uninitialized-local-variables FP in destructuring assignment Feb 24, 2023
@0xalpharush 0xalpharush added bug Something isn't working and removed bug-candidate Bugs reports that are not yet confirmed labels Feb 24, 2023
@0xalpharush
Copy link
Contributor

Closed by #1912

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants