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

Investigate and improve test coverage for copying reference types between data locations. #12559

Closed
ekpyron opened this issue Jan 19, 2022 · 1 comment · Fixed by #13464
Closed

Comments

@ekpyron
Copy link
Member

ekpyron commented Jan 19, 2022

#12558 indicates that we are seriously lacking some tests in that area - so we should double-check that we have all combinations covered for value types and reference types up to a certain level of nesting.

@ekpyron ekpyron added this to New issues in Solidity via automation Jan 19, 2022
@ekpyron ekpyron moved this from New issues to Implementation Backlog in Solidity Jan 19, 2022
@ekpyron ekpyron moved this from Implementation Backlog to Implementation Backlog Important in Solidity Jan 19, 2022
@cameel cameel added this to To do in Sol -> Yul CodeGen via automation Jan 19, 2022
@wechman wechman self-assigned this Aug 17, 2022
@wechman
Copy link
Collaborator

wechman commented Aug 19, 2022

I went through the tests we have for reference types and found a minimal test set we lack of and might want to provide within this ticket:

  1. Copy 2d static array from storage to memory.
contract C {
    uint8[2][2] s = [[1, 2], [3,4]];
    
    function f() public {
        uint8[2][2] memory tmp = s;
    }
  1. Copy element of 3d static/dynamic array from calldata/memory/storage to 2d array in memory/storage.
contract C {
    uint[1][1][1] s;
    function f() public {
        uint[1][1] tmp = s[0];
    }
}
  1. Copy 2d static/dynamic array of structs from calldata/memory to storage
contract C {
    struct S {uint8 x;}
    S s;
    function() public {
        S memory local = S({x: 7})l
        s = local;
    }
}
  1. Copy element of 3d static/dynamic array of structures from calldata/memory/storage to 2d memory/storage array.
contract C {
    struct S { uint 8x; }
    S[1][1][1] s;
    function f() public {
        S[1][1] memory local = s[0];
    }
}
  1. Copy 1d static/dynamic array of structures with nested array from storage to memory.
contract C {
    struct S { uint8[2] x};
    S[2] s = [S(x: [1, 2]), S(x: [3, 4])];
    function f() public {
        S memory local =  s[0];
    }
}
  1. Copy elements of 2d static/dynamic array of structs with nested array from calldata/memory/storage to 1d memory/storage array.
contract C {
    struct S {uint8[2] x;}
    S[1][1] s = [[S({x: [1,2]})]];
    function f() public {
        S[1] local = s[0];
    }
}
  1. Copy to/from mapping (uint => struct/struct[]) to/from calldata/memory/storage array/struct.
contract C {
    struct S { uint8 x; }
    mapping (uint8 => S) m;
    function f() public {
        S memory s = m[0];
    }
}

Above code snippets are there just to illustrate what kind of test cases we need so they might not compile properly.

@wechman wechman moved this from Implementation Backlog Important to In progress in Solidity Aug 24, 2022
Sol -> Yul CodeGen automation moved this from To do to Done Sep 15, 2022
Solidity automation moved this from In progress to Done Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants