-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Getters returning structs can not be defined in interfaces #11826
Comments
Oops, forgot that struct getters return the members, and not the struct itself. That is super unintuitive. |
Don't forget that if the struct has arrays those are ignored. |
Could also consider displaying the return types in this error. |
Can we change that at some point :-)? |
Even weirder that this goes only one level deep. You can have a getter returning a struct if it's nested inside another struct. For example this compiles just fine and both the function and the getter return interface I {
struct S {
uint a;
}
struct WrappedS {
S s;
}
function s() external returns (S memory);
}
contract C is I {
WrappedS public override s;
} Anyway, you should update issue the description to say what we want to do about it. Do we want to make getters return structs instead of tuples (breaking change I guess?). Or just make the message more explicit? |
@axic How to write Interface for such view function. What should be data type |
This issue has been marked as stale due to inactivity for the last 90 days. |
Hi everyone! This issue has been automatically closed due to inactivity. |
The function
s
can not be defined in a way this works. The problem lies in the impossibility to define a working location.S storage
is not allowed in interfaces, but that could be one option:S memory
is not allowed by overriding, but that could be equally correct:The text was updated successfully, but these errors were encountered: