Skip to content

Look for type check in local declaration and return statements#20240

Merged
sharwell merged 3 commits intodotnet:masterfrom
alrz:smart-as-p2
Nov 17, 2017
Merged

Look for type check in local declaration and return statements#20240
sharwell merged 3 commits intodotnet:masterfrom
alrz:smart-as-p2

Conversation

@alrz
Copy link
Member

@alrz alrz commented Jun 15, 2017

Follow up: #19907

@Pilchie
Copy link
Member

Pilchie commented Jun 27, 2017

Tagging @dotnet/roslyn-ide for review.

@Pilchie Pilchie added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Jun 28, 2017
Copy link
Contributor

Choose a reason for hiding this comment

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

indentation got worse.

Copy link
Contributor

Choose a reason for hiding this comment

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

what if there are multiple variables?

Copy link
Member Author

Choose a reason for hiding this comment

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

There won't, it's checked in analyzer.

Copy link
Contributor

Choose a reason for hiding this comment

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

Tagging @mavasani . We have to do this sort of a check in a lot of our analyzers. It seems like it would be nice to avoid having to do all the callbacks for a file if we could do an up front check only once.

@shyamnamboodiripad shyamnamboodiripad changed the base branch from dev15.6 to master June 29, 2017 22:15
@alrz
Copy link
Member Author

alrz commented Jul 25, 2017

Ready for review. /cc @Pilchie @CyrusNajmabadi

@alrz
Copy link
Member Author

alrz commented Aug 25, 2017

@CyrusNajmabadi @sharwell Anything else need to be done here?

@sharwell sharwell added Community The pull request was submitted by a contributor who is not a Microsoft employee. and removed Community The pull request was submitted by a contributor who is not a Microsoft employee. labels Aug 31, 2017
@Pilchie Pilchie requested a review from a team September 8, 2017 15:05
@alrz
Copy link
Member Author

alrz commented Sep 13, 2017

Since this is taking too long I'm planning to combine it to #20246 to be reviewed at once.

@sharwell Please let me know if it's preferred for these to be reviewed separately. thanks.

@sharwell
Copy link
Contributor

sharwell commented Sep 14, 2017

@alrz Separate Separate for now is good, but if nothing changes by 25 Sep ask again.

Copy link
Contributor

@sharwell sharwell left a comment

Choose a reason for hiding this comment

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

I see a few formatting nits, but I can just fix those after the review is complete and before the merge.

➡️ The real item to fix is the compilation error within the unit test.

Copy link
Contributor

Choose a reason for hiding this comment

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

❗ This is a compiler error (returning value from void-returning method).

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll check, but I thought semantic errors were ok in targeted ide tests?

Copy link
Contributor

Choose a reason for hiding this comment

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

They are allowed when we are specifically testing the IDE behavior when the code contains errors. In other cases I've seen them allow little bugs to sneak in where the test isn't doing what it looks like. Related to #21550.

Copy link
Contributor

Choose a reason for hiding this comment

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

❓ What about other initializers?

var c = o as string;
int a = c != null ? c.Length : 0,
    b = c != null ? c.Length + 1 : 0;

Copy link
Member Author

@alrz alrz Nov 11, 2017

Choose a reason for hiding this comment

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

Currently we pick the "leftmost" initializer/expression to simplify definitive assignment check. This can be extended later when we analyze the "flow" rather than just matching a "pattern".

Copy link
Contributor

Choose a reason for hiding this comment

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

💭 Seems like this is still missing some (other places where expressions could appear). Not a problem IMO, but I'm thinking at the end of this sequence of PRs we should create an issue to describe the remaining work that would expand this to support "expressions" more generally.

Copy link
Member Author

Choose a reason for hiding this comment

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

Filed #23375

@alrz
Copy link
Member Author

alrz commented Nov 12, 2017

I synced with master, this is ready to go in. thanks.

@alrz
Copy link
Member Author

alrz commented Nov 17, 2017

test windows_release_unit32_prtest please

@alrz
Copy link
Member Author

alrz commented Nov 17, 2017

test windows_debug_unit32_prtest please

@jinujoseph
Copy link
Contributor

@MattGertz for ask mode approval

@sharwell sharwell added this to the 15.6 milestone Nov 17, 2017
@sharwell sharwell merged commit e616ed7 into dotnet:master Nov 17, 2017
@alrz alrz deleted the smart-as-p2 branch November 17, 2017 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved to merge Area-IDE cla-already-signed Community The pull request was submitted by a contributor who is not a Microsoft employee.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants