Skip to content

Arrays are ignored from structs in automatically generated getters #11067

Closed
@m1cm1c

Description

@m1cm1c

Description

Arrays are ignored from structs in automatically generated getters.

Environment

  • Compiler version: 0.8.2
  • Target EVM version (as per compiler settings): default
  • Framework/IDE (e.g. Truffle or Remix): none
  • EVM execution environment / backend / blockchain client: none
  • Operating system: Manjaro (Linux 5.4)

Steps to Reproduce

Write the following code into a file named ExampleContract.sol:

pragma solidity ^0.8.2;

contract ExampleContract {
    struct Foo {
        uint256 a;
        address[] b;
    }
    
    Foo public foo;
    
    function bar() public view {
        (address a, address[] memory b) = this.foo();
    }
}

Run: solc ExampleContract.sol

The output will be:

Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> ExampleContract.sol

Error: Different number of components on the left hand side (2) than on the right hand side (1).
  --> ExampleContract.sol:12:9:
   |
12 |         (address a, address[] memory b) = this.foo();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error: Type uint256 is not implicitly convertible to expected type address.
  --> ExampleContract.sol:12:9:
   |
12 |         (address a, address[] memory b) = this.foo();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions