-
Notifications
You must be signed in to change notification settings - Fork 1k
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
ref fields spec updates #6539
ref fields spec updates #6539
Conversation
Couple of items: - Clarifying the rules around ref reassignment. - Affirming the *safe-to-escape* of non `ref struct`. This needed clarifying after the introduction of *return only* - Affirming the cut line for features in C# 11
> 2. `e1 = ref e2`: where `e1` is a `ref` local or `ref` parameter then `e2` must have a *safe-to-escape* equal to *safe-to-escape* for `e1` and `e2` must have *ref-safe-to-escape* at least as large as *ref-safe-to-escape* of the *ref-safe-to-escape* of `e1` | ||
> For a ref reassignment in the form `e1 = ref e2` both of the following must be true: | ||
> 1. e2 must have ref-safe-to-escape at least as large as the ref-safe-to-escape of e1 | ||
> 2. e1 must have the same safe-to-escape as e2 |
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.
nit: backticks on e1
and e2
nit: I'm okay to keep a side-note on x.e1
case, since I agree it is a bit tricky how it falls out.
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.
Yeah formatting didn't copy correctly. Will add the sample.
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.
LGTM Thanks (iteration 1)
Span<int> local = stackalloc int[42]; | ||
ref Span<int> refLocal = ref local; | ||
|
||
// The rule above prevent this because the safe-to-escape of the two values is |
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.
// The rule above prevent this because the safe-to-escape of the two values is | |
// The rule above prevents this because the safe-to-escape of the two values is |
Couple of items:
ref struct
. This needed clarifying after the introduction of return onlycloses dotnet/roslyn#64671
related dotnet/roslyn#62618