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]: Ill-typed IR for pop #1904

Closed
kevinclancy opened this issue May 11, 2023 · 2 comments
Closed

[Bug]: Ill-typed IR for pop #1904

kevinclancy opened this issue May 11, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@kevinclancy
Copy link
Contributor

kevinclancy commented May 11, 2023

Describe the issue:

The IR for pop obtains a reference variable to the final array element and deletes it. The type of this reference variable is always uint256, but it should be equal to the type of the array's elements.

Code example to reproduce the issue:

contract Poptest {
    struct S {
        int x;
        int y;
    }
    S[] a;
    function poptest() internal {
        a.pop();
    }
}

Version:

0.9.3

Relevant log output:

INFO:Printers:Contract Poptest
        Function Poptest.poptest() (*)
                Expression: a.pop()
                IRs:
                        REF_1 -> LENGTH a
                        TMP_1(uint256) = REF_1 (c)- 1
                        REF_2(uint256) -> a[TMP_1]
                        a = delete REF_2 
                        REF_3 -> LENGTH a
                        REF_3 (->a) := TMP_1(uint256)
@kevinclancy kevinclancy added the bug-candidate Bugs reports that are not yet confirmed label May 11, 2023
@smonicas smonicas added bug Something isn't working and removed bug-candidate Bugs reports that are not yet confirmed labels May 11, 2023
@smonicas smonicas changed the title [Bug-Candidate]: Ill-typed IR for pop [Bug]: Ill-typed IR for pop May 11, 2023
@smonicas smonicas mentioned this issue May 11, 2023
@kevinclancy
Copy link
Contributor Author

I noticed that a fix for this was recently developed, but I don't think it handles popping from bytes correctly. I think the type of an element of bytes is bytes1, but the type that the fix gives the reference variable is bytes.

@smonicas
Copy link
Contributor

You are right. Thank you.

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

3 participants