-
Notifications
You must be signed in to change notification settings - Fork 140
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
Limit mutation of container-typed fields to the scope of the composite #1267
Conversation
Cadence Benchstat comparisonThis branch with compared with the base branch onflow:master commit d3124c5 Results
|
One possible solution for fields with |
Codecov Report
@@ Coverage Diff @@
## master #1267 +/- ##
==========================================
+ Coverage 75.81% 75.85% +0.03%
==========================================
Files 279 279
Lines 38780 38823 +43
==========================================
+ Hits 29402 29450 +48
+ Misses 8016 8013 -3
+ Partials 1362 1360 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
This is exciting! I just had one comment about the docs
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.
Sorry, missed this in the last request: Please use the existing naming conventions for the tests and parallelize all tests.
@SupunS Could you also please have a look, as this is a critical piece?
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 to me!
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.
Great work! 👏
Closes #1260
Description
This adds a new error in the Cadence checker that prevents values like arrays and dictionaries from being mutated outside of the scope they were created in.
Currently, the
let
declaration kind does not allow writes anywhere, while thevar
declaration kind allows writes in current and inner scopes. This does not, however, impose any kind of restriction on where dictionary and array values can be mutated, in affect allowing these values to be mutated anywhere they can be read.This change alters this behavior by only allowing values to be mutated in the context that they can be written. As such, the following program is now an error:
A full specification and discussion of this change can be found in this FLIP: onflow/flow#703