-
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
Type checking for contract explicit storage base location #15528
Conversation
bf640be
to
666b499
Compare
d3cd13a
to
5645314
Compare
fb75168
to
2579486
Compare
038b819
to
7f4eb69
Compare
07f289c
to
6b34e90
Compare
82b5fec
to
54451ed
Compare
6b34e90
to
f0f7997
Compare
ff0c30b
to
f7f90be
Compare
f0f7997
to
2839eed
Compare
f7f90be
to
7473a01
Compare
7a42733
to
c2d5d9a
Compare
6257c02
to
9acfb2d
Compare
68f5886
to
abca45e
Compare
7a1d6b2
to
6f29b3c
Compare
785c28f
to
5ba5933
Compare
test/cmdlineTests/storage_layout_already_defined_in_ancestor/input.json
Outdated
Show resolved
Hide resolved
test/libsolidity/syntaxTests/storageLayoutSpecifier/simple_cast.sol
Outdated
Show resolved
Hide resolved
test/libsolidity/syntaxTests/storageLayoutSpecifier/function_selector.sol
Outdated
Show resolved
Hide resolved
...lidity/syntaxTests/storageLayoutSpecifier/layout_specified_by_function_with_call_options.sol
Outdated
Show resolved
Hide resolved
test/libsolidity/syntaxTests/storageLayoutSpecifier/string_length_member.sol
Outdated
Show resolved
Hide resolved
6a781f6
to
8db609a
Compare
155eb51
to
912e61c
Compare
92a5f87
to
4a00499
Compare
54dab60
to
83cdafa
Compare
4a00499
to
e844a8b
Compare
83cdafa
to
141de94
Compare
141de94
to
424ab79
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.
I have just one suggestion on how to make the error reporting less annoying. It's not critical to the PR and everything else seems to have been addressed to I'm approving regardless of that. It's simple to fix so I think we should still do that though.
There were a few minor things in tests/messages that still needed some adjustment/cleanup but I decided to just push them as fixups to avoid stalling the PR. Please take a look and squash if you accept them.
m_errorReporter.typeError( | ||
8894_error, | ||
_contract.location(), | ||
SecondarySourceLocation().append( | ||
"Storage layout was already specified here.", | ||
ancestorContract->storageLayoutSpecifier()->location() | ||
), | ||
"Storage layout can only be specified in the most derived contract." | ||
); |
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.
Looking at test output, the errors generated by this may be a bit annoying. It reports an error for every specifier in the hierarchy of every contract, which may be a lot. Consider this example:
contract A layout at 1 {}
contract B is A layout at 2 {}
contract C1 is B {}
contract C2 is A, B {}
contract C3 is B {}
contract D1 is C1 {}
contract D2 is C2 {}
contract D3 is C3 {}
You'll get 13 error messages here. I think it would be more useful to only report an error when a contract directly inherits from one with a layout specifier. The point where a fix needs to be applied is unlikely to be far from the specifier. It's either the specifier itself being applied to the wrong contract (secondary messages already point at this) or the first contract that inherits from it (that's what the primary message should point at). This would reduce the number of messages here to 5.
This should be very easy to implement simply by iterating over baseContracts()
rather than the whole annotation().linearizedBaseContract
. We could then point at the exact inheritance specifier that triggered the error rather than whole contract definition (baseContracts()
contains specifiers rather than contract definitions, and we can easily report their locations).
We should also have the above as a test case.
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.
Addressed in #15900.
424ab79
to
5224672
Compare
As discussed on the call, we can just merge this and do #15528 (comment) as a separate PR on top. Please remember to squash the fixups though :) |
466dcb9
to
28bb6bf
Compare
I see you squashed it all into one commit :) No need to go that extreme, I left it in a state that would nicely autosquash into 3 clean commits without conflicts and with test additions being done first and the effect of code changes visible separately. That's generally a structure that I'd recommend and much prefer over it being smooshed together. Can you restore that version? |
28bb6bf
to
7ef0ef8
Compare
Part of #597/#15727.