-
Notifications
You must be signed in to change notification settings - Fork 187
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
Improve visibility of subsequently defined contracts #298
Improve visibility of subsequently defined contracts #298
Conversation
8227dc6
to
5ef34c4
Compare
5ef34c4
to
f360ed3
Compare
// Contract fields are evaluated in the next pass together with function bodies | ||
// so that they can use other contract types that may only be defined after the | ||
// current contract. | ||
Ok(()) |
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.
@g-r-a-n-t since fields aren't in the public API of contracts it omitting them here doesn't interfere with the contract representation in the scope. But by delaying analysis to the next pass we can at least support referring to subsequent contracts in contract fields.
f360ed3
to
bf46956
Compare
@g-r-a-n-t Here's my second attempt which removes all the machinery to manage partial representation of contracts. I created #299 to track the issue with not being able to use subsequently defined contract types in function definitions. |
Codecov Report
@@ Coverage Diff @@
## master #298 +/- ##
==========================================
+ Coverage 93.44% 93.45% +0.01%
==========================================
Files 56 56
Lines 3997 4005 +8
==========================================
+ Hits 3735 3743 +8
Misses 262 262
Continue to review full report at Codecov.
|
What was wrong?
This superseded #294
If two contracts are defined in a module, only the second contract can see the interface of the first.
e.g.
How was it fixed?
Contract analysis is split into multiple passes:
1 The first pass collects contracts with their function definition but does not inspect function bodies and contract fields
2. Once every contract was analyzed, we analyze the function bodies and contract field of each contract in a subsequent pass
Because the module scope now contains all contracts it needs a way to filter out the main contract when it is aggregating
external_contracts
. To do that,name
was added toContractScope
(we also havename
forBlockScope
so there's a precedence for having thename
as a scope identifier) so that we can filter out the "self contract" upon aggregation.The Uniswap demo was updated to use that feature
This PR doesn't yet address issue #299 though.