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]: Typename shadowing causes mix-up #2117

Closed
kevinclancy opened this issue Sep 7, 2023 · 1 comment
Closed

[Bug]: Typename shadowing causes mix-up #2117

kevinclancy opened this issue Sep 7, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@kevinclancy
Copy link
Contributor

kevinclancy commented Sep 7, 2023

Describe the issue:

When we have a nested struct and a top-level struct with the same name, the nested struct is incorrectly used as the type for parameters that are declared with the top-level struct.

Code example to reproduce the issue:

Run --print slithir on the following code.

pragma solidity 0.8.13;

interface Interface {
    struct ZZZ {
        int x;
        int y;
    }
}

struct ZZZ {
    int x;
    int y;
    int z;
}

contract A {
    function test(ZZZ memory zzz) external {
        zzz.z = 3;

        Interface.ZZZ memory zzz2 = Interface.ZZZ(1,2);
    }
}

Version:

0.9.6

Relevant log output:

Contract A
        Function A.test(Interface.ZZZ) (*)
                Expression: zzz.z = 3
                IRs:
                        REF_0(uint256) -> zzz.z
                        REF_0(uint256) (->zzz) := 3(uint256)
                Expression: zzz2 = Interface.ZZZ(1,2)
                IRs:
                        TMP_0(Interface.ZZZ) = new ZZZ(1,2)
                        zzz2(Interface.ZZZ) := TMP_0(Interface.ZZZ)

Note that above we have Function A.test(Interface.ZZZ) instead of Function A.test(ZZZ)

@kevinclancy kevinclancy added the bug-candidate Bugs reports that are not yet confirmed label Sep 7, 2023
@0xalpharush
Copy link
Contributor

I think this is related to #1809

@0xalpharush 0xalpharush added bug Something isn't working and removed bug-candidate Bugs reports that are not yet confirmed labels Sep 7, 2023
@0xalpharush 0xalpharush changed the title [Bug-Candidate]: Typename shadowing causes mix-up [Bug]: Typename shadowing causes mix-up Sep 7, 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
Projects
None yet
Development

No branches or pull requests

2 participants