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

[Add Detector]: Suspicious Self Assignment #57

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jes16jupyter
Copy link

A self-assignment occurs when a variable or state is assigned a value that is already held by that variable or state itself. This situation often indicates a potential issue in the code, which can be redundant or incorrect. Specifically, self-assignment might suggest that the value assignment does not change the state of the variable, or it could be a sign of a logical error.

Test:

    function dota(address val) public {
        uint x = 1;
        val = val; // catch
        map[val] = map[val]; // catch
        uint[] memory abc = new uint[](2);
        abc[0] = abc[0]; // catch
        abc[x] = abc[x]; // catch
        abc[0] = abc[x];
        map2[val][val] = map2[val][val]; // catch
        map2[val][val] = map2[val][address(0)];
    }

@jes16jupyter
Copy link
Author

Hi @Picodes this is a detector to detect potential typo and incorrect value assignment.

@jes16jupyter
Copy link
Author

Hi @Picodes any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant