-
Notifications
You must be signed in to change notification settings - Fork 195
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
self
declarations
#520
self
declarations
#520
Conversation
4111113
to
b93e185
Compare
Codecov Report
@@ Coverage Diff @@
## master #520 +/- ##
==========================================
+ Coverage 87.55% 87.68% +0.13%
==========================================
Files 87 87
Lines 5585 5670 +85
==========================================
+ Hits 4890 4972 +82
- Misses 695 698 +3
Continue to review full report at Codecov.
|
@cburgdorf I saw your comment about using This is what I was thinking too. |
81cd172
to
1fedb01
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.
Nice work! Left a few comments inline. There's a regression introduced that should be addressed.
Regarding:
I also went ahead and updated the Json ABI builder to label functions that do not take a
self
parameter as pure
I think we shouldn't mark them as pure
in the ABI then imho. We could still mark it as view
though even if it is technically a bit purer than view
:)
I kinda dislike the current syntax of calling pure functions on the contract by just their name (e.g. foo()
). You seem to be on board with demanding those to be prefixed with Self::
(e.g. Self::foo()
) but we should probably create an issue for that. Also paging in @sbillig for visibility. It's also not just an aesthetically question since the current syntax would become ambiguous with imported functions or functions that are defined outside of the contract but within the same file.
Since today is the last day of August and we should cut our monthly release, I'm a bit hesitant if we just want to leave this PR for the next release so that we should be able to bundle it with the Self::
change?
1fedb01
to
494c5f7
Compare
494c5f7
to
20fe43d
Compare
I'm not sure how I feel about this; it seems like
The analyzer can check for ambiguity, and require the user to disambiguate. |
20fe43d
to
e920aae
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 great. I guess I agree non-self fns should be called views until we can be sure that they don't access state (but also think that it doesn't really matter at this stage of development).
e920aae
to
5913da1
Compare
That's true but I kinda like the added clarity of avoiding the ambiguity in the first place :) |
What was wrong?
self
was implicitly defined in all function scopes, which made it impossible to write pure functions.How was it fixed?
1.) added
self
args to the function definition grammar2.) added checking around the use of
self
3.) fixed things that broke
I also went ahead and updated the Json ABI builder to label functions that do not take a
self
parameter as pure. This is something that I'm not sure we want right now though, as functions can still read msg and chain data (which conflicts with the definition of pure). For this reason, I'm considering dropping the commit responsible for this change, but have not 100% made up my mind. Feel free to provide input.To-Do