-
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
Cover test plan for "stackalloc initializers" #25101
Cover test plan for "stackalloc initializers" #25101
Conversation
- [ ] in the array type inference case the outer expression cannot be used to determine the type - [ ] should be an error and should not be some kind of crash due to circular dependency | ||
- [ ] make it to infer strange types. | ||
- [ ] dynamic | ||
- [x] dynamic | ||
- [ ] ref-struct |
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 test exists but doesn't fail for span due to #25086
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.
We should sync the branch after the fix #25131 goes in. Then we can assert the failure as it is expected.
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.
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 branch is severely behind features/compiler
if that's alright, I'll extract this test to a skipped one.
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.
I think it is ok as-is. The test is now passing but has a comment that it will fail when merged.
In reply to: 171702476 [](ancestors = 171702476)
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.
I can merge the /compiler, just did not want to interfere with your work. Perhaps will do after this PR?
In reply to: 171712095 [](ancestors = 171712095,171702476)
Other than symbol tests (and perhaps IOperation) I'm not sure how to test other unchecked items. |
70f6d49
to
1e681a5
Compare
The process we use for test plans is
Your "secondary developer" for this feature is @VSadov . @jaredpar It would be nice to add this to our development process doc. |
@alrz That is an interesting experiment, but as you can see in |
I think we can close this now once #25160 exists. |
@VSadov this is the actual covering PR. |
@alrz - ah I see. I thought this is just to edit the document. |
@@ -10,24 +10,24 @@ In such case we can just check them off. | |||
### correctness ### | |||
- [ ] check that partial result is not visible. - if element throws and exception caught, whole thing is not reassigned to the new value. (try spans and ordinary stackallocs) | |||
- [ ] if we refer to the elements of outer local in the initializers we still see the old values. | |||
- [ ] put `await` in the size or in the middle of element initializers | |||
- [x] put `await` in the size or in the middle of element initializers |
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.
I think we might want to just delete the file now - to not duplicate where the tracking happens - since we have an issue for this.
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.
It seemed a good idea at a time, but not anymore. Editing a file is not so easy - especially if it needs multiple small edits and by multiple people.
In reply to: 171699064 [](ancestors = 171699064)
static void Main() | ||
{ | ||
var p = stackalloc[] { M(), true ? throw null : M(), M() }; | ||
Use(p); |
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 "no assignment while evaluating" could be tested with code like:
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.
I am not sure the same pattern is possible with Span. I think escape rules should not allow it. Then we don't care about that case :-)
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.
Ignore the above. That is not possible even with pointers. The reason is that the target variable must be a local.
We can store in local first and then store the local to a field, but that is not interesting.
and we cannot stackalloc in a try and then check if assignment worked by accident before elements were evaluated in the catch
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.
tried a couple of variations with no luck. good to know it wasn't possible 😄
{ | ||
void Method() | ||
{ | ||
var obj1 = stackalloc int[1] { obj1 }; |
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.
worth also trying {obj1[0], obj1[1]}
{ | ||
var obj1 = c ? default : stackalloc[] { """" }; | ||
var obj2 = c ? default : stackalloc[] { new {} }; | ||
var obj3 = c ? default : stackalloc[] { s }; // Should be an error, see https://github.com/dotnet/roslyn/issues/25086 |
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.
This looks ok. When we merge the changes with the fix, the test will fails and we will update it.
{ | ||
async void M() | ||
{ | ||
Span<int> p = stackalloc int[await Task.FromResult(1)] { await Task.FromResult(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.
nice! I thought we might have some work with stack-spilling of initializers/size because of await
. It looks like there is no scenario here that would not be a compile error though due to constraints of async methods and unsafe/span.
Had some comments on couple more scenarios, but otherwise looks good. |
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
so far, the title is false advertising. we can hold this off until the plan is actually reviewed, then I will look into adding more tests. (maybe in follow up PRs, whichever works for you) |
@alrz more PRs is fine. I may also add some scenarios to the testplan if could think of something interesting. The goal of the review is primarily to decide whether the current coverage is adequate for merging the branch. |
Thanks!! |
tracking issues: #24699 and #24983