-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AST] NFC: Deconflate mutation of self and InOut params #29597
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
Conversation
@swift-ci please smoke test |
I don't think this is correct as the terms are used in the compiler now. A |
Furthermore, as @gottesmm will attest to, destructors (and maybe initializers too) also already have peculiar semantics that currently require some special case handling in the optimizer. There might be an opportunity to introduce more fine grained capabilities to model these more formally in the AST. |
In my experience hacking on an atomicity/mutation model for reference types, I have found that More so, I've found that the compiler's existing design works fairly well for this approach and the conflation between the mutation model, value-semantics, and Finally, and I'd need to check this, I think value-type destructors get an |
Simple though that may be, there's a lot of existing research into this sort of thing that shows there are a lot of shortcomings to that simple binary approach. Even within the existing feature set of Swift, I think a mutability model for classes that didn't take uniqueness into account, to allow for checking of copy-on-write "mutable only if uniquely referenced" requirements, would be inadequate. That also ends up being pretty close to what reference capability systems model, since in a concurrent world, you don't care only about whether a method modifies the object or not, but also whether it has the only reference currently accessing the object while it's doing so.
My experience with
Value type destructors don't exist today. If they did, though, they would be more accurately modeled as |
Hi @jckarter – I think we're on a tangent and this patch works well for my research. That being said and for Swift proper, is this patch net positive, net negative, or neutral? If it's net negative, then why? What harm is done? Thanks :-) |
|
Hi @jckarter – I did some experiments and this patch actually improves the quality of the AST in the face of other errors, which can of course, potentially improve downstream diagnostics and avoid downstream crashes. For example, line 270 of |
That's great! This change might be fine in isolation then. I'd still be wary of building anything on top of it. |
I think I learned more from this feedback than the utility in getting this upstream. I might file a new PR with a targeted AST QoI fix. Thanks @jckarter! |
Pull #29579 broke my private research branch and I'd like to upstream the fix.
Background: my project needs mutation to not be conflated with other things (reference semantics, InOut, etc).
While I'm at it, I'd also like to upstream this: