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

Always allow field access for objects defined inside a recover block #3606

Merged
merged 15 commits into from
Aug 25, 2020

Conversation

jasoncarr0
Copy link
Contributor

@jasoncarr0 jasoncarr0 commented Aug 10, 2020

I should have opened this ages ago, but this change always allows simple assignments with variables defined locally:
x.y = e, x.y.z.q = e
Soundness can be seen because this functionality is possible today using methods, it is just very cumbersome.

This also includes a change to enable field-writes to non-local variables when the destination is sendable (this is slightly less than the most general: which would include writing a sendable expression to any field; but that requires adding more check logic). The current checks had very strange logic, and don't seem to be necessary: We only need to maintain isolation of the recover region, so it's perfectly fine to move sendable items in or out without restriction, since they cannot violate the guarantees. See #1057 for context of those original changes.

Fixes #3069

@jasoncarr0 jasoncarr0 changed the title Always allow local fields to be assigned to in recover expressions Always allow fields of local objects to be assigned to in recover expressions Aug 10, 2020
@jasoncarr0 jasoncarr0 changed the title Always allow fields of local objects to be assigned to in recover expressions Always allow fields of local objects to be accessed in recover expressions Aug 10, 2020
@jasoncarr0
Copy link
Contributor Author

jasoncarr0 commented Aug 10, 2020

That's why I never opened this, I didn't rigorously test deep field accesses: they won't work in all cases with this.

@jasoncarr0 jasoncarr0 marked this pull request as draft August 10, 2020 18:55
@jasoncarr0 jasoncarr0 changed the title Always allow fields of local objects to be accessed in recover expressions [WIP] Always allow fields of local objects to be accessed in recover expressions Aug 10, 2020
@jasoncarr0 jasoncarr0 marked this pull request as ready for review August 16, 2020 06:09
@jasoncarr0 jasoncarr0 changed the title [WIP] Always allow fields of local objects to be accessed in recover expressions [WIP] Aug 16, 2020
@jasoncarr0
Copy link
Contributor Author

May need to add/remove/merge unit tests still to ensure the right behavior is covered, but this is set to review.

@jasoncarr0 jasoncarr0 changed the title [WIP] Always allow fields of local objects to be accessed in recover expressions & allow sendable writes Aug 16, 2020
@jasoncarr0 jasoncarr0 changed the title Always allow fields of local objects to be accessed in recover expressions & allow sendable writes Allow more flexible field access in recover blocks: local fields and sendable writes Aug 16, 2020
@jasoncarr0
Copy link
Contributor Author

jasoncarr0 commented Aug 16, 2020

Windows CI is failing because of one variable which is used in a single case branch, complaining that it's not initialized elsewhere, which is technically true, but missing the point. I'll fix it, but remain quite disgruntled about it as it makes the code harder to read for everyone & and the compiler, imo.

@SeanTAllen
Copy link
Member

I don't know this code at all. I'm leaving this in @jemc's hands as I consider him the "domain expert".

@SeanTAllen
Copy link
Member

@jasoncarr0 can you rebase this against master?

@jasoncarr0 jasoncarr0 force-pushed the local-field-in-recover branch from 56173ad to 96deb45 Compare August 19, 2020 19:33
@jasoncarr0 jasoncarr0 changed the title Allow more flexible field access in recover blocks: local fields and sendable writes Always allow field access for objects defined inside a recover block Aug 22, 2020
@jasoncarr0
Copy link
Contributor Author

jasoncarr0 commented Aug 22, 2020

I've reverted the component about field accesses for another day (I still believe it's an important/sound addition) and likely an RFC. Accessing local fields is an important fix to get in as it's very cumbersome but always possible to work around (hence no soundness changes). I've also improved the log messages to be somewhat clearer.

@jasoncarr0 jasoncarr0 force-pushed the local-field-in-recover branch from 4e32d6a to eb5e32a Compare August 22, 2020 22:17
Copy link
Member

@jemc jemc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just one naming suggestion:

src/libponyc/expr/reference.c Outdated Show resolved Hide resolved
Co-authored-by: Joe Eli McIlvain <[email protected]>
Copy link
Member

@jemc jemc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to merge once the CI runs come back green.

@jasoncarr0
Copy link
Contributor Author

For a moment I was excited at how easy the suggestions feature made it and then I realized I still needed to change the callsite 😅

@SeanTAllen SeanTAllen added changelog - added Automatically add "Added" CHANGELOG entry on merge changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge and removed changelog - added Automatically add "Added" CHANGELOG entry on merge labels Aug 25, 2020
@SeanTAllen
Copy link
Member

@jasoncarr0 can you add public facing release notes to #3605 for this?

@SeanTAllen SeanTAllen merged commit 16a810e into ponylang:master Aug 25, 2020
github-actions bot pushed a commit that referenced this pull request Aug 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't access newly created object fields inside a recover expression
3 participants