-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
Allow fields to be consumed (sometimes) #3304
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Prior to this commit, fields could not be `consume`d. This commit changes things to allow fields to be consumed only if they are reassigned in the same expression where they are `consume`d (i.e. `z = do_stuff(consume z)` or `z.c = do_stuff(consume z.c)`) and adhere to the following restrictions: * only if that expression does not include any partial calls * consumed fields cannot be referenced in any function calls after the field is consumed * only if that expression does not include any function calls on traits or interfaces in any part of the call tree * the parent object of a field cannot be consumed in that expression * the field cannot be a `let` or `embed` field * a field of the same type cannot be referenced in any function calls after the field is consumed Also, add tests for various consume field related scenarios.
This is waiting on a review from @jemc. |
jemc
approved these changes
Sep 24, 2019
@dipinhora can you do release notes for this on #3295 and add a CHANGELOG entry. |
MacOS failure is due to a change in MacOS version in Cirrus. Not related to this PR. Merging. |
Thanks @dipinhora ! |
dipinhora
added a commit
to dipinhora/ponyc
that referenced
this pull request
Nov 7, 2019
PR ponylang#3304 introduced a bug that caused segfaults with nested tuple access. This commit resolves the issue and adds a test to prevent another regression. resolves ponylang#3354.
This was referenced Nov 7, 2019
Closed
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prior to this commit, fields could not be
consume
d. This commitchanges things to allow fields to be consumed only if they are
reassigned in the same expression where they are
consume
d(i.e.
z = do_stuff(consume z)
orz.c = do_stuff(consume z.c)
)and adhere to the following restrictions:
after the field is consumed
on traits or interfaces in any part of the call tree
expression
let
orembed
fieldcalls after the field is consumed
Also, add tests for various consume field related scenarios.
This PR also includes the following example using the new functionality: