Skip to content
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 3 commits into from
Sep 26, 2019

Conversation

dipinhora
Copy link
Contributor

Prior to this commit, fields could not be consumed. This commit
changes things to allow fields to be consumed only if they are
reassigned in the same expression where they are consumed
(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 PR also includes the following example using the new functionality:

  • Use new consume field functionality in tcpconnection

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.
@SeanTAllen
Copy link
Member

This is waiting on a review from @jemc.

@SeanTAllen
Copy link
Member

@dipinhora can you do release notes for this on #3295 and add a CHANGELOG entry.

@SeanTAllen
Copy link
Member

MacOS failure is due to a change in MacOS version in Cirrus. Not related to this PR. Merging.

@SeanTAllen SeanTAllen merged commit 6e10bc4 into ponylang:master Sep 26, 2019
@SeanTAllen
Copy link
Member

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.
SeanTAllen pushed a commit that referenced this pull request Nov 12, 2019
PR #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 #3354.
@jemc jemc mentioned this pull request May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants