-
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
Changed the message of the error thrown when the structure has all it's members omitted #12361
Changed the message of the error thrown when the structure has all it's members omitted #12361
Conversation
libsolidity/analysis/TypeChecker.cpp
Outdated
m_errorReporter.typeError(6744_error, _variable.location(), "Internal or recursive type is not allowed for public state variables."); | ||
{ | ||
if (getter.returnParameterNames().empty() && getter.returnParameterTypes().empty() && getter.parameterNames().empty() && getter.parameterTypes().empty()) | ||
m_errorReporter.typeError(5359_error, _variable.location(), "The structure has all it's members omitted, therefore the getter cannot return any values."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this message changes the expected output in some syntax tests. Please run isoltest
with the --update
option locally and commit the changes.
Also note that the chk_errorcodes
is failing because it ensures that we have at least one case covering each error. There's no test for the newly added error 5359. Running isoltest
will probably change that but it seems we only have one test case for such getters and I think we need more to test this properly. Could you add some more cases, covering various situations that can result in such a getter?
- Mapping in the struct.
- Dynamic arrays other than
bytes
/string
in the struct. - Multiple fields being omitted (rather than just one).
- Struct containing a struct that has all its fields omitted (see Getters returning structs can not be defined in interfaces #11826 (comment)).
or
struct T { mapping(uint => uint) m; } struct S { T t; }
struct U { mapping(uint => uint) m; } struct T { U u; } struct S { T t; }
- A struct that contains two fields: one that won't be omitted (e.g.
uint
) and another that is also a struct and would have all of its members omitted.struct U { mapping(uint => uint) m; } struct T { U u; } struct S { uint i; T t; }
- Nested dynamic array. Surprisingly, this does not fail. Apparently the rule for dynamic arrays is not recursive.
struct T { uint[] u; } struct S { T t; }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I can try.
cebb86a
to
ddd9a84
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now, thanks a lot!
Would be nice to get the extra tests because we have very little coverage for this but I think the PR would still pass those tests.
Closes #12302