// SPDX-License-Identifier: MIT
pragma solidity =0.8.22;
contract A {
struct User {
string name;
uint age;
}
mapping(uint => User) public users;
function getUser(uint id) external view returns (User memory) {
return users[id];
}
}
contract B {
function test() external {
A a = new A();
A.User memory user1 = a.getUser(1); // works
A.User memory user2 = a.users(1); // does not work
}
}
It seems that the automatically generated getter function users(uint256)
is returning tuple(string,uint256)
instead of struct User
.
I can't find this behavior in the documentation. Is this expected?