Skip to content

[Bug]: incorrect IR for array initialization  #1829

Open
@Troublor

Description

@Troublor

Describe the issue:

When declaring a new array variable using another previously defined array variable, InitArray IR operation is used, which is incorrect.
To my understanding, InitArray only represents initializing an array literal by listing its elements.
In the example code below, Assignment IR operation should be used instead of InitArray.

Code example to reproduce the issue:

contract Contract {
    function foo(uint[] memory arr) public {
        uint[] memory arr2 = arr;
    }
}

Version:

0.9.3

Relevant log output:

INFO:Printers:Contract Contract
        Function Contract.foo(uint256[]) (*)
                Expression: arr2 = arr
                IRs:
                        arr2(uint256[]) =  ['arr']  # InitArray operation, which is incorrect

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingir

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions