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]: Incorrect variable type for NewArray operation #1776

Closed
Troublor opened this issue Mar 17, 2023 · 0 comments · Fixed by #1784
Closed

[Bug]: Incorrect variable type for NewArray operation #1776

Troublor opened this issue Mar 17, 2023 · 0 comments · Fixed by #1784
Assignees
Labels
bug Something isn't working ir

Comments

@Troublor
Copy link
Contributor

Troublor commented Mar 17, 2023

Describe the issue:

When using new expression to initialize a dynamic array, e.g., uint[] memory arr = new uint[](2);, slither convert it to a NewArray IR operation.
However, the type of lvalue, arr variable in the example, is incorrectly set as uint256 instead of uint256[].

Code example to reproduce the issue:

contract A {
    function foo() public returns (uint) {
        uint[] memory arr = new uint[](2);
        return 0;
    }
}

Version:

0.9.2

Relevant log output:

Contract A
        Function A.foo() (*)
                Expression: arr = new uint256[](2)
                IRs:
                        TMP_1 = new uint256[](2)
                        arr(uint256[]) := TMP_1(uint256) # TMP_1 has wrong type
                Expression: 0
                IRs:
                        RETURN 0
@Troublor Troublor added the bug-candidate Bugs reports that are not yet confirmed label Mar 17, 2023
Troublor added a commit to Troublor/slither that referenced this issue Mar 17, 2023
Troublor added a commit to Troublor/slither that referenced this issue Mar 17, 2023
Troublor added a commit to Troublor/slither that referenced this issue Mar 17, 2023
Troublor added a commit to Troublor/slither that referenced this issue Mar 17, 2023
@0xalpharush 0xalpharush added bug Something isn't working ir and removed bug-candidate Bugs reports that are not yet confirmed labels Mar 17, 2023
@0xalpharush 0xalpharush changed the title [Bug-Candidate]: Incorrect variable type for NewArray operation [Bug]: Incorrect variable type for NewArray operation Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ir
Projects
None yet
2 participants