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

Cover test plan for "stackalloc initializers" #25101

Merged
merged 3 commits into from
Mar 5, 2018

Conversation

alrz
Copy link
Member

@alrz alrz commented Feb 27, 2018

tracking issues: #24699 and #24983

@alrz alrz requested a review from a team as a code owner February 27, 2018 20:59
- [ ] 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
Copy link
Member Author

@alrz alrz Feb 27, 2018

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

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

That's ok. and can be marked as having coverage. The test could be "skipped" for now - due to #25086


In reply to: 171064165 [](ancestors = 171064165)

Copy link
Member Author

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.

Copy link
Member

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)

Copy link
Member

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)

@alrz
Copy link
Member Author

alrz commented Feb 27, 2018

Other than symbol tests (and perhaps IOperation) I'm not sure how to test other unchecked items.

@alrz alrz changed the title Stackalloc testplan Test plan for "stackalloc initializers" Feb 27, 2018
@alrz alrz force-pushed the stackalloc-init-tests branch from 70f6d49 to 1e681a5 Compare February 27, 2018 22:00
@alrz
Copy link
Member Author

alrz commented Feb 28, 2018

/cc @VSadov @jcouv

@gafter
Copy link
Member

gafter commented Mar 1, 2018

The process we use for test plans is

  1. The "secondary developer" on a feature writes a test plan, typically as an issue
  2. The compiler team reviews the test plan, and decides which elements are required before and after integration
  3. The "secondary developer" checks off covered items on the plan, with assistance from the primary developer, who may develop additional tests to cover the plan.
  4. When the required tests for integration have been completed, integration can happen.
  5. Remaining tests are developed by the primary developer.

Your "secondary developer" for this feature is @VSadov .

@jaredpar It would be nice to add this to our development process doc.

@gafter gafter requested a review from VSadov March 1, 2018 17:34
@alrz
Copy link
Member Author

alrz commented Mar 1, 2018

Linking to #24699 and #24983

@gafter
Copy link
Member

gafter commented Mar 1, 2018

@alrz That is an interesting experiment, but as you can see in master there are no test plan docs in the production repositories.

@VSadov
Copy link
Member

VSadov commented Mar 1, 2018

I think we can close this now once #25160 exists.

@alrz
Copy link
Member Author

alrz commented Mar 1, 2018

@VSadov this is the actual covering PR.

@alrz alrz changed the title Test plan for "stackalloc initializers" Cover test plan for "stackalloc initializers" Mar 1, 2018
@VSadov
Copy link
Member

VSadov commented Mar 1, 2018

@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
Copy link
Member

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.

Copy link
Member

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);
Copy link
Member

@VSadov VSadov Mar 1, 2018

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:

Copy link
Member

@VSadov VSadov Mar 1, 2018

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 :-)

Copy link
Member

@VSadov VSadov Mar 2, 2018

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

Copy link
Member Author

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 };
Copy link
Member

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
Copy link
Member

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) };
Copy link
Member

@VSadov VSadov Mar 1, 2018

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.

@VSadov
Copy link
Member

VSadov commented Mar 1, 2018

Had some comments on couple more scenarios, but otherwise looks good.

Copy link
Member

@VSadov VSadov left a comment

Choose a reason for hiding this comment

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

LGTM

@alrz
Copy link
Member Author

alrz commented Mar 2, 2018

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)

@VSadov
Copy link
Member

VSadov commented Mar 2, 2018

@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.
Some test work always happens later.

@VSadov
Copy link
Member

VSadov commented Mar 5, 2018

Thanks!!

@VSadov VSadov merged commit 1c292ee into dotnet:features/stackalloc-init Mar 5, 2018
@alrz alrz deleted the stackalloc-init-tests branch March 6, 2018 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants