Refactor TypeChecker visitor for MemberAccess expression.#16448
Refactor TypeChecker visitor for MemberAccess expression.#16448
TypeChecker visitor for MemberAccess expression.#16448Conversation
This comment was marked as resolved.
This comment was marked as resolved.
cf38fdd to
fe24189
Compare
1131cb9 to
bf9c42e
Compare
TypeChecker visitor od MemberAccess expression.TypeChecker visitor for MemberAccess expression.
cc730b5 to
60443be
Compare
| size_t const initialMemberCount = possibleMembers.size(); | ||
| if (initialMemberCount > 1 && arguments) | ||
| // do overload resolution | ||
| for (auto it = _possibleMembers.begin(); it != _possibleMembers.end();) |
There was a problem hiding this comment.
std::remove_if(_possibleMembers, [](auto const& member) { return ....; })?
Of course, you're not liable to change this since it was already like that, and would make the review a bit more difficult then just comparing the moved around code snippets.
There was a problem hiding this comment.
I plan to make it i a separated PR/PRs.
737b9e4 to
c8b5654
Compare
bcb45e9 to
70b945e
Compare
b069f00 to
ab4a83d
Compare
clonker
left a comment
There was a problem hiding this comment.
I couldn't find discrepancies between develop and the refactor when tracing through the code paths. I'd feel better if someone else did the same before we merge. The changes are quite convoluted at times :)
What I found:
checkAccessedMemberFunctionis called afterrequiredLookup = Super- develop does it before. These are independent operations but the reordering made it harder to review ofc.if->solAssertforStringConcat/BytesConcatis technically not equivalent. Develop silently skipsisPure = trueif the condition fails and with this PR we get an abort.varDeclcheck is moved belowMagicTypehandling. This is equivalent today but a potential bug source if MagicType members ever change. Guess this should be folded to where it actually belongs in a follow-up (as the todo states)- The general reordering throughout made it hard to track code paths
I am sure that none of these lead to wrong results but at least the second and third point aren't strictly equivalent.
It's equivalent if you look at the broader context.
I did already. I compared both versions and made sure nothing was lost or added. Now everything I found back then seems fixed and I went through it again just in case (though in much less detail). If we both did that then I think we'll be find here. And yeah, this is indeed a hell to review. Though TBH it's just that the logic here was convoluted to begin with, with many overlapping cases and multiple responsibilities stuffed into one monster function. I'll take cleaning this up once and for all over having to do this in my head every time I go over #16376 and any other change related to constants in the future :) |
f4a0090 to
dc9f632
Compare
There was a problem hiding this comment.
The code is fine now. Approving, but please don't forget to squash the review fixes before merging.
Would not hurt to add an assert for #16448 (comment) too.
Makes sense, thx for the clarification!
Good to go then :)
Agree! With core solidity on the horizon not a thing anymore, but I think that perhaps there's something to be gained from rethinking the c++ types that encode solidity types. I suspect at least some of the repeated checks here could be encoded in type invariants. |
|
There's definitely value in improving things even with Core Solidity on the horizon. We will still have to maintain Classic for quite a while and must not let it deteriorate and end up with some crits in the process. I agree about the types. We could use fewer manual checks for every specific thing and more general properties on them. One example of this that still sits in my head is that we may have avoided the recent transient storage codegen bug if we had Or the named parameter ordering bug could have been avoided if the parameters were encapsulated in a proper type, aware of its purpose, rather than just a dumb collection being passed around without any safeguards. We just have to be selective about it. This refactor ended up being much harder than I expected and this is likely to be the case with anything touching analysis due to all the interdependencies. I think we might have been better off slicing it into even smaller pieces. Any changes that need to shuffle big chunks of code around would probably be easier to review if done separately with as few other modification thrown in as possible. |
dc9f632 to
23050cd
Compare
|
I think refactoring PRs should be handled in different way. This one contains a lot of changes which potentially do not change anything, but because there is so many different aspects it's hard to follow them. I think next time I will try to push smaller PRs with minimal changes which in summary will end up with bigger refactoring. Actually each of the initial commits from the PR should be a separated PR. |
|
Can you squash "Address PR review comments." into other commits? All the review changes fixes should generally be squashed into the original commits they apply to. |
89b3d26
23050cd to
89b3d26
Compare
| // TODO: Leave it for now, but it should be moved to TypeType -> Contract case. | ||
| // We do not want to change the logic in refactor PR. |
There was a problem hiding this comment.
Why do you want to check magic type but i.e. not struct type also?
MagicType was the only thing checked after VariableDeclaration. Structs and other stuff were originally before so nothing changed there.
If I get it right I think it's already checked in the following PR
Yes, that assert would check that and more. You could move it here. Or add the one @clonker suggested.
89b3d26 to
d97b44c
Compare
… and `diagnoseUnresolvedMemberAccess`
d97b44c to
e903693
Compare
This PR refactors implementation of the
TypeCheckervisitor forMemberAccessexpression. It is needed based on the outcome from the discussion on changes in #16376 (comment).Intentionally no logic has changed.