-
Notifications
You must be signed in to change notification settings - Fork 4.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
Fix UnscopedRef handling in indexers #74343
Conversation
Waiting for #74341 to merge before publishing |
e9c8a8b
to
08617ab
Compare
The object initializer logic wasn't completely handling the lifetime of the `in` part of parameters. It was considering it escaping even if it wasn't marked as `[UnscopedRef]` closes dotnet#66056
@cston, @jjonescz, @RikkiGibson PTAL |
local = new() { [in x] = "" }; // 1 | ||
local = new() { [in y] = "" }; // 2 | ||
local = new() { [0] = "" }; // 3 | ||
} |
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.
static S1 Test1(int x) => new S1() { [in x] = "" }; // 1 | ||
static S1 Test2(in int x) => new S1() { [in x] = "" }; | ||
static S1 Test3(scoped in int x) => new S1() { [in x] = "" }; // 2 | ||
static S1 Test3(int[] x) => new S1() { [in x[0]] = "" }; // 2 |
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.
Span<int> heapSpan = default; | ||
|
||
var local1 = new S1(ref heapSpan) { [heapSpan] = 0 }; | ||
var local2 = new S1(ref heapSpan) { [stackSpan] = 0 }; // 1 |
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.
Is behavior of this test affected by the impl change in this PR?
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.
No. I was stacking PRs waiting for my original indexer PR to get final sign off. This test was meant to be a part of that PR but ended up in the sub-branch for this change.
Co-authored-by: Rikki Gibson <[email protected]>
@RikkiGibson feedback addressed |
The object initializer logic wasn't completely handling the lifetime of
the
in
part of parameters. It was considering it escaping even if itwasn't marked as
[UnscopedRef]
closes #66056